advansys.c 517 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353
  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_SCSI_RESET_HOLD_TIME_US 60
  189. /*
  190. * Narrow boards only support 12-byte commands, while wide boards
  191. * extend to 16-byte commands.
  192. */
  193. #define ASC_MAX_CDB_LEN 12
  194. #define ADV_MAX_CDB_LEN 16
  195. /*
  196. * Inquiry SPC-2 SPI Byte 1 EVPD (Enable Vital Product Data)
  197. * and CmdDt (Command Support Data) field bit definitions.
  198. */
  199. #define ADV_INQ_RTN_VPD_AND_CMDDT 0x3
  200. #define ADV_INQ_RTN_CMDDT_FOR_OP_CODE 0x2
  201. #define ADV_INQ_RTN_VPD_FOR_PG_CODE 0x1
  202. #define ADV_INQ_RTN_STD_INQUIRY_DATA 0x0
  203. #define ASC_SCSIDIR_NOCHK 0x00
  204. #define ASC_SCSIDIR_T2H 0x08
  205. #define ASC_SCSIDIR_H2T 0x10
  206. #define ASC_SCSIDIR_NODATA 0x18
  207. #define SCSI_ASC_NOMEDIA 0x3A
  208. #define ASC_SRB_HOST(x) ((uchar)((uchar)(x) >> 4))
  209. #define ASC_SRB_TID(x) ((uchar)((uchar)(x) & (uchar)0x0F))
  210. #define ASC_SRB_LUN(x) ((uchar)((uint)(x) >> 13))
  211. #define PUT_CDB1(x) ((uchar)((uint)(x) >> 8))
  212. #define MS_SDTR_LEN 0x03
  213. #define MS_WDTR_LEN 0x02
  214. #define ASC_SG_LIST_PER_Q 7
  215. #define QS_FREE 0x00
  216. #define QS_READY 0x01
  217. #define QS_DISC1 0x02
  218. #define QS_DISC2 0x04
  219. #define QS_BUSY 0x08
  220. #define QS_ABORTED 0x40
  221. #define QS_DONE 0x80
  222. #define QC_NO_CALLBACK 0x01
  223. #define QC_SG_SWAP_QUEUE 0x02
  224. #define QC_SG_HEAD 0x04
  225. #define QC_DATA_IN 0x08
  226. #define QC_DATA_OUT 0x10
  227. #define QC_URGENT 0x20
  228. #define QC_MSG_OUT 0x40
  229. #define QC_REQ_SENSE 0x80
  230. #define QCSG_SG_XFER_LIST 0x02
  231. #define QCSG_SG_XFER_MORE 0x04
  232. #define QCSG_SG_XFER_END 0x08
  233. #define QD_IN_PROGRESS 0x00
  234. #define QD_NO_ERROR 0x01
  235. #define QD_ABORTED_BY_HOST 0x02
  236. #define QD_WITH_ERROR 0x04
  237. #define QD_INVALID_REQUEST 0x80
  238. #define QD_INVALID_HOST_NUM 0x81
  239. #define QD_INVALID_DEVICE 0x82
  240. #define QD_ERR_INTERNAL 0xFF
  241. #define QHSTA_NO_ERROR 0x00
  242. #define QHSTA_M_SEL_TIMEOUT 0x11
  243. #define QHSTA_M_DATA_OVER_RUN 0x12
  244. #define QHSTA_M_DATA_UNDER_RUN 0x12
  245. #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
  246. #define QHSTA_M_BAD_BUS_PHASE_SEQ 0x14
  247. #define QHSTA_D_QDONE_SG_LIST_CORRUPTED 0x21
  248. #define QHSTA_D_ASC_DVC_ERROR_CODE_SET 0x22
  249. #define QHSTA_D_HOST_ABORT_FAILED 0x23
  250. #define QHSTA_D_EXE_SCSI_Q_FAILED 0x24
  251. #define QHSTA_D_EXE_SCSI_Q_BUSY_TIMEOUT 0x25
  252. #define QHSTA_D_ASPI_NO_BUF_POOL 0x26
  253. #define QHSTA_M_WTM_TIMEOUT 0x41
  254. #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
  255. #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
  256. #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
  257. #define QHSTA_M_TARGET_STATUS_BUSY 0x45
  258. #define QHSTA_M_BAD_TAG_CODE 0x46
  259. #define QHSTA_M_BAD_QUEUE_FULL_OR_BUSY 0x47
  260. #define QHSTA_M_HUNG_REQ_SCSI_BUS_RESET 0x48
  261. #define QHSTA_D_LRAM_CMP_ERROR 0x81
  262. #define QHSTA_M_MICRO_CODE_ERROR_HALT 0xA1
  263. #define ASC_FLAG_SCSIQ_REQ 0x01
  264. #define ASC_FLAG_BIOS_SCSIQ_REQ 0x02
  265. #define ASC_FLAG_BIOS_ASYNC_IO 0x04
  266. #define ASC_FLAG_SRB_LINEAR_ADDR 0x08
  267. #define ASC_FLAG_WIN16 0x10
  268. #define ASC_FLAG_WIN32 0x20
  269. #define ASC_FLAG_ISA_OVER_16MB 0x40
  270. #define ASC_FLAG_DOS_VM_CALLBACK 0x80
  271. #define ASC_TAG_FLAG_EXTRA_BYTES 0x10
  272. #define ASC_TAG_FLAG_DISABLE_DISCONNECT 0x04
  273. #define ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX 0x08
  274. #define ASC_TAG_FLAG_DISABLE_CHK_COND_INT_HOST 0x40
  275. #define ASC_SCSIQ_CPY_BEG 4
  276. #define ASC_SCSIQ_SGHD_CPY_BEG 2
  277. #define ASC_SCSIQ_B_FWD 0
  278. #define ASC_SCSIQ_B_BWD 1
  279. #define ASC_SCSIQ_B_STATUS 2
  280. #define ASC_SCSIQ_B_QNO 3
  281. #define ASC_SCSIQ_B_CNTL 4
  282. #define ASC_SCSIQ_B_SG_QUEUE_CNT 5
  283. #define ASC_SCSIQ_D_DATA_ADDR 8
  284. #define ASC_SCSIQ_D_DATA_CNT 12
  285. #define ASC_SCSIQ_B_SENSE_LEN 20
  286. #define ASC_SCSIQ_DONE_INFO_BEG 22
  287. #define ASC_SCSIQ_D_SRBPTR 22
  288. #define ASC_SCSIQ_B_TARGET_IX 26
  289. #define ASC_SCSIQ_B_CDB_LEN 28
  290. #define ASC_SCSIQ_B_TAG_CODE 29
  291. #define ASC_SCSIQ_W_VM_ID 30
  292. #define ASC_SCSIQ_DONE_STATUS 32
  293. #define ASC_SCSIQ_HOST_STATUS 33
  294. #define ASC_SCSIQ_SCSI_STATUS 34
  295. #define ASC_SCSIQ_CDB_BEG 36
  296. #define ASC_SCSIQ_DW_REMAIN_XFER_ADDR 56
  297. #define ASC_SCSIQ_DW_REMAIN_XFER_CNT 60
  298. #define ASC_SCSIQ_B_FIRST_SG_WK_QP 48
  299. #define ASC_SCSIQ_B_SG_WK_QP 49
  300. #define ASC_SCSIQ_B_SG_WK_IX 50
  301. #define ASC_SCSIQ_W_ALT_DC1 52
  302. #define ASC_SCSIQ_B_LIST_CNT 6
  303. #define ASC_SCSIQ_B_CUR_LIST_CNT 7
  304. #define ASC_SGQ_B_SG_CNTL 4
  305. #define ASC_SGQ_B_SG_HEAD_QP 5
  306. #define ASC_SGQ_B_SG_LIST_CNT 6
  307. #define ASC_SGQ_B_SG_CUR_LIST_CNT 7
  308. #define ASC_SGQ_LIST_BEG 8
  309. #define ASC_DEF_SCSI1_QNG 4
  310. #define ASC_MAX_SCSI1_QNG 4
  311. #define ASC_DEF_SCSI2_QNG 16
  312. #define ASC_MAX_SCSI2_QNG 32
  313. #define ASC_TAG_CODE_MASK 0x23
  314. #define ASC_STOP_REQ_RISC_STOP 0x01
  315. #define ASC_STOP_ACK_RISC_STOP 0x03
  316. #define ASC_STOP_CLEAN_UP_BUSY_Q 0x10
  317. #define ASC_STOP_CLEAN_UP_DISC_Q 0x20
  318. #define ASC_STOP_HOST_REQ_RISC_HALT 0x40
  319. #define ASC_TIDLUN_TO_IX(tid, lun) (ASC_SCSI_TIX_TYPE)((tid) + ((lun)<<ASC_SCSI_ID_BITS))
  320. #define ASC_TID_TO_TARGET_ID(tid) (ASC_SCSI_BIT_ID_TYPE)(0x01 << (tid))
  321. #define ASC_TIX_TO_TARGET_ID(tix) (0x01 << ((tix) & ASC_MAX_TID))
  322. #define ASC_TIX_TO_TID(tix) ((tix) & ASC_MAX_TID)
  323. #define ASC_TID_TO_TIX(tid) ((tid) & ASC_MAX_TID)
  324. #define ASC_TIX_TO_LUN(tix) (((tix) >> ASC_SCSI_ID_BITS) & ASC_MAX_LUN)
  325. #define ASC_QNO_TO_QADDR(q_no) ((ASC_QADR_BEG)+((int)(q_no) << 6))
  326. typedef struct asc_scsiq_1 {
  327. uchar status;
  328. uchar q_no;
  329. uchar cntl;
  330. uchar sg_queue_cnt;
  331. uchar target_id;
  332. uchar target_lun;
  333. ASC_PADDR data_addr;
  334. ASC_DCNT data_cnt;
  335. ASC_PADDR sense_addr;
  336. uchar sense_len;
  337. uchar extra_bytes;
  338. } ASC_SCSIQ_1;
  339. typedef struct asc_scsiq_2 {
  340. ASC_VADDR srb_ptr;
  341. uchar target_ix;
  342. uchar flag;
  343. uchar cdb_len;
  344. uchar tag_code;
  345. ushort vm_id;
  346. } ASC_SCSIQ_2;
  347. typedef struct asc_scsiq_3 {
  348. uchar done_stat;
  349. uchar host_stat;
  350. uchar scsi_stat;
  351. uchar scsi_msg;
  352. } ASC_SCSIQ_3;
  353. typedef struct asc_scsiq_4 {
  354. uchar cdb[ASC_MAX_CDB_LEN];
  355. uchar y_first_sg_list_qp;
  356. uchar y_working_sg_qp;
  357. uchar y_working_sg_ix;
  358. uchar y_res;
  359. ushort x_req_count;
  360. ushort x_reconnect_rtn;
  361. ASC_PADDR x_saved_data_addr;
  362. ASC_DCNT x_saved_data_cnt;
  363. } ASC_SCSIQ_4;
  364. typedef struct asc_q_done_info {
  365. ASC_SCSIQ_2 d2;
  366. ASC_SCSIQ_3 d3;
  367. uchar q_status;
  368. uchar q_no;
  369. uchar cntl;
  370. uchar sense_len;
  371. uchar extra_bytes;
  372. uchar res;
  373. ASC_DCNT remain_bytes;
  374. } ASC_QDONE_INFO;
  375. typedef struct asc_sg_list {
  376. ASC_PADDR addr;
  377. ASC_DCNT bytes;
  378. } ASC_SG_LIST;
  379. typedef struct asc_sg_head {
  380. ushort entry_cnt;
  381. ushort queue_cnt;
  382. ushort entry_to_copy;
  383. ushort res;
  384. ASC_SG_LIST sg_list[ASC_MAX_SG_LIST];
  385. } ASC_SG_HEAD;
  386. #define ASC_MIN_SG_LIST 2
  387. typedef struct asc_min_sg_head {
  388. ushort entry_cnt;
  389. ushort queue_cnt;
  390. ushort entry_to_copy;
  391. ushort res;
  392. ASC_SG_LIST sg_list[ASC_MIN_SG_LIST];
  393. } ASC_MIN_SG_HEAD;
  394. #define QCX_SORT (0x0001)
  395. #define QCX_COALEASE (0x0002)
  396. typedef struct asc_scsi_q {
  397. ASC_SCSIQ_1 q1;
  398. ASC_SCSIQ_2 q2;
  399. uchar *cdbptr;
  400. ASC_SG_HEAD *sg_head;
  401. ushort remain_sg_entry_cnt;
  402. ushort next_sg_index;
  403. } ASC_SCSI_Q;
  404. typedef struct asc_scsi_req_q {
  405. ASC_SCSIQ_1 r1;
  406. ASC_SCSIQ_2 r2;
  407. uchar *cdbptr;
  408. ASC_SG_HEAD *sg_head;
  409. uchar *sense_ptr;
  410. ASC_SCSIQ_3 r3;
  411. uchar cdb[ASC_MAX_CDB_LEN];
  412. uchar sense[ASC_MIN_SENSE_LEN];
  413. } ASC_SCSI_REQ_Q;
  414. typedef struct asc_scsi_bios_req_q {
  415. ASC_SCSIQ_1 r1;
  416. ASC_SCSIQ_2 r2;
  417. uchar *cdbptr;
  418. ASC_SG_HEAD *sg_head;
  419. uchar *sense_ptr;
  420. ASC_SCSIQ_3 r3;
  421. uchar cdb[ASC_MAX_CDB_LEN];
  422. uchar sense[ASC_MIN_SENSE_LEN];
  423. } ASC_SCSI_BIOS_REQ_Q;
  424. typedef struct asc_risc_q {
  425. uchar fwd;
  426. uchar bwd;
  427. ASC_SCSIQ_1 i1;
  428. ASC_SCSIQ_2 i2;
  429. ASC_SCSIQ_3 i3;
  430. ASC_SCSIQ_4 i4;
  431. } ASC_RISC_Q;
  432. typedef struct asc_sg_list_q {
  433. uchar seq_no;
  434. uchar q_no;
  435. uchar cntl;
  436. uchar sg_head_qp;
  437. uchar sg_list_cnt;
  438. uchar sg_cur_list_cnt;
  439. } ASC_SG_LIST_Q;
  440. typedef struct asc_risc_sg_list_q {
  441. uchar fwd;
  442. uchar bwd;
  443. ASC_SG_LIST_Q sg;
  444. ASC_SG_LIST sg_list[7];
  445. } ASC_RISC_SG_LIST_Q;
  446. #define ASC_EXE_SCSI_IO_MAX_IDLE_LOOP 0x1000000UL
  447. #define ASC_EXE_SCSI_IO_MAX_WAIT_LOOP 1024
  448. #define ASCQ_ERR_NO_ERROR 0
  449. #define ASCQ_ERR_IO_NOT_FOUND 1
  450. #define ASCQ_ERR_LOCAL_MEM 2
  451. #define ASCQ_ERR_CHKSUM 3
  452. #define ASCQ_ERR_START_CHIP 4
  453. #define ASCQ_ERR_INT_TARGET_ID 5
  454. #define ASCQ_ERR_INT_LOCAL_MEM 6
  455. #define ASCQ_ERR_HALT_RISC 7
  456. #define ASCQ_ERR_GET_ASPI_ENTRY 8
  457. #define ASCQ_ERR_CLOSE_ASPI 9
  458. #define ASCQ_ERR_HOST_INQUIRY 0x0A
  459. #define ASCQ_ERR_SAVED_SRB_BAD 0x0B
  460. #define ASCQ_ERR_QCNTL_SG_LIST 0x0C
  461. #define ASCQ_ERR_Q_STATUS 0x0D
  462. #define ASCQ_ERR_WR_SCSIQ 0x0E
  463. #define ASCQ_ERR_PC_ADDR 0x0F
  464. #define ASCQ_ERR_SYN_OFFSET 0x10
  465. #define ASCQ_ERR_SYN_XFER_TIME 0x11
  466. #define ASCQ_ERR_LOCK_DMA 0x12
  467. #define ASCQ_ERR_UNLOCK_DMA 0x13
  468. #define ASCQ_ERR_VDS_CHK_INSTALL 0x14
  469. #define ASCQ_ERR_MICRO_CODE_HALT 0x15
  470. #define ASCQ_ERR_SET_LRAM_ADDR 0x16
  471. #define ASCQ_ERR_CUR_QNG 0x17
  472. #define ASCQ_ERR_SG_Q_LINKS 0x18
  473. #define ASCQ_ERR_SCSIQ_PTR 0x19
  474. #define ASCQ_ERR_ISR_RE_ENTRY 0x1A
  475. #define ASCQ_ERR_CRITICAL_RE_ENTRY 0x1B
  476. #define ASCQ_ERR_ISR_ON_CRITICAL 0x1C
  477. /*
  478. * Warning code values are set in ASC_DVC_VAR 'warn_code'.
  479. */
  480. #define ASC_WARN_NO_ERROR 0x0000
  481. #define ASC_WARN_IO_PORT_ROTATE 0x0001
  482. #define ASC_WARN_EEPROM_CHKSUM 0x0002
  483. #define ASC_WARN_IRQ_MODIFIED 0x0004
  484. #define ASC_WARN_AUTO_CONFIG 0x0008
  485. #define ASC_WARN_CMD_QNG_CONFLICT 0x0010
  486. #define ASC_WARN_EEPROM_RECOVER 0x0020
  487. #define ASC_WARN_CFG_MSW_RECOVER 0x0040
  488. #define ASC_WARN_SET_PCI_CONFIG_SPACE 0x0080
  489. /*
  490. * Error code values are set in ASC_DVC_VAR 'err_code'.
  491. */
  492. #define ASC_IERR_WRITE_EEPROM 0x0001
  493. #define ASC_IERR_MCODE_CHKSUM 0x0002
  494. #define ASC_IERR_SET_PC_ADDR 0x0004
  495. #define ASC_IERR_START_STOP_CHIP 0x0008
  496. #define ASC_IERR_IRQ_NO 0x0010
  497. #define ASC_IERR_SET_IRQ_NO 0x0020
  498. #define ASC_IERR_CHIP_VERSION 0x0040
  499. #define ASC_IERR_SET_SCSI_ID 0x0080
  500. #define ASC_IERR_GET_PHY_ADDR 0x0100
  501. #define ASC_IERR_BAD_SIGNATURE 0x0200
  502. #define ASC_IERR_NO_BUS_TYPE 0x0400
  503. #define ASC_IERR_SCAM 0x0800
  504. #define ASC_IERR_SET_SDTR 0x1000
  505. #define ASC_IERR_RW_LRAM 0x8000
  506. #define ASC_DEF_IRQ_NO 10
  507. #define ASC_MAX_IRQ_NO 15
  508. #define ASC_MIN_IRQ_NO 10
  509. #define ASC_MIN_REMAIN_Q (0x02)
  510. #define ASC_DEF_MAX_TOTAL_QNG (0xF0)
  511. #define ASC_MIN_TAG_Q_PER_DVC (0x04)
  512. #define ASC_DEF_TAG_Q_PER_DVC (0x04)
  513. #define ASC_MIN_FREE_Q ASC_MIN_REMAIN_Q
  514. #define ASC_MIN_TOTAL_QNG ((ASC_MAX_SG_QUEUE)+(ASC_MIN_FREE_Q))
  515. #define ASC_MAX_TOTAL_QNG 240
  516. #define ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG 16
  517. #define ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG 8
  518. #define ASC_MAX_PCI_INRAM_TOTAL_QNG 20
  519. #define ASC_MAX_INRAM_TAG_QNG 16
  520. #define ASC_IOADR_TABLE_MAX_IX 11
  521. #define ASC_IOADR_GAP 0x10
  522. #define ASC_LIB_SCSIQ_WK_SP 256
  523. #define ASC_MAX_SYN_XFER_NO 16
  524. #define ASC_SYN_MAX_OFFSET 0x0F
  525. #define ASC_DEF_SDTR_OFFSET 0x0F
  526. #define ASC_DEF_SDTR_INDEX 0x00
  527. #define ASC_SDTR_ULTRA_PCI_10MB_INDEX 0x02
  528. #define SYN_XFER_NS_0 25
  529. #define SYN_XFER_NS_1 30
  530. #define SYN_XFER_NS_2 35
  531. #define SYN_XFER_NS_3 40
  532. #define SYN_XFER_NS_4 50
  533. #define SYN_XFER_NS_5 60
  534. #define SYN_XFER_NS_6 70
  535. #define SYN_XFER_NS_7 85
  536. #define SYN_ULTRA_XFER_NS_0 12
  537. #define SYN_ULTRA_XFER_NS_1 19
  538. #define SYN_ULTRA_XFER_NS_2 25
  539. #define SYN_ULTRA_XFER_NS_3 32
  540. #define SYN_ULTRA_XFER_NS_4 38
  541. #define SYN_ULTRA_XFER_NS_5 44
  542. #define SYN_ULTRA_XFER_NS_6 50
  543. #define SYN_ULTRA_XFER_NS_7 57
  544. #define SYN_ULTRA_XFER_NS_8 63
  545. #define SYN_ULTRA_XFER_NS_9 69
  546. #define SYN_ULTRA_XFER_NS_10 75
  547. #define SYN_ULTRA_XFER_NS_11 82
  548. #define SYN_ULTRA_XFER_NS_12 88
  549. #define SYN_ULTRA_XFER_NS_13 94
  550. #define SYN_ULTRA_XFER_NS_14 100
  551. #define SYN_ULTRA_XFER_NS_15 107
  552. typedef struct ext_msg {
  553. uchar msg_type;
  554. uchar msg_len;
  555. uchar msg_req;
  556. union {
  557. struct {
  558. uchar sdtr_xfer_period;
  559. uchar sdtr_req_ack_offset;
  560. } sdtr;
  561. struct {
  562. uchar wdtr_width;
  563. } wdtr;
  564. struct {
  565. uchar mdp_b3;
  566. uchar mdp_b2;
  567. uchar mdp_b1;
  568. uchar mdp_b0;
  569. } mdp;
  570. } u_ext_msg;
  571. uchar res;
  572. } EXT_MSG;
  573. #define xfer_period u_ext_msg.sdtr.sdtr_xfer_period
  574. #define req_ack_offset u_ext_msg.sdtr.sdtr_req_ack_offset
  575. #define wdtr_width u_ext_msg.wdtr.wdtr_width
  576. #define mdp_b3 u_ext_msg.mdp_b3
  577. #define mdp_b2 u_ext_msg.mdp_b2
  578. #define mdp_b1 u_ext_msg.mdp_b1
  579. #define mdp_b0 u_ext_msg.mdp_b0
  580. typedef struct asc_dvc_cfg {
  581. ASC_SCSI_BIT_ID_TYPE can_tagged_qng;
  582. ASC_SCSI_BIT_ID_TYPE cmd_qng_enabled;
  583. ASC_SCSI_BIT_ID_TYPE disc_enable;
  584. ASC_SCSI_BIT_ID_TYPE sdtr_enable;
  585. uchar chip_scsi_id;
  586. uchar isa_dma_speed;
  587. uchar isa_dma_channel;
  588. uchar chip_version;
  589. ushort lib_serial_no;
  590. ushort lib_version;
  591. ushort mcode_date;
  592. ushort mcode_version;
  593. uchar max_tag_qng[ASC_MAX_TID + 1];
  594. uchar *overrun_buf;
  595. uchar sdtr_period_offset[ASC_MAX_TID + 1];
  596. uchar adapter_info[6];
  597. } ASC_DVC_CFG;
  598. #define ASC_DEF_DVC_CNTL 0xFFFF
  599. #define ASC_DEF_CHIP_SCSI_ID 7
  600. #define ASC_DEF_ISA_DMA_SPEED 4
  601. #define ASC_INIT_STATE_NULL 0x0000
  602. #define ASC_INIT_STATE_BEG_GET_CFG 0x0001
  603. #define ASC_INIT_STATE_END_GET_CFG 0x0002
  604. #define ASC_INIT_STATE_BEG_SET_CFG 0x0004
  605. #define ASC_INIT_STATE_END_SET_CFG 0x0008
  606. #define ASC_INIT_STATE_BEG_LOAD_MC 0x0010
  607. #define ASC_INIT_STATE_END_LOAD_MC 0x0020
  608. #define ASC_INIT_STATE_BEG_INQUIRY 0x0040
  609. #define ASC_INIT_STATE_END_INQUIRY 0x0080
  610. #define ASC_INIT_RESET_SCSI_DONE 0x0100
  611. #define ASC_INIT_STATE_WITHOUT_EEP 0x8000
  612. #define ASC_BUG_FIX_IF_NOT_DWB 0x0001
  613. #define ASC_BUG_FIX_ASYN_USE_SYN 0x0002
  614. #define ASYN_SDTR_DATA_FIX_PCI_REV_AB 0x41
  615. #define ASC_MIN_TAGGED_CMD 7
  616. #define ASC_MAX_SCSI_RESET_WAIT 30
  617. struct asc_dvc_var; /* Forward Declaration. */
  618. typedef struct asc_dvc_var {
  619. PortAddr iop_base;
  620. ushort err_code;
  621. ushort dvc_cntl;
  622. ushort bug_fix_cntl;
  623. ushort bus_type;
  624. ASC_SCSI_BIT_ID_TYPE init_sdtr;
  625. ASC_SCSI_BIT_ID_TYPE sdtr_done;
  626. ASC_SCSI_BIT_ID_TYPE use_tagged_qng;
  627. ASC_SCSI_BIT_ID_TYPE unit_not_ready;
  628. ASC_SCSI_BIT_ID_TYPE queue_full_or_busy;
  629. ASC_SCSI_BIT_ID_TYPE start_motor;
  630. uchar scsi_reset_wait;
  631. uchar chip_no;
  632. char is_in_int;
  633. uchar max_total_qng;
  634. uchar cur_total_qng;
  635. uchar in_critical_cnt;
  636. uchar irq_no;
  637. uchar last_q_shortage;
  638. ushort init_state;
  639. uchar cur_dvc_qng[ASC_MAX_TID + 1];
  640. uchar max_dvc_qng[ASC_MAX_TID + 1];
  641. ASC_SCSI_Q *scsiq_busy_head[ASC_MAX_TID + 1];
  642. ASC_SCSI_Q *scsiq_busy_tail[ASC_MAX_TID + 1];
  643. uchar sdtr_period_tbl[ASC_MAX_SYN_XFER_NO];
  644. ASC_DVC_CFG *cfg;
  645. ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer_always;
  646. char redo_scam;
  647. ushort res2;
  648. uchar dos_int13_table[ASC_MAX_TID + 1];
  649. ASC_DCNT max_dma_count;
  650. ASC_SCSI_BIT_ID_TYPE no_scam;
  651. ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer;
  652. uchar max_sdtr_index;
  653. uchar host_init_sdtr_index;
  654. struct asc_board *drv_ptr;
  655. ASC_DCNT uc_break;
  656. } ASC_DVC_VAR;
  657. typedef struct asc_dvc_inq_info {
  658. uchar type[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
  659. } ASC_DVC_INQ_INFO;
  660. typedef struct asc_cap_info {
  661. ASC_DCNT lba;
  662. ASC_DCNT blk_size;
  663. } ASC_CAP_INFO;
  664. typedef struct asc_cap_info_array {
  665. ASC_CAP_INFO cap_info[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
  666. } ASC_CAP_INFO_ARRAY;
  667. #define ASC_MCNTL_NO_SEL_TIMEOUT (ushort)0x0001
  668. #define ASC_MCNTL_NULL_TARGET (ushort)0x0002
  669. #define ASC_CNTL_INITIATOR (ushort)0x0001
  670. #define ASC_CNTL_BIOS_GT_1GB (ushort)0x0002
  671. #define ASC_CNTL_BIOS_GT_2_DISK (ushort)0x0004
  672. #define ASC_CNTL_BIOS_REMOVABLE (ushort)0x0008
  673. #define ASC_CNTL_NO_SCAM (ushort)0x0010
  674. #define ASC_CNTL_INT_MULTI_Q (ushort)0x0080
  675. #define ASC_CNTL_NO_LUN_SUPPORT (ushort)0x0040
  676. #define ASC_CNTL_NO_VERIFY_COPY (ushort)0x0100
  677. #define ASC_CNTL_RESET_SCSI (ushort)0x0200
  678. #define ASC_CNTL_INIT_INQUIRY (ushort)0x0400
  679. #define ASC_CNTL_INIT_VERBOSE (ushort)0x0800
  680. #define ASC_CNTL_SCSI_PARITY (ushort)0x1000
  681. #define ASC_CNTL_BURST_MODE (ushort)0x2000
  682. #define ASC_CNTL_SDTR_ENABLE_ULTRA (ushort)0x4000
  683. #define ASC_EEP_DVC_CFG_BEG_VL 2
  684. #define ASC_EEP_MAX_DVC_ADDR_VL 15
  685. #define ASC_EEP_DVC_CFG_BEG 32
  686. #define ASC_EEP_MAX_DVC_ADDR 45
  687. #define ASC_EEP_DEFINED_WORDS 10
  688. #define ASC_EEP_MAX_ADDR 63
  689. #define ASC_EEP_RES_WORDS 0
  690. #define ASC_EEP_MAX_RETRY 20
  691. #define ASC_MAX_INIT_BUSY_RETRY 8
  692. #define ASC_EEP_ISA_PNP_WSIZE 16
  693. /*
  694. * These macros keep the chip SCSI id and ISA DMA speed
  695. * bitfields in board order. C bitfields aren't portable
  696. * between big and little-endian platforms so they are
  697. * not used.
  698. */
  699. #define ASC_EEP_GET_CHIP_ID(cfg) ((cfg)->id_speed & 0x0f)
  700. #define ASC_EEP_GET_DMA_SPD(cfg) (((cfg)->id_speed & 0xf0) >> 4)
  701. #define ASC_EEP_SET_CHIP_ID(cfg, sid) \
  702. ((cfg)->id_speed = ((cfg)->id_speed & 0xf0) | ((sid) & ASC_MAX_TID))
  703. #define ASC_EEP_SET_DMA_SPD(cfg, spd) \
  704. ((cfg)->id_speed = ((cfg)->id_speed & 0x0f) | ((spd) & 0x0f) << 4)
  705. typedef struct asceep_config {
  706. ushort cfg_lsw;
  707. ushort cfg_msw;
  708. uchar init_sdtr;
  709. uchar disc_enable;
  710. uchar use_cmd_qng;
  711. uchar start_motor;
  712. uchar max_total_qng;
  713. uchar max_tag_qng;
  714. uchar bios_scan;
  715. uchar power_up_wait;
  716. uchar no_scam;
  717. uchar id_speed; /* low order 4 bits is chip scsi id */
  718. /* high order 4 bits is isa dma speed */
  719. uchar dos_int13_table[ASC_MAX_TID + 1];
  720. uchar adapter_info[6];
  721. ushort cntl;
  722. ushort chksum;
  723. } ASCEEP_CONFIG;
  724. #define ASC_PCI_CFG_LSW_SCSI_PARITY 0x0800
  725. #define ASC_PCI_CFG_LSW_BURST_MODE 0x0080
  726. #define ASC_PCI_CFG_LSW_INTR_ABLE 0x0020
  727. #define ASC_EEP_CMD_READ 0x80
  728. #define ASC_EEP_CMD_WRITE 0x40
  729. #define ASC_EEP_CMD_WRITE_ABLE 0x30
  730. #define ASC_EEP_CMD_WRITE_DISABLE 0x00
  731. #define ASC_OVERRUN_BSIZE 0x00000048UL
  732. #define ASC_CTRL_BREAK_ONCE 0x0001
  733. #define ASC_CTRL_BREAK_STAY_IDLE 0x0002
  734. #define ASCV_MSGOUT_BEG 0x0000
  735. #define ASCV_MSGOUT_SDTR_PERIOD (ASCV_MSGOUT_BEG+3)
  736. #define ASCV_MSGOUT_SDTR_OFFSET (ASCV_MSGOUT_BEG+4)
  737. #define ASCV_BREAK_SAVED_CODE (ushort)0x0006
  738. #define ASCV_MSGIN_BEG (ASCV_MSGOUT_BEG+8)
  739. #define ASCV_MSGIN_SDTR_PERIOD (ASCV_MSGIN_BEG+3)
  740. #define ASCV_MSGIN_SDTR_OFFSET (ASCV_MSGIN_BEG+4)
  741. #define ASCV_SDTR_DATA_BEG (ASCV_MSGIN_BEG+8)
  742. #define ASCV_SDTR_DONE_BEG (ASCV_SDTR_DATA_BEG+8)
  743. #define ASCV_MAX_DVC_QNG_BEG (ushort)0x0020
  744. #define ASCV_BREAK_ADDR (ushort)0x0028
  745. #define ASCV_BREAK_NOTIFY_COUNT (ushort)0x002A
  746. #define ASCV_BREAK_CONTROL (ushort)0x002C
  747. #define ASCV_BREAK_HIT_COUNT (ushort)0x002E
  748. #define ASCV_ASCDVC_ERR_CODE_W (ushort)0x0030
  749. #define ASCV_MCODE_CHKSUM_W (ushort)0x0032
  750. #define ASCV_MCODE_SIZE_W (ushort)0x0034
  751. #define ASCV_STOP_CODE_B (ushort)0x0036
  752. #define ASCV_DVC_ERR_CODE_B (ushort)0x0037
  753. #define ASCV_OVERRUN_PADDR_D (ushort)0x0038
  754. #define ASCV_OVERRUN_BSIZE_D (ushort)0x003C
  755. #define ASCV_HALTCODE_W (ushort)0x0040
  756. #define ASCV_CHKSUM_W (ushort)0x0042
  757. #define ASCV_MC_DATE_W (ushort)0x0044
  758. #define ASCV_MC_VER_W (ushort)0x0046
  759. #define ASCV_NEXTRDY_B (ushort)0x0048
  760. #define ASCV_DONENEXT_B (ushort)0x0049
  761. #define ASCV_USE_TAGGED_QNG_B (ushort)0x004A
  762. #define ASCV_SCSIBUSY_B (ushort)0x004B
  763. #define ASCV_Q_DONE_IN_PROGRESS_B (ushort)0x004C
  764. #define ASCV_CURCDB_B (ushort)0x004D
  765. #define ASCV_RCLUN_B (ushort)0x004E
  766. #define ASCV_BUSY_QHEAD_B (ushort)0x004F
  767. #define ASCV_DISC1_QHEAD_B (ushort)0x0050
  768. #define ASCV_DISC_ENABLE_B (ushort)0x0052
  769. #define ASCV_CAN_TAGGED_QNG_B (ushort)0x0053
  770. #define ASCV_HOSTSCSI_ID_B (ushort)0x0055
  771. #define ASCV_MCODE_CNTL_B (ushort)0x0056
  772. #define ASCV_NULL_TARGET_B (ushort)0x0057
  773. #define ASCV_FREE_Q_HEAD_W (ushort)0x0058
  774. #define ASCV_DONE_Q_TAIL_W (ushort)0x005A
  775. #define ASCV_FREE_Q_HEAD_B (ushort)(ASCV_FREE_Q_HEAD_W+1)
  776. #define ASCV_DONE_Q_TAIL_B (ushort)(ASCV_DONE_Q_TAIL_W+1)
  777. #define ASCV_HOST_FLAG_B (ushort)0x005D
  778. #define ASCV_TOTAL_READY_Q_B (ushort)0x0064
  779. #define ASCV_VER_SERIAL_B (ushort)0x0065
  780. #define ASCV_HALTCODE_SAVED_W (ushort)0x0066
  781. #define ASCV_WTM_FLAG_B (ushort)0x0068
  782. #define ASCV_RISC_FLAG_B (ushort)0x006A
  783. #define ASCV_REQ_SG_LIST_QP (ushort)0x006B
  784. #define ASC_HOST_FLAG_IN_ISR 0x01
  785. #define ASC_HOST_FLAG_ACK_INT 0x02
  786. #define ASC_RISC_FLAG_GEN_INT 0x01
  787. #define ASC_RISC_FLAG_REQ_SG_LIST 0x02
  788. #define IOP_CTRL (0x0F)
  789. #define IOP_STATUS (0x0E)
  790. #define IOP_INT_ACK IOP_STATUS
  791. #define IOP_REG_IFC (0x0D)
  792. #define IOP_SYN_OFFSET (0x0B)
  793. #define IOP_EXTRA_CONTROL (0x0D)
  794. #define IOP_REG_PC (0x0C)
  795. #define IOP_RAM_ADDR (0x0A)
  796. #define IOP_RAM_DATA (0x08)
  797. #define IOP_EEP_DATA (0x06)
  798. #define IOP_EEP_CMD (0x07)
  799. #define IOP_VERSION (0x03)
  800. #define IOP_CONFIG_HIGH (0x04)
  801. #define IOP_CONFIG_LOW (0x02)
  802. #define IOP_SIG_BYTE (0x01)
  803. #define IOP_SIG_WORD (0x00)
  804. #define IOP_REG_DC1 (0x0E)
  805. #define IOP_REG_DC0 (0x0C)
  806. #define IOP_REG_SB (0x0B)
  807. #define IOP_REG_DA1 (0x0A)
  808. #define IOP_REG_DA0 (0x08)
  809. #define IOP_REG_SC (0x09)
  810. #define IOP_DMA_SPEED (0x07)
  811. #define IOP_REG_FLAG (0x07)
  812. #define IOP_FIFO_H (0x06)
  813. #define IOP_FIFO_L (0x04)
  814. #define IOP_REG_ID (0x05)
  815. #define IOP_REG_QP (0x03)
  816. #define IOP_REG_IH (0x02)
  817. #define IOP_REG_IX (0x01)
  818. #define IOP_REG_AX (0x00)
  819. #define IFC_REG_LOCK (0x00)
  820. #define IFC_REG_UNLOCK (0x09)
  821. #define IFC_WR_EN_FILTER (0x10)
  822. #define IFC_RD_NO_EEPROM (0x10)
  823. #define IFC_SLEW_RATE (0x20)
  824. #define IFC_ACT_NEG (0x40)
  825. #define IFC_INP_FILTER (0x80)
  826. #define IFC_INIT_DEFAULT (IFC_ACT_NEG | IFC_REG_UNLOCK)
  827. #define SC_SEL (uchar)(0x80)
  828. #define SC_BSY (uchar)(0x40)
  829. #define SC_ACK (uchar)(0x20)
  830. #define SC_REQ (uchar)(0x10)
  831. #define SC_ATN (uchar)(0x08)
  832. #define SC_IO (uchar)(0x04)
  833. #define SC_CD (uchar)(0x02)
  834. #define SC_MSG (uchar)(0x01)
  835. #define SEC_SCSI_CTL (uchar)(0x80)
  836. #define SEC_ACTIVE_NEGATE (uchar)(0x40)
  837. #define SEC_SLEW_RATE (uchar)(0x20)
  838. #define SEC_ENABLE_FILTER (uchar)(0x10)
  839. #define ASC_HALT_EXTMSG_IN (ushort)0x8000
  840. #define ASC_HALT_CHK_CONDITION (ushort)0x8100
  841. #define ASC_HALT_SS_QUEUE_FULL (ushort)0x8200
  842. #define ASC_HALT_DISABLE_ASYN_USE_SYN_FIX (ushort)0x8300
  843. #define ASC_HALT_ENABLE_ASYN_USE_SYN_FIX (ushort)0x8400
  844. #define ASC_HALT_SDTR_REJECTED (ushort)0x4000
  845. #define ASC_HALT_HOST_COPY_SG_LIST_TO_RISC ( ushort )0x2000
  846. #define ASC_MAX_QNO 0xF8
  847. #define ASC_DATA_SEC_BEG (ushort)0x0080
  848. #define ASC_DATA_SEC_END (ushort)0x0080
  849. #define ASC_CODE_SEC_BEG (ushort)0x0080
  850. #define ASC_CODE_SEC_END (ushort)0x0080
  851. #define ASC_QADR_BEG (0x4000)
  852. #define ASC_QADR_USED (ushort)(ASC_MAX_QNO * 64)
  853. #define ASC_QADR_END (ushort)0x7FFF
  854. #define ASC_QLAST_ADR (ushort)0x7FC0
  855. #define ASC_QBLK_SIZE 0x40
  856. #define ASC_BIOS_DATA_QBEG 0xF8
  857. #define ASC_MIN_ACTIVE_QNO 0x01
  858. #define ASC_QLINK_END 0xFF
  859. #define ASC_EEPROM_WORDS 0x10
  860. #define ASC_MAX_MGS_LEN 0x10
  861. #define ASC_BIOS_ADDR_DEF 0xDC00
  862. #define ASC_BIOS_SIZE 0x3800
  863. #define ASC_BIOS_RAM_OFF 0x3800
  864. #define ASC_BIOS_RAM_SIZE 0x800
  865. #define ASC_BIOS_MIN_ADDR 0xC000
  866. #define ASC_BIOS_MAX_ADDR 0xEC00
  867. #define ASC_BIOS_BANK_SIZE 0x0400
  868. #define ASC_MCODE_START_ADDR 0x0080
  869. #define ASC_CFG0_HOST_INT_ON 0x0020
  870. #define ASC_CFG0_BIOS_ON 0x0040
  871. #define ASC_CFG0_VERA_BURST_ON 0x0080
  872. #define ASC_CFG0_SCSI_PARITY_ON 0x0800
  873. #define ASC_CFG1_SCSI_TARGET_ON 0x0080
  874. #define ASC_CFG1_LRAM_8BITS_ON 0x0800
  875. #define ASC_CFG_MSW_CLR_MASK 0x3080
  876. #define CSW_TEST1 (ASC_CS_TYPE)0x8000
  877. #define CSW_AUTO_CONFIG (ASC_CS_TYPE)0x4000
  878. #define CSW_RESERVED1 (ASC_CS_TYPE)0x2000
  879. #define CSW_IRQ_WRITTEN (ASC_CS_TYPE)0x1000
  880. #define CSW_33MHZ_SELECTED (ASC_CS_TYPE)0x0800
  881. #define CSW_TEST2 (ASC_CS_TYPE)0x0400
  882. #define CSW_TEST3 (ASC_CS_TYPE)0x0200
  883. #define CSW_RESERVED2 (ASC_CS_TYPE)0x0100
  884. #define CSW_DMA_DONE (ASC_CS_TYPE)0x0080
  885. #define CSW_FIFO_RDY (ASC_CS_TYPE)0x0040
  886. #define CSW_EEP_READ_DONE (ASC_CS_TYPE)0x0020
  887. #define CSW_HALTED (ASC_CS_TYPE)0x0010
  888. #define CSW_SCSI_RESET_ACTIVE (ASC_CS_TYPE)0x0008
  889. #define CSW_PARITY_ERR (ASC_CS_TYPE)0x0004
  890. #define CSW_SCSI_RESET_LATCH (ASC_CS_TYPE)0x0002
  891. #define CSW_INT_PENDING (ASC_CS_TYPE)0x0001
  892. #define CIW_CLR_SCSI_RESET_INT (ASC_CS_TYPE)0x1000
  893. #define CIW_INT_ACK (ASC_CS_TYPE)0x0100
  894. #define CIW_TEST1 (ASC_CS_TYPE)0x0200
  895. #define CIW_TEST2 (ASC_CS_TYPE)0x0400
  896. #define CIW_SEL_33MHZ (ASC_CS_TYPE)0x0800
  897. #define CIW_IRQ_ACT (ASC_CS_TYPE)0x1000
  898. #define CC_CHIP_RESET (uchar)0x80
  899. #define CC_SCSI_RESET (uchar)0x40
  900. #define CC_HALT (uchar)0x20
  901. #define CC_SINGLE_STEP (uchar)0x10
  902. #define CC_DMA_ABLE (uchar)0x08
  903. #define CC_TEST (uchar)0x04
  904. #define CC_BANK_ONE (uchar)0x02
  905. #define CC_DIAG (uchar)0x01
  906. #define ASC_1000_ID0W 0x04C1
  907. #define ASC_1000_ID0W_FIX 0x00C1
  908. #define ASC_1000_ID1B 0x25
  909. #define ASC_EISA_REV_IOP_MASK (0x0C83)
  910. #define ASC_EISA_PID_IOP_MASK (0x0C80)
  911. #define ASC_EISA_CFG_IOP_MASK (0x0C86)
  912. #define ASC_GET_EISA_SLOT(iop) (PortAddr)((iop) & 0xF000)
  913. #define INS_HALTINT (ushort)0x6281
  914. #define INS_HALT (ushort)0x6280
  915. #define INS_SINT (ushort)0x6200
  916. #define INS_RFLAG_WTM (ushort)0x7380
  917. #define ASC_MC_SAVE_CODE_WSIZE 0x500
  918. #define ASC_MC_SAVE_DATA_WSIZE 0x40
  919. typedef struct asc_mc_saved {
  920. ushort data[ASC_MC_SAVE_DATA_WSIZE];
  921. ushort code[ASC_MC_SAVE_CODE_WSIZE];
  922. } ASC_MC_SAVED;
  923. #define AscGetQDoneInProgress(port) AscReadLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B)
  924. #define AscPutQDoneInProgress(port, val) AscWriteLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B, val)
  925. #define AscGetVarFreeQHead(port) AscReadLramWord((port), ASCV_FREE_Q_HEAD_W)
  926. #define AscGetVarDoneQTail(port) AscReadLramWord((port), ASCV_DONE_Q_TAIL_W)
  927. #define AscPutVarFreeQHead(port, val) AscWriteLramWord((port), ASCV_FREE_Q_HEAD_W, val)
  928. #define AscPutVarDoneQTail(port, val) AscWriteLramWord((port), ASCV_DONE_Q_TAIL_W, val)
  929. #define AscGetRiscVarFreeQHead(port) AscReadLramByte((port), ASCV_NEXTRDY_B)
  930. #define AscGetRiscVarDoneQTail(port) AscReadLramByte((port), ASCV_DONENEXT_B)
  931. #define AscPutRiscVarFreeQHead(port, val) AscWriteLramByte((port), ASCV_NEXTRDY_B, val)
  932. #define AscPutRiscVarDoneQTail(port, val) AscWriteLramByte((port), ASCV_DONENEXT_B, val)
  933. #define AscPutMCodeSDTRDoneAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id), (data));
  934. #define AscGetMCodeSDTRDoneAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id));
  935. #define AscPutMCodeInitSDTRAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id), data);
  936. #define AscGetMCodeInitSDTRAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id));
  937. #define AscSynIndexToPeriod(index) (uchar)(asc_dvc->sdtr_period_tbl[ (index) ])
  938. #define AscGetChipSignatureByte(port) (uchar)inp((port)+IOP_SIG_BYTE)
  939. #define AscGetChipSignatureWord(port) (ushort)inpw((port)+IOP_SIG_WORD)
  940. #define AscGetChipVerNo(port) (uchar)inp((port)+IOP_VERSION)
  941. #define AscGetChipCfgLsw(port) (ushort)inpw((port)+IOP_CONFIG_LOW)
  942. #define AscGetChipCfgMsw(port) (ushort)inpw((port)+IOP_CONFIG_HIGH)
  943. #define AscSetChipCfgLsw(port, data) outpw((port)+IOP_CONFIG_LOW, data)
  944. #define AscSetChipCfgMsw(port, data) outpw((port)+IOP_CONFIG_HIGH, data)
  945. #define AscGetChipEEPCmd(port) (uchar)inp((port)+IOP_EEP_CMD)
  946. #define AscSetChipEEPCmd(port, data) outp((port)+IOP_EEP_CMD, data)
  947. #define AscGetChipEEPData(port) (ushort)inpw((port)+IOP_EEP_DATA)
  948. #define AscSetChipEEPData(port, data) outpw((port)+IOP_EEP_DATA, data)
  949. #define AscGetChipLramAddr(port) (ushort)inpw((PortAddr)((port)+IOP_RAM_ADDR))
  950. #define AscSetChipLramAddr(port, addr) outpw((PortAddr)((port)+IOP_RAM_ADDR), addr)
  951. #define AscGetChipLramData(port) (ushort)inpw((port)+IOP_RAM_DATA)
  952. #define AscSetChipLramData(port, data) outpw((port)+IOP_RAM_DATA, data)
  953. #define AscGetChipIFC(port) (uchar)inp((port)+IOP_REG_IFC)
  954. #define AscSetChipIFC(port, data) outp((port)+IOP_REG_IFC, data)
  955. #define AscGetChipStatus(port) (ASC_CS_TYPE)inpw((port)+IOP_STATUS)
  956. #define AscSetChipStatus(port, cs_val) outpw((port)+IOP_STATUS, cs_val)
  957. #define AscGetChipControl(port) (uchar)inp((port)+IOP_CTRL)
  958. #define AscSetChipControl(port, cc_val) outp((port)+IOP_CTRL, cc_val)
  959. #define AscGetChipSyn(port) (uchar)inp((port)+IOP_SYN_OFFSET)
  960. #define AscSetChipSyn(port, data) outp((port)+IOP_SYN_OFFSET, data)
  961. #define AscSetPCAddr(port, data) outpw((port)+IOP_REG_PC, data)
  962. #define AscGetPCAddr(port) (ushort)inpw((port)+IOP_REG_PC)
  963. #define AscIsIntPending(port) (AscGetChipStatus(port) & (CSW_INT_PENDING | CSW_SCSI_RESET_LATCH))
  964. #define AscGetChipScsiID(port) ((AscGetChipCfgLsw(port) >> 8) & ASC_MAX_TID)
  965. #define AscGetExtraControl(port) (uchar)inp((port)+IOP_EXTRA_CONTROL)
  966. #define AscSetExtraControl(port, data) outp((port)+IOP_EXTRA_CONTROL, data)
  967. #define AscReadChipAX(port) (ushort)inpw((port)+IOP_REG_AX)
  968. #define AscWriteChipAX(port, data) outpw((port)+IOP_REG_AX, data)
  969. #define AscReadChipIX(port) (uchar)inp((port)+IOP_REG_IX)
  970. #define AscWriteChipIX(port, data) outp((port)+IOP_REG_IX, data)
  971. #define AscReadChipIH(port) (ushort)inpw((port)+IOP_REG_IH)
  972. #define AscWriteChipIH(port, data) outpw((port)+IOP_REG_IH, data)
  973. #define AscReadChipQP(port) (uchar)inp((port)+IOP_REG_QP)
  974. #define AscWriteChipQP(port, data) outp((port)+IOP_REG_QP, data)
  975. #define AscReadChipFIFO_L(port) (ushort)inpw((port)+IOP_REG_FIFO_L)
  976. #define AscWriteChipFIFO_L(port, data) outpw((port)+IOP_REG_FIFO_L, data)
  977. #define AscReadChipFIFO_H(port) (ushort)inpw((port)+IOP_REG_FIFO_H)
  978. #define AscWriteChipFIFO_H(port, data) outpw((port)+IOP_REG_FIFO_H, data)
  979. #define AscReadChipDmaSpeed(port) (uchar)inp((port)+IOP_DMA_SPEED)
  980. #define AscWriteChipDmaSpeed(port, data) outp((port)+IOP_DMA_SPEED, data)
  981. #define AscReadChipDA0(port) (ushort)inpw((port)+IOP_REG_DA0)
  982. #define AscWriteChipDA0(port) outpw((port)+IOP_REG_DA0, data)
  983. #define AscReadChipDA1(port) (ushort)inpw((port)+IOP_REG_DA1)
  984. #define AscWriteChipDA1(port) outpw((port)+IOP_REG_DA1, data)
  985. #define AscReadChipDC0(port) (ushort)inpw((port)+IOP_REG_DC0)
  986. #define AscWriteChipDC0(port) outpw((port)+IOP_REG_DC0, data)
  987. #define AscReadChipDC1(port) (ushort)inpw((port)+IOP_REG_DC1)
  988. #define AscWriteChipDC1(port) outpw((port)+IOP_REG_DC1, data)
  989. #define AscReadChipDvcID(port) (uchar)inp((port)+IOP_REG_ID)
  990. #define AscWriteChipDvcID(port, data) outp((port)+IOP_REG_ID, data)
  991. static int AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg);
  992. static int AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg);
  993. static void AscWaitEEPRead(void);
  994. static void AscWaitEEPWrite(void);
  995. static ushort AscReadEEPWord(PortAddr, uchar);
  996. static ushort AscWriteEEPWord(PortAddr, uchar, ushort);
  997. static ushort AscGetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort);
  998. static int AscSetEEPConfigOnce(PortAddr, ASCEEP_CONFIG *, ushort);
  999. static int AscSetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort);
  1000. static int AscStartChip(PortAddr);
  1001. static int AscStopChip(PortAddr);
  1002. static void AscSetChipIH(PortAddr, ushort);
  1003. static int AscIsChipHalted(PortAddr);
  1004. static void AscAckInterrupt(PortAddr);
  1005. static void AscDisableInterrupt(PortAddr);
  1006. static void AscEnableInterrupt(PortAddr);
  1007. static void AscSetBank(PortAddr, uchar);
  1008. static int AscResetChipAndScsiBus(ASC_DVC_VAR *);
  1009. #ifdef CONFIG_ISA
  1010. static uchar AscGetIsaDmaSpeed(PortAddr);
  1011. #endif /* CONFIG_ISA */
  1012. static uchar AscReadLramByte(PortAddr, ushort);
  1013. static ushort AscReadLramWord(PortAddr, ushort);
  1014. #if CC_VERY_LONG_SG_LIST
  1015. static ASC_DCNT AscReadLramDWord(PortAddr, ushort);
  1016. #endif /* CC_VERY_LONG_SG_LIST */
  1017. static void AscWriteLramWord(PortAddr, ushort, ushort);
  1018. static void AscWriteLramByte(PortAddr, ushort, uchar);
  1019. static ASC_DCNT AscMemSumLramWord(PortAddr, ushort, int);
  1020. static void AscMemWordSetLram(PortAddr, ushort, ushort, int);
  1021. static void AscMemWordCopyPtrToLram(PortAddr, ushort, uchar *, int);
  1022. static void AscMemDWordCopyPtrToLram(PortAddr, ushort, uchar *, int);
  1023. static void AscMemWordCopyPtrFromLram(PortAddr, ushort, uchar *, int);
  1024. static ushort AscInitAscDvcVar(ASC_DVC_VAR *);
  1025. static ushort AscInitFromEEP(ASC_DVC_VAR *);
  1026. static ushort AscInitMicroCodeVar(ASC_DVC_VAR *);
  1027. static int AscTestExternalLram(ASC_DVC_VAR *);
  1028. static uchar AscMsgOutSDTR(ASC_DVC_VAR *, uchar, uchar);
  1029. static uchar AscCalSDTRData(ASC_DVC_VAR *, uchar, uchar);
  1030. static void AscSetChipSDTR(PortAddr, uchar, uchar);
  1031. static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *, uchar);
  1032. static uchar AscAllocFreeQueue(PortAddr, uchar);
  1033. static uchar AscAllocMultipleFreeQueue(PortAddr, uchar, uchar);
  1034. static int AscHostReqRiscHalt(PortAddr);
  1035. static int AscStopQueueExe(PortAddr);
  1036. static int AscSendScsiQueue(ASC_DVC_VAR *,
  1037. ASC_SCSI_Q *scsiq, uchar n_q_required);
  1038. static int AscPutReadyQueue(ASC_DVC_VAR *, ASC_SCSI_Q *, uchar);
  1039. static int AscPutReadySgListQueue(ASC_DVC_VAR *, ASC_SCSI_Q *, uchar);
  1040. static int AscSetChipSynRegAtID(PortAddr, uchar, uchar);
  1041. static int AscSetRunChipSynRegAtID(PortAddr, uchar, uchar);
  1042. static ushort AscInitLram(ASC_DVC_VAR *);
  1043. static ushort AscInitQLinkVar(ASC_DVC_VAR *);
  1044. static int AscSetLibErrorCode(ASC_DVC_VAR *, ushort);
  1045. static int AscIsrChipHalted(ASC_DVC_VAR *);
  1046. static uchar _AscCopyLramScsiDoneQ(PortAddr, ushort,
  1047. ASC_QDONE_INFO *, ASC_DCNT);
  1048. static int AscIsrQDone(ASC_DVC_VAR *);
  1049. #ifdef CONFIG_ISA
  1050. static ushort AscGetEisaChipCfg(PortAddr);
  1051. #endif /* CONFIG_ISA */
  1052. static uchar AscGetChipScsiCtrl(PortAddr);
  1053. static uchar AscGetChipVersion(PortAddr, ushort);
  1054. static ASC_DCNT AscLoadMicroCode(PortAddr, ushort, uchar *, ushort);
  1055. static void AscToggleIRQAct(PortAddr);
  1056. static inline ulong DvcEnterCritical(void);
  1057. static inline void DvcLeaveCritical(ulong);
  1058. static void DvcSleepMilliSecond(ASC_DCNT);
  1059. static void DvcDelayNanoSecond(ASC_DVC_VAR *, ASC_DCNT);
  1060. static void DvcPutScsiQ(PortAddr, ushort, uchar *, int);
  1061. static void DvcGetQinfo(PortAddr, ushort, uchar *, int);
  1062. static ushort AscInitAsc1000Driver(ASC_DVC_VAR *);
  1063. static void AscAsyncFix(ASC_DVC_VAR *, struct scsi_device *);
  1064. static int AscExeScsiQueue(ASC_DVC_VAR *, ASC_SCSI_Q *);
  1065. static int AscISR(ASC_DVC_VAR *);
  1066. static uint AscGetNumOfFreeQueue(ASC_DVC_VAR *, uchar, uchar);
  1067. static int AscSgListToQueue(int);
  1068. #ifdef CONFIG_ISA
  1069. static void AscEnableIsaDma(uchar);
  1070. #endif /* CONFIG_ISA */
  1071. static const char *advansys_info(struct Scsi_Host *shost);
  1072. /*
  1073. * --- Adv Library Constants and Macros
  1074. */
  1075. #define ADV_LIB_VERSION_MAJOR 5
  1076. #define ADV_LIB_VERSION_MINOR 14
  1077. /*
  1078. * Define Adv Library required special types.
  1079. */
  1080. /*
  1081. * Portable Data Types
  1082. *
  1083. * Any instance where a 32-bit long or pointer type is assumed
  1084. * for precision or HW defined structures, the following define
  1085. * types must be used. In Linux the char, short, and int types
  1086. * are all consistent at 8, 16, and 32 bits respectively. Pointers
  1087. * and long types are 64 bits on Alpha and UltraSPARC.
  1088. */
  1089. #define ADV_PADDR __u32 /* Physical address data type. */
  1090. #define ADV_VADDR __u32 /* Virtual address data type. */
  1091. #define ADV_DCNT __u32 /* Unsigned Data count type. */
  1092. #define ADV_SDCNT __s32 /* Signed Data count type. */
  1093. /*
  1094. * These macros are used to convert a virtual address to a
  1095. * 32-bit value. This currently can be used on Linux Alpha
  1096. * which uses 64-bit virtual address but a 32-bit bus address.
  1097. * This is likely to break in the future, but doing this now
  1098. * will give us time to change the HW and FW to handle 64-bit
  1099. * addresses.
  1100. */
  1101. #define ADV_VADDR_TO_U32 virt_to_bus
  1102. #define ADV_U32_TO_VADDR bus_to_virt
  1103. #define AdvPortAddr void __iomem * /* Virtual memory address size */
  1104. /*
  1105. * Define Adv Library required memory access macros.
  1106. */
  1107. #define ADV_MEM_READB(addr) readb(addr)
  1108. #define ADV_MEM_READW(addr) readw(addr)
  1109. #define ADV_MEM_WRITEB(addr, byte) writeb(byte, addr)
  1110. #define ADV_MEM_WRITEW(addr, word) writew(word, addr)
  1111. #define ADV_MEM_WRITEDW(addr, dword) writel(dword, addr)
  1112. #define ADV_CARRIER_COUNT (ASC_DEF_MAX_HOST_QNG + 15)
  1113. /*
  1114. * Define total number of simultaneous maximum element scatter-gather
  1115. * request blocks per wide adapter. ASC_DEF_MAX_HOST_QNG (253) is the
  1116. * maximum number of outstanding commands per wide host adapter. Each
  1117. * command uses one or more ADV_SG_BLOCK each with 15 scatter-gather
  1118. * elements. Allow each command to have at least one ADV_SG_BLOCK structure.
  1119. * This allows about 15 commands to have the maximum 17 ADV_SG_BLOCK
  1120. * structures or 255 scatter-gather elements.
  1121. *
  1122. */
  1123. #define ADV_TOT_SG_BLOCK ASC_DEF_MAX_HOST_QNG
  1124. /*
  1125. * Define Adv Library required maximum number of scatter-gather
  1126. * elements per request.
  1127. */
  1128. #define ADV_MAX_SG_LIST 255
  1129. /* Number of SG blocks needed. */
  1130. #define ADV_NUM_SG_BLOCK \
  1131. ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK)
  1132. /* Total contiguous memory needed for SG blocks. */
  1133. #define ADV_SG_TOTAL_MEM_SIZE \
  1134. (sizeof(ADV_SG_BLOCK) * ADV_NUM_SG_BLOCK)
  1135. #define ADV_PAGE_SIZE PAGE_SIZE
  1136. #define ADV_NUM_PAGE_CROSSING \
  1137. ((ADV_SG_TOTAL_MEM_SIZE + (ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
  1138. #define ADV_EEP_DVC_CFG_BEGIN (0x00)
  1139. #define ADV_EEP_DVC_CFG_END (0x15)
  1140. #define ADV_EEP_DVC_CTL_BEGIN (0x16) /* location of OEM name */
  1141. #define ADV_EEP_MAX_WORD_ADDR (0x1E)
  1142. #define ADV_EEP_DELAY_MS 100
  1143. #define ADV_EEPROM_BIG_ENDIAN 0x8000 /* EEPROM Bit 15 */
  1144. #define ADV_EEPROM_BIOS_ENABLE 0x4000 /* EEPROM Bit 14 */
  1145. /*
  1146. * For the ASC3550 Bit 13 is Termination Polarity control bit.
  1147. * For later ICs Bit 13 controls whether the CIS (Card Information
  1148. * Service Section) is loaded from EEPROM.
  1149. */
  1150. #define ADV_EEPROM_TERM_POL 0x2000 /* EEPROM Bit 13 */
  1151. #define ADV_EEPROM_CIS_LD 0x2000 /* EEPROM Bit 13 */
  1152. /*
  1153. * ASC38C1600 Bit 11
  1154. *
  1155. * If EEPROM Bit 11 is 0 for Function 0, then Function 0 will specify
  1156. * INT A in the PCI Configuration Space Int Pin field. If it is 1, then
  1157. * Function 0 will specify INT B.
  1158. *
  1159. * If EEPROM Bit 11 is 0 for Function 1, then Function 1 will specify
  1160. * INT B in the PCI Configuration Space Int Pin field. If it is 1, then
  1161. * Function 1 will specify INT A.
  1162. */
  1163. #define ADV_EEPROM_INTAB 0x0800 /* EEPROM Bit 11 */
  1164. typedef struct adveep_3550_config {
  1165. /* Word Offset, Description */
  1166. ushort cfg_lsw; /* 00 power up initialization */
  1167. /* bit 13 set - Term Polarity Control */
  1168. /* bit 14 set - BIOS Enable */
  1169. /* bit 15 set - Big Endian Mode */
  1170. ushort cfg_msw; /* 01 unused */
  1171. ushort disc_enable; /* 02 disconnect enable */
  1172. ushort wdtr_able; /* 03 Wide DTR able */
  1173. ushort sdtr_able; /* 04 Synchronous DTR able */
  1174. ushort start_motor; /* 05 send start up motor */
  1175. ushort tagqng_able; /* 06 tag queuing able */
  1176. ushort bios_scan; /* 07 BIOS device control */
  1177. ushort scam_tolerant; /* 08 no scam */
  1178. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1179. uchar bios_boot_delay; /* power up wait */
  1180. uchar scsi_reset_delay; /* 10 reset delay */
  1181. uchar bios_id_lun; /* first boot device scsi id & lun */
  1182. /* high nibble is lun */
  1183. /* low nibble is scsi id */
  1184. uchar termination; /* 11 0 - automatic */
  1185. /* 1 - low off / high off */
  1186. /* 2 - low off / high on */
  1187. /* 3 - low on / high on */
  1188. /* There is no low on / high off */
  1189. uchar reserved1; /* reserved byte (not used) */
  1190. ushort bios_ctrl; /* 12 BIOS control bits */
  1191. /* bit 0 BIOS don't act as initiator. */
  1192. /* bit 1 BIOS > 1 GB support */
  1193. /* bit 2 BIOS > 2 Disk Support */
  1194. /* bit 3 BIOS don't support removables */
  1195. /* bit 4 BIOS support bootable CD */
  1196. /* bit 5 BIOS scan enabled */
  1197. /* bit 6 BIOS support multiple LUNs */
  1198. /* bit 7 BIOS display of message */
  1199. /* bit 8 SCAM disabled */
  1200. /* bit 9 Reset SCSI bus during init. */
  1201. /* bit 10 */
  1202. /* bit 11 No verbose initialization. */
  1203. /* bit 12 SCSI parity enabled */
  1204. /* bit 13 */
  1205. /* bit 14 */
  1206. /* bit 15 */
  1207. ushort ultra_able; /* 13 ULTRA speed able */
  1208. ushort reserved2; /* 14 reserved */
  1209. uchar max_host_qng; /* 15 maximum host queuing */
  1210. uchar max_dvc_qng; /* maximum per device queuing */
  1211. ushort dvc_cntl; /* 16 control bit for driver */
  1212. ushort bug_fix; /* 17 control bit for bug fix */
  1213. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1214. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1215. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1216. ushort check_sum; /* 21 EEP check sum */
  1217. uchar oem_name[16]; /* 22 OEM name */
  1218. ushort dvc_err_code; /* 30 last device driver error code */
  1219. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1220. ushort adv_err_addr; /* 32 last uc error address */
  1221. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1222. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1223. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1224. ushort num_of_err; /* 36 number of error */
  1225. } ADVEEP_3550_CONFIG;
  1226. typedef struct adveep_38C0800_config {
  1227. /* Word Offset, Description */
  1228. ushort cfg_lsw; /* 00 power up initialization */
  1229. /* bit 13 set - Load CIS */
  1230. /* bit 14 set - BIOS Enable */
  1231. /* bit 15 set - Big Endian Mode */
  1232. ushort cfg_msw; /* 01 unused */
  1233. ushort disc_enable; /* 02 disconnect enable */
  1234. ushort wdtr_able; /* 03 Wide DTR able */
  1235. ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
  1236. ushort start_motor; /* 05 send start up motor */
  1237. ushort tagqng_able; /* 06 tag queuing able */
  1238. ushort bios_scan; /* 07 BIOS device control */
  1239. ushort scam_tolerant; /* 08 no scam */
  1240. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1241. uchar bios_boot_delay; /* power up wait */
  1242. uchar scsi_reset_delay; /* 10 reset delay */
  1243. uchar bios_id_lun; /* first boot device scsi id & lun */
  1244. /* high nibble is lun */
  1245. /* low nibble is scsi id */
  1246. uchar termination_se; /* 11 0 - automatic */
  1247. /* 1 - low off / high off */
  1248. /* 2 - low off / high on */
  1249. /* 3 - low on / high on */
  1250. /* There is no low on / high off */
  1251. uchar termination_lvd; /* 11 0 - automatic */
  1252. /* 1 - low off / high off */
  1253. /* 2 - low off / high on */
  1254. /* 3 - low on / high on */
  1255. /* There is no low on / high off */
  1256. ushort bios_ctrl; /* 12 BIOS control bits */
  1257. /* bit 0 BIOS don't act as initiator. */
  1258. /* bit 1 BIOS > 1 GB support */
  1259. /* bit 2 BIOS > 2 Disk Support */
  1260. /* bit 3 BIOS don't support removables */
  1261. /* bit 4 BIOS support bootable CD */
  1262. /* bit 5 BIOS scan enabled */
  1263. /* bit 6 BIOS support multiple LUNs */
  1264. /* bit 7 BIOS display of message */
  1265. /* bit 8 SCAM disabled */
  1266. /* bit 9 Reset SCSI bus during init. */
  1267. /* bit 10 */
  1268. /* bit 11 No verbose initialization. */
  1269. /* bit 12 SCSI parity enabled */
  1270. /* bit 13 */
  1271. /* bit 14 */
  1272. /* bit 15 */
  1273. ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
  1274. ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
  1275. uchar max_host_qng; /* 15 maximum host queueing */
  1276. uchar max_dvc_qng; /* maximum per device queuing */
  1277. ushort dvc_cntl; /* 16 control bit for driver */
  1278. ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
  1279. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1280. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1281. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1282. ushort check_sum; /* 21 EEP check sum */
  1283. uchar oem_name[16]; /* 22 OEM name */
  1284. ushort dvc_err_code; /* 30 last device driver error code */
  1285. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1286. ushort adv_err_addr; /* 32 last uc error address */
  1287. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1288. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1289. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1290. ushort reserved36; /* 36 reserved */
  1291. ushort reserved37; /* 37 reserved */
  1292. ushort reserved38; /* 38 reserved */
  1293. ushort reserved39; /* 39 reserved */
  1294. ushort reserved40; /* 40 reserved */
  1295. ushort reserved41; /* 41 reserved */
  1296. ushort reserved42; /* 42 reserved */
  1297. ushort reserved43; /* 43 reserved */
  1298. ushort reserved44; /* 44 reserved */
  1299. ushort reserved45; /* 45 reserved */
  1300. ushort reserved46; /* 46 reserved */
  1301. ushort reserved47; /* 47 reserved */
  1302. ushort reserved48; /* 48 reserved */
  1303. ushort reserved49; /* 49 reserved */
  1304. ushort reserved50; /* 50 reserved */
  1305. ushort reserved51; /* 51 reserved */
  1306. ushort reserved52; /* 52 reserved */
  1307. ushort reserved53; /* 53 reserved */
  1308. ushort reserved54; /* 54 reserved */
  1309. ushort reserved55; /* 55 reserved */
  1310. ushort cisptr_lsw; /* 56 CIS PTR LSW */
  1311. ushort cisprt_msw; /* 57 CIS PTR MSW */
  1312. ushort subsysvid; /* 58 SubSystem Vendor ID */
  1313. ushort subsysid; /* 59 SubSystem ID */
  1314. ushort reserved60; /* 60 reserved */
  1315. ushort reserved61; /* 61 reserved */
  1316. ushort reserved62; /* 62 reserved */
  1317. ushort reserved63; /* 63 reserved */
  1318. } ADVEEP_38C0800_CONFIG;
  1319. typedef struct adveep_38C1600_config {
  1320. /* Word Offset, Description */
  1321. ushort cfg_lsw; /* 00 power up initialization */
  1322. /* bit 11 set - Func. 0 INTB, Func. 1 INTA */
  1323. /* clear - Func. 0 INTA, Func. 1 INTB */
  1324. /* bit 13 set - Load CIS */
  1325. /* bit 14 set - BIOS Enable */
  1326. /* bit 15 set - Big Endian Mode */
  1327. ushort cfg_msw; /* 01 unused */
  1328. ushort disc_enable; /* 02 disconnect enable */
  1329. ushort wdtr_able; /* 03 Wide DTR able */
  1330. ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
  1331. ushort start_motor; /* 05 send start up motor */
  1332. ushort tagqng_able; /* 06 tag queuing able */
  1333. ushort bios_scan; /* 07 BIOS device control */
  1334. ushort scam_tolerant; /* 08 no scam */
  1335. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1336. uchar bios_boot_delay; /* power up wait */
  1337. uchar scsi_reset_delay; /* 10 reset delay */
  1338. uchar bios_id_lun; /* first boot device scsi id & lun */
  1339. /* high nibble is lun */
  1340. /* low nibble is scsi id */
  1341. uchar termination_se; /* 11 0 - automatic */
  1342. /* 1 - low off / high off */
  1343. /* 2 - low off / high on */
  1344. /* 3 - low on / high on */
  1345. /* There is no low on / high off */
  1346. uchar termination_lvd; /* 11 0 - automatic */
  1347. /* 1 - low off / high off */
  1348. /* 2 - low off / high on */
  1349. /* 3 - low on / high on */
  1350. /* There is no low on / high off */
  1351. ushort bios_ctrl; /* 12 BIOS control bits */
  1352. /* bit 0 BIOS don't act as initiator. */
  1353. /* bit 1 BIOS > 1 GB support */
  1354. /* bit 2 BIOS > 2 Disk Support */
  1355. /* bit 3 BIOS don't support removables */
  1356. /* bit 4 BIOS support bootable CD */
  1357. /* bit 5 BIOS scan enabled */
  1358. /* bit 6 BIOS support multiple LUNs */
  1359. /* bit 7 BIOS display of message */
  1360. /* bit 8 SCAM disabled */
  1361. /* bit 9 Reset SCSI bus during init. */
  1362. /* bit 10 Basic Integrity Checking disabled */
  1363. /* bit 11 No verbose initialization. */
  1364. /* bit 12 SCSI parity enabled */
  1365. /* bit 13 AIPP (Asyn. Info. Ph. Prot.) dis. */
  1366. /* bit 14 */
  1367. /* bit 15 */
  1368. ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
  1369. ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
  1370. uchar max_host_qng; /* 15 maximum host queueing */
  1371. uchar max_dvc_qng; /* maximum per device queuing */
  1372. ushort dvc_cntl; /* 16 control bit for driver */
  1373. ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
  1374. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1375. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1376. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1377. ushort check_sum; /* 21 EEP check sum */
  1378. uchar oem_name[16]; /* 22 OEM name */
  1379. ushort dvc_err_code; /* 30 last device driver error code */
  1380. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1381. ushort adv_err_addr; /* 32 last uc error address */
  1382. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1383. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1384. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1385. ushort reserved36; /* 36 reserved */
  1386. ushort reserved37; /* 37 reserved */
  1387. ushort reserved38; /* 38 reserved */
  1388. ushort reserved39; /* 39 reserved */
  1389. ushort reserved40; /* 40 reserved */
  1390. ushort reserved41; /* 41 reserved */
  1391. ushort reserved42; /* 42 reserved */
  1392. ushort reserved43; /* 43 reserved */
  1393. ushort reserved44; /* 44 reserved */
  1394. ushort reserved45; /* 45 reserved */
  1395. ushort reserved46; /* 46 reserved */
  1396. ushort reserved47; /* 47 reserved */
  1397. ushort reserved48; /* 48 reserved */
  1398. ushort reserved49; /* 49 reserved */
  1399. ushort reserved50; /* 50 reserved */
  1400. ushort reserved51; /* 51 reserved */
  1401. ushort reserved52; /* 52 reserved */
  1402. ushort reserved53; /* 53 reserved */
  1403. ushort reserved54; /* 54 reserved */
  1404. ushort reserved55; /* 55 reserved */
  1405. ushort cisptr_lsw; /* 56 CIS PTR LSW */
  1406. ushort cisprt_msw; /* 57 CIS PTR MSW */
  1407. ushort subsysvid; /* 58 SubSystem Vendor ID */
  1408. ushort subsysid; /* 59 SubSystem ID */
  1409. ushort reserved60; /* 60 reserved */
  1410. ushort reserved61; /* 61 reserved */
  1411. ushort reserved62; /* 62 reserved */
  1412. ushort reserved63; /* 63 reserved */
  1413. } ADVEEP_38C1600_CONFIG;
  1414. /*
  1415. * EEPROM Commands
  1416. */
  1417. #define ASC_EEP_CMD_DONE 0x0200
  1418. #define ASC_EEP_CMD_DONE_ERR 0x0001
  1419. /* cfg_word */
  1420. #define EEP_CFG_WORD_BIG_ENDIAN 0x8000
  1421. /* bios_ctrl */
  1422. #define BIOS_CTRL_BIOS 0x0001
  1423. #define BIOS_CTRL_EXTENDED_XLAT 0x0002
  1424. #define BIOS_CTRL_GT_2_DISK 0x0004
  1425. #define BIOS_CTRL_BIOS_REMOVABLE 0x0008
  1426. #define BIOS_CTRL_BOOTABLE_CD 0x0010
  1427. #define BIOS_CTRL_MULTIPLE_LUN 0x0040
  1428. #define BIOS_CTRL_DISPLAY_MSG 0x0080
  1429. #define BIOS_CTRL_NO_SCAM 0x0100
  1430. #define BIOS_CTRL_RESET_SCSI_BUS 0x0200
  1431. #define BIOS_CTRL_INIT_VERBOSE 0x0800
  1432. #define BIOS_CTRL_SCSI_PARITY 0x1000
  1433. #define BIOS_CTRL_AIPP_DIS 0x2000
  1434. #define ADV_3550_MEMSIZE 0x2000 /* 8 KB Internal Memory */
  1435. #define ADV_38C0800_MEMSIZE 0x4000 /* 16 KB Internal Memory */
  1436. /*
  1437. * XXX - Since ASC38C1600 Rev.3 has a local RAM failure issue, there is
  1438. * a special 16K Adv Library and Microcode version. After the issue is
  1439. * resolved, should restore 32K support.
  1440. *
  1441. * #define ADV_38C1600_MEMSIZE 0x8000L * 32 KB Internal Memory *
  1442. */
  1443. #define ADV_38C1600_MEMSIZE 0x4000 /* 16 KB Internal Memory */
  1444. /*
  1445. * Byte I/O register address from base of 'iop_base'.
  1446. */
  1447. #define IOPB_INTR_STATUS_REG 0x00
  1448. #define IOPB_CHIP_ID_1 0x01
  1449. #define IOPB_INTR_ENABLES 0x02
  1450. #define IOPB_CHIP_TYPE_REV 0x03
  1451. #define IOPB_RES_ADDR_4 0x04
  1452. #define IOPB_RES_ADDR_5 0x05
  1453. #define IOPB_RAM_DATA 0x06
  1454. #define IOPB_RES_ADDR_7 0x07
  1455. #define IOPB_FLAG_REG 0x08
  1456. #define IOPB_RES_ADDR_9 0x09
  1457. #define IOPB_RISC_CSR 0x0A
  1458. #define IOPB_RES_ADDR_B 0x0B
  1459. #define IOPB_RES_ADDR_C 0x0C
  1460. #define IOPB_RES_ADDR_D 0x0D
  1461. #define IOPB_SOFT_OVER_WR 0x0E
  1462. #define IOPB_RES_ADDR_F 0x0F
  1463. #define IOPB_MEM_CFG 0x10
  1464. #define IOPB_RES_ADDR_11 0x11
  1465. #define IOPB_GPIO_DATA 0x12
  1466. #define IOPB_RES_ADDR_13 0x13
  1467. #define IOPB_FLASH_PAGE 0x14
  1468. #define IOPB_RES_ADDR_15 0x15
  1469. #define IOPB_GPIO_CNTL 0x16
  1470. #define IOPB_RES_ADDR_17 0x17
  1471. #define IOPB_FLASH_DATA 0x18
  1472. #define IOPB_RES_ADDR_19 0x19
  1473. #define IOPB_RES_ADDR_1A 0x1A
  1474. #define IOPB_RES_ADDR_1B 0x1B
  1475. #define IOPB_RES_ADDR_1C 0x1C
  1476. #define IOPB_RES_ADDR_1D 0x1D
  1477. #define IOPB_RES_ADDR_1E 0x1E
  1478. #define IOPB_RES_ADDR_1F 0x1F
  1479. #define IOPB_DMA_CFG0 0x20
  1480. #define IOPB_DMA_CFG1 0x21
  1481. #define IOPB_TICKLE 0x22
  1482. #define IOPB_DMA_REG_WR 0x23
  1483. #define IOPB_SDMA_STATUS 0x24
  1484. #define IOPB_SCSI_BYTE_CNT 0x25
  1485. #define IOPB_HOST_BYTE_CNT 0x26
  1486. #define IOPB_BYTE_LEFT_TO_XFER 0x27
  1487. #define IOPB_BYTE_TO_XFER_0 0x28
  1488. #define IOPB_BYTE_TO_XFER_1 0x29
  1489. #define IOPB_BYTE_TO_XFER_2 0x2A
  1490. #define IOPB_BYTE_TO_XFER_3 0x2B
  1491. #define IOPB_ACC_GRP 0x2C
  1492. #define IOPB_RES_ADDR_2D 0x2D
  1493. #define IOPB_DEV_ID 0x2E
  1494. #define IOPB_RES_ADDR_2F 0x2F
  1495. #define IOPB_SCSI_DATA 0x30
  1496. #define IOPB_RES_ADDR_31 0x31
  1497. #define IOPB_RES_ADDR_32 0x32
  1498. #define IOPB_SCSI_DATA_HSHK 0x33
  1499. #define IOPB_SCSI_CTRL 0x34
  1500. #define IOPB_RES_ADDR_35 0x35
  1501. #define IOPB_RES_ADDR_36 0x36
  1502. #define IOPB_RES_ADDR_37 0x37
  1503. #define IOPB_RAM_BIST 0x38
  1504. #define IOPB_PLL_TEST 0x39
  1505. #define IOPB_PCI_INT_CFG 0x3A
  1506. #define IOPB_RES_ADDR_3B 0x3B
  1507. #define IOPB_RFIFO_CNT 0x3C
  1508. #define IOPB_RES_ADDR_3D 0x3D
  1509. #define IOPB_RES_ADDR_3E 0x3E
  1510. #define IOPB_RES_ADDR_3F 0x3F
  1511. /*
  1512. * Word I/O register address from base of 'iop_base'.
  1513. */
  1514. #define IOPW_CHIP_ID_0 0x00 /* CID0 */
  1515. #define IOPW_CTRL_REG 0x02 /* CC */
  1516. #define IOPW_RAM_ADDR 0x04 /* LA */
  1517. #define IOPW_RAM_DATA 0x06 /* LD */
  1518. #define IOPW_RES_ADDR_08 0x08
  1519. #define IOPW_RISC_CSR 0x0A /* CSR */
  1520. #define IOPW_SCSI_CFG0 0x0C /* CFG0 */
  1521. #define IOPW_SCSI_CFG1 0x0E /* CFG1 */
  1522. #define IOPW_RES_ADDR_10 0x10
  1523. #define IOPW_SEL_MASK 0x12 /* SM */
  1524. #define IOPW_RES_ADDR_14 0x14
  1525. #define IOPW_FLASH_ADDR 0x16 /* FA */
  1526. #define IOPW_RES_ADDR_18 0x18
  1527. #define IOPW_EE_CMD 0x1A /* EC */
  1528. #define IOPW_EE_DATA 0x1C /* ED */
  1529. #define IOPW_SFIFO_CNT 0x1E /* SFC */
  1530. #define IOPW_RES_ADDR_20 0x20
  1531. #define IOPW_Q_BASE 0x22 /* QB */
  1532. #define IOPW_QP 0x24 /* QP */
  1533. #define IOPW_IX 0x26 /* IX */
  1534. #define IOPW_SP 0x28 /* SP */
  1535. #define IOPW_PC 0x2A /* PC */
  1536. #define IOPW_RES_ADDR_2C 0x2C
  1537. #define IOPW_RES_ADDR_2E 0x2E
  1538. #define IOPW_SCSI_DATA 0x30 /* SD */
  1539. #define IOPW_SCSI_DATA_HSHK 0x32 /* SDH */
  1540. #define IOPW_SCSI_CTRL 0x34 /* SC */
  1541. #define IOPW_HSHK_CFG 0x36 /* HCFG */
  1542. #define IOPW_SXFR_STATUS 0x36 /* SXS */
  1543. #define IOPW_SXFR_CNTL 0x38 /* SXL */
  1544. #define IOPW_SXFR_CNTH 0x3A /* SXH */
  1545. #define IOPW_RES_ADDR_3C 0x3C
  1546. #define IOPW_RFIFO_DATA 0x3E /* RFD */
  1547. /*
  1548. * Doubleword I/O register address from base of 'iop_base'.
  1549. */
  1550. #define IOPDW_RES_ADDR_0 0x00
  1551. #define IOPDW_RAM_DATA 0x04
  1552. #define IOPDW_RES_ADDR_8 0x08
  1553. #define IOPDW_RES_ADDR_C 0x0C
  1554. #define IOPDW_RES_ADDR_10 0x10
  1555. #define IOPDW_COMMA 0x14
  1556. #define IOPDW_COMMB 0x18
  1557. #define IOPDW_RES_ADDR_1C 0x1C
  1558. #define IOPDW_SDMA_ADDR0 0x20
  1559. #define IOPDW_SDMA_ADDR1 0x24
  1560. #define IOPDW_SDMA_COUNT 0x28
  1561. #define IOPDW_SDMA_ERROR 0x2C
  1562. #define IOPDW_RDMA_ADDR0 0x30
  1563. #define IOPDW_RDMA_ADDR1 0x34
  1564. #define IOPDW_RDMA_COUNT 0x38
  1565. #define IOPDW_RDMA_ERROR 0x3C
  1566. #define ADV_CHIP_ID_BYTE 0x25
  1567. #define ADV_CHIP_ID_WORD 0x04C1
  1568. #define ADV_SC_SCSI_BUS_RESET 0x2000
  1569. #define ADV_INTR_ENABLE_HOST_INTR 0x01
  1570. #define ADV_INTR_ENABLE_SEL_INTR 0x02
  1571. #define ADV_INTR_ENABLE_DPR_INTR 0x04
  1572. #define ADV_INTR_ENABLE_RTA_INTR 0x08
  1573. #define ADV_INTR_ENABLE_RMA_INTR 0x10
  1574. #define ADV_INTR_ENABLE_RST_INTR 0x20
  1575. #define ADV_INTR_ENABLE_DPE_INTR 0x40
  1576. #define ADV_INTR_ENABLE_GLOBAL_INTR 0x80
  1577. #define ADV_INTR_STATUS_INTRA 0x01
  1578. #define ADV_INTR_STATUS_INTRB 0x02
  1579. #define ADV_INTR_STATUS_INTRC 0x04
  1580. #define ADV_RISC_CSR_STOP (0x0000)
  1581. #define ADV_RISC_TEST_COND (0x2000)
  1582. #define ADV_RISC_CSR_RUN (0x4000)
  1583. #define ADV_RISC_CSR_SINGLE_STEP (0x8000)
  1584. #define ADV_CTRL_REG_HOST_INTR 0x0100
  1585. #define ADV_CTRL_REG_SEL_INTR 0x0200
  1586. #define ADV_CTRL_REG_DPR_INTR 0x0400
  1587. #define ADV_CTRL_REG_RTA_INTR 0x0800
  1588. #define ADV_CTRL_REG_RMA_INTR 0x1000
  1589. #define ADV_CTRL_REG_RES_BIT14 0x2000
  1590. #define ADV_CTRL_REG_DPE_INTR 0x4000
  1591. #define ADV_CTRL_REG_POWER_DONE 0x8000
  1592. #define ADV_CTRL_REG_ANY_INTR 0xFF00
  1593. #define ADV_CTRL_REG_CMD_RESET 0x00C6
  1594. #define ADV_CTRL_REG_CMD_WR_IO_REG 0x00C5
  1595. #define ADV_CTRL_REG_CMD_RD_IO_REG 0x00C4
  1596. #define ADV_CTRL_REG_CMD_WR_PCI_CFG_SPACE 0x00C3
  1597. #define ADV_CTRL_REG_CMD_RD_PCI_CFG_SPACE 0x00C2
  1598. #define ADV_TICKLE_NOP 0x00
  1599. #define ADV_TICKLE_A 0x01
  1600. #define ADV_TICKLE_B 0x02
  1601. #define ADV_TICKLE_C 0x03
  1602. #define ADV_SCSI_CTRL_RSTOUT 0x2000
  1603. #define AdvIsIntPending(port) \
  1604. (AdvReadWordRegister(port, IOPW_CTRL_REG) & ADV_CTRL_REG_HOST_INTR)
  1605. /*
  1606. * SCSI_CFG0 Register bit definitions
  1607. */
  1608. #define TIMER_MODEAB 0xC000 /* Watchdog, Second, and Select. Timer Ctrl. */
  1609. #define PARITY_EN 0x2000 /* Enable SCSI Parity Error detection */
  1610. #define EVEN_PARITY 0x1000 /* Select Even Parity */
  1611. #define WD_LONG 0x0800 /* Watchdog Interval, 1: 57 min, 0: 13 sec */
  1612. #define QUEUE_128 0x0400 /* Queue Size, 1: 128 byte, 0: 64 byte */
  1613. #define PRIM_MODE 0x0100 /* Primitive SCSI mode */
  1614. #define SCAM_EN 0x0080 /* Enable SCAM selection */
  1615. #define SEL_TMO_LONG 0x0040 /* Sel/Resel Timeout, 1: 400 ms, 0: 1.6 ms */
  1616. #define CFRM_ID 0x0020 /* SCAM id sel. confirm., 1: fast, 0: 6.4 ms */
  1617. #define OUR_ID_EN 0x0010 /* Enable OUR_ID bits */
  1618. #define OUR_ID 0x000F /* SCSI ID */
  1619. /*
  1620. * SCSI_CFG1 Register bit definitions
  1621. */
  1622. #define BIG_ENDIAN 0x8000 /* Enable Big Endian Mode MIO:15, EEP:15 */
  1623. #define TERM_POL 0x2000 /* Terminator Polarity Ctrl. MIO:13, EEP:13 */
  1624. #define SLEW_RATE 0x1000 /* SCSI output buffer slew rate */
  1625. #define FILTER_SEL 0x0C00 /* Filter Period Selection */
  1626. #define FLTR_DISABLE 0x0000 /* Input Filtering Disabled */
  1627. #define FLTR_11_TO_20NS 0x0800 /* Input Filtering 11ns to 20ns */
  1628. #define FLTR_21_TO_39NS 0x0C00 /* Input Filtering 21ns to 39ns */
  1629. #define ACTIVE_DBL 0x0200 /* Disable Active Negation */
  1630. #define DIFF_MODE 0x0100 /* SCSI differential Mode (Read-Only) */
  1631. #define DIFF_SENSE 0x0080 /* 1: No SE cables, 0: SE cable (Read-Only) */
  1632. #define TERM_CTL_SEL 0x0040 /* Enable TERM_CTL_H and TERM_CTL_L */
  1633. #define TERM_CTL 0x0030 /* External SCSI Termination Bits */
  1634. #define TERM_CTL_H 0x0020 /* Enable External SCSI Upper Termination */
  1635. #define TERM_CTL_L 0x0010 /* Enable External SCSI Lower Termination */
  1636. #define CABLE_DETECT 0x000F /* External SCSI Cable Connection Status */
  1637. /*
  1638. * Addendum for ASC-38C0800 Chip
  1639. *
  1640. * The ASC-38C1600 Chip uses the same definitions except that the
  1641. * bus mode override bits [12:10] have been moved to byte register
  1642. * offset 0xE (IOPB_SOFT_OVER_WR) bits [12:10]. The [12:10] bits in
  1643. * SCSI_CFG1 are read-only and always available. Bit 14 (DIS_TERM_DRV)
  1644. * is not needed. The [12:10] bits in IOPB_SOFT_OVER_WR are write-only.
  1645. * Also each ASC-38C1600 function or channel uses only cable bits [5:4]
  1646. * and [1:0]. Bits [14], [7:6], [3:2] are unused.
  1647. */
  1648. #define DIS_TERM_DRV 0x4000 /* 1: Read c_det[3:0], 0: cannot read */
  1649. #define HVD_LVD_SE 0x1C00 /* Device Detect Bits */
  1650. #define HVD 0x1000 /* HVD Device Detect */
  1651. #define LVD 0x0800 /* LVD Device Detect */
  1652. #define SE 0x0400 /* SE Device Detect */
  1653. #define TERM_LVD 0x00C0 /* LVD Termination Bits */
  1654. #define TERM_LVD_HI 0x0080 /* Enable LVD Upper Termination */
  1655. #define TERM_LVD_LO 0x0040 /* Enable LVD Lower Termination */
  1656. #define TERM_SE 0x0030 /* SE Termination Bits */
  1657. #define TERM_SE_HI 0x0020 /* Enable SE Upper Termination */
  1658. #define TERM_SE_LO 0x0010 /* Enable SE Lower Termination */
  1659. #define C_DET_LVD 0x000C /* LVD Cable Detect Bits */
  1660. #define C_DET3 0x0008 /* Cable Detect for LVD External Wide */
  1661. #define C_DET2 0x0004 /* Cable Detect for LVD Internal Wide */
  1662. #define C_DET_SE 0x0003 /* SE Cable Detect Bits */
  1663. #define C_DET1 0x0002 /* Cable Detect for SE Internal Wide */
  1664. #define C_DET0 0x0001 /* Cable Detect for SE Internal Narrow */
  1665. #define CABLE_ILLEGAL_A 0x7
  1666. /* x 0 0 0 | on on | Illegal (all 3 connectors are used) */
  1667. #define CABLE_ILLEGAL_B 0xB
  1668. /* 0 x 0 0 | on on | Illegal (all 3 connectors are used) */
  1669. /*
  1670. * MEM_CFG Register bit definitions
  1671. */
  1672. #define BIOS_EN 0x40 /* BIOS Enable MIO:14,EEP:14 */
  1673. #define FAST_EE_CLK 0x20 /* Diagnostic Bit */
  1674. #define RAM_SZ 0x1C /* Specify size of RAM to RISC */
  1675. #define RAM_SZ_2KB 0x00 /* 2 KB */
  1676. #define RAM_SZ_4KB 0x04 /* 4 KB */
  1677. #define RAM_SZ_8KB 0x08 /* 8 KB */
  1678. #define RAM_SZ_16KB 0x0C /* 16 KB */
  1679. #define RAM_SZ_32KB 0x10 /* 32 KB */
  1680. #define RAM_SZ_64KB 0x14 /* 64 KB */
  1681. /*
  1682. * DMA_CFG0 Register bit definitions
  1683. *
  1684. * This register is only accessible to the host.
  1685. */
  1686. #define BC_THRESH_ENB 0x80 /* PCI DMA Start Conditions */
  1687. #define FIFO_THRESH 0x70 /* PCI DMA FIFO Threshold */
  1688. #define FIFO_THRESH_16B 0x00 /* 16 bytes */
  1689. #define FIFO_THRESH_32B 0x20 /* 32 bytes */
  1690. #define FIFO_THRESH_48B 0x30 /* 48 bytes */
  1691. #define FIFO_THRESH_64B 0x40 /* 64 bytes */
  1692. #define FIFO_THRESH_80B 0x50 /* 80 bytes (default) */
  1693. #define FIFO_THRESH_96B 0x60 /* 96 bytes */
  1694. #define FIFO_THRESH_112B 0x70 /* 112 bytes */
  1695. #define START_CTL 0x0C /* DMA start conditions */
  1696. #define START_CTL_TH 0x00 /* Wait threshold level (default) */
  1697. #define START_CTL_ID 0x04 /* Wait SDMA/SBUS idle */
  1698. #define START_CTL_THID 0x08 /* Wait threshold and SDMA/SBUS idle */
  1699. #define START_CTL_EMFU 0x0C /* Wait SDMA FIFO empty/full */
  1700. #define READ_CMD 0x03 /* Memory Read Method */
  1701. #define READ_CMD_MR 0x00 /* Memory Read */
  1702. #define READ_CMD_MRL 0x02 /* Memory Read Long */
  1703. #define READ_CMD_MRM 0x03 /* Memory Read Multiple (default) */
  1704. /*
  1705. * ASC-38C0800 RAM BIST Register bit definitions
  1706. */
  1707. #define RAM_TEST_MODE 0x80
  1708. #define PRE_TEST_MODE 0x40
  1709. #define NORMAL_MODE 0x00
  1710. #define RAM_TEST_DONE 0x10
  1711. #define RAM_TEST_STATUS 0x0F
  1712. #define RAM_TEST_HOST_ERROR 0x08
  1713. #define RAM_TEST_INTRAM_ERROR 0x04
  1714. #define RAM_TEST_RISC_ERROR 0x02
  1715. #define RAM_TEST_SCSI_ERROR 0x01
  1716. #define RAM_TEST_SUCCESS 0x00
  1717. #define PRE_TEST_VALUE 0x05
  1718. #define NORMAL_VALUE 0x00
  1719. /*
  1720. * ASC38C1600 Definitions
  1721. *
  1722. * IOPB_PCI_INT_CFG Bit Field Definitions
  1723. */
  1724. #define INTAB_LD 0x80 /* Value loaded from EEPROM Bit 11. */
  1725. /*
  1726. * Bit 1 can be set to change the interrupt for the Function to operate in
  1727. * Totem Pole mode. By default Bit 1 is 0 and the interrupt operates in
  1728. * Open Drain mode. Both functions of the ASC38C1600 must be set to the same
  1729. * mode, otherwise the operating mode is undefined.
  1730. */
  1731. #define TOTEMPOLE 0x02
  1732. /*
  1733. * Bit 0 can be used to change the Int Pin for the Function. The value is
  1734. * 0 by default for both Functions with Function 0 using INT A and Function
  1735. * B using INT B. For Function 0 if set, INT B is used. For Function 1 if set,
  1736. * INT A is used.
  1737. *
  1738. * EEPROM Word 0 Bit 11 for each Function may change the initial Int Pin
  1739. * value specified in the PCI Configuration Space.
  1740. */
  1741. #define INTAB 0x01
  1742. /* a_advlib.h */
  1743. /*
  1744. * Adv Library Status Definitions
  1745. */
  1746. #define ADV_TRUE 1
  1747. #define ADV_FALSE 0
  1748. #define ADV_NOERROR 1
  1749. #define ADV_SUCCESS 1
  1750. #define ADV_BUSY 0
  1751. #define ADV_ERROR (-1)
  1752. /*
  1753. * ADV_DVC_VAR 'warn_code' values
  1754. */
  1755. #define ASC_WARN_BUSRESET_ERROR 0x0001 /* SCSI Bus Reset error */
  1756. #define ASC_WARN_EEPROM_CHKSUM 0x0002 /* EEP check sum error */
  1757. #define ASC_WARN_EEPROM_TERMINATION 0x0004 /* EEP termination bad field */
  1758. #define ASC_WARN_SET_PCI_CONFIG_SPACE 0x0080 /* PCI config space set error */
  1759. #define ASC_WARN_ERROR 0xFFFF /* ADV_ERROR return */
  1760. #define ADV_MAX_TID 15 /* max. target identifier */
  1761. #define ADV_MAX_LUN 7 /* max. logical unit number */
  1762. /*
  1763. * Error code values are set in ADV_DVC_VAR 'err_code'.
  1764. */
  1765. #define ASC_IERR_WRITE_EEPROM 0x0001 /* write EEPROM error */
  1766. #define ASC_IERR_MCODE_CHKSUM 0x0002 /* micro code check sum error */
  1767. #define ASC_IERR_NO_CARRIER 0x0004 /* No more carrier memory. */
  1768. #define ASC_IERR_START_STOP_CHIP 0x0008 /* start/stop chip failed */
  1769. #define ASC_IERR_CHIP_VERSION 0x0040 /* wrong chip version */
  1770. #define ASC_IERR_SET_SCSI_ID 0x0080 /* set SCSI ID failed */
  1771. #define ASC_IERR_HVD_DEVICE 0x0100 /* HVD attached to LVD connector. */
  1772. #define ASC_IERR_BAD_SIGNATURE 0x0200 /* signature not found */
  1773. #define ASC_IERR_ILLEGAL_CONNECTION 0x0400 /* Illegal cable connection */
  1774. #define ASC_IERR_SINGLE_END_DEVICE 0x0800 /* Single-end used w/differential */
  1775. #define ASC_IERR_REVERSED_CABLE 0x1000 /* Narrow flat cable reversed */
  1776. #define ASC_IERR_BIST_PRE_TEST 0x2000 /* BIST pre-test error */
  1777. #define ASC_IERR_BIST_RAM_TEST 0x4000 /* BIST RAM test error */
  1778. #define ASC_IERR_BAD_CHIPTYPE 0x8000 /* Invalid 'chip_type' setting. */
  1779. /*
  1780. * Fixed locations of microcode operating variables.
  1781. */
  1782. #define ASC_MC_CODE_BEGIN_ADDR 0x0028 /* microcode start address */
  1783. #define ASC_MC_CODE_END_ADDR 0x002A /* microcode end address */
  1784. #define ASC_MC_CODE_CHK_SUM 0x002C /* microcode code checksum */
  1785. #define ASC_MC_VERSION_DATE 0x0038 /* microcode version */
  1786. #define ASC_MC_VERSION_NUM 0x003A /* microcode number */
  1787. #define ASC_MC_BIOSMEM 0x0040 /* BIOS RISC Memory Start */
  1788. #define ASC_MC_BIOSLEN 0x0050 /* BIOS RISC Memory Length */
  1789. #define ASC_MC_BIOS_SIGNATURE 0x0058 /* BIOS Signature 0x55AA */
  1790. #define ASC_MC_BIOS_VERSION 0x005A /* BIOS Version (2 bytes) */
  1791. #define ASC_MC_SDTR_SPEED1 0x0090 /* SDTR Speed for TID 0-3 */
  1792. #define ASC_MC_SDTR_SPEED2 0x0092 /* SDTR Speed for TID 4-7 */
  1793. #define ASC_MC_SDTR_SPEED3 0x0094 /* SDTR Speed for TID 8-11 */
  1794. #define ASC_MC_SDTR_SPEED4 0x0096 /* SDTR Speed for TID 12-15 */
  1795. #define ASC_MC_CHIP_TYPE 0x009A
  1796. #define ASC_MC_INTRB_CODE 0x009B
  1797. #define ASC_MC_WDTR_ABLE 0x009C
  1798. #define ASC_MC_SDTR_ABLE 0x009E
  1799. #define ASC_MC_TAGQNG_ABLE 0x00A0
  1800. #define ASC_MC_DISC_ENABLE 0x00A2
  1801. #define ASC_MC_IDLE_CMD_STATUS 0x00A4
  1802. #define ASC_MC_IDLE_CMD 0x00A6
  1803. #define ASC_MC_IDLE_CMD_PARAMETER 0x00A8
  1804. #define ASC_MC_DEFAULT_SCSI_CFG0 0x00AC
  1805. #define ASC_MC_DEFAULT_SCSI_CFG1 0x00AE
  1806. #define ASC_MC_DEFAULT_MEM_CFG 0x00B0
  1807. #define ASC_MC_DEFAULT_SEL_MASK 0x00B2
  1808. #define ASC_MC_SDTR_DONE 0x00B6
  1809. #define ASC_MC_NUMBER_OF_QUEUED_CMD 0x00C0
  1810. #define ASC_MC_NUMBER_OF_MAX_CMD 0x00D0
  1811. #define ASC_MC_DEVICE_HSHK_CFG_TABLE 0x0100
  1812. #define ASC_MC_CONTROL_FLAG 0x0122 /* Microcode control flag. */
  1813. #define ASC_MC_WDTR_DONE 0x0124
  1814. #define ASC_MC_CAM_MODE_MASK 0x015E /* CAM mode TID bitmask. */
  1815. #define ASC_MC_ICQ 0x0160
  1816. #define ASC_MC_IRQ 0x0164
  1817. #define ASC_MC_PPR_ABLE 0x017A
  1818. /*
  1819. * BIOS LRAM variable absolute offsets.
  1820. */
  1821. #define BIOS_CODESEG 0x54
  1822. #define BIOS_CODELEN 0x56
  1823. #define BIOS_SIGNATURE 0x58
  1824. #define BIOS_VERSION 0x5A
  1825. /*
  1826. * Microcode Control Flags
  1827. *
  1828. * Flags set by the Adv Library in RISC variable 'control_flag' (0x122)
  1829. * and handled by the microcode.
  1830. */
  1831. #define CONTROL_FLAG_IGNORE_PERR 0x0001 /* Ignore DMA Parity Errors */
  1832. #define CONTROL_FLAG_ENABLE_AIPP 0x0002 /* Enabled AIPP checking. */
  1833. /*
  1834. * ASC_MC_DEVICE_HSHK_CFG_TABLE microcode table or HSHK_CFG register format
  1835. */
  1836. #define HSHK_CFG_WIDE_XFR 0x8000
  1837. #define HSHK_CFG_RATE 0x0F00
  1838. #define HSHK_CFG_OFFSET 0x001F
  1839. #define ASC_DEF_MAX_HOST_QNG 0xFD /* Max. number of host commands (253) */
  1840. #define ASC_DEF_MIN_HOST_QNG 0x10 /* Min. number of host commands (16) */
  1841. #define ASC_DEF_MAX_DVC_QNG 0x3F /* Max. number commands per device (63) */
  1842. #define ASC_DEF_MIN_DVC_QNG 0x04 /* Min. number commands per device (4) */
  1843. #define ASC_QC_DATA_CHECK 0x01 /* Require ASC_QC_DATA_OUT set or clear. */
  1844. #define ASC_QC_DATA_OUT 0x02 /* Data out DMA transfer. */
  1845. #define ASC_QC_START_MOTOR 0x04 /* Send auto-start motor before request. */
  1846. #define ASC_QC_NO_OVERRUN 0x08 /* Don't report overrun. */
  1847. #define ASC_QC_FREEZE_TIDQ 0x10 /* Freeze TID queue after request. XXX TBD */
  1848. #define ASC_QSC_NO_DISC 0x01 /* Don't allow disconnect for request. */
  1849. #define ASC_QSC_NO_TAGMSG 0x02 /* Don't allow tag queuing for request. */
  1850. #define ASC_QSC_NO_SYNC 0x04 /* Don't use Synch. transfer on request. */
  1851. #define ASC_QSC_NO_WIDE 0x08 /* Don't use Wide transfer on request. */
  1852. #define ASC_QSC_REDO_DTR 0x10 /* Renegotiate WDTR/SDTR before request. */
  1853. /*
  1854. * Note: If a Tag Message is to be sent and neither ASC_QSC_HEAD_TAG or
  1855. * ASC_QSC_ORDERED_TAG is set, then a Simple Tag Message (0x20) is used.
  1856. */
  1857. #define ASC_QSC_HEAD_TAG 0x40 /* Use Head Tag Message (0x21). */
  1858. #define ASC_QSC_ORDERED_TAG 0x80 /* Use Ordered Tag Message (0x22). */
  1859. /*
  1860. * All fields here are accessed by the board microcode and need to be
  1861. * little-endian.
  1862. */
  1863. typedef struct adv_carr_t {
  1864. ADV_VADDR carr_va; /* Carrier Virtual Address */
  1865. ADV_PADDR carr_pa; /* Carrier Physical Address */
  1866. ADV_VADDR areq_vpa; /* ASC_SCSI_REQ_Q Virtual or Physical Address */
  1867. /*
  1868. * next_vpa [31:4] Carrier Virtual or Physical Next Pointer
  1869. *
  1870. * next_vpa [3:1] Reserved Bits
  1871. * next_vpa [0] Done Flag set in Response Queue.
  1872. */
  1873. ADV_VADDR next_vpa;
  1874. } ADV_CARR_T;
  1875. /*
  1876. * Mask used to eliminate low 4 bits of carrier 'next_vpa' field.
  1877. */
  1878. #define ASC_NEXT_VPA_MASK 0xFFFFFFF0
  1879. #define ASC_RQ_DONE 0x00000001
  1880. #define ASC_RQ_GOOD 0x00000002
  1881. #define ASC_CQ_STOPPER 0x00000000
  1882. #define ASC_GET_CARRP(carrp) ((carrp) & ASC_NEXT_VPA_MASK)
  1883. #define ADV_CARRIER_NUM_PAGE_CROSSING \
  1884. (((ADV_CARRIER_COUNT * sizeof(ADV_CARR_T)) + \
  1885. (ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
  1886. #define ADV_CARRIER_BUFSIZE \
  1887. ((ADV_CARRIER_COUNT + ADV_CARRIER_NUM_PAGE_CROSSING) * sizeof(ADV_CARR_T))
  1888. /*
  1889. * ASC_SCSI_REQ_Q 'a_flag' definitions
  1890. *
  1891. * The Adv Library should limit use to the lower nibble (4 bits) of
  1892. * a_flag. Drivers are free to use the upper nibble (4 bits) of a_flag.
  1893. */
  1894. #define ADV_POLL_REQUEST 0x01 /* poll for request completion */
  1895. #define ADV_SCSIQ_DONE 0x02 /* request done */
  1896. #define ADV_DONT_RETRY 0x08 /* don't do retry */
  1897. #define ADV_CHIP_ASC3550 0x01 /* Ultra-Wide IC */
  1898. #define ADV_CHIP_ASC38C0800 0x02 /* Ultra2-Wide/LVD IC */
  1899. #define ADV_CHIP_ASC38C1600 0x03 /* Ultra3-Wide/LVD2 IC */
  1900. /*
  1901. * Adapter temporary configuration structure
  1902. *
  1903. * This structure can be discarded after initialization. Don't add
  1904. * fields here needed after initialization.
  1905. *
  1906. * Field naming convention:
  1907. *
  1908. * *_enable indicates the field enables or disables a feature. The
  1909. * value of the field is never reset.
  1910. */
  1911. typedef struct adv_dvc_cfg {
  1912. ushort disc_enable; /* enable disconnection */
  1913. uchar chip_version; /* chip version */
  1914. uchar termination; /* Term. Ctrl. bits 6-5 of SCSI_CFG1 register */
  1915. ushort lib_version; /* Adv Library version number */
  1916. ushort control_flag; /* Microcode Control Flag */
  1917. ushort mcode_date; /* Microcode date */
  1918. ushort mcode_version; /* Microcode version */
  1919. ushort serial1; /* EEPROM serial number word 1 */
  1920. ushort serial2; /* EEPROM serial number word 2 */
  1921. ushort serial3; /* EEPROM serial number word 3 */
  1922. } ADV_DVC_CFG;
  1923. struct adv_dvc_var;
  1924. struct adv_scsi_req_q;
  1925. /*
  1926. * Adapter operation variable structure.
  1927. *
  1928. * One structure is required per host adapter.
  1929. *
  1930. * Field naming convention:
  1931. *
  1932. * *_able indicates both whether a feature should be enabled or disabled
  1933. * and whether a device isi capable of the feature. At initialization
  1934. * this field may be set, but later if a device is found to be incapable
  1935. * of the feature, the field is cleared.
  1936. */
  1937. typedef struct adv_dvc_var {
  1938. AdvPortAddr iop_base; /* I/O port address */
  1939. ushort err_code; /* fatal error code */
  1940. ushort bios_ctrl; /* BIOS control word, EEPROM word 12 */
  1941. ushort wdtr_able; /* try WDTR for a device */
  1942. ushort sdtr_able; /* try SDTR for a device */
  1943. ushort ultra_able; /* try SDTR Ultra speed for a device */
  1944. ushort sdtr_speed1; /* EEPROM SDTR Speed for TID 0-3 */
  1945. ushort sdtr_speed2; /* EEPROM SDTR Speed for TID 4-7 */
  1946. ushort sdtr_speed3; /* EEPROM SDTR Speed for TID 8-11 */
  1947. ushort sdtr_speed4; /* EEPROM SDTR Speed for TID 12-15 */
  1948. ushort tagqng_able; /* try tagged queuing with a device */
  1949. ushort ppr_able; /* PPR message capable per TID bitmask. */
  1950. uchar max_dvc_qng; /* maximum number of tagged commands per device */
  1951. ushort start_motor; /* start motor command allowed */
  1952. uchar scsi_reset_wait; /* delay in seconds after scsi bus reset */
  1953. uchar chip_no; /* should be assigned by caller */
  1954. uchar max_host_qng; /* maximum number of Q'ed command allowed */
  1955. uchar irq_no; /* IRQ number */
  1956. ushort no_scam; /* scam_tolerant of EEPROM */
  1957. struct asc_board *drv_ptr; /* driver pointer to private structure */
  1958. uchar chip_scsi_id; /* chip SCSI target ID */
  1959. uchar chip_type;
  1960. uchar bist_err_code;
  1961. ADV_CARR_T *carrier_buf;
  1962. ADV_CARR_T *carr_freelist; /* Carrier free list. */
  1963. ADV_CARR_T *icq_sp; /* Initiator command queue stopper pointer. */
  1964. ADV_CARR_T *irq_sp; /* Initiator response queue stopper pointer. */
  1965. ushort carr_pending_cnt; /* Count of pending carriers. */
  1966. /*
  1967. * Note: The following fields will not be used after initialization. The
  1968. * driver may discard the buffer after initialization is done.
  1969. */
  1970. ADV_DVC_CFG *cfg; /* temporary configuration structure */
  1971. } ADV_DVC_VAR;
  1972. #define NO_OF_SG_PER_BLOCK 15
  1973. typedef struct asc_sg_block {
  1974. uchar reserved1;
  1975. uchar reserved2;
  1976. uchar reserved3;
  1977. uchar sg_cnt; /* Valid entries in block. */
  1978. ADV_PADDR sg_ptr; /* Pointer to next sg block. */
  1979. struct {
  1980. ADV_PADDR sg_addr; /* SG element address. */
  1981. ADV_DCNT sg_count; /* SG element count. */
  1982. } sg_list[NO_OF_SG_PER_BLOCK];
  1983. } ADV_SG_BLOCK;
  1984. /*
  1985. * ADV_SCSI_REQ_Q - microcode request structure
  1986. *
  1987. * All fields in this structure up to byte 60 are used by the microcode.
  1988. * The microcode makes assumptions about the size and ordering of fields
  1989. * in this structure. Do not change the structure definition here without
  1990. * coordinating the change with the microcode.
  1991. *
  1992. * All fields accessed by microcode must be maintained in little_endian
  1993. * order.
  1994. */
  1995. typedef struct adv_scsi_req_q {
  1996. uchar cntl; /* Ucode flags and state (ASC_MC_QC_*). */
  1997. uchar target_cmd;
  1998. uchar target_id; /* Device target identifier. */
  1999. uchar target_lun; /* Device target logical unit number. */
  2000. ADV_PADDR data_addr; /* Data buffer physical address. */
  2001. ADV_DCNT data_cnt; /* Data count. Ucode sets to residual. */
  2002. ADV_PADDR sense_addr;
  2003. ADV_PADDR carr_pa;
  2004. uchar mflag;
  2005. uchar sense_len;
  2006. uchar cdb_len; /* SCSI CDB length. Must <= 16 bytes. */
  2007. uchar scsi_cntl;
  2008. uchar done_status; /* Completion status. */
  2009. uchar scsi_status; /* SCSI status byte. */
  2010. uchar host_status; /* Ucode host status. */
  2011. uchar sg_working_ix;
  2012. uchar cdb[12]; /* SCSI CDB bytes 0-11. */
  2013. ADV_PADDR sg_real_addr; /* SG list physical address. */
  2014. ADV_PADDR scsiq_rptr;
  2015. uchar cdb16[4]; /* SCSI CDB bytes 12-15. */
  2016. ADV_VADDR scsiq_ptr;
  2017. ADV_VADDR carr_va;
  2018. /*
  2019. * End of microcode structure - 60 bytes. The rest of the structure
  2020. * is used by the Adv Library and ignored by the microcode.
  2021. */
  2022. ADV_VADDR srb_ptr;
  2023. ADV_SG_BLOCK *sg_list_ptr; /* SG list virtual address. */
  2024. char *vdata_addr; /* Data buffer virtual address. */
  2025. uchar a_flag;
  2026. uchar pad[2]; /* Pad out to a word boundary. */
  2027. } ADV_SCSI_REQ_Q;
  2028. /*
  2029. * Microcode idle loop commands
  2030. */
  2031. #define IDLE_CMD_COMPLETED 0
  2032. #define IDLE_CMD_STOP_CHIP 0x0001
  2033. #define IDLE_CMD_STOP_CHIP_SEND_INT 0x0002
  2034. #define IDLE_CMD_SEND_INT 0x0004
  2035. #define IDLE_CMD_ABORT 0x0008
  2036. #define IDLE_CMD_DEVICE_RESET 0x0010
  2037. #define IDLE_CMD_SCSI_RESET_START 0x0020 /* Assert SCSI Bus Reset */
  2038. #define IDLE_CMD_SCSI_RESET_END 0x0040 /* Deassert SCSI Bus Reset */
  2039. #define IDLE_CMD_SCSIREQ 0x0080
  2040. #define IDLE_CMD_STATUS_SUCCESS 0x0001
  2041. #define IDLE_CMD_STATUS_FAILURE 0x0002
  2042. /*
  2043. * AdvSendIdleCmd() flag definitions.
  2044. */
  2045. #define ADV_NOWAIT 0x01
  2046. /*
  2047. * Wait loop time out values.
  2048. */
  2049. #define SCSI_WAIT_10_SEC 10UL /* 10 seconds */
  2050. #define SCSI_WAIT_100_MSEC 100UL /* 100 milliseconds */
  2051. #define SCSI_US_PER_MSEC 1000 /* microseconds per millisecond */
  2052. #define SCSI_MS_PER_SEC 1000UL /* milliseconds per second */
  2053. #define SCSI_MAX_RETRY 10 /* retry count */
  2054. #define ADV_ASYNC_RDMA_FAILURE 0x01 /* Fatal RDMA failure. */
  2055. #define ADV_ASYNC_SCSI_BUS_RESET_DET 0x02 /* Detected SCSI Bus Reset. */
  2056. #define ADV_ASYNC_CARRIER_READY_FAILURE 0x03 /* Carrier Ready failure. */
  2057. #define ADV_RDMA_IN_CARR_AND_Q_INVALID 0x04 /* RDMAed-in data invalid. */
  2058. #define ADV_HOST_SCSI_BUS_RESET 0x80 /* Host Initiated SCSI Bus Reset. */
  2059. /*
  2060. * Device drivers must define the following functions.
  2061. */
  2062. static inline ulong DvcEnterCritical(void);
  2063. static inline void DvcLeaveCritical(ulong);
  2064. static void DvcSleepMilliSecond(ADV_DCNT);
  2065. static ADV_PADDR DvcGetPhyAddr(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *,
  2066. uchar *, ASC_SDCNT *, int);
  2067. static void DvcDelayMicroSecond(ADV_DVC_VAR *, ushort);
  2068. /*
  2069. * Adv Library functions available to drivers.
  2070. */
  2071. static int AdvExeScsiQueue(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *);
  2072. static int AdvISR(ADV_DVC_VAR *);
  2073. static int AdvInitAsc3550Driver(ADV_DVC_VAR *);
  2074. static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *);
  2075. static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *);
  2076. static int AdvResetChipAndSB(ADV_DVC_VAR *);
  2077. static int AdvResetSB(ADV_DVC_VAR *asc_dvc);
  2078. /*
  2079. * Internal Adv Library functions.
  2080. */
  2081. static int AdvSendIdleCmd(ADV_DVC_VAR *, ushort, ADV_DCNT);
  2082. static int AdvInitFrom3550EEP(ADV_DVC_VAR *);
  2083. static int AdvInitFrom38C0800EEP(ADV_DVC_VAR *);
  2084. static int AdvInitFrom38C1600EEP(ADV_DVC_VAR *);
  2085. static ushort AdvGet3550EEPConfig(AdvPortAddr, ADVEEP_3550_CONFIG *);
  2086. static void AdvSet3550EEPConfig(AdvPortAddr, ADVEEP_3550_CONFIG *);
  2087. static ushort AdvGet38C0800EEPConfig(AdvPortAddr, ADVEEP_38C0800_CONFIG *);
  2088. static void AdvSet38C0800EEPConfig(AdvPortAddr, ADVEEP_38C0800_CONFIG *);
  2089. static ushort AdvGet38C1600EEPConfig(AdvPortAddr, ADVEEP_38C1600_CONFIG *);
  2090. static void AdvSet38C1600EEPConfig(AdvPortAddr, ADVEEP_38C1600_CONFIG *);
  2091. static void AdvWaitEEPCmd(AdvPortAddr);
  2092. static ushort AdvReadEEPWord(AdvPortAddr, int);
  2093. /* Read byte from a register. */
  2094. #define AdvReadByteRegister(iop_base, reg_off) \
  2095. (ADV_MEM_READB((iop_base) + (reg_off)))
  2096. /* Write byte to a register. */
  2097. #define AdvWriteByteRegister(iop_base, reg_off, byte) \
  2098. (ADV_MEM_WRITEB((iop_base) + (reg_off), (byte)))
  2099. /* Read word (2 bytes) from a register. */
  2100. #define AdvReadWordRegister(iop_base, reg_off) \
  2101. (ADV_MEM_READW((iop_base) + (reg_off)))
  2102. /* Write word (2 bytes) to a register. */
  2103. #define AdvWriteWordRegister(iop_base, reg_off, word) \
  2104. (ADV_MEM_WRITEW((iop_base) + (reg_off), (word)))
  2105. /* Write dword (4 bytes) to a register. */
  2106. #define AdvWriteDWordRegister(iop_base, reg_off, dword) \
  2107. (ADV_MEM_WRITEDW((iop_base) + (reg_off), (dword)))
  2108. /* Read byte from LRAM. */
  2109. #define AdvReadByteLram(iop_base, addr, byte) \
  2110. do { \
  2111. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
  2112. (byte) = ADV_MEM_READB((iop_base) + IOPB_RAM_DATA); \
  2113. } while (0)
  2114. /* Write byte to LRAM. */
  2115. #define AdvWriteByteLram(iop_base, addr, byte) \
  2116. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  2117. ADV_MEM_WRITEB((iop_base) + IOPB_RAM_DATA, (byte)))
  2118. /* Read word (2 bytes) from LRAM. */
  2119. #define AdvReadWordLram(iop_base, addr, word) \
  2120. do { \
  2121. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
  2122. (word) = (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA)); \
  2123. } while (0)
  2124. /* Write word (2 bytes) to LRAM. */
  2125. #define AdvWriteWordLram(iop_base, addr, word) \
  2126. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  2127. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
  2128. /* Write little-endian double word (4 bytes) to LRAM */
  2129. /* Because of unspecified C language ordering don't use auto-increment. */
  2130. #define AdvWriteDWordLramNoSwap(iop_base, addr, dword) \
  2131. ((ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  2132. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
  2133. cpu_to_le16((ushort) ((dword) & 0xFFFF)))), \
  2134. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr) + 2), \
  2135. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
  2136. cpu_to_le16((ushort) ((dword >> 16) & 0xFFFF)))))
  2137. /* Read word (2 bytes) from LRAM assuming that the address is already set. */
  2138. #define AdvReadWordAutoIncLram(iop_base) \
  2139. (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA))
  2140. /* Write word (2 bytes) to LRAM assuming that the address is already set. */
  2141. #define AdvWriteWordAutoIncLram(iop_base, word) \
  2142. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
  2143. /*
  2144. * Define macro to check for Condor signature.
  2145. *
  2146. * Evaluate to ADV_TRUE if a Condor chip is found the specified port
  2147. * address 'iop_base'. Otherwise evalue to ADV_FALSE.
  2148. */
  2149. #define AdvFindSignature(iop_base) \
  2150. (((AdvReadByteRegister((iop_base), IOPB_CHIP_ID_1) == \
  2151. ADV_CHIP_ID_BYTE) && \
  2152. (AdvReadWordRegister((iop_base), IOPW_CHIP_ID_0) == \
  2153. ADV_CHIP_ID_WORD)) ? ADV_TRUE : ADV_FALSE)
  2154. /*
  2155. * Define macro to Return the version number of the chip at 'iop_base'.
  2156. *
  2157. * The second parameter 'bus_type' is currently unused.
  2158. */
  2159. #define AdvGetChipVersion(iop_base, bus_type) \
  2160. AdvReadByteRegister((iop_base), IOPB_CHIP_TYPE_REV)
  2161. /*
  2162. * Abort an SRB in the chip's RISC Memory. The 'srb_ptr' argument must
  2163. * match the ASC_SCSI_REQ_Q 'srb_ptr' field.
  2164. *
  2165. * If the request has not yet been sent to the device it will simply be
  2166. * aborted from RISC memory. If the request is disconnected it will be
  2167. * aborted on reselection by sending an Abort Message to the target ID.
  2168. *
  2169. * Return value:
  2170. * ADV_TRUE(1) - Queue was successfully aborted.
  2171. * ADV_FALSE(0) - Queue was not found on the active queue list.
  2172. */
  2173. #define AdvAbortQueue(asc_dvc, scsiq) \
  2174. AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_ABORT, \
  2175. (ADV_DCNT) (scsiq))
  2176. /*
  2177. * Send a Bus Device Reset Message to the specified target ID.
  2178. *
  2179. * All outstanding commands will be purged if sending the
  2180. * Bus Device Reset Message is successful.
  2181. *
  2182. * Return Value:
  2183. * ADV_TRUE(1) - All requests on the target are purged.
  2184. * ADV_FALSE(0) - Couldn't issue Bus Device Reset Message; Requests
  2185. * are not purged.
  2186. */
  2187. #define AdvResetDevice(asc_dvc, target_id) \
  2188. AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_DEVICE_RESET, \
  2189. (ADV_DCNT) (target_id))
  2190. /*
  2191. * SCSI Wide Type definition.
  2192. */
  2193. #define ADV_SCSI_BIT_ID_TYPE ushort
  2194. /*
  2195. * AdvInitScsiTarget() 'cntl_flag' options.
  2196. */
  2197. #define ADV_SCAN_LUN 0x01
  2198. #define ADV_CAPINFO_NOLUN 0x02
  2199. /*
  2200. * Convert target id to target id bit mask.
  2201. */
  2202. #define ADV_TID_TO_TIDMASK(tid) (0x01 << ((tid) & ADV_MAX_TID))
  2203. /*
  2204. * ASC_SCSI_REQ_Q 'done_status' and 'host_status' return values.
  2205. */
  2206. #define QD_NO_STATUS 0x00 /* Request not completed yet. */
  2207. #define QD_NO_ERROR 0x01
  2208. #define QD_ABORTED_BY_HOST 0x02
  2209. #define QD_WITH_ERROR 0x04
  2210. #define QHSTA_NO_ERROR 0x00
  2211. #define QHSTA_M_SEL_TIMEOUT 0x11
  2212. #define QHSTA_M_DATA_OVER_RUN 0x12
  2213. #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
  2214. #define QHSTA_M_QUEUE_ABORTED 0x15
  2215. #define QHSTA_M_SXFR_SDMA_ERR 0x16 /* SXFR_STATUS SCSI DMA Error */
  2216. #define QHSTA_M_SXFR_SXFR_PERR 0x17 /* SXFR_STATUS SCSI Bus Parity Error */
  2217. #define QHSTA_M_RDMA_PERR 0x18 /* RISC PCI DMA parity error */
  2218. #define QHSTA_M_SXFR_OFF_UFLW 0x19 /* SXFR_STATUS Offset Underflow */
  2219. #define QHSTA_M_SXFR_OFF_OFLW 0x20 /* SXFR_STATUS Offset Overflow */
  2220. #define QHSTA_M_SXFR_WD_TMO 0x21 /* SXFR_STATUS Watchdog Timeout */
  2221. #define QHSTA_M_SXFR_DESELECTED 0x22 /* SXFR_STATUS Deselected */
  2222. /* Note: QHSTA_M_SXFR_XFR_OFLW is identical to QHSTA_M_DATA_OVER_RUN. */
  2223. #define QHSTA_M_SXFR_XFR_OFLW 0x12 /* SXFR_STATUS Transfer Overflow */
  2224. #define QHSTA_M_SXFR_XFR_PH_ERR 0x24 /* SXFR_STATUS Transfer Phase Error */
  2225. #define QHSTA_M_SXFR_UNKNOWN_ERROR 0x25 /* SXFR_STATUS Unknown Error */
  2226. #define QHSTA_M_SCSI_BUS_RESET 0x30 /* Request aborted from SBR */
  2227. #define QHSTA_M_SCSI_BUS_RESET_UNSOL 0x31 /* Request aborted from unsol. SBR */
  2228. #define QHSTA_M_BUS_DEVICE_RESET 0x32 /* Request aborted from BDR */
  2229. #define QHSTA_M_DIRECTION_ERR 0x35 /* Data Phase mismatch */
  2230. #define QHSTA_M_DIRECTION_ERR_HUNG 0x36 /* Data Phase mismatch and bus hang */
  2231. #define QHSTA_M_WTM_TIMEOUT 0x41
  2232. #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
  2233. #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
  2234. #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
  2235. #define QHSTA_M_INVALID_DEVICE 0x45 /* Bad target ID */
  2236. #define QHSTA_M_FROZEN_TIDQ 0x46 /* TID Queue frozen. */
  2237. #define QHSTA_M_SGBACKUP_ERROR 0x47 /* Scatter-Gather backup error */
  2238. /*
  2239. * DvcGetPhyAddr() flag arguments
  2240. */
  2241. #define ADV_IS_SCSIQ_FLAG 0x01 /* 'addr' is ASC_SCSI_REQ_Q pointer */
  2242. #define ADV_ASCGETSGLIST_VADDR 0x02 /* 'addr' is AscGetSGList() virtual addr */
  2243. #define ADV_IS_SENSE_FLAG 0x04 /* 'addr' is sense virtual pointer */
  2244. #define ADV_IS_DATA_FLAG 0x08 /* 'addr' is data virtual pointer */
  2245. #define ADV_IS_SGLIST_FLAG 0x10 /* 'addr' is sglist virtual pointer */
  2246. #define ADV_IS_CARRIER_FLAG 0x20 /* 'addr' is ADV_CARR_T pointer */
  2247. /* Return the address that is aligned at the next doubleword >= to 'addr'. */
  2248. #define ADV_8BALIGN(addr) (((ulong) (addr) + 0x7) & ~0x7)
  2249. #define ADV_16BALIGN(addr) (((ulong) (addr) + 0xF) & ~0xF)
  2250. #define ADV_32BALIGN(addr) (((ulong) (addr) + 0x1F) & ~0x1F)
  2251. /*
  2252. * Total contiguous memory needed for driver SG blocks.
  2253. *
  2254. * ADV_MAX_SG_LIST must be defined by a driver. It is the maximum
  2255. * number of scatter-gather elements the driver supports in a
  2256. * single request.
  2257. */
  2258. #define ADV_SG_LIST_MAX_BYTE_SIZE \
  2259. (sizeof(ADV_SG_BLOCK) * \
  2260. ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK))
  2261. /*
  2262. * --- Driver Constants and Macros
  2263. */
  2264. /* Reference Scsi_Host hostdata */
  2265. #define ASC_BOARDP(host) ((asc_board_t *) &((host)->hostdata))
  2266. /* asc_board_t flags */
  2267. #define ASC_HOST_IN_RESET 0x01
  2268. #define ASC_IS_WIDE_BOARD 0x04 /* AdvanSys Wide Board */
  2269. #define ASC_SELECT_QUEUE_DEPTHS 0x08
  2270. #define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0)
  2271. #define ASC_WIDE_BOARD(boardp) ((boardp)->flags & ASC_IS_WIDE_BOARD)
  2272. #define NO_ISA_DMA 0xff /* No ISA DMA Channel Used */
  2273. #define ASC_INFO_SIZE 128 /* advansys_info() line size */
  2274. #ifdef CONFIG_PROC_FS
  2275. /* /proc/scsi/advansys/[0...] related definitions */
  2276. #define ASC_PRTBUF_SIZE 2048
  2277. #define ASC_PRTLINE_SIZE 160
  2278. #define ASC_PRT_NEXT() \
  2279. if (cp) { \
  2280. totlen += len; \
  2281. leftlen -= len; \
  2282. if (leftlen == 0) { \
  2283. return totlen; \
  2284. } \
  2285. cp += len; \
  2286. }
  2287. #endif /* CONFIG_PROC_FS */
  2288. /* Asc Library return codes */
  2289. #define ASC_TRUE 1
  2290. #define ASC_FALSE 0
  2291. #define ASC_NOERROR 1
  2292. #define ASC_BUSY 0
  2293. #define ASC_ERROR (-1)
  2294. /* struct scsi_cmnd function return codes */
  2295. #define STATUS_BYTE(byte) (byte)
  2296. #define MSG_BYTE(byte) ((byte) << 8)
  2297. #define HOST_BYTE(byte) ((byte) << 16)
  2298. #define DRIVER_BYTE(byte) ((byte) << 24)
  2299. #ifndef ADVANSYS_STATS
  2300. #define ASC_STATS(shost, counter)
  2301. #define ASC_STATS_ADD(shost, counter, count)
  2302. #else /* ADVANSYS_STATS */
  2303. #define ASC_STATS(shost, counter) \
  2304. (ASC_BOARDP(shost)->asc_stats.counter++)
  2305. #define ASC_STATS_ADD(shost, counter, count) \
  2306. (ASC_BOARDP(shost)->asc_stats.counter += (count))
  2307. #endif /* ADVANSYS_STATS */
  2308. #define ASC_CEILING(val, unit) (((val) + ((unit) - 1))/(unit))
  2309. /* If the result wraps when calculating tenths, return 0. */
  2310. #define ASC_TENTHS(num, den) \
  2311. (((10 * ((num)/(den))) > (((num) * 10)/(den))) ? \
  2312. 0 : ((((num) * 10)/(den)) - (10 * ((num)/(den)))))
  2313. /*
  2314. * Display a message to the console.
  2315. */
  2316. #define ASC_PRINT(s) \
  2317. { \
  2318. printk("advansys: "); \
  2319. printk(s); \
  2320. }
  2321. #define ASC_PRINT1(s, a1) \
  2322. { \
  2323. printk("advansys: "); \
  2324. printk((s), (a1)); \
  2325. }
  2326. #define ASC_PRINT2(s, a1, a2) \
  2327. { \
  2328. printk("advansys: "); \
  2329. printk((s), (a1), (a2)); \
  2330. }
  2331. #define ASC_PRINT3(s, a1, a2, a3) \
  2332. { \
  2333. printk("advansys: "); \
  2334. printk((s), (a1), (a2), (a3)); \
  2335. }
  2336. #define ASC_PRINT4(s, a1, a2, a3, a4) \
  2337. { \
  2338. printk("advansys: "); \
  2339. printk((s), (a1), (a2), (a3), (a4)); \
  2340. }
  2341. #ifndef ADVANSYS_DEBUG
  2342. #define ASC_DBG(lvl, s)
  2343. #define ASC_DBG1(lvl, s, a1)
  2344. #define ASC_DBG2(lvl, s, a1, a2)
  2345. #define ASC_DBG3(lvl, s, a1, a2, a3)
  2346. #define ASC_DBG4(lvl, s, a1, a2, a3, a4)
  2347. #define ASC_DBG_PRT_SCSI_HOST(lvl, s)
  2348. #define ASC_DBG_PRT_SCSI_CMND(lvl, s)
  2349. #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp)
  2350. #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
  2351. #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone)
  2352. #define ADV_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
  2353. #define ASC_DBG_PRT_HEX(lvl, name, start, length)
  2354. #define ASC_DBG_PRT_CDB(lvl, cdb, len)
  2355. #define ASC_DBG_PRT_SENSE(lvl, sense, len)
  2356. #define ASC_DBG_PRT_INQUIRY(lvl, inq, len)
  2357. #else /* ADVANSYS_DEBUG */
  2358. /*
  2359. * Debugging Message Levels:
  2360. * 0: Errors Only
  2361. * 1: High-Level Tracing
  2362. * 2-N: Verbose Tracing
  2363. */
  2364. #define ASC_DBG(lvl, s) \
  2365. { \
  2366. if (asc_dbglvl >= (lvl)) { \
  2367. printk(s); \
  2368. } \
  2369. }
  2370. #define ASC_DBG1(lvl, s, a1) \
  2371. { \
  2372. if (asc_dbglvl >= (lvl)) { \
  2373. printk((s), (a1)); \
  2374. } \
  2375. }
  2376. #define ASC_DBG2(lvl, s, a1, a2) \
  2377. { \
  2378. if (asc_dbglvl >= (lvl)) { \
  2379. printk((s), (a1), (a2)); \
  2380. } \
  2381. }
  2382. #define ASC_DBG3(lvl, s, a1, a2, a3) \
  2383. { \
  2384. if (asc_dbglvl >= (lvl)) { \
  2385. printk((s), (a1), (a2), (a3)); \
  2386. } \
  2387. }
  2388. #define ASC_DBG4(lvl, s, a1, a2, a3, a4) \
  2389. { \
  2390. if (asc_dbglvl >= (lvl)) { \
  2391. printk((s), (a1), (a2), (a3), (a4)); \
  2392. } \
  2393. }
  2394. #define ASC_DBG_PRT_SCSI_HOST(lvl, s) \
  2395. { \
  2396. if (asc_dbglvl >= (lvl)) { \
  2397. asc_prt_scsi_host(s); \
  2398. } \
  2399. }
  2400. #define ASC_DBG_PRT_SCSI_CMND(lvl, s) \
  2401. { \
  2402. if (asc_dbglvl >= (lvl)) { \
  2403. asc_prt_scsi_cmnd(s); \
  2404. } \
  2405. }
  2406. #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp) \
  2407. { \
  2408. if (asc_dbglvl >= (lvl)) { \
  2409. asc_prt_asc_scsi_q(scsiqp); \
  2410. } \
  2411. }
  2412. #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone) \
  2413. { \
  2414. if (asc_dbglvl >= (lvl)) { \
  2415. asc_prt_asc_qdone_info(qdone); \
  2416. } \
  2417. }
  2418. #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp) \
  2419. { \
  2420. if (asc_dbglvl >= (lvl)) { \
  2421. asc_prt_adv_scsi_req_q(scsiqp); \
  2422. } \
  2423. }
  2424. #define ASC_DBG_PRT_HEX(lvl, name, start, length) \
  2425. { \
  2426. if (asc_dbglvl >= (lvl)) { \
  2427. asc_prt_hex((name), (start), (length)); \
  2428. } \
  2429. }
  2430. #define ASC_DBG_PRT_CDB(lvl, cdb, len) \
  2431. ASC_DBG_PRT_HEX((lvl), "CDB", (uchar *) (cdb), (len));
  2432. #define ASC_DBG_PRT_SENSE(lvl, sense, len) \
  2433. ASC_DBG_PRT_HEX((lvl), "SENSE", (uchar *) (sense), (len));
  2434. #define ASC_DBG_PRT_INQUIRY(lvl, inq, len) \
  2435. ASC_DBG_PRT_HEX((lvl), "INQUIRY", (uchar *) (inq), (len));
  2436. #endif /* ADVANSYS_DEBUG */
  2437. #ifndef ADVANSYS_ASSERT
  2438. #define ASC_ASSERT(a)
  2439. #else /* ADVANSYS_ASSERT */
  2440. #define ASC_ASSERT(a) \
  2441. { \
  2442. if (!(a)) { \
  2443. printk("ASC_ASSERT() Failure: file %s, line %d\n", \
  2444. __FILE__, __LINE__); \
  2445. } \
  2446. }
  2447. #endif /* ADVANSYS_ASSERT */
  2448. /*
  2449. * --- Driver Structures
  2450. */
  2451. #ifdef ADVANSYS_STATS
  2452. /* Per board statistics structure */
  2453. struct asc_stats {
  2454. /* Driver Entrypoint Statistics */
  2455. ADV_DCNT queuecommand; /* # calls to advansys_queuecommand() */
  2456. ADV_DCNT reset; /* # calls to advansys_eh_bus_reset() */
  2457. ADV_DCNT biosparam; /* # calls to advansys_biosparam() */
  2458. ADV_DCNT interrupt; /* # advansys_interrupt() calls */
  2459. ADV_DCNT callback; /* # calls to asc/adv_isr_callback() */
  2460. ADV_DCNT done; /* # calls to request's scsi_done function */
  2461. ADV_DCNT build_error; /* # asc/adv_build_req() ASC_ERROR returns. */
  2462. ADV_DCNT adv_build_noreq; /* # adv_build_req() adv_req_t alloc. fail. */
  2463. ADV_DCNT adv_build_nosg; /* # adv_build_req() adv_sgblk_t alloc. fail. */
  2464. /* AscExeScsiQueue()/AdvExeScsiQueue() Statistics */
  2465. ADV_DCNT exe_noerror; /* # ASC_NOERROR returns. */
  2466. ADV_DCNT exe_busy; /* # ASC_BUSY returns. */
  2467. ADV_DCNT exe_error; /* # ASC_ERROR returns. */
  2468. ADV_DCNT exe_unknown; /* # unknown returns. */
  2469. /* Data Transfer Statistics */
  2470. ADV_DCNT cont_cnt; /* # non-scatter-gather I/O requests received */
  2471. ADV_DCNT cont_xfer; /* # contiguous transfer 512-bytes */
  2472. ADV_DCNT sg_cnt; /* # scatter-gather I/O requests received */
  2473. ADV_DCNT sg_elem; /* # scatter-gather elements */
  2474. ADV_DCNT sg_xfer; /* # scatter-gather transfer 512-bytes */
  2475. };
  2476. #endif /* ADVANSYS_STATS */
  2477. /*
  2478. * Adv Library Request Structures
  2479. *
  2480. * The following two structures are used to process Wide Board requests.
  2481. *
  2482. * The ADV_SCSI_REQ_Q structure in adv_req_t is passed to the Adv Library
  2483. * and microcode with the ADV_SCSI_REQ_Q field 'srb_ptr' pointing to the
  2484. * adv_req_t. The adv_req_t structure 'cmndp' field in turn points to the
  2485. * Mid-Level SCSI request structure.
  2486. *
  2487. * Zero or more ADV_SG_BLOCK are used with each ADV_SCSI_REQ_Q. Each
  2488. * ADV_SG_BLOCK structure holds 15 scatter-gather elements. Under Linux
  2489. * up to 255 scatter-gather elements may be used per request or
  2490. * ADV_SCSI_REQ_Q.
  2491. *
  2492. * Both structures must be 32 byte aligned.
  2493. */
  2494. typedef struct adv_sgblk {
  2495. ADV_SG_BLOCK sg_block; /* Sgblock structure. */
  2496. uchar align[32]; /* Sgblock structure padding. */
  2497. struct adv_sgblk *next_sgblkp; /* Next scatter-gather structure. */
  2498. } adv_sgblk_t;
  2499. typedef struct adv_req {
  2500. ADV_SCSI_REQ_Q scsi_req_q; /* Adv Library request structure. */
  2501. uchar align[32]; /* Request structure padding. */
  2502. struct scsi_cmnd *cmndp; /* Mid-Level SCSI command pointer. */
  2503. adv_sgblk_t *sgblkp; /* Adv Library scatter-gather pointer. */
  2504. struct adv_req *next_reqp; /* Next Request Structure. */
  2505. } adv_req_t;
  2506. /*
  2507. * Structure allocated for each board.
  2508. *
  2509. * This structure is allocated by scsi_host_alloc() at the end
  2510. * of the 'Scsi_Host' structure starting at the 'hostdata'
  2511. * field. It is guaranteed to be allocated from DMA-able memory.
  2512. */
  2513. typedef struct asc_board {
  2514. struct device *dev;
  2515. int id; /* Board Id */
  2516. uint flags; /* Board flags */
  2517. union {
  2518. ASC_DVC_VAR asc_dvc_var; /* Narrow board */
  2519. ADV_DVC_VAR adv_dvc_var; /* Wide board */
  2520. } dvc_var;
  2521. union {
  2522. ASC_DVC_CFG asc_dvc_cfg; /* Narrow board */
  2523. ADV_DVC_CFG adv_dvc_cfg; /* Wide board */
  2524. } dvc_cfg;
  2525. ushort asc_n_io_port; /* Number I/O ports. */
  2526. ADV_SCSI_BIT_ID_TYPE init_tidmask; /* Target init./valid mask */
  2527. struct scsi_device *device[ADV_MAX_TID + 1]; /* Mid-Level Scsi Device */
  2528. ushort reqcnt[ADV_MAX_TID + 1]; /* Starvation request count */
  2529. ADV_SCSI_BIT_ID_TYPE queue_full; /* Queue full mask */
  2530. ushort queue_full_cnt[ADV_MAX_TID + 1]; /* Queue full count */
  2531. union {
  2532. ASCEEP_CONFIG asc_eep; /* Narrow EEPROM config. */
  2533. ADVEEP_3550_CONFIG adv_3550_eep; /* 3550 EEPROM config. */
  2534. ADVEEP_38C0800_CONFIG adv_38C0800_eep; /* 38C0800 EEPROM config. */
  2535. ADVEEP_38C1600_CONFIG adv_38C1600_eep; /* 38C1600 EEPROM config. */
  2536. } eep_config;
  2537. ulong last_reset; /* Saved last reset time */
  2538. spinlock_t lock; /* Board spinlock */
  2539. /* /proc/scsi/advansys/[0...] */
  2540. char *prtbuf; /* /proc print buffer */
  2541. #ifdef ADVANSYS_STATS
  2542. struct asc_stats asc_stats; /* Board statistics */
  2543. #endif /* ADVANSYS_STATS */
  2544. /*
  2545. * The following fields are used only for Narrow Boards.
  2546. */
  2547. uchar sdtr_data[ASC_MAX_TID + 1]; /* SDTR information */
  2548. /*
  2549. * The following fields are used only for Wide Boards.
  2550. */
  2551. void __iomem *ioremap_addr; /* I/O Memory remap address. */
  2552. ushort ioport; /* I/O Port address. */
  2553. ADV_CARR_T *carrp; /* ADV_CARR_T memory block. */
  2554. adv_req_t *orig_reqp; /* adv_req_t memory block. */
  2555. adv_req_t *adv_reqp; /* Request structures. */
  2556. adv_sgblk_t *adv_sgblkp; /* Scatter-gather structures. */
  2557. ushort bios_signature; /* BIOS Signature. */
  2558. ushort bios_version; /* BIOS Version. */
  2559. ushort bios_codeseg; /* BIOS Code Segment. */
  2560. ushort bios_codelen; /* BIOS Code Segment Length. */
  2561. } asc_board_t;
  2562. #define adv_dvc_to_board(adv_dvc) container_of(adv_dvc, struct asc_board, \
  2563. dvc_var.adv_dvc_var)
  2564. #define adv_dvc_to_pdev(adv_dvc) to_pci_dev(adv_dvc_to_board(adv_dvc)->dev)
  2565. /* Number of boards detected in system. */
  2566. static int asc_board_count;
  2567. /* Overrun buffer used by all narrow boards. */
  2568. static uchar overrun_buf[ASC_OVERRUN_BSIZE] = { 0 };
  2569. /*
  2570. * Global structures required to issue a command.
  2571. */
  2572. static ASC_SCSI_Q asc_scsi_q = { {0} };
  2573. static ASC_SG_HEAD asc_sg_head = { 0 };
  2574. #ifdef ADVANSYS_DEBUG
  2575. static int asc_dbglvl = 3;
  2576. #endif /* ADVANSYS_DEBUG */
  2577. /*
  2578. * --- Driver Function Prototypes
  2579. */
  2580. static int advansys_slave_configure(struct scsi_device *);
  2581. static int asc_execute_scsi_cmnd(struct scsi_cmnd *);
  2582. static int asc_build_req(asc_board_t *, struct scsi_cmnd *);
  2583. static int adv_build_req(asc_board_t *, struct scsi_cmnd *, ADV_SCSI_REQ_Q **);
  2584. static int adv_get_sglist(asc_board_t *, adv_req_t *, struct scsi_cmnd *, int);
  2585. #ifdef CONFIG_PROC_FS
  2586. static int asc_proc_copy(off_t, off_t, char *, int, char *, int);
  2587. static int asc_prt_board_devices(struct Scsi_Host *, char *, int);
  2588. static int asc_prt_adv_bios(struct Scsi_Host *, char *, int);
  2589. static int asc_get_eeprom_string(ushort *serialnum, uchar *cp);
  2590. static int asc_prt_asc_board_eeprom(struct Scsi_Host *, char *, int);
  2591. static int asc_prt_adv_board_eeprom(struct Scsi_Host *, char *, int);
  2592. static int asc_prt_driver_conf(struct Scsi_Host *, char *, int);
  2593. static int asc_prt_asc_board_info(struct Scsi_Host *, char *, int);
  2594. static int asc_prt_adv_board_info(struct Scsi_Host *, char *, int);
  2595. static int asc_prt_line(char *, int, char *fmt, ...);
  2596. #endif /* CONFIG_PROC_FS */
  2597. /* Statistics function prototypes. */
  2598. #ifdef ADVANSYS_STATS
  2599. #ifdef CONFIG_PROC_FS
  2600. static int asc_prt_board_stats(struct Scsi_Host *, char *, int);
  2601. #endif /* CONFIG_PROC_FS */
  2602. #endif /* ADVANSYS_STATS */
  2603. /* Debug function prototypes. */
  2604. #ifdef ADVANSYS_DEBUG
  2605. static void asc_prt_scsi_host(struct Scsi_Host *);
  2606. static void asc_prt_scsi_cmnd(struct scsi_cmnd *);
  2607. static void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *);
  2608. static void asc_prt_asc_dvc_var(ASC_DVC_VAR *);
  2609. static void asc_prt_asc_scsi_q(ASC_SCSI_Q *);
  2610. static void asc_prt_asc_qdone_info(ASC_QDONE_INFO *);
  2611. static void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *);
  2612. static void asc_prt_adv_dvc_var(ADV_DVC_VAR *);
  2613. static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *);
  2614. static void asc_prt_adv_sgblock(int, ADV_SG_BLOCK *);
  2615. static void asc_prt_hex(char *f, uchar *, int);
  2616. #endif /* ADVANSYS_DEBUG */
  2617. #ifdef CONFIG_PROC_FS
  2618. /*
  2619. * advansys_proc_info() - /proc/scsi/advansys/{0,1,2,3,...}
  2620. *
  2621. * *buffer: I/O buffer
  2622. * **start: if inout == FALSE pointer into buffer where user read should start
  2623. * offset: current offset into a /proc/scsi/advansys/[0...] file
  2624. * length: length of buffer
  2625. * hostno: Scsi_Host host_no
  2626. * inout: TRUE - user is writing; FALSE - user is reading
  2627. *
  2628. * Return the number of bytes read from or written to a
  2629. * /proc/scsi/advansys/[0...] file.
  2630. *
  2631. * Note: This function uses the per board buffer 'prtbuf' which is
  2632. * allocated when the board is initialized in advansys_detect(). The
  2633. * buffer is ASC_PRTBUF_SIZE bytes. The function asc_proc_copy() is
  2634. * used to write to the buffer. The way asc_proc_copy() is written
  2635. * if 'prtbuf' is too small it will not be overwritten. Instead the
  2636. * user just won't get all the available statistics.
  2637. */
  2638. static int
  2639. advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
  2640. off_t offset, int length, int inout)
  2641. {
  2642. asc_board_t *boardp;
  2643. char *cp;
  2644. int cplen;
  2645. int cnt;
  2646. int totcnt;
  2647. int leftlen;
  2648. char *curbuf;
  2649. off_t advoffset;
  2650. ASC_DBG(1, "advansys_proc_info: begin\n");
  2651. /*
  2652. * User write not supported.
  2653. */
  2654. if (inout == TRUE) {
  2655. return (-ENOSYS);
  2656. }
  2657. /*
  2658. * User read of /proc/scsi/advansys/[0...] file.
  2659. */
  2660. boardp = ASC_BOARDP(shost);
  2661. /* Copy read data starting at the beginning of the buffer. */
  2662. *start = buffer;
  2663. curbuf = buffer;
  2664. advoffset = 0;
  2665. totcnt = 0;
  2666. leftlen = length;
  2667. /*
  2668. * Get board configuration information.
  2669. *
  2670. * advansys_info() returns the board string from its own static buffer.
  2671. */
  2672. cp = (char *)advansys_info(shost);
  2673. strcat(cp, "\n");
  2674. cplen = strlen(cp);
  2675. /* Copy board information. */
  2676. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  2677. totcnt += cnt;
  2678. leftlen -= cnt;
  2679. if (leftlen == 0) {
  2680. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2681. return totcnt;
  2682. }
  2683. advoffset += cplen;
  2684. curbuf += cnt;
  2685. /*
  2686. * Display Wide Board BIOS Information.
  2687. */
  2688. if (ASC_WIDE_BOARD(boardp)) {
  2689. cp = boardp->prtbuf;
  2690. cplen = asc_prt_adv_bios(shost, cp, ASC_PRTBUF_SIZE);
  2691. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  2692. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
  2693. cplen);
  2694. totcnt += cnt;
  2695. leftlen -= cnt;
  2696. if (leftlen == 0) {
  2697. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2698. return totcnt;
  2699. }
  2700. advoffset += cplen;
  2701. curbuf += cnt;
  2702. }
  2703. /*
  2704. * Display driver information for each device attached to the board.
  2705. */
  2706. cp = boardp->prtbuf;
  2707. cplen = asc_prt_board_devices(shost, cp, ASC_PRTBUF_SIZE);
  2708. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  2709. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  2710. totcnt += cnt;
  2711. leftlen -= cnt;
  2712. if (leftlen == 0) {
  2713. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2714. return totcnt;
  2715. }
  2716. advoffset += cplen;
  2717. curbuf += cnt;
  2718. /*
  2719. * Display EEPROM configuration for the board.
  2720. */
  2721. cp = boardp->prtbuf;
  2722. if (ASC_NARROW_BOARD(boardp)) {
  2723. cplen = asc_prt_asc_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
  2724. } else {
  2725. cplen = asc_prt_adv_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
  2726. }
  2727. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  2728. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  2729. totcnt += cnt;
  2730. leftlen -= cnt;
  2731. if (leftlen == 0) {
  2732. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2733. return totcnt;
  2734. }
  2735. advoffset += cplen;
  2736. curbuf += cnt;
  2737. /*
  2738. * Display driver configuration and information for the board.
  2739. */
  2740. cp = boardp->prtbuf;
  2741. cplen = asc_prt_driver_conf(shost, cp, ASC_PRTBUF_SIZE);
  2742. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  2743. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  2744. totcnt += cnt;
  2745. leftlen -= cnt;
  2746. if (leftlen == 0) {
  2747. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2748. return totcnt;
  2749. }
  2750. advoffset += cplen;
  2751. curbuf += cnt;
  2752. #ifdef ADVANSYS_STATS
  2753. /*
  2754. * Display driver statistics for the board.
  2755. */
  2756. cp = boardp->prtbuf;
  2757. cplen = asc_prt_board_stats(shost, cp, ASC_PRTBUF_SIZE);
  2758. ASC_ASSERT(cplen <= ASC_PRTBUF_SIZE);
  2759. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  2760. totcnt += cnt;
  2761. leftlen -= cnt;
  2762. if (leftlen == 0) {
  2763. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2764. return totcnt;
  2765. }
  2766. advoffset += cplen;
  2767. curbuf += cnt;
  2768. #endif /* ADVANSYS_STATS */
  2769. /*
  2770. * Display Asc Library dynamic configuration information
  2771. * for the board.
  2772. */
  2773. cp = boardp->prtbuf;
  2774. if (ASC_NARROW_BOARD(boardp)) {
  2775. cplen = asc_prt_asc_board_info(shost, cp, ASC_PRTBUF_SIZE);
  2776. } else {
  2777. cplen = asc_prt_adv_board_info(shost, cp, ASC_PRTBUF_SIZE);
  2778. }
  2779. ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
  2780. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  2781. totcnt += cnt;
  2782. leftlen -= cnt;
  2783. if (leftlen == 0) {
  2784. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2785. return totcnt;
  2786. }
  2787. advoffset += cplen;
  2788. curbuf += cnt;
  2789. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  2790. return totcnt;
  2791. }
  2792. #endif /* CONFIG_PROC_FS */
  2793. /*
  2794. * advansys_info()
  2795. *
  2796. * Return suitable for printing on the console with the argument
  2797. * adapter's configuration information.
  2798. *
  2799. * Note: The information line should not exceed ASC_INFO_SIZE bytes,
  2800. * otherwise the static 'info' array will be overrun.
  2801. */
  2802. static const char *advansys_info(struct Scsi_Host *shost)
  2803. {
  2804. static char info[ASC_INFO_SIZE];
  2805. asc_board_t *boardp;
  2806. ASC_DVC_VAR *asc_dvc_varp;
  2807. ADV_DVC_VAR *adv_dvc_varp;
  2808. char *busname;
  2809. char *widename = NULL;
  2810. boardp = ASC_BOARDP(shost);
  2811. if (ASC_NARROW_BOARD(boardp)) {
  2812. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  2813. ASC_DBG(1, "advansys_info: begin\n");
  2814. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  2815. if ((asc_dvc_varp->bus_type & ASC_IS_ISAPNP) ==
  2816. ASC_IS_ISAPNP) {
  2817. busname = "ISA PnP";
  2818. } else {
  2819. busname = "ISA";
  2820. }
  2821. sprintf(info,
  2822. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X, DMA 0x%X",
  2823. ASC_VERSION, busname,
  2824. (ulong)shost->io_port,
  2825. (ulong)shost->io_port + ASC_IOADR_GAP - 1,
  2826. shost->irq, shost->dma_channel);
  2827. } else {
  2828. if (asc_dvc_varp->bus_type & ASC_IS_VL) {
  2829. busname = "VL";
  2830. } else if (asc_dvc_varp->bus_type & ASC_IS_EISA) {
  2831. busname = "EISA";
  2832. } else if (asc_dvc_varp->bus_type & ASC_IS_PCI) {
  2833. if ((asc_dvc_varp->bus_type & ASC_IS_PCI_ULTRA)
  2834. == ASC_IS_PCI_ULTRA) {
  2835. busname = "PCI Ultra";
  2836. } else {
  2837. busname = "PCI";
  2838. }
  2839. } else {
  2840. busname = "?";
  2841. ASC_PRINT2("advansys_info: board %d: unknown "
  2842. "bus type %d\n", boardp->id,
  2843. asc_dvc_varp->bus_type);
  2844. }
  2845. sprintf(info,
  2846. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X",
  2847. ASC_VERSION, busname, (ulong)shost->io_port,
  2848. (ulong)shost->io_port + ASC_IOADR_GAP - 1,
  2849. shost->irq);
  2850. }
  2851. } else {
  2852. /*
  2853. * Wide Adapter Information
  2854. *
  2855. * Memory-mapped I/O is used instead of I/O space to access
  2856. * the adapter, but display the I/O Port range. The Memory
  2857. * I/O address is displayed through the driver /proc file.
  2858. */
  2859. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  2860. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  2861. widename = "Ultra-Wide";
  2862. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  2863. widename = "Ultra2-Wide";
  2864. } else {
  2865. widename = "Ultra3-Wide";
  2866. }
  2867. sprintf(info,
  2868. "AdvanSys SCSI %s: PCI %s: PCIMEM 0x%lX-0x%lX, IRQ 0x%X",
  2869. ASC_VERSION, widename, (ulong)adv_dvc_varp->iop_base,
  2870. (ulong)adv_dvc_varp->iop_base + boardp->asc_n_io_port - 1, shost->irq);
  2871. }
  2872. ASC_ASSERT(strlen(info) < ASC_INFO_SIZE);
  2873. ASC_DBG(1, "advansys_info: end\n");
  2874. return info;
  2875. }
  2876. static void asc_scsi_done(struct scsi_cmnd *scp)
  2877. {
  2878. struct asc_board *boardp = ASC_BOARDP(scp->device->host);
  2879. if (scp->use_sg)
  2880. dma_unmap_sg(boardp->dev,
  2881. (struct scatterlist *)scp->request_buffer,
  2882. scp->use_sg, scp->sc_data_direction);
  2883. else if (scp->request_bufflen)
  2884. dma_unmap_single(boardp->dev, scp->SCp.dma_handle,
  2885. scp->request_bufflen, scp->sc_data_direction);
  2886. ASC_STATS(scp->device->host, done);
  2887. scp->scsi_done(scp);
  2888. }
  2889. /*
  2890. * advansys_queuecommand() - interrupt-driven I/O entrypoint.
  2891. *
  2892. * This function always returns 0. Command return status is saved
  2893. * in the 'scp' result field.
  2894. */
  2895. static int
  2896. advansys_queuecommand(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *))
  2897. {
  2898. struct Scsi_Host *shost = scp->device->host;
  2899. asc_board_t *boardp = ASC_BOARDP(shost);
  2900. unsigned long flags;
  2901. int asc_res, result = 0;
  2902. ASC_STATS(shost, queuecommand);
  2903. scp->scsi_done = done;
  2904. /*
  2905. * host_lock taken by mid-level prior to call, but need
  2906. * to protect against own ISR
  2907. */
  2908. spin_lock_irqsave(&boardp->lock, flags);
  2909. asc_res = asc_execute_scsi_cmnd(scp);
  2910. spin_unlock_irqrestore(&boardp->lock, flags);
  2911. switch (asc_res) {
  2912. case ASC_NOERROR:
  2913. break;
  2914. case ASC_BUSY:
  2915. result = SCSI_MLQUEUE_HOST_BUSY;
  2916. break;
  2917. case ASC_ERROR:
  2918. default:
  2919. asc_scsi_done(scp);
  2920. break;
  2921. }
  2922. return result;
  2923. }
  2924. /*
  2925. * advansys_reset()
  2926. *
  2927. * Reset the bus associated with the command 'scp'.
  2928. *
  2929. * This function runs its own thread. Interrupts must be blocked but
  2930. * sleeping is allowed and no locking other than for host structures is
  2931. * required. Returns SUCCESS or FAILED.
  2932. */
  2933. static int advansys_reset(struct scsi_cmnd *scp)
  2934. {
  2935. struct Scsi_Host *shost;
  2936. asc_board_t *boardp;
  2937. ASC_DVC_VAR *asc_dvc_varp;
  2938. ADV_DVC_VAR *adv_dvc_varp;
  2939. ulong flags;
  2940. int status;
  2941. int ret = SUCCESS;
  2942. ASC_DBG1(1, "advansys_reset: 0x%lx\n", (ulong)scp);
  2943. #ifdef ADVANSYS_STATS
  2944. if (scp->device->host != NULL) {
  2945. ASC_STATS(scp->device->host, reset);
  2946. }
  2947. #endif /* ADVANSYS_STATS */
  2948. if ((shost = scp->device->host) == NULL) {
  2949. scp->result = HOST_BYTE(DID_ERROR);
  2950. return FAILED;
  2951. }
  2952. boardp = ASC_BOARDP(shost);
  2953. ASC_PRINT1("advansys_reset: board %d: SCSI bus reset started...\n",
  2954. boardp->id);
  2955. /*
  2956. * Check for re-entrancy.
  2957. */
  2958. spin_lock_irqsave(&boardp->lock, flags);
  2959. if (boardp->flags & ASC_HOST_IN_RESET) {
  2960. spin_unlock_irqrestore(&boardp->lock, flags);
  2961. return FAILED;
  2962. }
  2963. boardp->flags |= ASC_HOST_IN_RESET;
  2964. spin_unlock_irqrestore(&boardp->lock, flags);
  2965. if (ASC_NARROW_BOARD(boardp)) {
  2966. /*
  2967. * Narrow Board
  2968. */
  2969. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  2970. /*
  2971. * Reset the chip and SCSI bus.
  2972. */
  2973. ASC_DBG(1, "advansys_reset: before AscInitAsc1000Driver()\n");
  2974. status = AscInitAsc1000Driver(asc_dvc_varp);
  2975. /* Refer to ASC_IERR_* defintions for meaning of 'err_code'. */
  2976. if (asc_dvc_varp->err_code) {
  2977. ASC_PRINT2("advansys_reset: board %d: SCSI bus reset "
  2978. "error: 0x%x\n", boardp->id,
  2979. asc_dvc_varp->err_code);
  2980. ret = FAILED;
  2981. } else if (status) {
  2982. ASC_PRINT2("advansys_reset: board %d: SCSI bus reset "
  2983. "warning: 0x%x\n", boardp->id, status);
  2984. } else {
  2985. ASC_PRINT1("advansys_reset: board %d: SCSI bus reset "
  2986. "successful.\n", boardp->id);
  2987. }
  2988. ASC_DBG(1, "advansys_reset: after AscInitAsc1000Driver()\n");
  2989. spin_lock_irqsave(&boardp->lock, flags);
  2990. } else {
  2991. /*
  2992. * Wide Board
  2993. *
  2994. * If the suggest reset bus flags are set, then reset the bus.
  2995. * Otherwise only reset the device.
  2996. */
  2997. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  2998. /*
  2999. * Reset the target's SCSI bus.
  3000. */
  3001. ASC_DBG(1, "advansys_reset: before AdvResetChipAndSB()\n");
  3002. switch (AdvResetChipAndSB(adv_dvc_varp)) {
  3003. case ASC_TRUE:
  3004. ASC_PRINT1("advansys_reset: board %d: SCSI bus reset "
  3005. "successful.\n", boardp->id);
  3006. break;
  3007. case ASC_FALSE:
  3008. default:
  3009. ASC_PRINT1("advansys_reset: board %d: SCSI bus reset "
  3010. "error.\n", boardp->id);
  3011. ret = FAILED;
  3012. break;
  3013. }
  3014. spin_lock_irqsave(&boardp->lock, flags);
  3015. (void)AdvISR(adv_dvc_varp);
  3016. }
  3017. /* Board lock is held. */
  3018. /* Save the time of the most recently completed reset. */
  3019. boardp->last_reset = jiffies;
  3020. /* Clear reset flag. */
  3021. boardp->flags &= ~ASC_HOST_IN_RESET;
  3022. spin_unlock_irqrestore(&boardp->lock, flags);
  3023. ASC_DBG1(1, "advansys_reset: ret %d\n", ret);
  3024. return ret;
  3025. }
  3026. /*
  3027. * advansys_biosparam()
  3028. *
  3029. * Translate disk drive geometry if the "BIOS greater than 1 GB"
  3030. * support is enabled for a drive.
  3031. *
  3032. * ip (information pointer) is an int array with the following definition:
  3033. * ip[0]: heads
  3034. * ip[1]: sectors
  3035. * ip[2]: cylinders
  3036. */
  3037. static int
  3038. advansys_biosparam(struct scsi_device *sdev, struct block_device *bdev,
  3039. sector_t capacity, int ip[])
  3040. {
  3041. asc_board_t *boardp;
  3042. ASC_DBG(1, "advansys_biosparam: begin\n");
  3043. ASC_STATS(sdev->host, biosparam);
  3044. boardp = ASC_BOARDP(sdev->host);
  3045. if (ASC_NARROW_BOARD(boardp)) {
  3046. if ((boardp->dvc_var.asc_dvc_var.dvc_cntl &
  3047. ASC_CNTL_BIOS_GT_1GB) && capacity > 0x200000) {
  3048. ip[0] = 255;
  3049. ip[1] = 63;
  3050. } else {
  3051. ip[0] = 64;
  3052. ip[1] = 32;
  3053. }
  3054. } else {
  3055. if ((boardp->dvc_var.adv_dvc_var.bios_ctrl &
  3056. BIOS_CTRL_EXTENDED_XLAT) && capacity > 0x200000) {
  3057. ip[0] = 255;
  3058. ip[1] = 63;
  3059. } else {
  3060. ip[0] = 64;
  3061. ip[1] = 32;
  3062. }
  3063. }
  3064. ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
  3065. ASC_DBG(1, "advansys_biosparam: end\n");
  3066. return 0;
  3067. }
  3068. static struct scsi_host_template advansys_template = {
  3069. .proc_name = "advansys",
  3070. #ifdef CONFIG_PROC_FS
  3071. .proc_info = advansys_proc_info,
  3072. #endif
  3073. .name = "advansys",
  3074. .info = advansys_info,
  3075. .queuecommand = advansys_queuecommand,
  3076. .eh_bus_reset_handler = advansys_reset,
  3077. .bios_param = advansys_biosparam,
  3078. .slave_configure = advansys_slave_configure,
  3079. /*
  3080. * Because the driver may control an ISA adapter 'unchecked_isa_dma'
  3081. * must be set. The flag will be cleared in advansys_board_found
  3082. * for non-ISA adapters.
  3083. */
  3084. .unchecked_isa_dma = 1,
  3085. /*
  3086. * All adapters controlled by this driver are capable of large
  3087. * scatter-gather lists. According to the mid-level SCSI documentation
  3088. * this obviates any performance gain provided by setting
  3089. * 'use_clustering'. But empirically while CPU utilization is increased
  3090. * by enabling clustering, I/O throughput increases as well.
  3091. */
  3092. .use_clustering = ENABLE_CLUSTERING,
  3093. };
  3094. /*
  3095. * --- Miscellaneous Driver Functions
  3096. */
  3097. /*
  3098. * First-level interrupt handler.
  3099. *
  3100. * 'dev_id' is a pointer to the interrupting adapter's asc_board_t. Because
  3101. * all boards are currently checked for interrupts on each interrupt, 'dev_id'
  3102. * is not referenced. 'dev_id' could be used to identify an interrupt passed
  3103. * to the AdvanSys driver which is for a device sharing an interrupt with
  3104. * an AdvanSys adapter.
  3105. */
  3106. static irqreturn_t advansys_interrupt(int irq, void *dev_id)
  3107. {
  3108. unsigned long flags;
  3109. struct Scsi_Host *shost = dev_id;
  3110. asc_board_t *boardp = ASC_BOARDP(shost);
  3111. irqreturn_t result = IRQ_NONE;
  3112. ASC_DBG1(2, "advansys_interrupt: boardp 0x%p\n", boardp);
  3113. spin_lock_irqsave(&boardp->lock, flags);
  3114. if (ASC_NARROW_BOARD(boardp)) {
  3115. /*
  3116. * Narrow Board
  3117. */
  3118. if (AscIsIntPending(shost->io_port)) {
  3119. result = IRQ_HANDLED;
  3120. ASC_STATS(shost, interrupt);
  3121. ASC_DBG(1, "advansys_interrupt: before AscISR()\n");
  3122. AscISR(&boardp->dvc_var.asc_dvc_var);
  3123. }
  3124. } else {
  3125. /*
  3126. * Wide Board
  3127. */
  3128. ASC_DBG(1, "advansys_interrupt: before AdvISR()\n");
  3129. if (AdvISR(&boardp->dvc_var.adv_dvc_var)) {
  3130. result = IRQ_HANDLED;
  3131. ASC_STATS(shost, interrupt);
  3132. }
  3133. }
  3134. spin_unlock_irqrestore(&boardp->lock, flags);
  3135. /*
  3136. * If interrupts were enabled on entry, then they
  3137. * are now enabled here.
  3138. */
  3139. ASC_DBG(1, "advansys_interrupt: end\n");
  3140. return result;
  3141. }
  3142. static void
  3143. advansys_narrow_slave_configure(struct scsi_device *sdev, ASC_DVC_VAR *asc_dvc)
  3144. {
  3145. ASC_SCSI_BIT_ID_TYPE tid_bit = 1 << sdev->id;
  3146. ASC_SCSI_BIT_ID_TYPE orig_use_tagged_qng = asc_dvc->use_tagged_qng;
  3147. if (sdev->lun == 0) {
  3148. ASC_SCSI_BIT_ID_TYPE orig_init_sdtr = asc_dvc->init_sdtr;
  3149. if ((asc_dvc->cfg->sdtr_enable & tid_bit) && sdev->sdtr) {
  3150. asc_dvc->init_sdtr |= tid_bit;
  3151. } else {
  3152. asc_dvc->init_sdtr &= ~tid_bit;
  3153. }
  3154. if (orig_init_sdtr != asc_dvc->init_sdtr)
  3155. AscAsyncFix(asc_dvc, sdev);
  3156. }
  3157. if (sdev->tagged_supported) {
  3158. if (asc_dvc->cfg->cmd_qng_enabled & tid_bit) {
  3159. if (sdev->lun == 0) {
  3160. asc_dvc->cfg->can_tagged_qng |= tid_bit;
  3161. asc_dvc->use_tagged_qng |= tid_bit;
  3162. }
  3163. scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
  3164. asc_dvc->max_dvc_qng[sdev->id]);
  3165. }
  3166. } else {
  3167. if (sdev->lun == 0) {
  3168. asc_dvc->cfg->can_tagged_qng &= ~tid_bit;
  3169. asc_dvc->use_tagged_qng &= ~tid_bit;
  3170. }
  3171. scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
  3172. }
  3173. if ((sdev->lun == 0) &&
  3174. (orig_use_tagged_qng != asc_dvc->use_tagged_qng)) {
  3175. AscWriteLramByte(asc_dvc->iop_base, ASCV_DISC_ENABLE_B,
  3176. asc_dvc->cfg->disc_enable);
  3177. AscWriteLramByte(asc_dvc->iop_base, ASCV_USE_TAGGED_QNG_B,
  3178. asc_dvc->use_tagged_qng);
  3179. AscWriteLramByte(asc_dvc->iop_base, ASCV_CAN_TAGGED_QNG_B,
  3180. asc_dvc->cfg->can_tagged_qng);
  3181. asc_dvc->max_dvc_qng[sdev->id] =
  3182. asc_dvc->cfg->max_tag_qng[sdev->id];
  3183. AscWriteLramByte(asc_dvc->iop_base,
  3184. (ushort)(ASCV_MAX_DVC_QNG_BEG + sdev->id),
  3185. asc_dvc->max_dvc_qng[sdev->id]);
  3186. }
  3187. }
  3188. /*
  3189. * Wide Transfers
  3190. *
  3191. * If the EEPROM enabled WDTR for the device and the device supports wide
  3192. * bus (16 bit) transfers, then turn on the device's 'wdtr_able' bit and
  3193. * write the new value to the microcode.
  3194. */
  3195. static void
  3196. advansys_wide_enable_wdtr(AdvPortAddr iop_base, unsigned short tidmask)
  3197. {
  3198. unsigned short cfg_word;
  3199. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
  3200. if ((cfg_word & tidmask) != 0)
  3201. return;
  3202. cfg_word |= tidmask;
  3203. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
  3204. /*
  3205. * Clear the microcode SDTR and WDTR negotiation done indicators for
  3206. * the target to cause it to negotiate with the new setting set above.
  3207. * WDTR when accepted causes the target to enter asynchronous mode, so
  3208. * SDTR must be negotiated.
  3209. */
  3210. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  3211. cfg_word &= ~tidmask;
  3212. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  3213. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
  3214. cfg_word &= ~tidmask;
  3215. AdvWriteWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
  3216. }
  3217. /*
  3218. * Synchronous Transfers
  3219. *
  3220. * If the EEPROM enabled SDTR for the device and the device
  3221. * supports synchronous transfers, then turn on the device's
  3222. * 'sdtr_able' bit. Write the new value to the microcode.
  3223. */
  3224. static void
  3225. advansys_wide_enable_sdtr(AdvPortAddr iop_base, unsigned short tidmask)
  3226. {
  3227. unsigned short cfg_word;
  3228. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
  3229. if ((cfg_word & tidmask) != 0)
  3230. return;
  3231. cfg_word |= tidmask;
  3232. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
  3233. /*
  3234. * Clear the microcode "SDTR negotiation" done indicator for the
  3235. * target to cause it to negotiate with the new setting set above.
  3236. */
  3237. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  3238. cfg_word &= ~tidmask;
  3239. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  3240. }
  3241. /*
  3242. * PPR (Parallel Protocol Request) Capable
  3243. *
  3244. * If the device supports DT mode, then it must be PPR capable.
  3245. * The PPR message will be used in place of the SDTR and WDTR
  3246. * messages to negotiate synchronous speed and offset, transfer
  3247. * width, and protocol options.
  3248. */
  3249. static void advansys_wide_enable_ppr(ADV_DVC_VAR *adv_dvc,
  3250. AdvPortAddr iop_base, unsigned short tidmask)
  3251. {
  3252. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
  3253. adv_dvc->ppr_able |= tidmask;
  3254. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
  3255. }
  3256. static void
  3257. advansys_wide_slave_configure(struct scsi_device *sdev, ADV_DVC_VAR *adv_dvc)
  3258. {
  3259. AdvPortAddr iop_base = adv_dvc->iop_base;
  3260. unsigned short tidmask = 1 << sdev->id;
  3261. if (sdev->lun == 0) {
  3262. /*
  3263. * Handle WDTR, SDTR, and Tag Queuing. If the feature
  3264. * is enabled in the EEPROM and the device supports the
  3265. * feature, then enable it in the microcode.
  3266. */
  3267. if ((adv_dvc->wdtr_able & tidmask) && sdev->wdtr)
  3268. advansys_wide_enable_wdtr(iop_base, tidmask);
  3269. if ((adv_dvc->sdtr_able & tidmask) && sdev->sdtr)
  3270. advansys_wide_enable_sdtr(iop_base, tidmask);
  3271. if (adv_dvc->chip_type == ADV_CHIP_ASC38C1600 && sdev->ppr)
  3272. advansys_wide_enable_ppr(adv_dvc, iop_base, tidmask);
  3273. /*
  3274. * Tag Queuing is disabled for the BIOS which runs in polled
  3275. * mode and would see no benefit from Tag Queuing. Also by
  3276. * disabling Tag Queuing in the BIOS devices with Tag Queuing
  3277. * bugs will at least work with the BIOS.
  3278. */
  3279. if ((adv_dvc->tagqng_able & tidmask) &&
  3280. sdev->tagged_supported) {
  3281. unsigned short cfg_word;
  3282. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, cfg_word);
  3283. cfg_word |= tidmask;
  3284. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  3285. cfg_word);
  3286. AdvWriteByteLram(iop_base,
  3287. ASC_MC_NUMBER_OF_MAX_CMD + sdev->id,
  3288. adv_dvc->max_dvc_qng);
  3289. }
  3290. }
  3291. if ((adv_dvc->tagqng_able & tidmask) && sdev->tagged_supported) {
  3292. scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
  3293. adv_dvc->max_dvc_qng);
  3294. } else {
  3295. scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
  3296. }
  3297. }
  3298. /*
  3299. * Set the number of commands to queue per device for the
  3300. * specified host adapter.
  3301. */
  3302. static int advansys_slave_configure(struct scsi_device *sdev)
  3303. {
  3304. asc_board_t *boardp = ASC_BOARDP(sdev->host);
  3305. boardp->flags |= ASC_SELECT_QUEUE_DEPTHS;
  3306. /*
  3307. * Save a pointer to the sdev and set its initial/maximum
  3308. * queue depth. Only save the pointer for a lun0 dev though.
  3309. */
  3310. if (sdev->lun == 0)
  3311. boardp->device[sdev->id] = sdev;
  3312. if (ASC_NARROW_BOARD(boardp))
  3313. advansys_narrow_slave_configure(sdev,
  3314. &boardp->dvc_var.asc_dvc_var);
  3315. else
  3316. advansys_wide_slave_configure(sdev,
  3317. &boardp->dvc_var.adv_dvc_var);
  3318. return 0;
  3319. }
  3320. /*
  3321. * Execute a single 'Scsi_Cmnd'.
  3322. *
  3323. * The function 'done' is called when the request has been completed.
  3324. *
  3325. * Scsi_Cmnd:
  3326. *
  3327. * host - board controlling device
  3328. * device - device to send command
  3329. * target - target of device
  3330. * lun - lun of device
  3331. * cmd_len - length of SCSI CDB
  3332. * cmnd - buffer for SCSI 8, 10, or 12 byte CDB
  3333. * use_sg - if non-zero indicates scatter-gather request with use_sg elements
  3334. *
  3335. * if (use_sg == 0) {
  3336. * request_buffer - buffer address for request
  3337. * request_bufflen - length of request buffer
  3338. * } else {
  3339. * request_buffer - pointer to scatterlist structure
  3340. * }
  3341. *
  3342. * sense_buffer - sense command buffer
  3343. *
  3344. * result (4 bytes of an int):
  3345. * Byte Meaning
  3346. * 0 SCSI Status Byte Code
  3347. * 1 SCSI One Byte Message Code
  3348. * 2 Host Error Code
  3349. * 3 Mid-Level Error Code
  3350. *
  3351. * host driver fields:
  3352. * SCp - Scsi_Pointer used for command processing status
  3353. * scsi_done - used to save caller's done function
  3354. * host_scribble - used for pointer to another struct scsi_cmnd
  3355. *
  3356. * If this function returns ASC_NOERROR the request will be completed
  3357. * from the interrupt handler.
  3358. *
  3359. * If this function returns ASC_ERROR the host error code has been set,
  3360. * and the called must call asc_scsi_done.
  3361. *
  3362. * If ASC_BUSY is returned the request will be returned to the midlayer
  3363. * and re-tried later.
  3364. */
  3365. static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
  3366. {
  3367. asc_board_t *boardp;
  3368. ASC_DVC_VAR *asc_dvc_varp;
  3369. ADV_DVC_VAR *adv_dvc_varp;
  3370. ADV_SCSI_REQ_Q *adv_scsiqp;
  3371. struct scsi_device *device;
  3372. int ret;
  3373. ASC_DBG2(1, "asc_execute_scsi_cmnd: scp 0x%lx, done 0x%lx\n",
  3374. (ulong)scp, (ulong)scp->scsi_done);
  3375. boardp = ASC_BOARDP(scp->device->host);
  3376. device = boardp->device[scp->device->id];
  3377. if (ASC_NARROW_BOARD(boardp)) {
  3378. /*
  3379. * Build and execute Narrow Board request.
  3380. */
  3381. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  3382. /*
  3383. * Build Asc Library request structure using the
  3384. * global structures 'asc_scsi_req' and 'asc_sg_head'.
  3385. *
  3386. * If an error is returned, then the request has been
  3387. * queued on the board done queue. It will be completed
  3388. * by the caller.
  3389. *
  3390. * asc_build_req() can not return ASC_BUSY.
  3391. */
  3392. if (asc_build_req(boardp, scp) == ASC_ERROR) {
  3393. ASC_STATS(scp->device->host, build_error);
  3394. return ASC_ERROR;
  3395. }
  3396. switch (ret = AscExeScsiQueue(asc_dvc_varp, &asc_scsi_q)) {
  3397. case ASC_NOERROR:
  3398. ASC_STATS(scp->device->host, exe_noerror);
  3399. /*
  3400. * Increment monotonically increasing per device
  3401. * successful request counter. Wrapping doesn't matter.
  3402. */
  3403. boardp->reqcnt[scp->device->id]++;
  3404. ASC_DBG(1, "asc_execute_scsi_cmnd: AscExeScsiQueue(), "
  3405. "ASC_NOERROR\n");
  3406. break;
  3407. case ASC_BUSY:
  3408. ASC_STATS(scp->device->host, exe_busy);
  3409. break;
  3410. case ASC_ERROR:
  3411. ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
  3412. "AscExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
  3413. boardp->id, asc_dvc_varp->err_code);
  3414. ASC_STATS(scp->device->host, exe_error);
  3415. scp->result = HOST_BYTE(DID_ERROR);
  3416. break;
  3417. default:
  3418. ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
  3419. "AscExeScsiQueue() unknown, err_code 0x%x\n",
  3420. boardp->id, asc_dvc_varp->err_code);
  3421. ASC_STATS(scp->device->host, exe_unknown);
  3422. scp->result = HOST_BYTE(DID_ERROR);
  3423. break;
  3424. }
  3425. } else {
  3426. /*
  3427. * Build and execute Wide Board request.
  3428. */
  3429. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  3430. /*
  3431. * Build and get a pointer to an Adv Library request structure.
  3432. *
  3433. * If the request is successfully built then send it below,
  3434. * otherwise return with an error.
  3435. */
  3436. switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
  3437. case ASC_NOERROR:
  3438. ASC_DBG(3, "asc_execute_scsi_cmnd: adv_build_req "
  3439. "ASC_NOERROR\n");
  3440. break;
  3441. case ASC_BUSY:
  3442. ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req "
  3443. "ASC_BUSY\n");
  3444. /*
  3445. * The asc_stats fields 'adv_build_noreq' and
  3446. * 'adv_build_nosg' count wide board busy conditions.
  3447. * They are updated in adv_build_req and
  3448. * adv_get_sglist, respectively.
  3449. */
  3450. return ASC_BUSY;
  3451. case ASC_ERROR:
  3452. default:
  3453. ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req "
  3454. "ASC_ERROR\n");
  3455. ASC_STATS(scp->device->host, build_error);
  3456. return ASC_ERROR;
  3457. }
  3458. switch (ret = AdvExeScsiQueue(adv_dvc_varp, adv_scsiqp)) {
  3459. case ASC_NOERROR:
  3460. ASC_STATS(scp->device->host, exe_noerror);
  3461. /*
  3462. * Increment monotonically increasing per device
  3463. * successful request counter. Wrapping doesn't matter.
  3464. */
  3465. boardp->reqcnt[scp->device->id]++;
  3466. ASC_DBG(1, "asc_execute_scsi_cmnd: AdvExeScsiQueue(), "
  3467. "ASC_NOERROR\n");
  3468. break;
  3469. case ASC_BUSY:
  3470. ASC_STATS(scp->device->host, exe_busy);
  3471. break;
  3472. case ASC_ERROR:
  3473. ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
  3474. "AdvExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
  3475. boardp->id, adv_dvc_varp->err_code);
  3476. ASC_STATS(scp->device->host, exe_error);
  3477. scp->result = HOST_BYTE(DID_ERROR);
  3478. break;
  3479. default:
  3480. ASC_PRINT2("asc_execute_scsi_cmnd: board %d: "
  3481. "AdvExeScsiQueue() unknown, err_code 0x%x\n",
  3482. boardp->id, adv_dvc_varp->err_code);
  3483. ASC_STATS(scp->device->host, exe_unknown);
  3484. scp->result = HOST_BYTE(DID_ERROR);
  3485. break;
  3486. }
  3487. }
  3488. ASC_DBG(1, "asc_execute_scsi_cmnd: end\n");
  3489. return ret;
  3490. }
  3491. /*
  3492. * Build a request structure for the Asc Library (Narrow Board).
  3493. *
  3494. * The global structures 'asc_scsi_q' and 'asc_sg_head' are
  3495. * used to build the request.
  3496. *
  3497. * If an error occurs, then return ASC_ERROR.
  3498. */
  3499. static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
  3500. {
  3501. /*
  3502. * Mutually exclusive access is required to 'asc_scsi_q' and
  3503. * 'asc_sg_head' until after the request is started.
  3504. */
  3505. memset(&asc_scsi_q, 0, sizeof(ASC_SCSI_Q));
  3506. /*
  3507. * Point the ASC_SCSI_Q to the 'struct scsi_cmnd'.
  3508. */
  3509. asc_scsi_q.q2.srb_ptr = ASC_VADDR_TO_U32(scp);
  3510. /*
  3511. * Build the ASC_SCSI_Q request.
  3512. */
  3513. asc_scsi_q.cdbptr = &scp->cmnd[0];
  3514. asc_scsi_q.q2.cdb_len = scp->cmd_len;
  3515. asc_scsi_q.q1.target_id = ASC_TID_TO_TARGET_ID(scp->device->id);
  3516. asc_scsi_q.q1.target_lun = scp->device->lun;
  3517. asc_scsi_q.q2.target_ix =
  3518. ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
  3519. asc_scsi_q.q1.sense_addr =
  3520. cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
  3521. asc_scsi_q.q1.sense_len = sizeof(scp->sense_buffer);
  3522. /*
  3523. * If there are any outstanding requests for the current target,
  3524. * then every 255th request send an ORDERED request. This heuristic
  3525. * tries to retain the benefit of request sorting while preventing
  3526. * request starvation. 255 is the max number of tags or pending commands
  3527. * a device may have outstanding.
  3528. *
  3529. * The request count is incremented below for every successfully
  3530. * started request.
  3531. *
  3532. */
  3533. if ((boardp->dvc_var.asc_dvc_var.cur_dvc_qng[scp->device->id] > 0) &&
  3534. (boardp->reqcnt[scp->device->id] % 255) == 0) {
  3535. asc_scsi_q.q2.tag_code = MSG_ORDERED_TAG;
  3536. } else {
  3537. asc_scsi_q.q2.tag_code = MSG_SIMPLE_TAG;
  3538. }
  3539. /*
  3540. * Build ASC_SCSI_Q for a contiguous buffer or a scatter-gather
  3541. * buffer command.
  3542. */
  3543. if (scp->use_sg == 0) {
  3544. /*
  3545. * CDB request of single contiguous buffer.
  3546. */
  3547. ASC_STATS(scp->device->host, cont_cnt);
  3548. scp->SCp.dma_handle = scp->request_bufflen ?
  3549. dma_map_single(boardp->dev, scp->request_buffer,
  3550. scp->request_bufflen,
  3551. scp->sc_data_direction) : 0;
  3552. asc_scsi_q.q1.data_addr = cpu_to_le32(scp->SCp.dma_handle);
  3553. asc_scsi_q.q1.data_cnt = cpu_to_le32(scp->request_bufflen);
  3554. ASC_STATS_ADD(scp->device->host, cont_xfer,
  3555. ASC_CEILING(scp->request_bufflen, 512));
  3556. asc_scsi_q.q1.sg_queue_cnt = 0;
  3557. asc_scsi_q.sg_head = NULL;
  3558. } else {
  3559. /*
  3560. * CDB scatter-gather request list.
  3561. */
  3562. int sgcnt;
  3563. int use_sg;
  3564. struct scatterlist *slp;
  3565. slp = (struct scatterlist *)scp->request_buffer;
  3566. use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
  3567. scp->sc_data_direction);
  3568. if (use_sg > scp->device->host->sg_tablesize) {
  3569. ASC_PRINT3("asc_build_req: board %d: use_sg %d > "
  3570. "sg_tablesize %d\n", boardp->id, use_sg,
  3571. scp->device->host->sg_tablesize);
  3572. dma_unmap_sg(boardp->dev, slp, scp->use_sg,
  3573. scp->sc_data_direction);
  3574. scp->result = HOST_BYTE(DID_ERROR);
  3575. return ASC_ERROR;
  3576. }
  3577. ASC_STATS(scp->device->host, sg_cnt);
  3578. /*
  3579. * Use global ASC_SG_HEAD structure and set the ASC_SCSI_Q
  3580. * structure to point to it.
  3581. */
  3582. memset(&asc_sg_head, 0, sizeof(ASC_SG_HEAD));
  3583. asc_scsi_q.q1.cntl |= QC_SG_HEAD;
  3584. asc_scsi_q.sg_head = &asc_sg_head;
  3585. asc_scsi_q.q1.data_cnt = 0;
  3586. asc_scsi_q.q1.data_addr = 0;
  3587. /* This is a byte value, otherwise it would need to be swapped. */
  3588. asc_sg_head.entry_cnt = asc_scsi_q.q1.sg_queue_cnt = use_sg;
  3589. ASC_STATS_ADD(scp->device->host, sg_elem,
  3590. asc_sg_head.entry_cnt);
  3591. /*
  3592. * Convert scatter-gather list into ASC_SG_HEAD list.
  3593. */
  3594. for (sgcnt = 0; sgcnt < use_sg; sgcnt++, slp++) {
  3595. asc_sg_head.sg_list[sgcnt].addr =
  3596. cpu_to_le32(sg_dma_address(slp));
  3597. asc_sg_head.sg_list[sgcnt].bytes =
  3598. cpu_to_le32(sg_dma_len(slp));
  3599. ASC_STATS_ADD(scp->device->host, sg_xfer,
  3600. ASC_CEILING(sg_dma_len(slp), 512));
  3601. }
  3602. }
  3603. ASC_DBG_PRT_ASC_SCSI_Q(2, &asc_scsi_q);
  3604. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  3605. return ASC_NOERROR;
  3606. }
  3607. /*
  3608. * Build a request structure for the Adv Library (Wide Board).
  3609. *
  3610. * If an adv_req_t can not be allocated to issue the request,
  3611. * then return ASC_BUSY. If an error occurs, then return ASC_ERROR.
  3612. *
  3613. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the
  3614. * microcode for DMA addresses or math operations are byte swapped
  3615. * to little-endian order.
  3616. */
  3617. static int
  3618. adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
  3619. ADV_SCSI_REQ_Q **adv_scsiqpp)
  3620. {
  3621. adv_req_t *reqp;
  3622. ADV_SCSI_REQ_Q *scsiqp;
  3623. int i;
  3624. int ret;
  3625. /*
  3626. * Allocate an adv_req_t structure from the board to execute
  3627. * the command.
  3628. */
  3629. if (boardp->adv_reqp == NULL) {
  3630. ASC_DBG(1, "adv_build_req: no free adv_req_t\n");
  3631. ASC_STATS(scp->device->host, adv_build_noreq);
  3632. return ASC_BUSY;
  3633. } else {
  3634. reqp = boardp->adv_reqp;
  3635. boardp->adv_reqp = reqp->next_reqp;
  3636. reqp->next_reqp = NULL;
  3637. }
  3638. /*
  3639. * Get 32-byte aligned ADV_SCSI_REQ_Q and ADV_SG_BLOCK pointers.
  3640. */
  3641. scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
  3642. /*
  3643. * Initialize the structure.
  3644. */
  3645. scsiqp->cntl = scsiqp->scsi_cntl = scsiqp->done_status = 0;
  3646. /*
  3647. * Set the ADV_SCSI_REQ_Q 'srb_ptr' to point to the adv_req_t structure.
  3648. */
  3649. scsiqp->srb_ptr = ASC_VADDR_TO_U32(reqp);
  3650. /*
  3651. * Set the adv_req_t 'cmndp' to point to the struct scsi_cmnd structure.
  3652. */
  3653. reqp->cmndp = scp;
  3654. /*
  3655. * Build the ADV_SCSI_REQ_Q request.
  3656. */
  3657. /* Set CDB length and copy it to the request structure. */
  3658. scsiqp->cdb_len = scp->cmd_len;
  3659. /* Copy first 12 CDB bytes to cdb[]. */
  3660. for (i = 0; i < scp->cmd_len && i < 12; i++) {
  3661. scsiqp->cdb[i] = scp->cmnd[i];
  3662. }
  3663. /* Copy last 4 CDB bytes, if present, to cdb16[]. */
  3664. for (; i < scp->cmd_len; i++) {
  3665. scsiqp->cdb16[i - 12] = scp->cmnd[i];
  3666. }
  3667. scsiqp->target_id = scp->device->id;
  3668. scsiqp->target_lun = scp->device->lun;
  3669. scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
  3670. scsiqp->sense_len = sizeof(scp->sense_buffer);
  3671. /*
  3672. * Build ADV_SCSI_REQ_Q for a contiguous buffer or a scatter-gather
  3673. * buffer command.
  3674. */
  3675. scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
  3676. scsiqp->vdata_addr = scp->request_buffer;
  3677. scsiqp->data_addr = cpu_to_le32(virt_to_bus(scp->request_buffer));
  3678. if (scp->use_sg == 0) {
  3679. /*
  3680. * CDB request of single contiguous buffer.
  3681. */
  3682. reqp->sgblkp = NULL;
  3683. scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
  3684. if (scp->request_bufflen) {
  3685. scsiqp->vdata_addr = scp->request_buffer;
  3686. scp->SCp.dma_handle =
  3687. dma_map_single(boardp->dev, scp->request_buffer,
  3688. scp->request_bufflen,
  3689. scp->sc_data_direction);
  3690. } else {
  3691. scsiqp->vdata_addr = NULL;
  3692. scp->SCp.dma_handle = 0;
  3693. }
  3694. scsiqp->data_addr = cpu_to_le32(scp->SCp.dma_handle);
  3695. scsiqp->sg_list_ptr = NULL;
  3696. scsiqp->sg_real_addr = 0;
  3697. ASC_STATS(scp->device->host, cont_cnt);
  3698. ASC_STATS_ADD(scp->device->host, cont_xfer,
  3699. ASC_CEILING(scp->request_bufflen, 512));
  3700. } else {
  3701. /*
  3702. * CDB scatter-gather request list.
  3703. */
  3704. struct scatterlist *slp;
  3705. int use_sg;
  3706. slp = (struct scatterlist *)scp->request_buffer;
  3707. use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
  3708. scp->sc_data_direction);
  3709. if (use_sg > ADV_MAX_SG_LIST) {
  3710. ASC_PRINT3("adv_build_req: board %d: use_sg %d > "
  3711. "ADV_MAX_SG_LIST %d\n", boardp->id, use_sg,
  3712. scp->device->host->sg_tablesize);
  3713. dma_unmap_sg(boardp->dev, slp, scp->use_sg,
  3714. scp->sc_data_direction);
  3715. scp->result = HOST_BYTE(DID_ERROR);
  3716. /*
  3717. * Free the 'adv_req_t' structure by adding it back
  3718. * to the board free list.
  3719. */
  3720. reqp->next_reqp = boardp->adv_reqp;
  3721. boardp->adv_reqp = reqp;
  3722. return ASC_ERROR;
  3723. }
  3724. ret = adv_get_sglist(boardp, reqp, scp, use_sg);
  3725. if (ret != ADV_SUCCESS) {
  3726. /*
  3727. * Free the adv_req_t structure by adding it back to
  3728. * the board free list.
  3729. */
  3730. reqp->next_reqp = boardp->adv_reqp;
  3731. boardp->adv_reqp = reqp;
  3732. return ret;
  3733. }
  3734. ASC_STATS(scp->device->host, sg_cnt);
  3735. ASC_STATS_ADD(scp->device->host, sg_elem, use_sg);
  3736. }
  3737. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  3738. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  3739. *adv_scsiqpp = scsiqp;
  3740. return ASC_NOERROR;
  3741. }
  3742. /*
  3743. * Build scatter-gather list for Adv Library (Wide Board).
  3744. *
  3745. * Additional ADV_SG_BLOCK structures will need to be allocated
  3746. * if the total number of scatter-gather elements exceeds
  3747. * NO_OF_SG_PER_BLOCK (15). The ADV_SG_BLOCK structures are
  3748. * assumed to be physically contiguous.
  3749. *
  3750. * Return:
  3751. * ADV_SUCCESS(1) - SG List successfully created
  3752. * ADV_ERROR(-1) - SG List creation failed
  3753. */
  3754. static int
  3755. adv_get_sglist(asc_board_t *boardp, adv_req_t *reqp, struct scsi_cmnd *scp,
  3756. int use_sg)
  3757. {
  3758. adv_sgblk_t *sgblkp;
  3759. ADV_SCSI_REQ_Q *scsiqp;
  3760. struct scatterlist *slp;
  3761. int sg_elem_cnt;
  3762. ADV_SG_BLOCK *sg_block, *prev_sg_block;
  3763. ADV_PADDR sg_block_paddr;
  3764. int i;
  3765. scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
  3766. slp = (struct scatterlist *)scp->request_buffer;
  3767. sg_elem_cnt = use_sg;
  3768. prev_sg_block = NULL;
  3769. reqp->sgblkp = NULL;
  3770. do {
  3771. /*
  3772. * Allocate a 'adv_sgblk_t' structure from the board free
  3773. * list. One 'adv_sgblk_t' structure holds NO_OF_SG_PER_BLOCK
  3774. * (15) scatter-gather elements.
  3775. */
  3776. if ((sgblkp = boardp->adv_sgblkp) == NULL) {
  3777. ASC_DBG(1, "adv_get_sglist: no free adv_sgblk_t\n");
  3778. ASC_STATS(scp->device->host, adv_build_nosg);
  3779. /*
  3780. * Allocation failed. Free 'adv_sgblk_t' structures already
  3781. * allocated for the request.
  3782. */
  3783. while ((sgblkp = reqp->sgblkp) != NULL) {
  3784. /* Remove 'sgblkp' from the request list. */
  3785. reqp->sgblkp = sgblkp->next_sgblkp;
  3786. /* Add 'sgblkp' to the board free list. */
  3787. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  3788. boardp->adv_sgblkp = sgblkp;
  3789. }
  3790. return ASC_BUSY;
  3791. } else {
  3792. /* Complete 'adv_sgblk_t' board allocation. */
  3793. boardp->adv_sgblkp = sgblkp->next_sgblkp;
  3794. sgblkp->next_sgblkp = NULL;
  3795. /*
  3796. * Get 8 byte aligned virtual and physical addresses for
  3797. * the allocated ADV_SG_BLOCK structure.
  3798. */
  3799. sg_block =
  3800. (ADV_SG_BLOCK *)ADV_8BALIGN(&sgblkp->sg_block);
  3801. sg_block_paddr = virt_to_bus(sg_block);
  3802. /*
  3803. * Check if this is the first 'adv_sgblk_t' for the request.
  3804. */
  3805. if (reqp->sgblkp == NULL) {
  3806. /* Request's first scatter-gather block. */
  3807. reqp->sgblkp = sgblkp;
  3808. /*
  3809. * Set ADV_SCSI_REQ_T ADV_SG_BLOCK virtual and physical
  3810. * address pointers.
  3811. */
  3812. scsiqp->sg_list_ptr = sg_block;
  3813. scsiqp->sg_real_addr =
  3814. cpu_to_le32(sg_block_paddr);
  3815. } else {
  3816. /* Request's second or later scatter-gather block. */
  3817. sgblkp->next_sgblkp = reqp->sgblkp;
  3818. reqp->sgblkp = sgblkp;
  3819. /*
  3820. * Point the previous ADV_SG_BLOCK structure to
  3821. * the newly allocated ADV_SG_BLOCK structure.
  3822. */
  3823. ASC_ASSERT(prev_sg_block != NULL);
  3824. prev_sg_block->sg_ptr =
  3825. cpu_to_le32(sg_block_paddr);
  3826. }
  3827. }
  3828. for (i = 0; i < NO_OF_SG_PER_BLOCK; i++) {
  3829. sg_block->sg_list[i].sg_addr =
  3830. cpu_to_le32(sg_dma_address(slp));
  3831. sg_block->sg_list[i].sg_count =
  3832. cpu_to_le32(sg_dma_len(slp));
  3833. ASC_STATS_ADD(scp->device->host, sg_xfer,
  3834. ASC_CEILING(sg_dma_len(slp), 512));
  3835. if (--sg_elem_cnt == 0) { /* Last ADV_SG_BLOCK and scatter-gather entry. */
  3836. sg_block->sg_cnt = i + 1;
  3837. sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in list. */
  3838. return ADV_SUCCESS;
  3839. }
  3840. slp++;
  3841. }
  3842. sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
  3843. prev_sg_block = sg_block;
  3844. }
  3845. while (1);
  3846. /* NOTREACHED */
  3847. }
  3848. /*
  3849. * asc_isr_callback() - Second Level Interrupt Handler called by AscISR().
  3850. *
  3851. * Interrupt callback function for the Narrow SCSI Asc Library.
  3852. */
  3853. static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
  3854. {
  3855. asc_board_t *boardp;
  3856. struct scsi_cmnd *scp;
  3857. struct Scsi_Host *shost;
  3858. ASC_DBG2(1, "asc_isr_callback: asc_dvc_varp 0x%lx, qdonep 0x%lx\n",
  3859. (ulong)asc_dvc_varp, (ulong)qdonep);
  3860. ASC_DBG_PRT_ASC_QDONE_INFO(2, qdonep);
  3861. /*
  3862. * Get the struct scsi_cmnd structure and Scsi_Host structure for the
  3863. * command that has been completed.
  3864. */
  3865. scp = (struct scsi_cmnd *)ASC_U32_TO_VADDR(qdonep->d2.srb_ptr);
  3866. ASC_DBG1(1, "asc_isr_callback: scp 0x%lx\n", (ulong)scp);
  3867. if (scp == NULL) {
  3868. ASC_PRINT("asc_isr_callback: scp is NULL\n");
  3869. return;
  3870. }
  3871. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  3872. shost = scp->device->host;
  3873. ASC_STATS(shost, callback);
  3874. ASC_DBG1(1, "asc_isr_callback: shost 0x%lx\n", (ulong)shost);
  3875. boardp = ASC_BOARDP(shost);
  3876. ASC_ASSERT(asc_dvc_varp == &boardp->dvc_var.asc_dvc_var);
  3877. /*
  3878. * 'qdonep' contains the command's ending status.
  3879. */
  3880. switch (qdonep->d3.done_stat) {
  3881. case QD_NO_ERROR:
  3882. ASC_DBG(2, "asc_isr_callback: QD_NO_ERROR\n");
  3883. scp->result = 0;
  3884. /*
  3885. * Check for an underrun condition.
  3886. *
  3887. * If there was no error and an underrun condition, then
  3888. * return the number of underrun bytes.
  3889. */
  3890. if (scp->request_bufflen != 0 && qdonep->remain_bytes != 0 &&
  3891. qdonep->remain_bytes <= scp->request_bufflen) {
  3892. ASC_DBG1(1,
  3893. "asc_isr_callback: underrun condition %u bytes\n",
  3894. (unsigned)qdonep->remain_bytes);
  3895. scp->resid = qdonep->remain_bytes;
  3896. }
  3897. break;
  3898. case QD_WITH_ERROR:
  3899. ASC_DBG(2, "asc_isr_callback: QD_WITH_ERROR\n");
  3900. switch (qdonep->d3.host_stat) {
  3901. case QHSTA_NO_ERROR:
  3902. if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
  3903. ASC_DBG(2,
  3904. "asc_isr_callback: SAM_STAT_CHECK_CONDITION\n");
  3905. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  3906. sizeof(scp->sense_buffer));
  3907. /*
  3908. * Note: The 'status_byte()' macro used by target drivers
  3909. * defined in scsi.h shifts the status byte returned by
  3910. * host drivers right by 1 bit. This is why target drivers
  3911. * also use right shifted status byte definitions. For
  3912. * instance target drivers use CHECK_CONDITION, defined to
  3913. * 0x1, instead of the SCSI defined check condition value
  3914. * of 0x2. Host drivers are supposed to return the status
  3915. * byte as it is defined by SCSI.
  3916. */
  3917. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  3918. STATUS_BYTE(qdonep->d3.scsi_stat);
  3919. } else {
  3920. scp->result = STATUS_BYTE(qdonep->d3.scsi_stat);
  3921. }
  3922. break;
  3923. default:
  3924. /* QHSTA error occurred */
  3925. ASC_DBG1(1, "asc_isr_callback: host_stat 0x%x\n",
  3926. qdonep->d3.host_stat);
  3927. scp->result = HOST_BYTE(DID_BAD_TARGET);
  3928. break;
  3929. }
  3930. break;
  3931. case QD_ABORTED_BY_HOST:
  3932. ASC_DBG(1, "asc_isr_callback: QD_ABORTED_BY_HOST\n");
  3933. scp->result =
  3934. HOST_BYTE(DID_ABORT) | MSG_BYTE(qdonep->d3.
  3935. scsi_msg) |
  3936. STATUS_BYTE(qdonep->d3.scsi_stat);
  3937. break;
  3938. default:
  3939. ASC_DBG1(1, "asc_isr_callback: done_stat 0x%x\n",
  3940. qdonep->d3.done_stat);
  3941. scp->result =
  3942. HOST_BYTE(DID_ERROR) | MSG_BYTE(qdonep->d3.
  3943. scsi_msg) |
  3944. STATUS_BYTE(qdonep->d3.scsi_stat);
  3945. break;
  3946. }
  3947. /*
  3948. * If the 'init_tidmask' bit isn't already set for the target and the
  3949. * current request finished normally, then set the bit for the target
  3950. * to indicate that a device is present.
  3951. */
  3952. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  3953. qdonep->d3.done_stat == QD_NO_ERROR &&
  3954. qdonep->d3.host_stat == QHSTA_NO_ERROR) {
  3955. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  3956. }
  3957. asc_scsi_done(scp);
  3958. return;
  3959. }
  3960. /*
  3961. * adv_isr_callback() - Second Level Interrupt Handler called by AdvISR().
  3962. *
  3963. * Callback function for the Wide SCSI Adv Library.
  3964. */
  3965. static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
  3966. {
  3967. asc_board_t *boardp;
  3968. adv_req_t *reqp;
  3969. adv_sgblk_t *sgblkp;
  3970. struct scsi_cmnd *scp;
  3971. struct Scsi_Host *shost;
  3972. ADV_DCNT resid_cnt;
  3973. ASC_DBG2(1, "adv_isr_callback: adv_dvc_varp 0x%lx, scsiqp 0x%lx\n",
  3974. (ulong)adv_dvc_varp, (ulong)scsiqp);
  3975. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  3976. /*
  3977. * Get the adv_req_t structure for the command that has been
  3978. * completed. The adv_req_t structure actually contains the
  3979. * completed ADV_SCSI_REQ_Q structure.
  3980. */
  3981. reqp = (adv_req_t *)ADV_U32_TO_VADDR(scsiqp->srb_ptr);
  3982. ASC_DBG1(1, "adv_isr_callback: reqp 0x%lx\n", (ulong)reqp);
  3983. if (reqp == NULL) {
  3984. ASC_PRINT("adv_isr_callback: reqp is NULL\n");
  3985. return;
  3986. }
  3987. /*
  3988. * Get the struct scsi_cmnd structure and Scsi_Host structure for the
  3989. * command that has been completed.
  3990. *
  3991. * Note: The adv_req_t request structure and adv_sgblk_t structure,
  3992. * if any, are dropped, because a board structure pointer can not be
  3993. * determined.
  3994. */
  3995. scp = reqp->cmndp;
  3996. ASC_DBG1(1, "adv_isr_callback: scp 0x%lx\n", (ulong)scp);
  3997. if (scp == NULL) {
  3998. ASC_PRINT
  3999. ("adv_isr_callback: scp is NULL; adv_req_t dropped.\n");
  4000. return;
  4001. }
  4002. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  4003. shost = scp->device->host;
  4004. ASC_STATS(shost, callback);
  4005. ASC_DBG1(1, "adv_isr_callback: shost 0x%lx\n", (ulong)shost);
  4006. boardp = ASC_BOARDP(shost);
  4007. ASC_ASSERT(adv_dvc_varp == &boardp->dvc_var.adv_dvc_var);
  4008. /*
  4009. * 'done_status' contains the command's ending status.
  4010. */
  4011. switch (scsiqp->done_status) {
  4012. case QD_NO_ERROR:
  4013. ASC_DBG(2, "adv_isr_callback: QD_NO_ERROR\n");
  4014. scp->result = 0;
  4015. /*
  4016. * Check for an underrun condition.
  4017. *
  4018. * If there was no error and an underrun condition, then
  4019. * then return the number of underrun bytes.
  4020. */
  4021. resid_cnt = le32_to_cpu(scsiqp->data_cnt);
  4022. if (scp->request_bufflen != 0 && resid_cnt != 0 &&
  4023. resid_cnt <= scp->request_bufflen) {
  4024. ASC_DBG1(1,
  4025. "adv_isr_callback: underrun condition %lu bytes\n",
  4026. (ulong)resid_cnt);
  4027. scp->resid = resid_cnt;
  4028. }
  4029. break;
  4030. case QD_WITH_ERROR:
  4031. ASC_DBG(2, "adv_isr_callback: QD_WITH_ERROR\n");
  4032. switch (scsiqp->host_status) {
  4033. case QHSTA_NO_ERROR:
  4034. if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
  4035. ASC_DBG(2,
  4036. "adv_isr_callback: SAM_STAT_CHECK_CONDITION\n");
  4037. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  4038. sizeof(scp->sense_buffer));
  4039. /*
  4040. * Note: The 'status_byte()' macro used by target drivers
  4041. * defined in scsi.h shifts the status byte returned by
  4042. * host drivers right by 1 bit. This is why target drivers
  4043. * also use right shifted status byte definitions. For
  4044. * instance target drivers use CHECK_CONDITION, defined to
  4045. * 0x1, instead of the SCSI defined check condition value
  4046. * of 0x2. Host drivers are supposed to return the status
  4047. * byte as it is defined by SCSI.
  4048. */
  4049. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  4050. STATUS_BYTE(scsiqp->scsi_status);
  4051. } else {
  4052. scp->result = STATUS_BYTE(scsiqp->scsi_status);
  4053. }
  4054. break;
  4055. default:
  4056. /* Some other QHSTA error occurred. */
  4057. ASC_DBG1(1, "adv_isr_callback: host_status 0x%x\n",
  4058. scsiqp->host_status);
  4059. scp->result = HOST_BYTE(DID_BAD_TARGET);
  4060. break;
  4061. }
  4062. break;
  4063. case QD_ABORTED_BY_HOST:
  4064. ASC_DBG(1, "adv_isr_callback: QD_ABORTED_BY_HOST\n");
  4065. scp->result =
  4066. HOST_BYTE(DID_ABORT) | STATUS_BYTE(scsiqp->scsi_status);
  4067. break;
  4068. default:
  4069. ASC_DBG1(1, "adv_isr_callback: done_status 0x%x\n",
  4070. scsiqp->done_status);
  4071. scp->result =
  4072. HOST_BYTE(DID_ERROR) | STATUS_BYTE(scsiqp->scsi_status);
  4073. break;
  4074. }
  4075. /*
  4076. * If the 'init_tidmask' bit isn't already set for the target and the
  4077. * current request finished normally, then set the bit for the target
  4078. * to indicate that a device is present.
  4079. */
  4080. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  4081. scsiqp->done_status == QD_NO_ERROR &&
  4082. scsiqp->host_status == QHSTA_NO_ERROR) {
  4083. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  4084. }
  4085. asc_scsi_done(scp);
  4086. /*
  4087. * Free all 'adv_sgblk_t' structures allocated for the request.
  4088. */
  4089. while ((sgblkp = reqp->sgblkp) != NULL) {
  4090. /* Remove 'sgblkp' from the request list. */
  4091. reqp->sgblkp = sgblkp->next_sgblkp;
  4092. /* Add 'sgblkp' to the board free list. */
  4093. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  4094. boardp->adv_sgblkp = sgblkp;
  4095. }
  4096. /*
  4097. * Free the adv_req_t structure used with the command by adding
  4098. * it back to the board free list.
  4099. */
  4100. reqp->next_reqp = boardp->adv_reqp;
  4101. boardp->adv_reqp = reqp;
  4102. ASC_DBG(1, "adv_isr_callback: done\n");
  4103. return;
  4104. }
  4105. /*
  4106. * adv_async_callback() - Adv Library asynchronous event callback function.
  4107. */
  4108. static void adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
  4109. {
  4110. switch (code) {
  4111. case ADV_ASYNC_SCSI_BUS_RESET_DET:
  4112. /*
  4113. * The firmware detected a SCSI Bus reset.
  4114. */
  4115. ASC_DBG(0,
  4116. "adv_async_callback: ADV_ASYNC_SCSI_BUS_RESET_DET\n");
  4117. break;
  4118. case ADV_ASYNC_RDMA_FAILURE:
  4119. /*
  4120. * Handle RDMA failure by resetting the SCSI Bus and
  4121. * possibly the chip if it is unresponsive. Log the error
  4122. * with a unique code.
  4123. */
  4124. ASC_DBG(0, "adv_async_callback: ADV_ASYNC_RDMA_FAILURE\n");
  4125. AdvResetChipAndSB(adv_dvc_varp);
  4126. break;
  4127. case ADV_HOST_SCSI_BUS_RESET:
  4128. /*
  4129. * Host generated SCSI bus reset occurred.
  4130. */
  4131. ASC_DBG(0, "adv_async_callback: ADV_HOST_SCSI_BUS_RESET\n");
  4132. break;
  4133. default:
  4134. ASC_DBG1(0, "DvcAsyncCallBack: unknown code 0x%x\n", code);
  4135. break;
  4136. }
  4137. }
  4138. #ifdef CONFIG_PROC_FS
  4139. /*
  4140. * asc_prt_board_devices()
  4141. *
  4142. * Print driver information for devices attached to the board.
  4143. *
  4144. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  4145. * cf. asc_prt_line().
  4146. *
  4147. * Return the number of characters copied into 'cp'. No more than
  4148. * 'cplen' characters will be copied to 'cp'.
  4149. */
  4150. static int asc_prt_board_devices(struct Scsi_Host *shost, char *cp, int cplen)
  4151. {
  4152. asc_board_t *boardp;
  4153. int leftlen;
  4154. int totlen;
  4155. int len;
  4156. int chip_scsi_id;
  4157. int i;
  4158. boardp = ASC_BOARDP(shost);
  4159. leftlen = cplen;
  4160. totlen = len = 0;
  4161. len = asc_prt_line(cp, leftlen,
  4162. "\nDevice Information for AdvanSys SCSI Host %d:\n",
  4163. shost->host_no);
  4164. ASC_PRT_NEXT();
  4165. if (ASC_NARROW_BOARD(boardp)) {
  4166. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  4167. } else {
  4168. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  4169. }
  4170. len = asc_prt_line(cp, leftlen, "Target IDs Detected:");
  4171. ASC_PRT_NEXT();
  4172. for (i = 0; i <= ADV_MAX_TID; i++) {
  4173. if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) {
  4174. len = asc_prt_line(cp, leftlen, " %X,", i);
  4175. ASC_PRT_NEXT();
  4176. }
  4177. }
  4178. len = asc_prt_line(cp, leftlen, " (%X=Host Adapter)\n", chip_scsi_id);
  4179. ASC_PRT_NEXT();
  4180. return totlen;
  4181. }
  4182. /*
  4183. * Display Wide Board BIOS Information.
  4184. */
  4185. static int asc_prt_adv_bios(struct Scsi_Host *shost, char *cp, int cplen)
  4186. {
  4187. asc_board_t *boardp;
  4188. int leftlen;
  4189. int totlen;
  4190. int len;
  4191. ushort major, minor, letter;
  4192. boardp = ASC_BOARDP(shost);
  4193. leftlen = cplen;
  4194. totlen = len = 0;
  4195. len = asc_prt_line(cp, leftlen, "\nROM BIOS Version: ");
  4196. ASC_PRT_NEXT();
  4197. /*
  4198. * If the BIOS saved a valid signature, then fill in
  4199. * the BIOS code segment base address.
  4200. */
  4201. if (boardp->bios_signature != 0x55AA) {
  4202. len = asc_prt_line(cp, leftlen, "Disabled or Pre-3.1\n");
  4203. ASC_PRT_NEXT();
  4204. len = asc_prt_line(cp, leftlen,
  4205. "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n");
  4206. ASC_PRT_NEXT();
  4207. len = asc_prt_line(cp, leftlen,
  4208. "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
  4209. ASC_PRT_NEXT();
  4210. } else {
  4211. major = (boardp->bios_version >> 12) & 0xF;
  4212. minor = (boardp->bios_version >> 8) & 0xF;
  4213. letter = (boardp->bios_version & 0xFF);
  4214. len = asc_prt_line(cp, leftlen, "%d.%d%c\n",
  4215. major, minor,
  4216. letter >= 26 ? '?' : letter + 'A');
  4217. ASC_PRT_NEXT();
  4218. /*
  4219. * Current available ROM BIOS release is 3.1I for UW
  4220. * and 3.2I for U2W. This code doesn't differentiate
  4221. * UW and U2W boards.
  4222. */
  4223. if (major < 3 || (major <= 3 && minor < 1) ||
  4224. (major <= 3 && minor <= 1 && letter < ('I' - 'A'))) {
  4225. len = asc_prt_line(cp, leftlen,
  4226. "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n");
  4227. ASC_PRT_NEXT();
  4228. len = asc_prt_line(cp, leftlen,
  4229. "ftp://ftp.connectcom.net/pub\n");
  4230. ASC_PRT_NEXT();
  4231. }
  4232. }
  4233. return totlen;
  4234. }
  4235. /*
  4236. * Add serial number to information bar if signature AAh
  4237. * is found in at bit 15-9 (7 bits) of word 1.
  4238. *
  4239. * Serial Number consists fo 12 alpha-numeric digits.
  4240. *
  4241. * 1 - Product type (A,B,C,D..) Word0: 15-13 (3 bits)
  4242. * 2 - MFG Location (A,B,C,D..) Word0: 12-10 (3 bits)
  4243. * 3-4 - Product ID (0-99) Word0: 9-0 (10 bits)
  4244. * 5 - Product revision (A-J) Word0: " "
  4245. *
  4246. * Signature Word1: 15-9 (7 bits)
  4247. * 6 - Year (0-9) Word1: 8-6 (3 bits) & Word2: 15 (1 bit)
  4248. * 7-8 - Week of the year (1-52) Word1: 5-0 (6 bits)
  4249. *
  4250. * 9-12 - Serial Number (A001-Z999) Word2: 14-0 (15 bits)
  4251. *
  4252. * Note 1: Only production cards will have a serial number.
  4253. *
  4254. * Note 2: Signature is most significant 7 bits (0xFE).
  4255. *
  4256. * Returns ASC_TRUE if serial number found, otherwise returns ASC_FALSE.
  4257. */
  4258. static int asc_get_eeprom_string(ushort *serialnum, uchar *cp)
  4259. {
  4260. ushort w, num;
  4261. if ((serialnum[1] & 0xFE00) != ((ushort)0xAA << 8)) {
  4262. return ASC_FALSE;
  4263. } else {
  4264. /*
  4265. * First word - 6 digits.
  4266. */
  4267. w = serialnum[0];
  4268. /* Product type - 1st digit. */
  4269. if ((*cp = 'A' + ((w & 0xE000) >> 13)) == 'H') {
  4270. /* Product type is P=Prototype */
  4271. *cp += 0x8;
  4272. }
  4273. cp++;
  4274. /* Manufacturing location - 2nd digit. */
  4275. *cp++ = 'A' + ((w & 0x1C00) >> 10);
  4276. /* Product ID - 3rd, 4th digits. */
  4277. num = w & 0x3FF;
  4278. *cp++ = '0' + (num / 100);
  4279. num %= 100;
  4280. *cp++ = '0' + (num / 10);
  4281. /* Product revision - 5th digit. */
  4282. *cp++ = 'A' + (num % 10);
  4283. /*
  4284. * Second word
  4285. */
  4286. w = serialnum[1];
  4287. /*
  4288. * Year - 6th digit.
  4289. *
  4290. * If bit 15 of third word is set, then the
  4291. * last digit of the year is greater than 7.
  4292. */
  4293. if (serialnum[2] & 0x8000) {
  4294. *cp++ = '8' + ((w & 0x1C0) >> 6);
  4295. } else {
  4296. *cp++ = '0' + ((w & 0x1C0) >> 6);
  4297. }
  4298. /* Week of year - 7th, 8th digits. */
  4299. num = w & 0x003F;
  4300. *cp++ = '0' + num / 10;
  4301. num %= 10;
  4302. *cp++ = '0' + num;
  4303. /*
  4304. * Third word
  4305. */
  4306. w = serialnum[2] & 0x7FFF;
  4307. /* Serial number - 9th digit. */
  4308. *cp++ = 'A' + (w / 1000);
  4309. /* 10th, 11th, 12th digits. */
  4310. num = w % 1000;
  4311. *cp++ = '0' + num / 100;
  4312. num %= 100;
  4313. *cp++ = '0' + num / 10;
  4314. num %= 10;
  4315. *cp++ = '0' + num;
  4316. *cp = '\0'; /* Null Terminate the string. */
  4317. return ASC_TRUE;
  4318. }
  4319. }
  4320. /*
  4321. * asc_prt_asc_board_eeprom()
  4322. *
  4323. * Print board EEPROM configuration.
  4324. *
  4325. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  4326. * cf. asc_prt_line().
  4327. *
  4328. * Return the number of characters copied into 'cp'. No more than
  4329. * 'cplen' characters will be copied to 'cp'.
  4330. */
  4331. static int asc_prt_asc_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
  4332. {
  4333. asc_board_t *boardp;
  4334. ASC_DVC_VAR *asc_dvc_varp;
  4335. int leftlen;
  4336. int totlen;
  4337. int len;
  4338. ASCEEP_CONFIG *ep;
  4339. int i;
  4340. #ifdef CONFIG_ISA
  4341. int isa_dma_speed[] = { 10, 8, 7, 6, 5, 4, 3, 2 };
  4342. #endif /* CONFIG_ISA */
  4343. uchar serialstr[13];
  4344. boardp = ASC_BOARDP(shost);
  4345. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  4346. ep = &boardp->eep_config.asc_eep;
  4347. leftlen = cplen;
  4348. totlen = len = 0;
  4349. len = asc_prt_line(cp, leftlen,
  4350. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
  4351. shost->host_no);
  4352. ASC_PRT_NEXT();
  4353. if (asc_get_eeprom_string((ushort *)&ep->adapter_info[0], serialstr)
  4354. == ASC_TRUE) {
  4355. len =
  4356. asc_prt_line(cp, leftlen, " Serial Number: %s\n",
  4357. serialstr);
  4358. ASC_PRT_NEXT();
  4359. } else {
  4360. if (ep->adapter_info[5] == 0xBB) {
  4361. len = asc_prt_line(cp, leftlen,
  4362. " Default Settings Used for EEPROM-less Adapter.\n");
  4363. ASC_PRT_NEXT();
  4364. } else {
  4365. len = asc_prt_line(cp, leftlen,
  4366. " Serial Number Signature Not Present.\n");
  4367. ASC_PRT_NEXT();
  4368. }
  4369. }
  4370. len = asc_prt_line(cp, leftlen,
  4371. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  4372. ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng,
  4373. ep->max_tag_qng);
  4374. ASC_PRT_NEXT();
  4375. len = asc_prt_line(cp, leftlen,
  4376. " cntl 0x%x, no_scam 0x%x\n", ep->cntl, ep->no_scam);
  4377. ASC_PRT_NEXT();
  4378. len = asc_prt_line(cp, leftlen, " Target ID: ");
  4379. ASC_PRT_NEXT();
  4380. for (i = 0; i <= ASC_MAX_TID; i++) {
  4381. len = asc_prt_line(cp, leftlen, " %d", i);
  4382. ASC_PRT_NEXT();
  4383. }
  4384. len = asc_prt_line(cp, leftlen, "\n");
  4385. ASC_PRT_NEXT();
  4386. len = asc_prt_line(cp, leftlen, " Disconnects: ");
  4387. ASC_PRT_NEXT();
  4388. for (i = 0; i <= ASC_MAX_TID; i++) {
  4389. len = asc_prt_line(cp, leftlen, " %c",
  4390. (ep->
  4391. disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  4392. 'N');
  4393. ASC_PRT_NEXT();
  4394. }
  4395. len = asc_prt_line(cp, leftlen, "\n");
  4396. ASC_PRT_NEXT();
  4397. len = asc_prt_line(cp, leftlen, " Command Queuing: ");
  4398. ASC_PRT_NEXT();
  4399. for (i = 0; i <= ASC_MAX_TID; i++) {
  4400. len = asc_prt_line(cp, leftlen, " %c",
  4401. (ep->
  4402. use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  4403. 'N');
  4404. ASC_PRT_NEXT();
  4405. }
  4406. len = asc_prt_line(cp, leftlen, "\n");
  4407. ASC_PRT_NEXT();
  4408. len = asc_prt_line(cp, leftlen, " Start Motor: ");
  4409. ASC_PRT_NEXT();
  4410. for (i = 0; i <= ASC_MAX_TID; i++) {
  4411. len = asc_prt_line(cp, leftlen, " %c",
  4412. (ep->
  4413. start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  4414. 'N');
  4415. ASC_PRT_NEXT();
  4416. }
  4417. len = asc_prt_line(cp, leftlen, "\n");
  4418. ASC_PRT_NEXT();
  4419. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  4420. ASC_PRT_NEXT();
  4421. for (i = 0; i <= ASC_MAX_TID; i++) {
  4422. len = asc_prt_line(cp, leftlen, " %c",
  4423. (ep->
  4424. init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  4425. 'N');
  4426. ASC_PRT_NEXT();
  4427. }
  4428. len = asc_prt_line(cp, leftlen, "\n");
  4429. ASC_PRT_NEXT();
  4430. #ifdef CONFIG_ISA
  4431. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  4432. len = asc_prt_line(cp, leftlen,
  4433. " Host ISA DMA speed: %d MB/S\n",
  4434. isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]);
  4435. ASC_PRT_NEXT();
  4436. }
  4437. #endif /* CONFIG_ISA */
  4438. return totlen;
  4439. }
  4440. /*
  4441. * asc_prt_adv_board_eeprom()
  4442. *
  4443. * Print board EEPROM configuration.
  4444. *
  4445. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  4446. * cf. asc_prt_line().
  4447. *
  4448. * Return the number of characters copied into 'cp'. No more than
  4449. * 'cplen' characters will be copied to 'cp'.
  4450. */
  4451. static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
  4452. {
  4453. asc_board_t *boardp;
  4454. ADV_DVC_VAR *adv_dvc_varp;
  4455. int leftlen;
  4456. int totlen;
  4457. int len;
  4458. int i;
  4459. char *termstr;
  4460. uchar serialstr[13];
  4461. ADVEEP_3550_CONFIG *ep_3550 = NULL;
  4462. ADVEEP_38C0800_CONFIG *ep_38C0800 = NULL;
  4463. ADVEEP_38C1600_CONFIG *ep_38C1600 = NULL;
  4464. ushort word;
  4465. ushort *wordp;
  4466. ushort sdtr_speed = 0;
  4467. boardp = ASC_BOARDP(shost);
  4468. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  4469. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4470. ep_3550 = &boardp->eep_config.adv_3550_eep;
  4471. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  4472. ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
  4473. } else {
  4474. ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
  4475. }
  4476. leftlen = cplen;
  4477. totlen = len = 0;
  4478. len = asc_prt_line(cp, leftlen,
  4479. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
  4480. shost->host_no);
  4481. ASC_PRT_NEXT();
  4482. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4483. wordp = &ep_3550->serial_number_word1;
  4484. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  4485. wordp = &ep_38C0800->serial_number_word1;
  4486. } else {
  4487. wordp = &ep_38C1600->serial_number_word1;
  4488. }
  4489. if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) {
  4490. len =
  4491. asc_prt_line(cp, leftlen, " Serial Number: %s\n",
  4492. serialstr);
  4493. ASC_PRT_NEXT();
  4494. } else {
  4495. len = asc_prt_line(cp, leftlen,
  4496. " Serial Number Signature Not Present.\n");
  4497. ASC_PRT_NEXT();
  4498. }
  4499. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4500. len = asc_prt_line(cp, leftlen,
  4501. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  4502. ep_3550->adapter_scsi_id,
  4503. ep_3550->max_host_qng, ep_3550->max_dvc_qng);
  4504. ASC_PRT_NEXT();
  4505. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  4506. len = asc_prt_line(cp, leftlen,
  4507. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  4508. ep_38C0800->adapter_scsi_id,
  4509. ep_38C0800->max_host_qng,
  4510. ep_38C0800->max_dvc_qng);
  4511. ASC_PRT_NEXT();
  4512. } else {
  4513. len = asc_prt_line(cp, leftlen,
  4514. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  4515. ep_38C1600->adapter_scsi_id,
  4516. ep_38C1600->max_host_qng,
  4517. ep_38C1600->max_dvc_qng);
  4518. ASC_PRT_NEXT();
  4519. }
  4520. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4521. word = ep_3550->termination;
  4522. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  4523. word = ep_38C0800->termination_lvd;
  4524. } else {
  4525. word = ep_38C1600->termination_lvd;
  4526. }
  4527. switch (word) {
  4528. case 1:
  4529. termstr = "Low Off/High Off";
  4530. break;
  4531. case 2:
  4532. termstr = "Low Off/High On";
  4533. break;
  4534. case 3:
  4535. termstr = "Low On/High On";
  4536. break;
  4537. default:
  4538. case 0:
  4539. termstr = "Automatic";
  4540. break;
  4541. }
  4542. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4543. len = asc_prt_line(cp, leftlen,
  4544. " termination: %u (%s), bios_ctrl: 0x%x\n",
  4545. ep_3550->termination, termstr,
  4546. ep_3550->bios_ctrl);
  4547. ASC_PRT_NEXT();
  4548. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  4549. len = asc_prt_line(cp, leftlen,
  4550. " termination: %u (%s), bios_ctrl: 0x%x\n",
  4551. ep_38C0800->termination_lvd, termstr,
  4552. ep_38C0800->bios_ctrl);
  4553. ASC_PRT_NEXT();
  4554. } else {
  4555. len = asc_prt_line(cp, leftlen,
  4556. " termination: %u (%s), bios_ctrl: 0x%x\n",
  4557. ep_38C1600->termination_lvd, termstr,
  4558. ep_38C1600->bios_ctrl);
  4559. ASC_PRT_NEXT();
  4560. }
  4561. len = asc_prt_line(cp, leftlen, " Target ID: ");
  4562. ASC_PRT_NEXT();
  4563. for (i = 0; i <= ADV_MAX_TID; i++) {
  4564. len = asc_prt_line(cp, leftlen, " %X", i);
  4565. ASC_PRT_NEXT();
  4566. }
  4567. len = asc_prt_line(cp, leftlen, "\n");
  4568. ASC_PRT_NEXT();
  4569. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4570. word = ep_3550->disc_enable;
  4571. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  4572. word = ep_38C0800->disc_enable;
  4573. } else {
  4574. word = ep_38C1600->disc_enable;
  4575. }
  4576. len = asc_prt_line(cp, leftlen, " Disconnects: ");
  4577. ASC_PRT_NEXT();
  4578. for (i = 0; i <= ADV_MAX_TID; i++) {
  4579. len = asc_prt_line(cp, leftlen, " %c",
  4580. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  4581. ASC_PRT_NEXT();
  4582. }
  4583. len = asc_prt_line(cp, leftlen, "\n");
  4584. ASC_PRT_NEXT();
  4585. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4586. word = ep_3550->tagqng_able;
  4587. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  4588. word = ep_38C0800->tagqng_able;
  4589. } else {
  4590. word = ep_38C1600->tagqng_able;
  4591. }
  4592. len = asc_prt_line(cp, leftlen, " Command Queuing: ");
  4593. ASC_PRT_NEXT();
  4594. for (i = 0; i <= ADV_MAX_TID; i++) {
  4595. len = asc_prt_line(cp, leftlen, " %c",
  4596. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  4597. ASC_PRT_NEXT();
  4598. }
  4599. len = asc_prt_line(cp, leftlen, "\n");
  4600. ASC_PRT_NEXT();
  4601. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4602. word = ep_3550->start_motor;
  4603. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  4604. word = ep_38C0800->start_motor;
  4605. } else {
  4606. word = ep_38C1600->start_motor;
  4607. }
  4608. len = asc_prt_line(cp, leftlen, " Start Motor: ");
  4609. ASC_PRT_NEXT();
  4610. for (i = 0; i <= ADV_MAX_TID; i++) {
  4611. len = asc_prt_line(cp, leftlen, " %c",
  4612. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  4613. ASC_PRT_NEXT();
  4614. }
  4615. len = asc_prt_line(cp, leftlen, "\n");
  4616. ASC_PRT_NEXT();
  4617. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4618. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  4619. ASC_PRT_NEXT();
  4620. for (i = 0; i <= ADV_MAX_TID; i++) {
  4621. len = asc_prt_line(cp, leftlen, " %c",
  4622. (ep_3550->
  4623. sdtr_able & ADV_TID_TO_TIDMASK(i)) ?
  4624. 'Y' : 'N');
  4625. ASC_PRT_NEXT();
  4626. }
  4627. len = asc_prt_line(cp, leftlen, "\n");
  4628. ASC_PRT_NEXT();
  4629. }
  4630. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4631. len = asc_prt_line(cp, leftlen, " Ultra Transfer: ");
  4632. ASC_PRT_NEXT();
  4633. for (i = 0; i <= ADV_MAX_TID; i++) {
  4634. len = asc_prt_line(cp, leftlen, " %c",
  4635. (ep_3550->
  4636. ultra_able & ADV_TID_TO_TIDMASK(i))
  4637. ? 'Y' : 'N');
  4638. ASC_PRT_NEXT();
  4639. }
  4640. len = asc_prt_line(cp, leftlen, "\n");
  4641. ASC_PRT_NEXT();
  4642. }
  4643. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  4644. word = ep_3550->wdtr_able;
  4645. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  4646. word = ep_38C0800->wdtr_able;
  4647. } else {
  4648. word = ep_38C1600->wdtr_able;
  4649. }
  4650. len = asc_prt_line(cp, leftlen, " Wide Transfer: ");
  4651. ASC_PRT_NEXT();
  4652. for (i = 0; i <= ADV_MAX_TID; i++) {
  4653. len = asc_prt_line(cp, leftlen, " %c",
  4654. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  4655. ASC_PRT_NEXT();
  4656. }
  4657. len = asc_prt_line(cp, leftlen, "\n");
  4658. ASC_PRT_NEXT();
  4659. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 ||
  4660. adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) {
  4661. len = asc_prt_line(cp, leftlen,
  4662. " Synchronous Transfer Speed (Mhz):\n ");
  4663. ASC_PRT_NEXT();
  4664. for (i = 0; i <= ADV_MAX_TID; i++) {
  4665. char *speed_str;
  4666. if (i == 0) {
  4667. sdtr_speed = adv_dvc_varp->sdtr_speed1;
  4668. } else if (i == 4) {
  4669. sdtr_speed = adv_dvc_varp->sdtr_speed2;
  4670. } else if (i == 8) {
  4671. sdtr_speed = adv_dvc_varp->sdtr_speed3;
  4672. } else if (i == 12) {
  4673. sdtr_speed = adv_dvc_varp->sdtr_speed4;
  4674. }
  4675. switch (sdtr_speed & ADV_MAX_TID) {
  4676. case 0:
  4677. speed_str = "Off";
  4678. break;
  4679. case 1:
  4680. speed_str = " 5";
  4681. break;
  4682. case 2:
  4683. speed_str = " 10";
  4684. break;
  4685. case 3:
  4686. speed_str = " 20";
  4687. break;
  4688. case 4:
  4689. speed_str = " 40";
  4690. break;
  4691. case 5:
  4692. speed_str = " 80";
  4693. break;
  4694. default:
  4695. speed_str = "Unk";
  4696. break;
  4697. }
  4698. len = asc_prt_line(cp, leftlen, "%X:%s ", i, speed_str);
  4699. ASC_PRT_NEXT();
  4700. if (i == 7) {
  4701. len = asc_prt_line(cp, leftlen, "\n ");
  4702. ASC_PRT_NEXT();
  4703. }
  4704. sdtr_speed >>= 4;
  4705. }
  4706. len = asc_prt_line(cp, leftlen, "\n");
  4707. ASC_PRT_NEXT();
  4708. }
  4709. return totlen;
  4710. }
  4711. /*
  4712. * asc_prt_driver_conf()
  4713. *
  4714. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  4715. * cf. asc_prt_line().
  4716. *
  4717. * Return the number of characters copied into 'cp'. No more than
  4718. * 'cplen' characters will be copied to 'cp'.
  4719. */
  4720. static int asc_prt_driver_conf(struct Scsi_Host *shost, char *cp, int cplen)
  4721. {
  4722. asc_board_t *boardp;
  4723. int leftlen;
  4724. int totlen;
  4725. int len;
  4726. int chip_scsi_id;
  4727. boardp = ASC_BOARDP(shost);
  4728. leftlen = cplen;
  4729. totlen = len = 0;
  4730. len = asc_prt_line(cp, leftlen,
  4731. "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n",
  4732. shost->host_no);
  4733. ASC_PRT_NEXT();
  4734. len = asc_prt_line(cp, leftlen,
  4735. " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n",
  4736. shost->host_busy, shost->last_reset, shost->max_id,
  4737. shost->max_lun, shost->max_channel);
  4738. ASC_PRT_NEXT();
  4739. len = asc_prt_line(cp, leftlen,
  4740. " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n",
  4741. shost->unique_id, shost->can_queue, shost->this_id,
  4742. shost->sg_tablesize, shost->cmd_per_lun);
  4743. ASC_PRT_NEXT();
  4744. len = asc_prt_line(cp, leftlen,
  4745. " unchecked_isa_dma %d, use_clustering %d\n",
  4746. shost->unchecked_isa_dma, shost->use_clustering);
  4747. ASC_PRT_NEXT();
  4748. len = asc_prt_line(cp, leftlen,
  4749. " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n",
  4750. boardp->flags, boardp->last_reset, jiffies,
  4751. boardp->asc_n_io_port);
  4752. ASC_PRT_NEXT();
  4753. len = asc_prt_line(cp, leftlen, " io_port 0x%x\n", shost->io_port);
  4754. ASC_PRT_NEXT();
  4755. if (ASC_NARROW_BOARD(boardp)) {
  4756. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  4757. } else {
  4758. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  4759. }
  4760. return totlen;
  4761. }
  4762. /*
  4763. * asc_prt_asc_board_info()
  4764. *
  4765. * Print dynamic board configuration information.
  4766. *
  4767. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  4768. * cf. asc_prt_line().
  4769. *
  4770. * Return the number of characters copied into 'cp'. No more than
  4771. * 'cplen' characters will be copied to 'cp'.
  4772. */
  4773. static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen)
  4774. {
  4775. asc_board_t *boardp;
  4776. int chip_scsi_id;
  4777. int leftlen;
  4778. int totlen;
  4779. int len;
  4780. ASC_DVC_VAR *v;
  4781. ASC_DVC_CFG *c;
  4782. int i;
  4783. int renegotiate = 0;
  4784. boardp = ASC_BOARDP(shost);
  4785. v = &boardp->dvc_var.asc_dvc_var;
  4786. c = &boardp->dvc_cfg.asc_dvc_cfg;
  4787. chip_scsi_id = c->chip_scsi_id;
  4788. leftlen = cplen;
  4789. totlen = len = 0;
  4790. len = asc_prt_line(cp, leftlen,
  4791. "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  4792. shost->host_no);
  4793. ASC_PRT_NEXT();
  4794. len = asc_prt_line(cp, leftlen,
  4795. " chip_version %u, lib_version 0x%x, lib_serial_no %u, mcode_date 0x%x\n",
  4796. c->chip_version, c->lib_version, c->lib_serial_no,
  4797. c->mcode_date);
  4798. ASC_PRT_NEXT();
  4799. len = asc_prt_line(cp, leftlen,
  4800. " mcode_version 0x%x, err_code %u\n",
  4801. c->mcode_version, v->err_code);
  4802. ASC_PRT_NEXT();
  4803. /* Current number of commands waiting for the host. */
  4804. len = asc_prt_line(cp, leftlen,
  4805. " Total Command Pending: %d\n", v->cur_total_qng);
  4806. ASC_PRT_NEXT();
  4807. len = asc_prt_line(cp, leftlen, " Command Queuing:");
  4808. ASC_PRT_NEXT();
  4809. for (i = 0; i <= ASC_MAX_TID; i++) {
  4810. if ((chip_scsi_id == i) ||
  4811. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  4812. continue;
  4813. }
  4814. len = asc_prt_line(cp, leftlen, " %X:%c",
  4815. i,
  4816. (v->
  4817. use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ?
  4818. 'Y' : 'N');
  4819. ASC_PRT_NEXT();
  4820. }
  4821. len = asc_prt_line(cp, leftlen, "\n");
  4822. ASC_PRT_NEXT();
  4823. /* Current number of commands waiting for a device. */
  4824. len = asc_prt_line(cp, leftlen, " Command Queue Pending:");
  4825. ASC_PRT_NEXT();
  4826. for (i = 0; i <= ASC_MAX_TID; i++) {
  4827. if ((chip_scsi_id == i) ||
  4828. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  4829. continue;
  4830. }
  4831. len = asc_prt_line(cp, leftlen, " %X:%u", i, v->cur_dvc_qng[i]);
  4832. ASC_PRT_NEXT();
  4833. }
  4834. len = asc_prt_line(cp, leftlen, "\n");
  4835. ASC_PRT_NEXT();
  4836. /* Current limit on number of commands that can be sent to a device. */
  4837. len = asc_prt_line(cp, leftlen, " Command Queue Limit:");
  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:%u", i, v->max_dvc_qng[i]);
  4845. ASC_PRT_NEXT();
  4846. }
  4847. len = asc_prt_line(cp, leftlen, "\n");
  4848. ASC_PRT_NEXT();
  4849. /* Indicate whether the device has returned queue full status. */
  4850. len = asc_prt_line(cp, leftlen, " Command Queue Full:");
  4851. ASC_PRT_NEXT();
  4852. for (i = 0; i <= ASC_MAX_TID; i++) {
  4853. if ((chip_scsi_id == i) ||
  4854. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  4855. continue;
  4856. }
  4857. if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) {
  4858. len = asc_prt_line(cp, leftlen, " %X:Y-%d",
  4859. i, boardp->queue_full_cnt[i]);
  4860. } else {
  4861. len = asc_prt_line(cp, leftlen, " %X:N", i);
  4862. }
  4863. ASC_PRT_NEXT();
  4864. }
  4865. len = asc_prt_line(cp, leftlen, "\n");
  4866. ASC_PRT_NEXT();
  4867. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  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:%c",
  4875. i,
  4876. (v->
  4877. sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  4878. 'N');
  4879. ASC_PRT_NEXT();
  4880. }
  4881. len = asc_prt_line(cp, leftlen, "\n");
  4882. ASC_PRT_NEXT();
  4883. for (i = 0; i <= ASC_MAX_TID; i++) {
  4884. uchar syn_period_ix;
  4885. if ((chip_scsi_id == i) ||
  4886. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  4887. ((v->init_sdtr & ADV_TID_TO_TIDMASK(i)) == 0)) {
  4888. continue;
  4889. }
  4890. len = asc_prt_line(cp, leftlen, " %X:", i);
  4891. ASC_PRT_NEXT();
  4892. if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0) {
  4893. len = asc_prt_line(cp, leftlen, " Asynchronous");
  4894. ASC_PRT_NEXT();
  4895. } else {
  4896. syn_period_ix =
  4897. (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index -
  4898. 1);
  4899. len = asc_prt_line(cp, leftlen,
  4900. " Transfer Period Factor: %d (%d.%d Mhz),",
  4901. v->sdtr_period_tbl[syn_period_ix],
  4902. 250 /
  4903. v->sdtr_period_tbl[syn_period_ix],
  4904. ASC_TENTHS(250,
  4905. v->
  4906. sdtr_period_tbl
  4907. [syn_period_ix]));
  4908. ASC_PRT_NEXT();
  4909. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  4910. boardp->
  4911. sdtr_data[i] & ASC_SYN_MAX_OFFSET);
  4912. ASC_PRT_NEXT();
  4913. }
  4914. if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  4915. len = asc_prt_line(cp, leftlen, "*\n");
  4916. renegotiate = 1;
  4917. } else {
  4918. len = asc_prt_line(cp, leftlen, "\n");
  4919. }
  4920. ASC_PRT_NEXT();
  4921. }
  4922. if (renegotiate) {
  4923. len = asc_prt_line(cp, leftlen,
  4924. " * = Re-negotiation pending before next command.\n");
  4925. ASC_PRT_NEXT();
  4926. }
  4927. return totlen;
  4928. }
  4929. /*
  4930. * asc_prt_adv_board_info()
  4931. *
  4932. * Print dynamic board configuration information.
  4933. *
  4934. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  4935. * cf. asc_prt_line().
  4936. *
  4937. * Return the number of characters copied into 'cp'. No more than
  4938. * 'cplen' characters will be copied to 'cp'.
  4939. */
  4940. static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
  4941. {
  4942. asc_board_t *boardp;
  4943. int leftlen;
  4944. int totlen;
  4945. int len;
  4946. int i;
  4947. ADV_DVC_VAR *v;
  4948. ADV_DVC_CFG *c;
  4949. AdvPortAddr iop_base;
  4950. ushort chip_scsi_id;
  4951. ushort lramword;
  4952. uchar lrambyte;
  4953. ushort tagqng_able;
  4954. ushort sdtr_able, wdtr_able;
  4955. ushort wdtr_done, sdtr_done;
  4956. ushort period = 0;
  4957. int renegotiate = 0;
  4958. boardp = ASC_BOARDP(shost);
  4959. v = &boardp->dvc_var.adv_dvc_var;
  4960. c = &boardp->dvc_cfg.adv_dvc_cfg;
  4961. iop_base = v->iop_base;
  4962. chip_scsi_id = v->chip_scsi_id;
  4963. leftlen = cplen;
  4964. totlen = len = 0;
  4965. len = asc_prt_line(cp, leftlen,
  4966. "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  4967. shost->host_no);
  4968. ASC_PRT_NEXT();
  4969. len = asc_prt_line(cp, leftlen,
  4970. " iop_base 0x%lx, cable_detect: %X, err_code %u\n",
  4971. v->iop_base,
  4972. AdvReadWordRegister(iop_base,
  4973. IOPW_SCSI_CFG1) & CABLE_DETECT,
  4974. v->err_code);
  4975. ASC_PRT_NEXT();
  4976. len = asc_prt_line(cp, leftlen,
  4977. " chip_version %u, lib_version 0x%x, mcode_date 0x%x, mcode_version 0x%x\n",
  4978. c->chip_version, c->lib_version, c->mcode_date,
  4979. c->mcode_version);
  4980. ASC_PRT_NEXT();
  4981. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  4982. len = asc_prt_line(cp, leftlen, " Queuing Enabled:");
  4983. ASC_PRT_NEXT();
  4984. for (i = 0; i <= ADV_MAX_TID; i++) {
  4985. if ((chip_scsi_id == i) ||
  4986. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  4987. continue;
  4988. }
  4989. len = asc_prt_line(cp, leftlen, " %X:%c",
  4990. i,
  4991. (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  4992. 'N');
  4993. ASC_PRT_NEXT();
  4994. }
  4995. len = asc_prt_line(cp, leftlen, "\n");
  4996. ASC_PRT_NEXT();
  4997. len = asc_prt_line(cp, leftlen, " Queue Limit:");
  4998. ASC_PRT_NEXT();
  4999. for (i = 0; i <= ADV_MAX_TID; i++) {
  5000. if ((chip_scsi_id == i) ||
  5001. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5002. continue;
  5003. }
  5004. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i,
  5005. lrambyte);
  5006. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  5007. ASC_PRT_NEXT();
  5008. }
  5009. len = asc_prt_line(cp, leftlen, "\n");
  5010. ASC_PRT_NEXT();
  5011. len = asc_prt_line(cp, leftlen, " Command Pending:");
  5012. ASC_PRT_NEXT();
  5013. for (i = 0; i <= ADV_MAX_TID; i++) {
  5014. if ((chip_scsi_id == i) ||
  5015. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5016. continue;
  5017. }
  5018. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i,
  5019. lrambyte);
  5020. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  5021. ASC_PRT_NEXT();
  5022. }
  5023. len = asc_prt_line(cp, leftlen, "\n");
  5024. ASC_PRT_NEXT();
  5025. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  5026. len = asc_prt_line(cp, leftlen, " Wide Enabled:");
  5027. ASC_PRT_NEXT();
  5028. for (i = 0; i <= ADV_MAX_TID; i++) {
  5029. if ((chip_scsi_id == i) ||
  5030. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5031. continue;
  5032. }
  5033. len = asc_prt_line(cp, leftlen, " %X:%c",
  5034. i,
  5035. (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  5036. 'N');
  5037. ASC_PRT_NEXT();
  5038. }
  5039. len = asc_prt_line(cp, leftlen, "\n");
  5040. ASC_PRT_NEXT();
  5041. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done);
  5042. len = asc_prt_line(cp, leftlen, " Transfer Bit Width:");
  5043. ASC_PRT_NEXT();
  5044. for (i = 0; i <= ADV_MAX_TID; i++) {
  5045. if ((chip_scsi_id == i) ||
  5046. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5047. continue;
  5048. }
  5049. AdvReadWordLram(iop_base,
  5050. ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  5051. lramword);
  5052. len = asc_prt_line(cp, leftlen, " %X:%d",
  5053. i, (lramword & 0x8000) ? 16 : 8);
  5054. ASC_PRT_NEXT();
  5055. if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) &&
  5056. (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  5057. len = asc_prt_line(cp, leftlen, "*");
  5058. ASC_PRT_NEXT();
  5059. renegotiate = 1;
  5060. }
  5061. }
  5062. len = asc_prt_line(cp, leftlen, "\n");
  5063. ASC_PRT_NEXT();
  5064. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  5065. len = asc_prt_line(cp, leftlen, " Synchronous Enabled:");
  5066. ASC_PRT_NEXT();
  5067. for (i = 0; i <= ADV_MAX_TID; i++) {
  5068. if ((chip_scsi_id == i) ||
  5069. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5070. continue;
  5071. }
  5072. len = asc_prt_line(cp, leftlen, " %X:%c",
  5073. i,
  5074. (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  5075. 'N');
  5076. ASC_PRT_NEXT();
  5077. }
  5078. len = asc_prt_line(cp, leftlen, "\n");
  5079. ASC_PRT_NEXT();
  5080. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done);
  5081. for (i = 0; i <= ADV_MAX_TID; i++) {
  5082. AdvReadWordLram(iop_base,
  5083. ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  5084. lramword);
  5085. lramword &= ~0x8000;
  5086. if ((chip_scsi_id == i) ||
  5087. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  5088. ((sdtr_able & ADV_TID_TO_TIDMASK(i)) == 0)) {
  5089. continue;
  5090. }
  5091. len = asc_prt_line(cp, leftlen, " %X:", i);
  5092. ASC_PRT_NEXT();
  5093. if ((lramword & 0x1F) == 0) { /* Check for REQ/ACK Offset 0. */
  5094. len = asc_prt_line(cp, leftlen, " Asynchronous");
  5095. ASC_PRT_NEXT();
  5096. } else {
  5097. len =
  5098. asc_prt_line(cp, leftlen,
  5099. " Transfer Period Factor: ");
  5100. ASC_PRT_NEXT();
  5101. if ((lramword & 0x1F00) == 0x1100) { /* 80 Mhz */
  5102. len =
  5103. asc_prt_line(cp, leftlen, "9 (80.0 Mhz),");
  5104. ASC_PRT_NEXT();
  5105. } else if ((lramword & 0x1F00) == 0x1000) { /* 40 Mhz */
  5106. len =
  5107. asc_prt_line(cp, leftlen, "10 (40.0 Mhz),");
  5108. ASC_PRT_NEXT();
  5109. } else { /* 20 Mhz or below. */
  5110. period = (((lramword >> 8) * 25) + 50) / 4;
  5111. if (period == 0) { /* Should never happen. */
  5112. len =
  5113. asc_prt_line(cp, leftlen,
  5114. "%d (? Mhz), ");
  5115. ASC_PRT_NEXT();
  5116. } else {
  5117. len = asc_prt_line(cp, leftlen,
  5118. "%d (%d.%d Mhz),",
  5119. period, 250 / period,
  5120. ASC_TENTHS(250,
  5121. period));
  5122. ASC_PRT_NEXT();
  5123. }
  5124. }
  5125. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  5126. lramword & 0x1F);
  5127. ASC_PRT_NEXT();
  5128. }
  5129. if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  5130. len = asc_prt_line(cp, leftlen, "*\n");
  5131. renegotiate = 1;
  5132. } else {
  5133. len = asc_prt_line(cp, leftlen, "\n");
  5134. }
  5135. ASC_PRT_NEXT();
  5136. }
  5137. if (renegotiate) {
  5138. len = asc_prt_line(cp, leftlen,
  5139. " * = Re-negotiation pending before next command.\n");
  5140. ASC_PRT_NEXT();
  5141. }
  5142. return totlen;
  5143. }
  5144. /*
  5145. * asc_proc_copy()
  5146. *
  5147. * Copy proc information to a read buffer taking into account the current
  5148. * read offset in the file and the remaining space in the read buffer.
  5149. */
  5150. static int
  5151. asc_proc_copy(off_t advoffset, off_t offset, char *curbuf, int leftlen,
  5152. char *cp, int cplen)
  5153. {
  5154. int cnt = 0;
  5155. ASC_DBG3(2, "asc_proc_copy: offset %d, advoffset %d, cplen %d\n",
  5156. (unsigned)offset, (unsigned)advoffset, cplen);
  5157. if (offset <= advoffset) {
  5158. /* Read offset below current offset, copy everything. */
  5159. cnt = min(cplen, leftlen);
  5160. ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  5161. (ulong)curbuf, (ulong)cp, cnt);
  5162. memcpy(curbuf, cp, cnt);
  5163. } else if (offset < advoffset + cplen) {
  5164. /* Read offset within current range, partial copy. */
  5165. cnt = (advoffset + cplen) - offset;
  5166. cp = (cp + cplen) - cnt;
  5167. cnt = min(cnt, leftlen);
  5168. ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  5169. (ulong)curbuf, (ulong)cp, cnt);
  5170. memcpy(curbuf, cp, cnt);
  5171. }
  5172. return cnt;
  5173. }
  5174. /*
  5175. * asc_prt_line()
  5176. *
  5177. * If 'cp' is NULL print to the console, otherwise print to a buffer.
  5178. *
  5179. * Return 0 if printing to the console, otherwise return the number of
  5180. * bytes written to the buffer.
  5181. *
  5182. * Note: If any single line is greater than ASC_PRTLINE_SIZE bytes the stack
  5183. * will be corrupted. 's[]' is defined to be ASC_PRTLINE_SIZE bytes.
  5184. */
  5185. static int asc_prt_line(char *buf, int buflen, char *fmt, ...)
  5186. {
  5187. va_list args;
  5188. int ret;
  5189. char s[ASC_PRTLINE_SIZE];
  5190. va_start(args, fmt);
  5191. ret = vsprintf(s, fmt, args);
  5192. ASC_ASSERT(ret < ASC_PRTLINE_SIZE);
  5193. if (buf == NULL) {
  5194. (void)printk(s);
  5195. ret = 0;
  5196. } else {
  5197. ret = min(buflen, ret);
  5198. memcpy(buf, s, ret);
  5199. }
  5200. va_end(args);
  5201. return ret;
  5202. }
  5203. #endif /* CONFIG_PROC_FS */
  5204. /*
  5205. * --- Functions Required by the Asc Library
  5206. */
  5207. /*
  5208. * Delay for 'n' milliseconds. Don't use the 'jiffies'
  5209. * global variable which is incremented once every 5 ms
  5210. * from a timer interrupt, because this function may be
  5211. * called when interrupts are disabled.
  5212. */
  5213. static void DvcSleepMilliSecond(ADV_DCNT n)
  5214. {
  5215. ASC_DBG1(4, "DvcSleepMilliSecond: %lu\n", (ulong)n);
  5216. mdelay(n);
  5217. }
  5218. /*
  5219. * Currently and inline noop but leave as a placeholder.
  5220. * Leave DvcEnterCritical() as a noop placeholder.
  5221. */
  5222. static inline ulong DvcEnterCritical(void)
  5223. {
  5224. return 0;
  5225. }
  5226. /*
  5227. * Critical sections are all protected by the board spinlock.
  5228. * Leave DvcLeaveCritical() as a noop placeholder.
  5229. */
  5230. static inline void DvcLeaveCritical(ulong flags)
  5231. {
  5232. return;
  5233. }
  5234. /*
  5235. * void
  5236. * DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  5237. *
  5238. * Calling/Exit State:
  5239. * none
  5240. *
  5241. * Description:
  5242. * Output an ASC_SCSI_Q structure to the chip
  5243. */
  5244. static void
  5245. DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  5246. {
  5247. int i;
  5248. ASC_DBG_PRT_HEX(2, "DvcPutScsiQ", outbuf, 2 * words);
  5249. AscSetChipLramAddr(iop_base, s_addr);
  5250. for (i = 0; i < 2 * words; i += 2) {
  5251. if (i == 4 || i == 20) {
  5252. continue;
  5253. }
  5254. outpw(iop_base + IOP_RAM_DATA,
  5255. ((ushort)outbuf[i + 1] << 8) | outbuf[i]);
  5256. }
  5257. }
  5258. /*
  5259. * void
  5260. * DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  5261. *
  5262. * Calling/Exit State:
  5263. * none
  5264. *
  5265. * Description:
  5266. * Input an ASC_QDONE_INFO structure from the chip
  5267. */
  5268. static void
  5269. DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  5270. {
  5271. int i;
  5272. ushort word;
  5273. AscSetChipLramAddr(iop_base, s_addr);
  5274. for (i = 0; i < 2 * words; i += 2) {
  5275. if (i == 10) {
  5276. continue;
  5277. }
  5278. word = inpw(iop_base + IOP_RAM_DATA);
  5279. inbuf[i] = word & 0xff;
  5280. inbuf[i + 1] = (word >> 8) & 0xff;
  5281. }
  5282. ASC_DBG_PRT_HEX(2, "DvcGetQinfo", inbuf, 2 * words);
  5283. }
  5284. /*
  5285. * Return the BIOS address of the adapter at the specified
  5286. * I/O port and with the specified bus type.
  5287. */
  5288. static unsigned short __devinit
  5289. AscGetChipBiosAddress(PortAddr iop_base, unsigned short bus_type)
  5290. {
  5291. unsigned short cfg_lsw;
  5292. unsigned short bios_addr;
  5293. /*
  5294. * The PCI BIOS is re-located by the motherboard BIOS. Because
  5295. * of this the driver can not determine where a PCI BIOS is
  5296. * loaded and executes.
  5297. */
  5298. if (bus_type & ASC_IS_PCI)
  5299. return 0;
  5300. #ifdef CONFIG_ISA
  5301. if ((bus_type & ASC_IS_EISA) != 0) {
  5302. cfg_lsw = AscGetEisaChipCfg(iop_base);
  5303. cfg_lsw &= 0x000F;
  5304. bios_addr = ASC_BIOS_MIN_ADDR + cfg_lsw * ASC_BIOS_BANK_SIZE;
  5305. return bios_addr;
  5306. }
  5307. #endif /* CONFIG_ISA */
  5308. cfg_lsw = AscGetChipCfgLsw(iop_base);
  5309. /*
  5310. * ISA PnP uses the top bit as the 32K BIOS flag
  5311. */
  5312. if (bus_type == ASC_IS_ISAPNP)
  5313. cfg_lsw &= 0x7FFF;
  5314. bios_addr = ASC_BIOS_MIN_ADDR + (cfg_lsw >> 12) * ASC_BIOS_BANK_SIZE;
  5315. return bios_addr;
  5316. }
  5317. /*
  5318. * --- Functions Required by the Adv Library
  5319. */
  5320. /*
  5321. * DvcGetPhyAddr()
  5322. *
  5323. * Return the physical address of 'vaddr' and set '*lenp' to the
  5324. * number of physically contiguous bytes that follow 'vaddr'.
  5325. * 'flag' indicates the type of structure whose physical address
  5326. * is being translated.
  5327. *
  5328. * Note: Because Linux currently doesn't page the kernel and all
  5329. * kernel buffers are physically contiguous, leave '*lenp' unchanged.
  5330. */
  5331. ADV_PADDR
  5332. DvcGetPhyAddr(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq,
  5333. uchar *vaddr, ADV_SDCNT *lenp, int flag)
  5334. {
  5335. ADV_PADDR paddr;
  5336. paddr = virt_to_bus(vaddr);
  5337. ASC_DBG4(4,
  5338. "DvcGetPhyAddr: vaddr 0x%lx, lenp 0x%lx *lenp %lu, paddr 0x%lx\n",
  5339. (ulong)vaddr, (ulong)lenp, (ulong)*((ulong *)lenp),
  5340. (ulong)paddr);
  5341. return paddr;
  5342. }
  5343. /*
  5344. * --- Tracing and Debugging Functions
  5345. */
  5346. #ifdef ADVANSYS_STATS
  5347. #ifdef CONFIG_PROC_FS
  5348. /*
  5349. * asc_prt_board_stats()
  5350. *
  5351. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  5352. * cf. asc_prt_line().
  5353. *
  5354. * Return the number of characters copied into 'cp'. No more than
  5355. * 'cplen' characters will be copied to 'cp'.
  5356. */
  5357. static int asc_prt_board_stats(struct Scsi_Host *shost, char *cp, int cplen)
  5358. {
  5359. int leftlen;
  5360. int totlen;
  5361. int len;
  5362. struct asc_stats *s;
  5363. asc_board_t *boardp;
  5364. leftlen = cplen;
  5365. totlen = len = 0;
  5366. boardp = ASC_BOARDP(shost);
  5367. s = &boardp->asc_stats;
  5368. len = asc_prt_line(cp, leftlen,
  5369. "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n",
  5370. shost->host_no);
  5371. ASC_PRT_NEXT();
  5372. len = asc_prt_line(cp, leftlen,
  5373. " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n",
  5374. s->queuecommand, s->reset, s->biosparam,
  5375. s->interrupt);
  5376. ASC_PRT_NEXT();
  5377. len = asc_prt_line(cp, leftlen,
  5378. " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n",
  5379. s->callback, s->done, s->build_error,
  5380. s->adv_build_noreq, s->adv_build_nosg);
  5381. ASC_PRT_NEXT();
  5382. len = asc_prt_line(cp, leftlen,
  5383. " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n",
  5384. s->exe_noerror, s->exe_busy, s->exe_error,
  5385. s->exe_unknown);
  5386. ASC_PRT_NEXT();
  5387. /*
  5388. * Display data transfer statistics.
  5389. */
  5390. if (s->cont_cnt > 0) {
  5391. len = asc_prt_line(cp, leftlen, " cont_cnt %lu, ", s->cont_cnt);
  5392. ASC_PRT_NEXT();
  5393. len = asc_prt_line(cp, leftlen, "cont_xfer %lu.%01lu kb ",
  5394. s->cont_xfer / 2,
  5395. ASC_TENTHS(s->cont_xfer, 2));
  5396. ASC_PRT_NEXT();
  5397. /* Contiguous transfer average size */
  5398. len = asc_prt_line(cp, leftlen, "avg_xfer %lu.%01lu kb\n",
  5399. (s->cont_xfer / 2) / s->cont_cnt,
  5400. ASC_TENTHS((s->cont_xfer / 2), s->cont_cnt));
  5401. ASC_PRT_NEXT();
  5402. }
  5403. if (s->sg_cnt > 0) {
  5404. len = asc_prt_line(cp, leftlen, " sg_cnt %lu, sg_elem %lu, ",
  5405. s->sg_cnt, s->sg_elem);
  5406. ASC_PRT_NEXT();
  5407. len = asc_prt_line(cp, leftlen, "sg_xfer %lu.%01lu kb\n",
  5408. s->sg_xfer / 2, ASC_TENTHS(s->sg_xfer, 2));
  5409. ASC_PRT_NEXT();
  5410. /* Scatter gather transfer statistics */
  5411. len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ",
  5412. s->sg_elem / s->sg_cnt,
  5413. ASC_TENTHS(s->sg_elem, s->sg_cnt));
  5414. ASC_PRT_NEXT();
  5415. len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ",
  5416. (s->sg_xfer / 2) / s->sg_elem,
  5417. ASC_TENTHS((s->sg_xfer / 2), s->sg_elem));
  5418. ASC_PRT_NEXT();
  5419. len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n",
  5420. (s->sg_xfer / 2) / s->sg_cnt,
  5421. ASC_TENTHS((s->sg_xfer / 2), s->sg_cnt));
  5422. ASC_PRT_NEXT();
  5423. }
  5424. /*
  5425. * Display request queuing statistics.
  5426. */
  5427. len = asc_prt_line(cp, leftlen,
  5428. " Active and Waiting Request Queues (Time Unit: %d HZ):\n",
  5429. HZ);
  5430. ASC_PRT_NEXT();
  5431. return totlen;
  5432. }
  5433. #endif /* CONFIG_PROC_FS */
  5434. #endif /* ADVANSYS_STATS */
  5435. #ifdef ADVANSYS_DEBUG
  5436. /*
  5437. * asc_prt_scsi_host()
  5438. */
  5439. static void asc_prt_scsi_host(struct Scsi_Host *s)
  5440. {
  5441. asc_board_t *boardp;
  5442. boardp = ASC_BOARDP(s);
  5443. printk("Scsi_Host at addr 0x%lx\n", (ulong)s);
  5444. printk(" host_busy %u, host_no %d, last_reset %d,\n",
  5445. s->host_busy, s->host_no, (unsigned)s->last_reset);
  5446. printk(" base 0x%lx, io_port 0x%lx, irq 0x%x,\n",
  5447. (ulong)s->base, (ulong)s->io_port, s->irq);
  5448. printk(" dma_channel %d, this_id %d, can_queue %d,\n",
  5449. s->dma_channel, s->this_id, s->can_queue);
  5450. printk(" cmd_per_lun %d, sg_tablesize %d, unchecked_isa_dma %d\n",
  5451. s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma);
  5452. if (ASC_NARROW_BOARD(boardp)) {
  5453. asc_prt_asc_dvc_var(&ASC_BOARDP(s)->dvc_var.asc_dvc_var);
  5454. asc_prt_asc_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.asc_dvc_cfg);
  5455. } else {
  5456. asc_prt_adv_dvc_var(&ASC_BOARDP(s)->dvc_var.adv_dvc_var);
  5457. asc_prt_adv_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.adv_dvc_cfg);
  5458. }
  5459. }
  5460. /*
  5461. * asc_prt_scsi_cmnd()
  5462. */
  5463. static void asc_prt_scsi_cmnd(struct scsi_cmnd *s)
  5464. {
  5465. printk("struct scsi_cmnd at addr 0x%lx\n", (ulong)s);
  5466. printk(" host 0x%lx, device 0x%lx, target %u, lun %u, channel %u,\n",
  5467. (ulong)s->device->host, (ulong)s->device, s->device->id,
  5468. s->device->lun, s->device->channel);
  5469. asc_prt_hex(" CDB", s->cmnd, s->cmd_len);
  5470. printk("sc_data_direction %u, resid %d\n",
  5471. s->sc_data_direction, s->resid);
  5472. printk(" use_sg %u, sglist_len %u\n", s->use_sg, s->sglist_len);
  5473. printk(" serial_number 0x%x, retries %d, allowed %d\n",
  5474. (unsigned)s->serial_number, s->retries, s->allowed);
  5475. printk(" timeout_per_command %d\n", s->timeout_per_command);
  5476. printk(" scsi_done 0x%p, done 0x%p, host_scribble 0x%p, result 0x%x\n",
  5477. s->scsi_done, s->done, s->host_scribble, s->result);
  5478. printk(" tag %u, pid %u\n", (unsigned)s->tag, (unsigned)s->pid);
  5479. }
  5480. /*
  5481. * asc_prt_asc_dvc_var()
  5482. */
  5483. static void asc_prt_asc_dvc_var(ASC_DVC_VAR *h)
  5484. {
  5485. printk("ASC_DVC_VAR at addr 0x%lx\n", (ulong)h);
  5486. printk(" iop_base 0x%x, err_code 0x%x, dvc_cntl 0x%x, bug_fix_cntl "
  5487. "%d,\n", h->iop_base, h->err_code, h->dvc_cntl, h->bug_fix_cntl);
  5488. printk(" bus_type %d, init_sdtr 0x%x,\n", h->bus_type,
  5489. (unsigned)h->init_sdtr);
  5490. printk(" sdtr_done 0x%x, use_tagged_qng 0x%x, unit_not_ready 0x%x, "
  5491. "chip_no 0x%x,\n", (unsigned)h->sdtr_done,
  5492. (unsigned)h->use_tagged_qng, (unsigned)h->unit_not_ready,
  5493. (unsigned)h->chip_no);
  5494. printk(" queue_full_or_busy 0x%x, start_motor 0x%x, scsi_reset_wait "
  5495. "%u,\n", (unsigned)h->queue_full_or_busy,
  5496. (unsigned)h->start_motor, (unsigned)h->scsi_reset_wait);
  5497. printk(" is_in_int %u, max_total_qng %u, cur_total_qng %u, "
  5498. "in_critical_cnt %u,\n", (unsigned)h->is_in_int,
  5499. (unsigned)h->max_total_qng, (unsigned)h->cur_total_qng,
  5500. (unsigned)h->in_critical_cnt);
  5501. printk(" last_q_shortage %u, init_state 0x%x, no_scam 0x%x, "
  5502. "pci_fix_asyn_xfer 0x%x,\n", (unsigned)h->last_q_shortage,
  5503. (unsigned)h->init_state, (unsigned)h->no_scam,
  5504. (unsigned)h->pci_fix_asyn_xfer);
  5505. printk(" cfg 0x%lx, irq_no 0x%x\n", (ulong)h->cfg, (unsigned)h->irq_no);
  5506. }
  5507. /*
  5508. * asc_prt_asc_dvc_cfg()
  5509. */
  5510. static void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *h)
  5511. {
  5512. printk("ASC_DVC_CFG at addr 0x%lx\n", (ulong)h);
  5513. printk(" can_tagged_qng 0x%x, cmd_qng_enabled 0x%x,\n",
  5514. h->can_tagged_qng, h->cmd_qng_enabled);
  5515. printk(" disc_enable 0x%x, sdtr_enable 0x%x,\n",
  5516. h->disc_enable, h->sdtr_enable);
  5517. printk
  5518. (" chip_scsi_id %d, isa_dma_speed %d, isa_dma_channel %d, chip_version %d,\n",
  5519. h->chip_scsi_id, h->isa_dma_speed, h->isa_dma_channel,
  5520. h->chip_version);
  5521. printk
  5522. (" pci_device_id %d, lib_serial_no %u, lib_version %u, mcode_date 0x%x,\n",
  5523. to_pci_dev(h->dev)->device, h->lib_serial_no, h->lib_version,
  5524. h->mcode_date);
  5525. printk(" mcode_version %d, overrun_buf 0x%lx\n",
  5526. h->mcode_version, (ulong)h->overrun_buf);
  5527. }
  5528. /*
  5529. * asc_prt_asc_scsi_q()
  5530. */
  5531. static void asc_prt_asc_scsi_q(ASC_SCSI_Q *q)
  5532. {
  5533. ASC_SG_HEAD *sgp;
  5534. int i;
  5535. printk("ASC_SCSI_Q at addr 0x%lx\n", (ulong)q);
  5536. printk
  5537. (" target_ix 0x%x, target_lun %u, srb_ptr 0x%lx, tag_code 0x%x,\n",
  5538. q->q2.target_ix, q->q1.target_lun, (ulong)q->q2.srb_ptr,
  5539. q->q2.tag_code);
  5540. printk
  5541. (" data_addr 0x%lx, data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  5542. (ulong)le32_to_cpu(q->q1.data_addr),
  5543. (ulong)le32_to_cpu(q->q1.data_cnt),
  5544. (ulong)le32_to_cpu(q->q1.sense_addr), q->q1.sense_len);
  5545. printk(" cdbptr 0x%lx, cdb_len %u, sg_head 0x%lx, sg_queue_cnt %u\n",
  5546. (ulong)q->cdbptr, q->q2.cdb_len,
  5547. (ulong)q->sg_head, q->q1.sg_queue_cnt);
  5548. if (q->sg_head) {
  5549. sgp = q->sg_head;
  5550. printk("ASC_SG_HEAD at addr 0x%lx\n", (ulong)sgp);
  5551. printk(" entry_cnt %u, queue_cnt %u\n", sgp->entry_cnt,
  5552. sgp->queue_cnt);
  5553. for (i = 0; i < sgp->entry_cnt; i++) {
  5554. printk(" [%u]: addr 0x%lx, bytes %lu\n",
  5555. i, (ulong)le32_to_cpu(sgp->sg_list[i].addr),
  5556. (ulong)le32_to_cpu(sgp->sg_list[i].bytes));
  5557. }
  5558. }
  5559. }
  5560. /*
  5561. * asc_prt_asc_qdone_info()
  5562. */
  5563. static void asc_prt_asc_qdone_info(ASC_QDONE_INFO *q)
  5564. {
  5565. printk("ASC_QDONE_INFO at addr 0x%lx\n", (ulong)q);
  5566. printk(" srb_ptr 0x%lx, target_ix %u, cdb_len %u, tag_code %u,\n",
  5567. (ulong)q->d2.srb_ptr, q->d2.target_ix, q->d2.cdb_len,
  5568. q->d2.tag_code);
  5569. printk
  5570. (" done_stat 0x%x, host_stat 0x%x, scsi_stat 0x%x, scsi_msg 0x%x\n",
  5571. q->d3.done_stat, q->d3.host_stat, q->d3.scsi_stat, q->d3.scsi_msg);
  5572. }
  5573. /*
  5574. * asc_prt_adv_dvc_var()
  5575. *
  5576. * Display an ADV_DVC_VAR structure.
  5577. */
  5578. static void asc_prt_adv_dvc_var(ADV_DVC_VAR *h)
  5579. {
  5580. printk(" ADV_DVC_VAR at addr 0x%lx\n", (ulong)h);
  5581. printk(" iop_base 0x%lx, err_code 0x%x, ultra_able 0x%x\n",
  5582. (ulong)h->iop_base, h->err_code, (unsigned)h->ultra_able);
  5583. printk(" isr_callback 0x%lx, sdtr_able 0x%x, wdtr_able 0x%x\n",
  5584. (ulong)h->isr_callback, (unsigned)h->sdtr_able,
  5585. (unsigned)h->wdtr_able);
  5586. printk(" start_motor 0x%x, scsi_reset_wait 0x%x, irq_no 0x%x,\n",
  5587. (unsigned)h->start_motor,
  5588. (unsigned)h->scsi_reset_wait, (unsigned)h->irq_no);
  5589. printk(" max_host_qng %u, max_dvc_qng %u, carr_freelist 0x%lxn\n",
  5590. (unsigned)h->max_host_qng, (unsigned)h->max_dvc_qng,
  5591. (ulong)h->carr_freelist);
  5592. printk(" icq_sp 0x%lx, irq_sp 0x%lx\n",
  5593. (ulong)h->icq_sp, (ulong)h->irq_sp);
  5594. printk(" no_scam 0x%x, tagqng_able 0x%x\n",
  5595. (unsigned)h->no_scam, (unsigned)h->tagqng_able);
  5596. printk(" chip_scsi_id 0x%x, cfg 0x%lx\n",
  5597. (unsigned)h->chip_scsi_id, (ulong)h->cfg);
  5598. }
  5599. /*
  5600. * asc_prt_adv_dvc_cfg()
  5601. *
  5602. * Display an ADV_DVC_CFG structure.
  5603. */
  5604. static void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *h)
  5605. {
  5606. printk(" ADV_DVC_CFG at addr 0x%lx\n", (ulong)h);
  5607. printk(" disc_enable 0x%x, termination 0x%x\n",
  5608. h->disc_enable, h->termination);
  5609. printk(" chip_version 0x%x, mcode_date 0x%x\n",
  5610. h->chip_version, h->mcode_date);
  5611. printk(" mcode_version 0x%x, pci_device_id 0x%x, lib_version %u\n",
  5612. h->mcode_version, to_pci_dev(h->dev)->device, h->lib_version);
  5613. printk(" control_flag 0x%x\n", h->control_flag);
  5614. }
  5615. /*
  5616. * asc_prt_adv_scsi_req_q()
  5617. *
  5618. * Display an ADV_SCSI_REQ_Q structure.
  5619. */
  5620. static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
  5621. {
  5622. int sg_blk_cnt;
  5623. struct asc_sg_block *sg_ptr;
  5624. printk("ADV_SCSI_REQ_Q at addr 0x%lx\n", (ulong)q);
  5625. printk(" target_id %u, target_lun %u, srb_ptr 0x%lx, a_flag 0x%x\n",
  5626. q->target_id, q->target_lun, (ulong)q->srb_ptr, q->a_flag);
  5627. printk(" cntl 0x%x, data_addr 0x%lx, vdata_addr 0x%lx\n",
  5628. q->cntl, (ulong)le32_to_cpu(q->data_addr), (ulong)q->vdata_addr);
  5629. printk(" data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  5630. (ulong)le32_to_cpu(q->data_cnt),
  5631. (ulong)le32_to_cpu(q->sense_addr), q->sense_len);
  5632. printk
  5633. (" cdb_len %u, done_status 0x%x, host_status 0x%x, scsi_status 0x%x\n",
  5634. q->cdb_len, q->done_status, q->host_status, q->scsi_status);
  5635. printk(" sg_working_ix 0x%x, target_cmd %u\n",
  5636. q->sg_working_ix, q->target_cmd);
  5637. printk(" scsiq_rptr 0x%lx, sg_real_addr 0x%lx, sg_list_ptr 0x%lx\n",
  5638. (ulong)le32_to_cpu(q->scsiq_rptr),
  5639. (ulong)le32_to_cpu(q->sg_real_addr), (ulong)q->sg_list_ptr);
  5640. /* Display the request's ADV_SG_BLOCK structures. */
  5641. if (q->sg_list_ptr != NULL) {
  5642. sg_blk_cnt = 0;
  5643. while (1) {
  5644. /*
  5645. * 'sg_ptr' is a physical address. Convert it to a virtual
  5646. * address by indexing 'sg_blk_cnt' into the virtual address
  5647. * array 'sg_list_ptr'.
  5648. *
  5649. * XXX - Assumes all SG physical blocks are virtually contiguous.
  5650. */
  5651. sg_ptr =
  5652. &(((ADV_SG_BLOCK *)(q->sg_list_ptr))[sg_blk_cnt]);
  5653. asc_prt_adv_sgblock(sg_blk_cnt, sg_ptr);
  5654. if (sg_ptr->sg_ptr == 0) {
  5655. break;
  5656. }
  5657. sg_blk_cnt++;
  5658. }
  5659. }
  5660. }
  5661. /*
  5662. * asc_prt_adv_sgblock()
  5663. *
  5664. * Display an ADV_SG_BLOCK structure.
  5665. */
  5666. static void asc_prt_adv_sgblock(int sgblockno, ADV_SG_BLOCK *b)
  5667. {
  5668. int i;
  5669. printk(" ASC_SG_BLOCK at addr 0x%lx (sgblockno %d)\n",
  5670. (ulong)b, sgblockno);
  5671. printk(" sg_cnt %u, sg_ptr 0x%lx\n",
  5672. b->sg_cnt, (ulong)le32_to_cpu(b->sg_ptr));
  5673. ASC_ASSERT(b->sg_cnt <= NO_OF_SG_PER_BLOCK);
  5674. if (b->sg_ptr != 0) {
  5675. ASC_ASSERT(b->sg_cnt == NO_OF_SG_PER_BLOCK);
  5676. }
  5677. for (i = 0; i < b->sg_cnt; i++) {
  5678. printk(" [%u]: sg_addr 0x%lx, sg_count 0x%lx\n",
  5679. i, (ulong)b->sg_list[i].sg_addr,
  5680. (ulong)b->sg_list[i].sg_count);
  5681. }
  5682. }
  5683. /*
  5684. * asc_prt_hex()
  5685. *
  5686. * Print hexadecimal output in 4 byte groupings 32 bytes
  5687. * or 8 double-words per line.
  5688. */
  5689. static void asc_prt_hex(char *f, uchar *s, int l)
  5690. {
  5691. int i;
  5692. int j;
  5693. int k;
  5694. int m;
  5695. printk("%s: (%d bytes)\n", f, l);
  5696. for (i = 0; i < l; i += 32) {
  5697. /* Display a maximum of 8 double-words per line. */
  5698. if ((k = (l - i) / 4) >= 8) {
  5699. k = 8;
  5700. m = 0;
  5701. } else {
  5702. m = (l - i) % 4;
  5703. }
  5704. for (j = 0; j < k; j++) {
  5705. printk(" %2.2X%2.2X%2.2X%2.2X",
  5706. (unsigned)s[i + (j * 4)],
  5707. (unsigned)s[i + (j * 4) + 1],
  5708. (unsigned)s[i + (j * 4) + 2],
  5709. (unsigned)s[i + (j * 4) + 3]);
  5710. }
  5711. switch (m) {
  5712. case 0:
  5713. default:
  5714. break;
  5715. case 1:
  5716. printk(" %2.2X", (unsigned)s[i + (j * 4)]);
  5717. break;
  5718. case 2:
  5719. printk(" %2.2X%2.2X",
  5720. (unsigned)s[i + (j * 4)],
  5721. (unsigned)s[i + (j * 4) + 1]);
  5722. break;
  5723. case 3:
  5724. printk(" %2.2X%2.2X%2.2X",
  5725. (unsigned)s[i + (j * 4) + 1],
  5726. (unsigned)s[i + (j * 4) + 2],
  5727. (unsigned)s[i + (j * 4) + 3]);
  5728. break;
  5729. }
  5730. printk("\n");
  5731. }
  5732. }
  5733. #endif /* ADVANSYS_DEBUG */
  5734. /*
  5735. * --- Asc Library Functions
  5736. */
  5737. static ushort __devinit AscGetEisaChipCfg(PortAddr iop_base)
  5738. {
  5739. PortAddr eisa_cfg_iop;
  5740. eisa_cfg_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  5741. (PortAddr) (ASC_EISA_CFG_IOP_MASK);
  5742. return (inpw(eisa_cfg_iop));
  5743. }
  5744. static uchar __devinit AscSetChipScsiID(PortAddr iop_base, uchar new_host_id)
  5745. {
  5746. ushort cfg_lsw;
  5747. if (AscGetChipScsiID(iop_base) == new_host_id) {
  5748. return (new_host_id);
  5749. }
  5750. cfg_lsw = AscGetChipCfgLsw(iop_base);
  5751. cfg_lsw &= 0xF8FF;
  5752. cfg_lsw |= (ushort)((new_host_id & ASC_MAX_TID) << 8);
  5753. AscSetChipCfgLsw(iop_base, cfg_lsw);
  5754. return (AscGetChipScsiID(iop_base));
  5755. }
  5756. static unsigned char __devinit AscGetChipScsiCtrl(PortAddr iop_base)
  5757. {
  5758. unsigned char sc;
  5759. AscSetBank(iop_base, 1);
  5760. sc = inp(iop_base + IOP_REG_SC);
  5761. AscSetBank(iop_base, 0);
  5762. return sc;
  5763. }
  5764. static unsigned char __devinit
  5765. AscGetChipVersion(PortAddr iop_base, unsigned short bus_type)
  5766. {
  5767. if (bus_type & ASC_IS_EISA) {
  5768. PortAddr eisa_iop;
  5769. unsigned char revision;
  5770. eisa_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  5771. (PortAddr) ASC_EISA_REV_IOP_MASK;
  5772. revision = inp(eisa_iop);
  5773. return ASC_CHIP_MIN_VER_EISA - 1 + revision;
  5774. }
  5775. return AscGetChipVerNo(iop_base);
  5776. }
  5777. static ASC_DCNT
  5778. AscLoadMicroCode(PortAddr iop_base,
  5779. ushort s_addr, uchar *mcode_buf, ushort mcode_size)
  5780. {
  5781. ASC_DCNT chksum;
  5782. ushort mcode_word_size;
  5783. ushort mcode_chksum;
  5784. /* Write the microcode buffer starting at LRAM address 0. */
  5785. mcode_word_size = (ushort)(mcode_size >> 1);
  5786. AscMemWordSetLram(iop_base, s_addr, 0, mcode_word_size);
  5787. AscMemWordCopyPtrToLram(iop_base, s_addr, mcode_buf, mcode_word_size);
  5788. chksum = AscMemSumLramWord(iop_base, s_addr, mcode_word_size);
  5789. ASC_DBG1(1, "AscLoadMicroCode: chksum 0x%lx\n", (ulong)chksum);
  5790. mcode_chksum = (ushort)AscMemSumLramWord(iop_base,
  5791. (ushort)ASC_CODE_SEC_BEG,
  5792. (ushort)((mcode_size -
  5793. s_addr - (ushort)
  5794. ASC_CODE_SEC_BEG) /
  5795. 2));
  5796. ASC_DBG1(1, "AscLoadMicroCode: mcode_chksum 0x%lx\n",
  5797. (ulong)mcode_chksum);
  5798. AscWriteLramWord(iop_base, ASCV_MCODE_CHKSUM_W, mcode_chksum);
  5799. AscWriteLramWord(iop_base, ASCV_MCODE_SIZE_W, mcode_size);
  5800. return (chksum);
  5801. }
  5802. static int AscFindSignature(PortAddr iop_base)
  5803. {
  5804. ushort sig_word;
  5805. ASC_DBG2(1, "AscFindSignature: AscGetChipSignatureByte(0x%x) 0x%x\n",
  5806. iop_base, AscGetChipSignatureByte(iop_base));
  5807. if (AscGetChipSignatureByte(iop_base) == (uchar)ASC_1000_ID1B) {
  5808. ASC_DBG2(1,
  5809. "AscFindSignature: AscGetChipSignatureWord(0x%x) 0x%x\n",
  5810. iop_base, AscGetChipSignatureWord(iop_base));
  5811. sig_word = AscGetChipSignatureWord(iop_base);
  5812. if ((sig_word == (ushort)ASC_1000_ID0W) ||
  5813. (sig_word == (ushort)ASC_1000_ID0W_FIX)) {
  5814. return (1);
  5815. }
  5816. }
  5817. return (0);
  5818. }
  5819. static void __devinit AscToggleIRQAct(PortAddr iop_base)
  5820. {
  5821. AscSetChipStatus(iop_base, CIW_IRQ_ACT);
  5822. AscSetChipStatus(iop_base, 0);
  5823. return;
  5824. }
  5825. static uchar __devinit AscGetChipIRQ(PortAddr iop_base, ushort bus_type)
  5826. {
  5827. ushort cfg_lsw;
  5828. uchar chip_irq;
  5829. if ((bus_type & ASC_IS_EISA) != 0) {
  5830. cfg_lsw = AscGetEisaChipCfg(iop_base);
  5831. chip_irq = (uchar)(((cfg_lsw >> 8) & 0x07) + 10);
  5832. if ((chip_irq == 13) || (chip_irq > 15)) {
  5833. return (0);
  5834. }
  5835. return (chip_irq);
  5836. }
  5837. if ((bus_type & ASC_IS_VL) != 0) {
  5838. cfg_lsw = AscGetChipCfgLsw(iop_base);
  5839. chip_irq = (uchar)(((cfg_lsw >> 2) & 0x07));
  5840. if ((chip_irq == 0) || (chip_irq == 4) || (chip_irq == 7)) {
  5841. return (0);
  5842. }
  5843. return ((uchar)(chip_irq + (ASC_MIN_IRQ_NO - 1)));
  5844. }
  5845. cfg_lsw = AscGetChipCfgLsw(iop_base);
  5846. chip_irq = (uchar)(((cfg_lsw >> 2) & 0x03));
  5847. if (chip_irq == 3)
  5848. chip_irq += (uchar)2;
  5849. return ((uchar)(chip_irq + ASC_MIN_IRQ_NO));
  5850. }
  5851. static uchar __devinit
  5852. AscSetChipIRQ(PortAddr iop_base, uchar irq_no, ushort bus_type)
  5853. {
  5854. ushort cfg_lsw;
  5855. if ((bus_type & ASC_IS_VL) != 0) {
  5856. if (irq_no != 0) {
  5857. if ((irq_no < ASC_MIN_IRQ_NO)
  5858. || (irq_no > ASC_MAX_IRQ_NO)) {
  5859. irq_no = 0;
  5860. } else {
  5861. irq_no -= (uchar)((ASC_MIN_IRQ_NO - 1));
  5862. }
  5863. }
  5864. cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFE3);
  5865. cfg_lsw |= (ushort)0x0010;
  5866. AscSetChipCfgLsw(iop_base, cfg_lsw);
  5867. AscToggleIRQAct(iop_base);
  5868. cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFE0);
  5869. cfg_lsw |= (ushort)((irq_no & 0x07) << 2);
  5870. AscSetChipCfgLsw(iop_base, cfg_lsw);
  5871. AscToggleIRQAct(iop_base);
  5872. return (AscGetChipIRQ(iop_base, bus_type));
  5873. }
  5874. if ((bus_type & (ASC_IS_ISA)) != 0) {
  5875. if (irq_no == 15)
  5876. irq_no -= (uchar)2;
  5877. irq_no -= (uchar)ASC_MIN_IRQ_NO;
  5878. cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFF3);
  5879. cfg_lsw |= (ushort)((irq_no & 0x03) << 2);
  5880. AscSetChipCfgLsw(iop_base, cfg_lsw);
  5881. return (AscGetChipIRQ(iop_base, bus_type));
  5882. }
  5883. return (0);
  5884. }
  5885. #ifdef CONFIG_ISA
  5886. static void __devinit AscEnableIsaDma(uchar dma_channel)
  5887. {
  5888. if (dma_channel < 4) {
  5889. outp(0x000B, (ushort)(0xC0 | dma_channel));
  5890. outp(0x000A, dma_channel);
  5891. } else if (dma_channel < 8) {
  5892. outp(0x00D6, (ushort)(0xC0 | (dma_channel - 4)));
  5893. outp(0x00D4, (ushort)(dma_channel - 4));
  5894. }
  5895. return;
  5896. }
  5897. #endif /* CONFIG_ISA */
  5898. static int AscIsrChipHalted(ASC_DVC_VAR *asc_dvc)
  5899. {
  5900. EXT_MSG ext_msg;
  5901. EXT_MSG out_msg;
  5902. ushort halt_q_addr;
  5903. int sdtr_accept;
  5904. ushort int_halt_code;
  5905. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  5906. ASC_SCSI_BIT_ID_TYPE target_id;
  5907. PortAddr iop_base;
  5908. uchar tag_code;
  5909. uchar q_status;
  5910. uchar halt_qp;
  5911. uchar sdtr_data;
  5912. uchar target_ix;
  5913. uchar q_cntl, tid_no;
  5914. uchar cur_dvc_qng;
  5915. uchar asyn_sdtr;
  5916. uchar scsi_status;
  5917. asc_board_t *boardp;
  5918. ASC_ASSERT(asc_dvc->drv_ptr != NULL);
  5919. boardp = asc_dvc->drv_ptr;
  5920. iop_base = asc_dvc->iop_base;
  5921. int_halt_code = AscReadLramWord(iop_base, ASCV_HALTCODE_W);
  5922. halt_qp = AscReadLramByte(iop_base, ASCV_CURCDB_B);
  5923. halt_q_addr = ASC_QNO_TO_QADDR(halt_qp);
  5924. target_ix = AscReadLramByte(iop_base,
  5925. (ushort)(halt_q_addr +
  5926. (ushort)ASC_SCSIQ_B_TARGET_IX));
  5927. q_cntl =
  5928. AscReadLramByte(iop_base,
  5929. (ushort)(halt_q_addr + (ushort)ASC_SCSIQ_B_CNTL));
  5930. tid_no = ASC_TIX_TO_TID(target_ix);
  5931. target_id = (uchar)ASC_TID_TO_TARGET_ID(tid_no);
  5932. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  5933. asyn_sdtr = ASYN_SDTR_DATA_FIX_PCI_REV_AB;
  5934. } else {
  5935. asyn_sdtr = 0;
  5936. }
  5937. if (int_halt_code == ASC_HALT_DISABLE_ASYN_USE_SYN_FIX) {
  5938. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  5939. AscSetChipSDTR(iop_base, 0, tid_no);
  5940. boardp->sdtr_data[tid_no] = 0;
  5941. }
  5942. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  5943. return (0);
  5944. } else if (int_halt_code == ASC_HALT_ENABLE_ASYN_USE_SYN_FIX) {
  5945. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  5946. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  5947. boardp->sdtr_data[tid_no] = asyn_sdtr;
  5948. }
  5949. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  5950. return (0);
  5951. } else if (int_halt_code == ASC_HALT_EXTMSG_IN) {
  5952. AscMemWordCopyPtrFromLram(iop_base,
  5953. ASCV_MSGIN_BEG,
  5954. (uchar *)&ext_msg,
  5955. sizeof(EXT_MSG) >> 1);
  5956. if (ext_msg.msg_type == EXTENDED_MESSAGE &&
  5957. ext_msg.msg_req == EXTENDED_SDTR &&
  5958. ext_msg.msg_len == MS_SDTR_LEN) {
  5959. sdtr_accept = TRUE;
  5960. if ((ext_msg.req_ack_offset > ASC_SYN_MAX_OFFSET)) {
  5961. sdtr_accept = FALSE;
  5962. ext_msg.req_ack_offset = ASC_SYN_MAX_OFFSET;
  5963. }
  5964. if ((ext_msg.xfer_period <
  5965. asc_dvc->sdtr_period_tbl[asc_dvc->
  5966. host_init_sdtr_index])
  5967. || (ext_msg.xfer_period >
  5968. asc_dvc->sdtr_period_tbl[asc_dvc->
  5969. max_sdtr_index])) {
  5970. sdtr_accept = FALSE;
  5971. ext_msg.xfer_period =
  5972. asc_dvc->sdtr_period_tbl[asc_dvc->
  5973. host_init_sdtr_index];
  5974. }
  5975. if (sdtr_accept) {
  5976. sdtr_data =
  5977. AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
  5978. ext_msg.req_ack_offset);
  5979. if ((sdtr_data == 0xFF)) {
  5980. q_cntl |= QC_MSG_OUT;
  5981. asc_dvc->init_sdtr &= ~target_id;
  5982. asc_dvc->sdtr_done &= ~target_id;
  5983. AscSetChipSDTR(iop_base, asyn_sdtr,
  5984. tid_no);
  5985. boardp->sdtr_data[tid_no] = asyn_sdtr;
  5986. }
  5987. }
  5988. if (ext_msg.req_ack_offset == 0) {
  5989. q_cntl &= ~QC_MSG_OUT;
  5990. asc_dvc->init_sdtr &= ~target_id;
  5991. asc_dvc->sdtr_done &= ~target_id;
  5992. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  5993. } else {
  5994. if (sdtr_accept && (q_cntl & QC_MSG_OUT)) {
  5995. q_cntl &= ~QC_MSG_OUT;
  5996. asc_dvc->sdtr_done |= target_id;
  5997. asc_dvc->init_sdtr |= target_id;
  5998. asc_dvc->pci_fix_asyn_xfer &=
  5999. ~target_id;
  6000. sdtr_data =
  6001. AscCalSDTRData(asc_dvc,
  6002. ext_msg.xfer_period,
  6003. ext_msg.
  6004. req_ack_offset);
  6005. AscSetChipSDTR(iop_base, sdtr_data,
  6006. tid_no);
  6007. boardp->sdtr_data[tid_no] = sdtr_data;
  6008. } else {
  6009. q_cntl |= QC_MSG_OUT;
  6010. AscMsgOutSDTR(asc_dvc,
  6011. ext_msg.xfer_period,
  6012. ext_msg.req_ack_offset);
  6013. asc_dvc->pci_fix_asyn_xfer &=
  6014. ~target_id;
  6015. sdtr_data =
  6016. AscCalSDTRData(asc_dvc,
  6017. ext_msg.xfer_period,
  6018. ext_msg.
  6019. req_ack_offset);
  6020. AscSetChipSDTR(iop_base, sdtr_data,
  6021. tid_no);
  6022. boardp->sdtr_data[tid_no] = sdtr_data;
  6023. asc_dvc->sdtr_done |= target_id;
  6024. asc_dvc->init_sdtr |= target_id;
  6025. }
  6026. }
  6027. AscWriteLramByte(iop_base,
  6028. (ushort)(halt_q_addr +
  6029. (ushort)ASC_SCSIQ_B_CNTL),
  6030. q_cntl);
  6031. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  6032. return (0);
  6033. } else if (ext_msg.msg_type == EXTENDED_MESSAGE &&
  6034. ext_msg.msg_req == EXTENDED_WDTR &&
  6035. ext_msg.msg_len == MS_WDTR_LEN) {
  6036. ext_msg.wdtr_width = 0;
  6037. AscMemWordCopyPtrToLram(iop_base,
  6038. ASCV_MSGOUT_BEG,
  6039. (uchar *)&ext_msg,
  6040. sizeof(EXT_MSG) >> 1);
  6041. q_cntl |= QC_MSG_OUT;
  6042. AscWriteLramByte(iop_base,
  6043. (ushort)(halt_q_addr +
  6044. (ushort)ASC_SCSIQ_B_CNTL),
  6045. q_cntl);
  6046. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  6047. return (0);
  6048. } else {
  6049. ext_msg.msg_type = MESSAGE_REJECT;
  6050. AscMemWordCopyPtrToLram(iop_base,
  6051. ASCV_MSGOUT_BEG,
  6052. (uchar *)&ext_msg,
  6053. sizeof(EXT_MSG) >> 1);
  6054. q_cntl |= QC_MSG_OUT;
  6055. AscWriteLramByte(iop_base,
  6056. (ushort)(halt_q_addr +
  6057. (ushort)ASC_SCSIQ_B_CNTL),
  6058. q_cntl);
  6059. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  6060. return (0);
  6061. }
  6062. } else if (int_halt_code == ASC_HALT_CHK_CONDITION) {
  6063. q_cntl |= QC_REQ_SENSE;
  6064. if ((asc_dvc->init_sdtr & target_id) != 0) {
  6065. asc_dvc->sdtr_done &= ~target_id;
  6066. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  6067. q_cntl |= QC_MSG_OUT;
  6068. AscMsgOutSDTR(asc_dvc,
  6069. asc_dvc->
  6070. sdtr_period_tbl[(sdtr_data >> 4) &
  6071. (uchar)(asc_dvc->
  6072. max_sdtr_index -
  6073. 1)],
  6074. (uchar)(sdtr_data & (uchar)
  6075. ASC_SYN_MAX_OFFSET));
  6076. }
  6077. AscWriteLramByte(iop_base,
  6078. (ushort)(halt_q_addr +
  6079. (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
  6080. tag_code = AscReadLramByte(iop_base,
  6081. (ushort)(halt_q_addr + (ushort)
  6082. ASC_SCSIQ_B_TAG_CODE));
  6083. tag_code &= 0xDC;
  6084. if ((asc_dvc->pci_fix_asyn_xfer & target_id)
  6085. && !(asc_dvc->pci_fix_asyn_xfer_always & target_id)
  6086. ) {
  6087. tag_code |= (ASC_TAG_FLAG_DISABLE_DISCONNECT
  6088. | ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX);
  6089. }
  6090. AscWriteLramByte(iop_base,
  6091. (ushort)(halt_q_addr +
  6092. (ushort)ASC_SCSIQ_B_TAG_CODE),
  6093. tag_code);
  6094. q_status = AscReadLramByte(iop_base,
  6095. (ushort)(halt_q_addr + (ushort)
  6096. ASC_SCSIQ_B_STATUS));
  6097. q_status |= (QS_READY | QS_BUSY);
  6098. AscWriteLramByte(iop_base,
  6099. (ushort)(halt_q_addr +
  6100. (ushort)ASC_SCSIQ_B_STATUS),
  6101. q_status);
  6102. scsi_busy = AscReadLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B);
  6103. scsi_busy &= ~target_id;
  6104. AscWriteLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B, scsi_busy);
  6105. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  6106. return (0);
  6107. } else if (int_halt_code == ASC_HALT_SDTR_REJECTED) {
  6108. AscMemWordCopyPtrFromLram(iop_base,
  6109. ASCV_MSGOUT_BEG,
  6110. (uchar *)&out_msg,
  6111. sizeof(EXT_MSG) >> 1);
  6112. if ((out_msg.msg_type == EXTENDED_MESSAGE) &&
  6113. (out_msg.msg_len == MS_SDTR_LEN) &&
  6114. (out_msg.msg_req == EXTENDED_SDTR)) {
  6115. asc_dvc->init_sdtr &= ~target_id;
  6116. asc_dvc->sdtr_done &= ~target_id;
  6117. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  6118. boardp->sdtr_data[tid_no] = asyn_sdtr;
  6119. }
  6120. q_cntl &= ~QC_MSG_OUT;
  6121. AscWriteLramByte(iop_base,
  6122. (ushort)(halt_q_addr +
  6123. (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
  6124. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  6125. return (0);
  6126. } else if (int_halt_code == ASC_HALT_SS_QUEUE_FULL) {
  6127. scsi_status = AscReadLramByte(iop_base,
  6128. (ushort)((ushort)halt_q_addr +
  6129. (ushort)
  6130. ASC_SCSIQ_SCSI_STATUS));
  6131. cur_dvc_qng =
  6132. AscReadLramByte(iop_base,
  6133. (ushort)((ushort)ASC_QADR_BEG +
  6134. (ushort)target_ix));
  6135. if ((cur_dvc_qng > 0) && (asc_dvc->cur_dvc_qng[tid_no] > 0)) {
  6136. scsi_busy = AscReadLramByte(iop_base,
  6137. (ushort)ASCV_SCSIBUSY_B);
  6138. scsi_busy |= target_id;
  6139. AscWriteLramByte(iop_base,
  6140. (ushort)ASCV_SCSIBUSY_B, scsi_busy);
  6141. asc_dvc->queue_full_or_busy |= target_id;
  6142. if (scsi_status == SAM_STAT_TASK_SET_FULL) {
  6143. if (cur_dvc_qng > ASC_MIN_TAGGED_CMD) {
  6144. cur_dvc_qng -= 1;
  6145. asc_dvc->max_dvc_qng[tid_no] =
  6146. cur_dvc_qng;
  6147. AscWriteLramByte(iop_base,
  6148. (ushort)((ushort)
  6149. ASCV_MAX_DVC_QNG_BEG
  6150. + (ushort)
  6151. tid_no),
  6152. cur_dvc_qng);
  6153. /*
  6154. * Set the device queue depth to the number of
  6155. * active requests when the QUEUE FULL condition
  6156. * was encountered.
  6157. */
  6158. boardp->queue_full |= target_id;
  6159. boardp->queue_full_cnt[tid_no] =
  6160. cur_dvc_qng;
  6161. }
  6162. }
  6163. }
  6164. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  6165. return (0);
  6166. }
  6167. #if CC_VERY_LONG_SG_LIST
  6168. else if (int_halt_code == ASC_HALT_HOST_COPY_SG_LIST_TO_RISC) {
  6169. uchar q_no;
  6170. ushort q_addr;
  6171. uchar sg_wk_q_no;
  6172. uchar first_sg_wk_q_no;
  6173. ASC_SCSI_Q *scsiq; /* Ptr to driver request. */
  6174. ASC_SG_HEAD *sg_head; /* Ptr to driver SG request. */
  6175. ASC_SG_LIST_Q scsi_sg_q; /* Structure written to queue. */
  6176. ushort sg_list_dwords;
  6177. ushort sg_entry_cnt;
  6178. uchar next_qp;
  6179. int i;
  6180. q_no = AscReadLramByte(iop_base, (ushort)ASCV_REQ_SG_LIST_QP);
  6181. if (q_no == ASC_QLINK_END) {
  6182. return (0);
  6183. }
  6184. q_addr = ASC_QNO_TO_QADDR(q_no);
  6185. /*
  6186. * Convert the request's SRB pointer to a host ASC_SCSI_REQ
  6187. * structure pointer using a macro provided by the driver.
  6188. * The ASC_SCSI_REQ pointer provides a pointer to the
  6189. * host ASC_SG_HEAD structure.
  6190. */
  6191. /* Read request's SRB pointer. */
  6192. scsiq = (ASC_SCSI_Q *)
  6193. ASC_SRB2SCSIQ(ASC_U32_TO_VADDR(AscReadLramDWord(iop_base,
  6194. (ushort)
  6195. (q_addr +
  6196. ASC_SCSIQ_D_SRBPTR))));
  6197. /*
  6198. * Get request's first and working SG queue.
  6199. */
  6200. sg_wk_q_no = AscReadLramByte(iop_base,
  6201. (ushort)(q_addr +
  6202. ASC_SCSIQ_B_SG_WK_QP));
  6203. first_sg_wk_q_no = AscReadLramByte(iop_base,
  6204. (ushort)(q_addr +
  6205. ASC_SCSIQ_B_FIRST_SG_WK_QP));
  6206. /*
  6207. * Reset request's working SG queue back to the
  6208. * first SG queue.
  6209. */
  6210. AscWriteLramByte(iop_base,
  6211. (ushort)(q_addr +
  6212. (ushort)ASC_SCSIQ_B_SG_WK_QP),
  6213. first_sg_wk_q_no);
  6214. sg_head = scsiq->sg_head;
  6215. /*
  6216. * Set sg_entry_cnt to the number of SG elements
  6217. * that will be completed on this interrupt.
  6218. *
  6219. * Note: The allocated SG queues contain ASC_MAX_SG_LIST - 1
  6220. * SG elements. The data_cnt and data_addr fields which
  6221. * add 1 to the SG element capacity are not used when
  6222. * restarting SG handling after a halt.
  6223. */
  6224. if (scsiq->remain_sg_entry_cnt > (ASC_MAX_SG_LIST - 1)) {
  6225. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  6226. /*
  6227. * Keep track of remaining number of SG elements that will
  6228. * need to be handled on the next interrupt.
  6229. */
  6230. scsiq->remain_sg_entry_cnt -= (ASC_MAX_SG_LIST - 1);
  6231. } else {
  6232. sg_entry_cnt = scsiq->remain_sg_entry_cnt;
  6233. scsiq->remain_sg_entry_cnt = 0;
  6234. }
  6235. /*
  6236. * Copy SG elements into the list of allocated SG queues.
  6237. *
  6238. * Last index completed is saved in scsiq->next_sg_index.
  6239. */
  6240. next_qp = first_sg_wk_q_no;
  6241. q_addr = ASC_QNO_TO_QADDR(next_qp);
  6242. scsi_sg_q.sg_head_qp = q_no;
  6243. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  6244. for (i = 0; i < sg_head->queue_cnt; i++) {
  6245. scsi_sg_q.seq_no = i + 1;
  6246. if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
  6247. sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
  6248. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  6249. /*
  6250. * After very first SG queue RISC FW uses next
  6251. * SG queue first element then checks sg_list_cnt
  6252. * against zero and then decrements, so set
  6253. * sg_list_cnt 1 less than number of SG elements
  6254. * in each SG queue.
  6255. */
  6256. scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q - 1;
  6257. scsi_sg_q.sg_cur_list_cnt =
  6258. ASC_SG_LIST_PER_Q - 1;
  6259. } else {
  6260. /*
  6261. * This is the last SG queue in the list of
  6262. * allocated SG queues. If there are more
  6263. * SG elements than will fit in the allocated
  6264. * queues, then set the QCSG_SG_XFER_MORE flag.
  6265. */
  6266. if (scsiq->remain_sg_entry_cnt != 0) {
  6267. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  6268. } else {
  6269. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  6270. }
  6271. /* equals sg_entry_cnt * 2 */
  6272. sg_list_dwords = sg_entry_cnt << 1;
  6273. scsi_sg_q.sg_list_cnt = sg_entry_cnt - 1;
  6274. scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt - 1;
  6275. sg_entry_cnt = 0;
  6276. }
  6277. scsi_sg_q.q_no = next_qp;
  6278. AscMemWordCopyPtrToLram(iop_base,
  6279. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  6280. (uchar *)&scsi_sg_q,
  6281. sizeof(ASC_SG_LIST_Q) >> 1);
  6282. AscMemDWordCopyPtrToLram(iop_base,
  6283. q_addr + ASC_SGQ_LIST_BEG,
  6284. (uchar *)&sg_head->
  6285. sg_list[scsiq->next_sg_index],
  6286. sg_list_dwords);
  6287. scsiq->next_sg_index += ASC_SG_LIST_PER_Q;
  6288. /*
  6289. * If the just completed SG queue contained the
  6290. * last SG element, then no more SG queues need
  6291. * to be written.
  6292. */
  6293. if (scsi_sg_q.cntl & QCSG_SG_XFER_END) {
  6294. break;
  6295. }
  6296. next_qp = AscReadLramByte(iop_base,
  6297. (ushort)(q_addr +
  6298. ASC_SCSIQ_B_FWD));
  6299. q_addr = ASC_QNO_TO_QADDR(next_qp);
  6300. }
  6301. /*
  6302. * Clear the halt condition so the RISC will be restarted
  6303. * after the return.
  6304. */
  6305. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  6306. return (0);
  6307. }
  6308. #endif /* CC_VERY_LONG_SG_LIST */
  6309. return (0);
  6310. }
  6311. static uchar
  6312. _AscCopyLramScsiDoneQ(PortAddr iop_base,
  6313. ushort q_addr,
  6314. ASC_QDONE_INFO *scsiq, ASC_DCNT max_dma_count)
  6315. {
  6316. ushort _val;
  6317. uchar sg_queue_cnt;
  6318. DvcGetQinfo(iop_base,
  6319. q_addr + ASC_SCSIQ_DONE_INFO_BEG,
  6320. (uchar *)scsiq,
  6321. (sizeof(ASC_SCSIQ_2) + sizeof(ASC_SCSIQ_3)) / 2);
  6322. _val = AscReadLramWord(iop_base,
  6323. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS));
  6324. scsiq->q_status = (uchar)_val;
  6325. scsiq->q_no = (uchar)(_val >> 8);
  6326. _val = AscReadLramWord(iop_base,
  6327. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_CNTL));
  6328. scsiq->cntl = (uchar)_val;
  6329. sg_queue_cnt = (uchar)(_val >> 8);
  6330. _val = AscReadLramWord(iop_base,
  6331. (ushort)(q_addr +
  6332. (ushort)ASC_SCSIQ_B_SENSE_LEN));
  6333. scsiq->sense_len = (uchar)_val;
  6334. scsiq->extra_bytes = (uchar)(_val >> 8);
  6335. /*
  6336. * Read high word of remain bytes from alternate location.
  6337. */
  6338. scsiq->remain_bytes = (((ADV_DCNT)AscReadLramWord(iop_base,
  6339. (ushort)(q_addr +
  6340. (ushort)
  6341. ASC_SCSIQ_W_ALT_DC1)))
  6342. << 16);
  6343. /*
  6344. * Read low word of remain bytes from original location.
  6345. */
  6346. scsiq->remain_bytes += AscReadLramWord(iop_base,
  6347. (ushort)(q_addr + (ushort)
  6348. ASC_SCSIQ_DW_REMAIN_XFER_CNT));
  6349. scsiq->remain_bytes &= max_dma_count;
  6350. return (sg_queue_cnt);
  6351. }
  6352. static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
  6353. {
  6354. uchar next_qp;
  6355. uchar n_q_used;
  6356. uchar sg_list_qp;
  6357. uchar sg_queue_cnt;
  6358. uchar q_cnt;
  6359. uchar done_q_tail;
  6360. uchar tid_no;
  6361. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  6362. ASC_SCSI_BIT_ID_TYPE target_id;
  6363. PortAddr iop_base;
  6364. ushort q_addr;
  6365. ushort sg_q_addr;
  6366. uchar cur_target_qng;
  6367. ASC_QDONE_INFO scsiq_buf;
  6368. ASC_QDONE_INFO *scsiq;
  6369. int false_overrun;
  6370. iop_base = asc_dvc->iop_base;
  6371. n_q_used = 1;
  6372. scsiq = (ASC_QDONE_INFO *)&scsiq_buf;
  6373. done_q_tail = (uchar)AscGetVarDoneQTail(iop_base);
  6374. q_addr = ASC_QNO_TO_QADDR(done_q_tail);
  6375. next_qp = AscReadLramByte(iop_base,
  6376. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_FWD));
  6377. if (next_qp != ASC_QLINK_END) {
  6378. AscPutVarDoneQTail(iop_base, next_qp);
  6379. q_addr = ASC_QNO_TO_QADDR(next_qp);
  6380. sg_queue_cnt = _AscCopyLramScsiDoneQ(iop_base, q_addr, scsiq,
  6381. asc_dvc->max_dma_count);
  6382. AscWriteLramByte(iop_base,
  6383. (ushort)(q_addr +
  6384. (ushort)ASC_SCSIQ_B_STATUS),
  6385. (uchar)(scsiq->
  6386. q_status & (uchar)~(QS_READY |
  6387. QS_ABORTED)));
  6388. tid_no = ASC_TIX_TO_TID(scsiq->d2.target_ix);
  6389. target_id = ASC_TIX_TO_TARGET_ID(scsiq->d2.target_ix);
  6390. if ((scsiq->cntl & QC_SG_HEAD) != 0) {
  6391. sg_q_addr = q_addr;
  6392. sg_list_qp = next_qp;
  6393. for (q_cnt = 0; q_cnt < sg_queue_cnt; q_cnt++) {
  6394. sg_list_qp = AscReadLramByte(iop_base,
  6395. (ushort)(sg_q_addr
  6396. + (ushort)
  6397. ASC_SCSIQ_B_FWD));
  6398. sg_q_addr = ASC_QNO_TO_QADDR(sg_list_qp);
  6399. if (sg_list_qp == ASC_QLINK_END) {
  6400. AscSetLibErrorCode(asc_dvc,
  6401. ASCQ_ERR_SG_Q_LINKS);
  6402. scsiq->d3.done_stat = QD_WITH_ERROR;
  6403. scsiq->d3.host_stat =
  6404. QHSTA_D_QDONE_SG_LIST_CORRUPTED;
  6405. goto FATAL_ERR_QDONE;
  6406. }
  6407. AscWriteLramByte(iop_base,
  6408. (ushort)(sg_q_addr + (ushort)
  6409. ASC_SCSIQ_B_STATUS),
  6410. QS_FREE);
  6411. }
  6412. n_q_used = sg_queue_cnt + 1;
  6413. AscPutVarDoneQTail(iop_base, sg_list_qp);
  6414. }
  6415. if (asc_dvc->queue_full_or_busy & target_id) {
  6416. cur_target_qng = AscReadLramByte(iop_base,
  6417. (ushort)((ushort)
  6418. ASC_QADR_BEG
  6419. + (ushort)
  6420. scsiq->d2.
  6421. target_ix));
  6422. if (cur_target_qng < asc_dvc->max_dvc_qng[tid_no]) {
  6423. scsi_busy = AscReadLramByte(iop_base, (ushort)
  6424. ASCV_SCSIBUSY_B);
  6425. scsi_busy &= ~target_id;
  6426. AscWriteLramByte(iop_base,
  6427. (ushort)ASCV_SCSIBUSY_B,
  6428. scsi_busy);
  6429. asc_dvc->queue_full_or_busy &= ~target_id;
  6430. }
  6431. }
  6432. if (asc_dvc->cur_total_qng >= n_q_used) {
  6433. asc_dvc->cur_total_qng -= n_q_used;
  6434. if (asc_dvc->cur_dvc_qng[tid_no] != 0) {
  6435. asc_dvc->cur_dvc_qng[tid_no]--;
  6436. }
  6437. } else {
  6438. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CUR_QNG);
  6439. scsiq->d3.done_stat = QD_WITH_ERROR;
  6440. goto FATAL_ERR_QDONE;
  6441. }
  6442. if ((scsiq->d2.srb_ptr == 0UL) ||
  6443. ((scsiq->q_status & QS_ABORTED) != 0)) {
  6444. return (0x11);
  6445. } else if (scsiq->q_status == QS_DONE) {
  6446. false_overrun = FALSE;
  6447. if (scsiq->extra_bytes != 0) {
  6448. scsiq->remain_bytes +=
  6449. (ADV_DCNT)scsiq->extra_bytes;
  6450. }
  6451. if (scsiq->d3.done_stat == QD_WITH_ERROR) {
  6452. if (scsiq->d3.host_stat ==
  6453. QHSTA_M_DATA_OVER_RUN) {
  6454. if ((scsiq->
  6455. cntl & (QC_DATA_IN | QC_DATA_OUT))
  6456. == 0) {
  6457. scsiq->d3.done_stat =
  6458. QD_NO_ERROR;
  6459. scsiq->d3.host_stat =
  6460. QHSTA_NO_ERROR;
  6461. } else if (false_overrun) {
  6462. scsiq->d3.done_stat =
  6463. QD_NO_ERROR;
  6464. scsiq->d3.host_stat =
  6465. QHSTA_NO_ERROR;
  6466. }
  6467. } else if (scsiq->d3.host_stat ==
  6468. QHSTA_M_HUNG_REQ_SCSI_BUS_RESET) {
  6469. AscStopChip(iop_base);
  6470. AscSetChipControl(iop_base,
  6471. (uchar)(CC_SCSI_RESET
  6472. | CC_HALT));
  6473. DvcDelayNanoSecond(asc_dvc, 60000);
  6474. AscSetChipControl(iop_base, CC_HALT);
  6475. AscSetChipStatus(iop_base,
  6476. CIW_CLR_SCSI_RESET_INT);
  6477. AscSetChipStatus(iop_base, 0);
  6478. AscSetChipControl(iop_base, 0);
  6479. }
  6480. }
  6481. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  6482. asc_isr_callback(asc_dvc, scsiq);
  6483. } else {
  6484. if ((AscReadLramByte(iop_base,
  6485. (ushort)(q_addr + (ushort)
  6486. ASC_SCSIQ_CDB_BEG))
  6487. == START_STOP)) {
  6488. asc_dvc->unit_not_ready &= ~target_id;
  6489. if (scsiq->d3.done_stat != QD_NO_ERROR) {
  6490. asc_dvc->start_motor &=
  6491. ~target_id;
  6492. }
  6493. }
  6494. }
  6495. return (1);
  6496. } else {
  6497. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_Q_STATUS);
  6498. FATAL_ERR_QDONE:
  6499. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  6500. asc_isr_callback(asc_dvc, scsiq);
  6501. }
  6502. return (0x80);
  6503. }
  6504. }
  6505. return (0);
  6506. }
  6507. static int AscISR(ASC_DVC_VAR *asc_dvc)
  6508. {
  6509. ASC_CS_TYPE chipstat;
  6510. PortAddr iop_base;
  6511. ushort saved_ram_addr;
  6512. uchar ctrl_reg;
  6513. uchar saved_ctrl_reg;
  6514. int int_pending;
  6515. int status;
  6516. uchar host_flag;
  6517. iop_base = asc_dvc->iop_base;
  6518. int_pending = FALSE;
  6519. if (AscIsIntPending(iop_base) == 0) {
  6520. return int_pending;
  6521. }
  6522. if ((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0) {
  6523. return (ERR);
  6524. }
  6525. if (asc_dvc->in_critical_cnt != 0) {
  6526. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_ON_CRITICAL);
  6527. return (ERR);
  6528. }
  6529. if (asc_dvc->is_in_int) {
  6530. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_RE_ENTRY);
  6531. return (ERR);
  6532. }
  6533. asc_dvc->is_in_int = TRUE;
  6534. ctrl_reg = AscGetChipControl(iop_base);
  6535. saved_ctrl_reg = ctrl_reg & (~(CC_SCSI_RESET | CC_CHIP_RESET |
  6536. CC_SINGLE_STEP | CC_DIAG | CC_TEST));
  6537. chipstat = AscGetChipStatus(iop_base);
  6538. if (chipstat & CSW_SCSI_RESET_LATCH) {
  6539. if (!(asc_dvc->bus_type & (ASC_IS_VL | ASC_IS_EISA))) {
  6540. int i = 10;
  6541. int_pending = TRUE;
  6542. asc_dvc->sdtr_done = 0;
  6543. saved_ctrl_reg &= (uchar)(~CC_HALT);
  6544. while ((AscGetChipStatus(iop_base) &
  6545. CSW_SCSI_RESET_ACTIVE) && (i-- > 0)) {
  6546. DvcSleepMilliSecond(100);
  6547. }
  6548. AscSetChipControl(iop_base, (CC_CHIP_RESET | CC_HALT));
  6549. AscSetChipControl(iop_base, CC_HALT);
  6550. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  6551. AscSetChipStatus(iop_base, 0);
  6552. chipstat = AscGetChipStatus(iop_base);
  6553. }
  6554. }
  6555. saved_ram_addr = AscGetChipLramAddr(iop_base);
  6556. host_flag = AscReadLramByte(iop_base,
  6557. ASCV_HOST_FLAG_B) &
  6558. (uchar)(~ASC_HOST_FLAG_IN_ISR);
  6559. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  6560. (uchar)(host_flag | (uchar)ASC_HOST_FLAG_IN_ISR));
  6561. if ((chipstat & CSW_INT_PENDING)
  6562. || (int_pending)
  6563. ) {
  6564. AscAckInterrupt(iop_base);
  6565. int_pending = TRUE;
  6566. if ((chipstat & CSW_HALTED) && (ctrl_reg & CC_SINGLE_STEP)) {
  6567. if (AscIsrChipHalted(asc_dvc) == ERR) {
  6568. goto ISR_REPORT_QDONE_FATAL_ERROR;
  6569. } else {
  6570. saved_ctrl_reg &= (uchar)(~CC_HALT);
  6571. }
  6572. } else {
  6573. ISR_REPORT_QDONE_FATAL_ERROR:
  6574. if ((asc_dvc->dvc_cntl & ASC_CNTL_INT_MULTI_Q) != 0) {
  6575. while (((status =
  6576. AscIsrQDone(asc_dvc)) & 0x01) != 0) {
  6577. }
  6578. } else {
  6579. do {
  6580. if ((status =
  6581. AscIsrQDone(asc_dvc)) == 1) {
  6582. break;
  6583. }
  6584. } while (status == 0x11);
  6585. }
  6586. if ((status & 0x80) != 0)
  6587. int_pending = ERR;
  6588. }
  6589. }
  6590. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  6591. AscSetChipLramAddr(iop_base, saved_ram_addr);
  6592. AscSetChipControl(iop_base, saved_ctrl_reg);
  6593. asc_dvc->is_in_int = FALSE;
  6594. return (int_pending);
  6595. }
  6596. /* Microcode buffer is kept after initialization for error recovery. */
  6597. static uchar _asc_mcode_buf[] = {
  6598. 0x01, 0x03, 0x01, 0x19, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  6599. 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
  6600. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  6601. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  6602. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  6603. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x12, 0x0D, 0x05,
  6604. 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  6605. 0xFF, 0x80, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  6606. 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0xFF,
  6607. 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
  6608. 0x00, 0x00, 0xE4, 0x88, 0x00, 0x00, 0x00, 0x00, 0x80, 0x73, 0x48, 0x04,
  6609. 0x36, 0x00, 0x00, 0xA2, 0xC2, 0x00, 0x80, 0x73, 0x03, 0x23, 0x36, 0x40,
  6610. 0xB6, 0x00, 0x36, 0x00, 0x05, 0xD6, 0x0C, 0xD2, 0x12, 0xDA, 0x00, 0xA2,
  6611. 0xC2, 0x00, 0x92, 0x80, 0x1E, 0x98, 0x50, 0x00, 0xF5, 0x00, 0x48, 0x98,
  6612. 0xDF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x4F, 0x00, 0xF5, 0x00,
  6613. 0x48, 0x98, 0xEF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x80, 0x62,
  6614. 0x92, 0x80, 0x00, 0x46, 0x15, 0xEE, 0x13, 0xEA, 0x02, 0x01, 0x09, 0xD8,
  6615. 0xCD, 0x04, 0x4D, 0x00, 0x00, 0xA3, 0xD6, 0x00, 0xA6, 0x97, 0x7F, 0x23,
  6616. 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84, 0xD2, 0xC1, 0x80, 0x73, 0xCD, 0x04,
  6617. 0x4D, 0x00, 0x00, 0xA3, 0xDA, 0x01, 0xA6, 0x97, 0xC6, 0x81, 0xC2, 0x88,
  6618. 0x80, 0x73, 0x80, 0x77, 0x00, 0x01, 0x01, 0xA1, 0xFE, 0x00, 0x4F, 0x00,
  6619. 0x84, 0x97, 0x07, 0xA6, 0x08, 0x01, 0x00, 0x33, 0x03, 0x00, 0xC2, 0x88,
  6620. 0x03, 0x03, 0x01, 0xDE, 0xC2, 0x88, 0xCE, 0x00, 0x69, 0x60, 0xCE, 0x00,
  6621. 0x02, 0x03, 0x4A, 0x60, 0x00, 0xA2, 0x78, 0x01, 0x80, 0x63, 0x07, 0xA6,
  6622. 0x24, 0x01, 0x78, 0x81, 0x03, 0x03, 0x80, 0x63, 0xE2, 0x00, 0x07, 0xA6,
  6623. 0x34, 0x01, 0x00, 0x33, 0x04, 0x00, 0xC2, 0x88, 0x03, 0x07, 0x02, 0x01,
  6624. 0x04, 0xCA, 0x0D, 0x23, 0x68, 0x98, 0x4D, 0x04, 0x04, 0x85, 0x05, 0xD8,
  6625. 0x0D, 0x23, 0x68, 0x98, 0xCD, 0x04, 0x15, 0x23, 0xF8, 0x88, 0xFB, 0x23,
  6626. 0x02, 0x61, 0x82, 0x01, 0x80, 0x63, 0x02, 0x03, 0x06, 0xA3, 0x62, 0x01,
  6627. 0x00, 0x33, 0x0A, 0x00, 0xC2, 0x88, 0x4E, 0x00, 0x07, 0xA3, 0x6E, 0x01,
  6628. 0x00, 0x33, 0x0B, 0x00, 0xC2, 0x88, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33,
  6629. 0x1A, 0x00, 0xC2, 0x88, 0x50, 0x04, 0x88, 0x81, 0x06, 0xAB, 0x82, 0x01,
  6630. 0x88, 0x81, 0x4E, 0x00, 0x07, 0xA3, 0x92, 0x01, 0x50, 0x00, 0x00, 0xA3,
  6631. 0x3C, 0x01, 0x00, 0x05, 0x7C, 0x81, 0x46, 0x97, 0x02, 0x01, 0x05, 0xC6,
  6632. 0x04, 0x23, 0xA0, 0x01, 0x15, 0x23, 0xA1, 0x01, 0xBE, 0x81, 0xFD, 0x23,
  6633. 0x02, 0x61, 0x82, 0x01, 0x0A, 0xDA, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA0,
  6634. 0xB4, 0x01, 0x80, 0x63, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33, 0x1B, 0x00,
  6635. 0xC2, 0x88, 0x06, 0x23, 0x68, 0x98, 0xCD, 0x04, 0xE6, 0x84, 0x06, 0x01,
  6636. 0x00, 0xA2, 0xD4, 0x01, 0x57, 0x60, 0x00, 0xA0, 0xDA, 0x01, 0xE6, 0x84,
  6637. 0x80, 0x23, 0xA0, 0x01, 0xE6, 0x84, 0x80, 0x73, 0x4B, 0x00, 0x06, 0x61,
  6638. 0x00, 0xA2, 0x00, 0x02, 0x04, 0x01, 0x0C, 0xDE, 0x02, 0x01, 0x03, 0xCC,
  6639. 0x4F, 0x00, 0x84, 0x97, 0xFC, 0x81, 0x08, 0x23, 0x02, 0x41, 0x82, 0x01,
  6640. 0x4F, 0x00, 0x62, 0x97, 0x48, 0x04, 0x84, 0x80, 0xF0, 0x97, 0x00, 0x46,
  6641. 0x56, 0x00, 0x03, 0xC0, 0x01, 0x23, 0xE8, 0x00, 0x81, 0x73, 0x06, 0x29,
  6642. 0x03, 0x42, 0x06, 0xE2, 0x03, 0xEE, 0x6B, 0xEB, 0x11, 0x23, 0xF8, 0x88,
  6643. 0x04, 0x98, 0xF0, 0x80, 0x80, 0x73, 0x80, 0x77, 0x07, 0xA4, 0x2A, 0x02,
  6644. 0x7C, 0x95, 0x06, 0xA6, 0x34, 0x02, 0x03, 0xA6, 0x4C, 0x04, 0x46, 0x82,
  6645. 0x04, 0x01, 0x03, 0xD8, 0xB4, 0x98, 0x6A, 0x96, 0x46, 0x82, 0xFE, 0x95,
  6646. 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0xB6, 0x2D, 0x02, 0xA6, 0x6C, 0x02,
  6647. 0x07, 0xA6, 0x5A, 0x02, 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x62, 0x02,
  6648. 0xC2, 0x88, 0x7C, 0x95, 0x48, 0x82, 0x60, 0x96, 0x48, 0x82, 0x04, 0x23,
  6649. 0xA0, 0x01, 0x14, 0x23, 0xA1, 0x01, 0x3C, 0x84, 0x04, 0x01, 0x0C, 0xDC,
  6650. 0xE0, 0x23, 0x25, 0x61, 0xEF, 0x00, 0x14, 0x01, 0x4F, 0x04, 0xA8, 0x01,
  6651. 0x6F, 0x00, 0xA5, 0x01, 0x03, 0x23, 0xA4, 0x01, 0x06, 0x23, 0x9C, 0x01,
  6652. 0x24, 0x2B, 0x1C, 0x01, 0x02, 0xA6, 0xAA, 0x02, 0x07, 0xA6, 0x5A, 0x02,
  6653. 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x20, 0x04, 0x01, 0xA6, 0xB4, 0x02,
  6654. 0x00, 0xA6, 0xB4, 0x02, 0x00, 0x33, 0x12, 0x00, 0xC2, 0x88, 0x00, 0x0E,
  6655. 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0x8C, 0x02, 0x4D, 0x04, 0x04, 0x01,
  6656. 0x0B, 0xDC, 0xE7, 0x23, 0x04, 0x61, 0x84, 0x01, 0x10, 0x31, 0x12, 0x35,
  6657. 0x14, 0x01, 0xEC, 0x00, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0xEA, 0x82,
  6658. 0x18, 0x23, 0x04, 0x61, 0x18, 0xA0, 0xE2, 0x02, 0x04, 0x01, 0xA2, 0xC8,
  6659. 0x00, 0x33, 0x1F, 0x00, 0xC2, 0x88, 0x08, 0x31, 0x0A, 0x35, 0x0C, 0x39,
  6660. 0x0E, 0x3D, 0x7E, 0x98, 0xB6, 0x2D, 0x01, 0xA6, 0x14, 0x03, 0x00, 0xA6,
  6661. 0x14, 0x03, 0x07, 0xA6, 0x0C, 0x03, 0x06, 0xA6, 0x10, 0x03, 0x03, 0xA6,
  6662. 0x20, 0x04, 0x02, 0xA6, 0x6C, 0x02, 0x00, 0x33, 0x33, 0x00, 0xC2, 0x88,
  6663. 0x7C, 0x95, 0xEE, 0x82, 0x60, 0x96, 0xEE, 0x82, 0x82, 0x98, 0x80, 0x42,
  6664. 0x7E, 0x98, 0x64, 0xE4, 0x04, 0x01, 0x2D, 0xC8, 0x31, 0x05, 0x07, 0x01,
  6665. 0x00, 0xA2, 0x54, 0x03, 0x00, 0x43, 0x87, 0x01, 0x05, 0x05, 0x86, 0x98,
  6666. 0x7E, 0x98, 0x00, 0xA6, 0x16, 0x03, 0x07, 0xA6, 0x4C, 0x03, 0x03, 0xA6,
  6667. 0x3C, 0x04, 0x06, 0xA6, 0x50, 0x03, 0x01, 0xA6, 0x16, 0x03, 0x00, 0x33,
  6668. 0x25, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x32, 0x83, 0x60, 0x96, 0x32, 0x83,
  6669. 0x04, 0x01, 0x10, 0xCE, 0x07, 0xC8, 0x05, 0x05, 0xEB, 0x04, 0x00, 0x33,
  6670. 0x00, 0x20, 0xC0, 0x20, 0x81, 0x62, 0x72, 0x83, 0x00, 0x01, 0x05, 0x05,
  6671. 0xFF, 0xA2, 0x7A, 0x03, 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x2E, 0x83,
  6672. 0x05, 0x05, 0x15, 0x01, 0x00, 0xA2, 0x9A, 0x03, 0xEC, 0x00, 0x6E, 0x00,
  6673. 0x95, 0x01, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0x01, 0xA6, 0x96, 0x03,
  6674. 0x00, 0xA6, 0x96, 0x03, 0x10, 0x84, 0x80, 0x42, 0x7E, 0x98, 0x01, 0xA6,
  6675. 0xA4, 0x03, 0x00, 0xA6, 0xBC, 0x03, 0x10, 0x84, 0xA8, 0x98, 0x80, 0x42,
  6676. 0x01, 0xA6, 0xA4, 0x03, 0x07, 0xA6, 0xB2, 0x03, 0xD4, 0x83, 0x7C, 0x95,
  6677. 0xA8, 0x83, 0x00, 0x33, 0x2F, 0x00, 0xC2, 0x88, 0xA8, 0x98, 0x80, 0x42,
  6678. 0x00, 0xA6, 0xBC, 0x03, 0x07, 0xA6, 0xCA, 0x03, 0xD4, 0x83, 0x7C, 0x95,
  6679. 0xC0, 0x83, 0x00, 0x33, 0x26, 0x00, 0xC2, 0x88, 0x38, 0x2B, 0x80, 0x32,
  6680. 0x80, 0x36, 0x04, 0x23, 0xA0, 0x01, 0x12, 0x23, 0xA1, 0x01, 0x10, 0x84,
  6681. 0x07, 0xF0, 0x06, 0xA4, 0xF4, 0x03, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23,
  6682. 0x83, 0x03, 0x80, 0x63, 0x03, 0xA6, 0x0E, 0x04, 0x07, 0xA6, 0x06, 0x04,
  6683. 0x06, 0xA6, 0x0A, 0x04, 0x00, 0x33, 0x17, 0x00, 0xC2, 0x88, 0x7C, 0x95,
  6684. 0xF4, 0x83, 0x60, 0x96, 0xF4, 0x83, 0x20, 0x84, 0x07, 0xF0, 0x06, 0xA4,
  6685. 0x20, 0x04, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23, 0x83, 0x03, 0x80, 0x63,
  6686. 0xB6, 0x2D, 0x03, 0xA6, 0x3C, 0x04, 0x07, 0xA6, 0x34, 0x04, 0x06, 0xA6,
  6687. 0x38, 0x04, 0x00, 0x33, 0x30, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x20, 0x84,
  6688. 0x60, 0x96, 0x20, 0x84, 0x1D, 0x01, 0x06, 0xCC, 0x00, 0x33, 0x00, 0x84,
  6689. 0xC0, 0x20, 0x00, 0x23, 0xEA, 0x00, 0x81, 0x62, 0xA2, 0x0D, 0x80, 0x63,
  6690. 0x07, 0xA6, 0x5A, 0x04, 0x00, 0x33, 0x18, 0x00, 0xC2, 0x88, 0x03, 0x03,
  6691. 0x80, 0x63, 0xA3, 0x01, 0x07, 0xA4, 0x64, 0x04, 0x23, 0x01, 0x00, 0xA2,
  6692. 0x86, 0x04, 0x0A, 0xA0, 0x76, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1D, 0x00,
  6693. 0xC2, 0x88, 0x0B, 0xA0, 0x82, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1E, 0x00,
  6694. 0xC2, 0x88, 0x42, 0x23, 0xF8, 0x88, 0x00, 0x23, 0x22, 0xA3, 0xE6, 0x04,
  6695. 0x08, 0x23, 0x22, 0xA3, 0xA2, 0x04, 0x28, 0x23, 0x22, 0xA3, 0xAE, 0x04,
  6696. 0x02, 0x23, 0x22, 0xA3, 0xC4, 0x04, 0x42, 0x23, 0xF8, 0x88, 0x4A, 0x00,
  6697. 0x06, 0x61, 0x00, 0xA0, 0xAE, 0x04, 0x45, 0x23, 0xF8, 0x88, 0x04, 0x98,
  6698. 0x00, 0xA2, 0xC0, 0x04, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x82, 0xC0, 0x20,
  6699. 0x81, 0x62, 0xE8, 0x81, 0x47, 0x23, 0xF8, 0x88, 0x04, 0x01, 0x0B, 0xDE,
  6700. 0x04, 0x98, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x81, 0xC0, 0x20, 0x81, 0x62,
  6701. 0x14, 0x01, 0x00, 0xA0, 0x00, 0x02, 0x43, 0x23, 0xF8, 0x88, 0x04, 0x23,
  6702. 0xA0, 0x01, 0x44, 0x23, 0xA1, 0x01, 0x80, 0x73, 0x4D, 0x00, 0x03, 0xA3,
  6703. 0xF4, 0x04, 0x00, 0x33, 0x27, 0x00, 0xC2, 0x88, 0x04, 0x01, 0x04, 0xDC,
  6704. 0x02, 0x23, 0xA2, 0x01, 0x04, 0x23, 0xA0, 0x01, 0x04, 0x98, 0x26, 0x95,
  6705. 0x4B, 0x00, 0xF6, 0x00, 0x4F, 0x04, 0x4F, 0x00, 0x00, 0xA3, 0x22, 0x05,
  6706. 0x00, 0x05, 0x76, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x1C, 0x05, 0x0A, 0x85,
  6707. 0x46, 0x97, 0xCD, 0x04, 0x24, 0x85, 0x48, 0x04, 0x84, 0x80, 0x02, 0x01,
  6708. 0x03, 0xDA, 0x80, 0x23, 0x82, 0x01, 0x34, 0x85, 0x02, 0x23, 0xA0, 0x01,
  6709. 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x40, 0x05, 0x1D, 0x01, 0x04, 0xD6,
  6710. 0xFF, 0x23, 0x86, 0x41, 0x4B, 0x60, 0xCB, 0x00, 0xFF, 0x23, 0x80, 0x01,
  6711. 0x49, 0x00, 0x81, 0x01, 0x04, 0x01, 0x02, 0xC8, 0x30, 0x01, 0x80, 0x01,
  6712. 0xF7, 0x04, 0x03, 0x01, 0x49, 0x04, 0x80, 0x01, 0xC9, 0x00, 0x00, 0x05,
  6713. 0x00, 0x01, 0xFF, 0xA0, 0x60, 0x05, 0x77, 0x04, 0x01, 0x23, 0xEA, 0x00,
  6714. 0x5D, 0x00, 0xFE, 0xC7, 0x00, 0x62, 0x00, 0x23, 0xEA, 0x00, 0x00, 0x63,
  6715. 0x07, 0xA4, 0xF8, 0x05, 0x03, 0x03, 0x02, 0xA0, 0x8E, 0x05, 0xF4, 0x85,
  6716. 0x00, 0x33, 0x2D, 0x00, 0xC2, 0x88, 0x04, 0xA0, 0xB8, 0x05, 0x80, 0x63,
  6717. 0x00, 0x23, 0xDF, 0x00, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0xA4, 0x05,
  6718. 0x1D, 0x01, 0x06, 0xD6, 0x02, 0x23, 0x02, 0x41, 0x82, 0x01, 0x50, 0x00,
  6719. 0x62, 0x97, 0x04, 0x85, 0x04, 0x23, 0x02, 0x41, 0x82, 0x01, 0x04, 0x85,
  6720. 0x08, 0xA0, 0xBE, 0x05, 0xF4, 0x85, 0x03, 0xA0, 0xC4, 0x05, 0xF4, 0x85,
  6721. 0x01, 0xA0, 0xCE, 0x05, 0x88, 0x00, 0x80, 0x63, 0xCC, 0x86, 0x07, 0xA0,
  6722. 0xEE, 0x05, 0x5F, 0x00, 0x00, 0x2B, 0xDF, 0x08, 0x00, 0xA2, 0xE6, 0x05,
  6723. 0x80, 0x67, 0x80, 0x63, 0x01, 0xA2, 0x7A, 0x06, 0x7C, 0x85, 0x06, 0x23,
  6724. 0x68, 0x98, 0x48, 0x23, 0xF8, 0x88, 0x07, 0x23, 0x80, 0x00, 0x06, 0x87,
  6725. 0x80, 0x63, 0x7C, 0x85, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63, 0x4A, 0x00,
  6726. 0x06, 0x61, 0x00, 0xA2, 0x36, 0x06, 0x1D, 0x01, 0x16, 0xD4, 0xC0, 0x23,
  6727. 0x07, 0x41, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x1C, 0x06, 0x00, 0x33,
  6728. 0x37, 0x00, 0xC2, 0x88, 0x1D, 0x01, 0x01, 0xD6, 0x20, 0x23, 0x63, 0x60,
  6729. 0x83, 0x03, 0x80, 0x63, 0x02, 0x23, 0xDF, 0x00, 0x07, 0xA6, 0x7C, 0x05,
  6730. 0xEF, 0x04, 0x6F, 0x00, 0x00, 0x63, 0x4B, 0x00, 0x06, 0x41, 0xCB, 0x00,
  6731. 0x52, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x4E, 0x06, 0x1D, 0x01, 0x03, 0xCA,
  6732. 0xC0, 0x23, 0x07, 0x41, 0x00, 0x63, 0x1D, 0x01, 0x04, 0xCC, 0x00, 0x33,
  6733. 0x00, 0x83, 0xC0, 0x20, 0x81, 0x62, 0x80, 0x23, 0x07, 0x41, 0x00, 0x63,
  6734. 0x80, 0x67, 0x08, 0x23, 0x83, 0x03, 0x80, 0x63, 0x00, 0x63, 0x01, 0x23,
  6735. 0xDF, 0x00, 0x06, 0xA6, 0x84, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67,
  6736. 0x80, 0x63, 0x00, 0x33, 0x00, 0x40, 0xC0, 0x20, 0x81, 0x62, 0x00, 0x63,
  6737. 0x00, 0x00, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x94, 0x06,
  6738. 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x00, 0x01, 0xA0, 0x14, 0x07, 0x00, 0x2B,
  6739. 0x40, 0x0E, 0x80, 0x63, 0x01, 0x00, 0x06, 0xA6, 0xAA, 0x06, 0x07, 0xA6,
  6740. 0x7C, 0x05, 0x40, 0x0E, 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0xA2, 0x06,
  6741. 0x06, 0xA6, 0xBC, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67, 0x40, 0x0E,
  6742. 0x80, 0x63, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63,
  6743. 0x07, 0xA6, 0xD6, 0x06, 0x00, 0x33, 0x2A, 0x00, 0xC2, 0x88, 0x03, 0x03,
  6744. 0x80, 0x63, 0x89, 0x00, 0x0A, 0x2B, 0x07, 0xA6, 0xE8, 0x06, 0x00, 0x33,
  6745. 0x29, 0x00, 0xC2, 0x88, 0x00, 0x43, 0x00, 0xA2, 0xF4, 0x06, 0xC0, 0x0E,
  6746. 0x80, 0x63, 0xDE, 0x86, 0xC0, 0x0E, 0x00, 0x33, 0x00, 0x80, 0xC0, 0x20,
  6747. 0x81, 0x62, 0x04, 0x01, 0x02, 0xDA, 0x80, 0x63, 0x7C, 0x85, 0x80, 0x7B,
  6748. 0x80, 0x63, 0x06, 0xA6, 0x8C, 0x06, 0x00, 0x33, 0x2C, 0x00, 0xC2, 0x88,
  6749. 0x0C, 0xA2, 0x2E, 0x07, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6,
  6750. 0x2C, 0x07, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x33, 0x3D, 0x00, 0xC2, 0x88,
  6751. 0x00, 0x00, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0x0C, 0xA0, 0x44, 0x07,
  6752. 0x07, 0xA6, 0x7C, 0x05, 0xBF, 0x23, 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84,
  6753. 0x00, 0x63, 0xF0, 0x04, 0x01, 0x01, 0xF1, 0x00, 0x00, 0x01, 0xF2, 0x00,
  6754. 0x01, 0x05, 0x80, 0x01, 0x72, 0x04, 0x71, 0x00, 0x81, 0x01, 0x70, 0x04,
  6755. 0x80, 0x05, 0x81, 0x05, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04,
  6756. 0x01, 0x01, 0xF1, 0x00, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04, 0x71, 0x00,
  6757. 0x81, 0x01, 0x72, 0x00, 0x80, 0x01, 0x71, 0x04, 0x70, 0x00, 0x80, 0x01,
  6758. 0x70, 0x04, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x00, 0x01,
  6759. 0xF1, 0x00, 0x70, 0x00, 0x80, 0x01, 0x70, 0x04, 0x71, 0x00, 0x80, 0x01,
  6760. 0x72, 0x00, 0x81, 0x01, 0x71, 0x04, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04,
  6761. 0x00, 0x63, 0x00, 0x23, 0xB3, 0x01, 0x83, 0x05, 0xA3, 0x01, 0xA2, 0x01,
  6762. 0xA1, 0x01, 0x01, 0x23, 0xA0, 0x01, 0x00, 0x01, 0xC8, 0x00, 0x03, 0xA1,
  6763. 0xC4, 0x07, 0x00, 0x33, 0x07, 0x00, 0xC2, 0x88, 0x80, 0x05, 0x81, 0x05,
  6764. 0x04, 0x01, 0x11, 0xC8, 0x48, 0x00, 0xB0, 0x01, 0xB1, 0x01, 0x08, 0x23,
  6765. 0xB2, 0x01, 0x05, 0x01, 0x48, 0x04, 0x00, 0x43, 0x00, 0xA2, 0xE4, 0x07,
  6766. 0x00, 0x05, 0xDA, 0x87, 0x00, 0x01, 0xC8, 0x00, 0xFF, 0x23, 0x80, 0x01,
  6767. 0x05, 0x05, 0x00, 0x63, 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04,
  6768. 0x00, 0x02, 0x80, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04, 0x00, 0x63,
  6769. 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04, 0x00, 0x02, 0x00, 0xA0,
  6770. 0x14, 0x08, 0x16, 0x88, 0x00, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04,
  6771. 0x00, 0x63, 0xF3, 0x04, 0x00, 0x23, 0xF4, 0x00, 0x74, 0x00, 0x80, 0x43,
  6772. 0xF4, 0x00, 0xCF, 0x40, 0x00, 0xA2, 0x44, 0x08, 0x74, 0x04, 0x02, 0x01,
  6773. 0xF7, 0xC9, 0xF6, 0xD9, 0x00, 0x01, 0x01, 0xA1, 0x24, 0x08, 0x04, 0x98,
  6774. 0x26, 0x95, 0x24, 0x88, 0x73, 0x04, 0x00, 0x63, 0xF3, 0x04, 0x75, 0x04,
  6775. 0x5A, 0x88, 0x02, 0x01, 0x04, 0xD8, 0x46, 0x97, 0x04, 0x98, 0x26, 0x95,
  6776. 0x4A, 0x88, 0x75, 0x00, 0x00, 0xA3, 0x64, 0x08, 0x00, 0x05, 0x4E, 0x88,
  6777. 0x73, 0x04, 0x00, 0x63, 0x80, 0x7B, 0x80, 0x63, 0x06, 0xA6, 0x76, 0x08,
  6778. 0x00, 0x33, 0x3E, 0x00, 0xC2, 0x88, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63,
  6779. 0x00, 0x63, 0x38, 0x2B, 0x9C, 0x88, 0x38, 0x2B, 0x92, 0x88, 0x32, 0x09,
  6780. 0x31, 0x05, 0x92, 0x98, 0x05, 0x05, 0xB2, 0x09, 0x00, 0x63, 0x00, 0x32,
  6781. 0x00, 0x36, 0x00, 0x3A, 0x00, 0x3E, 0x00, 0x63, 0x80, 0x32, 0x80, 0x36,
  6782. 0x80, 0x3A, 0x80, 0x3E, 0xB4, 0x3D, 0x00, 0x63, 0x38, 0x2B, 0x40, 0x32,
  6783. 0x40, 0x36, 0x40, 0x3A, 0x40, 0x3E, 0x00, 0x63, 0x5A, 0x20, 0xC9, 0x40,
  6784. 0x00, 0xA0, 0xB4, 0x08, 0x5D, 0x00, 0xFE, 0xC3, 0x00, 0x63, 0x80, 0x73,
  6785. 0xE6, 0x20, 0x02, 0x23, 0xE8, 0x00, 0x82, 0x73, 0xFF, 0xFD, 0x80, 0x73,
  6786. 0x13, 0x23, 0xF8, 0x88, 0x66, 0x20, 0xC0, 0x20, 0x04, 0x23, 0xA0, 0x01,
  6787. 0xA1, 0x23, 0xA1, 0x01, 0x81, 0x62, 0xE2, 0x88, 0x80, 0x73, 0x80, 0x77,
  6788. 0x68, 0x00, 0x00, 0xA2, 0x80, 0x00, 0x03, 0xC2, 0xF1, 0xC7, 0x41, 0x23,
  6789. 0xF8, 0x88, 0x11, 0x23, 0xA1, 0x01, 0x04, 0x23, 0xA0, 0x01, 0xE6, 0x84,
  6790. };
  6791. static ushort _asc_mcode_size = sizeof(_asc_mcode_buf);
  6792. static ADV_DCNT _asc_mcode_chksum = 0x012C453FUL;
  6793. #define ASC_SYN_OFFSET_ONE_DISABLE_LIST 16
  6794. static uchar _syn_offset_one_disable_cmd[ASC_SYN_OFFSET_ONE_DISABLE_LIST] = {
  6795. INQUIRY,
  6796. REQUEST_SENSE,
  6797. READ_CAPACITY,
  6798. READ_TOC,
  6799. MODE_SELECT,
  6800. MODE_SENSE,
  6801. MODE_SELECT_10,
  6802. MODE_SENSE_10,
  6803. 0xFF,
  6804. 0xFF,
  6805. 0xFF,
  6806. 0xFF,
  6807. 0xFF,
  6808. 0xFF,
  6809. 0xFF,
  6810. 0xFF
  6811. };
  6812. static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
  6813. {
  6814. PortAddr iop_base;
  6815. ulong last_int_level;
  6816. int sta;
  6817. int n_q_required;
  6818. int disable_syn_offset_one_fix;
  6819. int i;
  6820. ASC_PADDR addr;
  6821. ushort sg_entry_cnt = 0;
  6822. ushort sg_entry_cnt_minus_one = 0;
  6823. uchar target_ix;
  6824. uchar tid_no;
  6825. uchar sdtr_data;
  6826. uchar extra_bytes;
  6827. uchar scsi_cmd;
  6828. uchar disable_cmd;
  6829. ASC_SG_HEAD *sg_head;
  6830. ASC_DCNT data_cnt;
  6831. iop_base = asc_dvc->iop_base;
  6832. sg_head = scsiq->sg_head;
  6833. if (asc_dvc->err_code != 0)
  6834. return (ERR);
  6835. scsiq->q1.q_no = 0;
  6836. if ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES) == 0) {
  6837. scsiq->q1.extra_bytes = 0;
  6838. }
  6839. sta = 0;
  6840. target_ix = scsiq->q2.target_ix;
  6841. tid_no = ASC_TIX_TO_TID(target_ix);
  6842. n_q_required = 1;
  6843. if (scsiq->cdbptr[0] == REQUEST_SENSE) {
  6844. if ((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) {
  6845. asc_dvc->sdtr_done &= ~scsiq->q1.target_id;
  6846. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  6847. AscMsgOutSDTR(asc_dvc,
  6848. asc_dvc->
  6849. sdtr_period_tbl[(sdtr_data >> 4) &
  6850. (uchar)(asc_dvc->
  6851. max_sdtr_index -
  6852. 1)],
  6853. (uchar)(sdtr_data & (uchar)
  6854. ASC_SYN_MAX_OFFSET));
  6855. scsiq->q1.cntl |= (QC_MSG_OUT | QC_URGENT);
  6856. }
  6857. }
  6858. last_int_level = DvcEnterCritical();
  6859. if (asc_dvc->in_critical_cnt != 0) {
  6860. DvcLeaveCritical(last_int_level);
  6861. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CRITICAL_RE_ENTRY);
  6862. return (ERR);
  6863. }
  6864. asc_dvc->in_critical_cnt++;
  6865. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  6866. if ((sg_entry_cnt = sg_head->entry_cnt) == 0) {
  6867. asc_dvc->in_critical_cnt--;
  6868. DvcLeaveCritical(last_int_level);
  6869. return (ERR);
  6870. }
  6871. #if !CC_VERY_LONG_SG_LIST
  6872. if (sg_entry_cnt > ASC_MAX_SG_LIST) {
  6873. asc_dvc->in_critical_cnt--;
  6874. DvcLeaveCritical(last_int_level);
  6875. return (ERR);
  6876. }
  6877. #endif /* !CC_VERY_LONG_SG_LIST */
  6878. if (sg_entry_cnt == 1) {
  6879. scsiq->q1.data_addr =
  6880. (ADV_PADDR)sg_head->sg_list[0].addr;
  6881. scsiq->q1.data_cnt =
  6882. (ADV_DCNT)sg_head->sg_list[0].bytes;
  6883. scsiq->q1.cntl &= ~(QC_SG_HEAD | QC_SG_SWAP_QUEUE);
  6884. }
  6885. sg_entry_cnt_minus_one = sg_entry_cnt - 1;
  6886. }
  6887. scsi_cmd = scsiq->cdbptr[0];
  6888. disable_syn_offset_one_fix = FALSE;
  6889. if ((asc_dvc->pci_fix_asyn_xfer & scsiq->q1.target_id) &&
  6890. !(asc_dvc->pci_fix_asyn_xfer_always & scsiq->q1.target_id)) {
  6891. if (scsiq->q1.cntl & QC_SG_HEAD) {
  6892. data_cnt = 0;
  6893. for (i = 0; i < sg_entry_cnt; i++) {
  6894. data_cnt +=
  6895. (ADV_DCNT)le32_to_cpu(sg_head->sg_list[i].
  6896. bytes);
  6897. }
  6898. } else {
  6899. data_cnt = le32_to_cpu(scsiq->q1.data_cnt);
  6900. }
  6901. if (data_cnt != 0UL) {
  6902. if (data_cnt < 512UL) {
  6903. disable_syn_offset_one_fix = TRUE;
  6904. } else {
  6905. for (i = 0; i < ASC_SYN_OFFSET_ONE_DISABLE_LIST;
  6906. i++) {
  6907. disable_cmd =
  6908. _syn_offset_one_disable_cmd[i];
  6909. if (disable_cmd == 0xFF) {
  6910. break;
  6911. }
  6912. if (scsi_cmd == disable_cmd) {
  6913. disable_syn_offset_one_fix =
  6914. TRUE;
  6915. break;
  6916. }
  6917. }
  6918. }
  6919. }
  6920. }
  6921. if (disable_syn_offset_one_fix) {
  6922. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
  6923. scsiq->q2.tag_code |= (ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX |
  6924. ASC_TAG_FLAG_DISABLE_DISCONNECT);
  6925. } else {
  6926. scsiq->q2.tag_code &= 0x27;
  6927. }
  6928. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  6929. if (asc_dvc->bug_fix_cntl) {
  6930. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  6931. if ((scsi_cmd == READ_6) ||
  6932. (scsi_cmd == READ_10)) {
  6933. addr =
  6934. (ADV_PADDR)le32_to_cpu(sg_head->
  6935. sg_list
  6936. [sg_entry_cnt_minus_one].
  6937. addr) +
  6938. (ADV_DCNT)le32_to_cpu(sg_head->
  6939. sg_list
  6940. [sg_entry_cnt_minus_one].
  6941. bytes);
  6942. extra_bytes =
  6943. (uchar)((ushort)addr & 0x0003);
  6944. if ((extra_bytes != 0)
  6945. &&
  6946. ((scsiq->q2.
  6947. tag_code &
  6948. ASC_TAG_FLAG_EXTRA_BYTES)
  6949. == 0)) {
  6950. scsiq->q2.tag_code |=
  6951. ASC_TAG_FLAG_EXTRA_BYTES;
  6952. scsiq->q1.extra_bytes =
  6953. extra_bytes;
  6954. data_cnt =
  6955. le32_to_cpu(sg_head->
  6956. sg_list
  6957. [sg_entry_cnt_minus_one].
  6958. bytes);
  6959. data_cnt -=
  6960. (ASC_DCNT) extra_bytes;
  6961. sg_head->
  6962. sg_list
  6963. [sg_entry_cnt_minus_one].
  6964. bytes =
  6965. cpu_to_le32(data_cnt);
  6966. }
  6967. }
  6968. }
  6969. }
  6970. sg_head->entry_to_copy = sg_head->entry_cnt;
  6971. #if CC_VERY_LONG_SG_LIST
  6972. /*
  6973. * Set the sg_entry_cnt to the maximum possible. The rest of
  6974. * the SG elements will be copied when the RISC completes the
  6975. * SG elements that fit and halts.
  6976. */
  6977. if (sg_entry_cnt > ASC_MAX_SG_LIST) {
  6978. sg_entry_cnt = ASC_MAX_SG_LIST;
  6979. }
  6980. #endif /* CC_VERY_LONG_SG_LIST */
  6981. n_q_required = AscSgListToQueue(sg_entry_cnt);
  6982. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, n_q_required) >=
  6983. (uint) n_q_required)
  6984. || ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  6985. if ((sta =
  6986. AscSendScsiQueue(asc_dvc, scsiq,
  6987. n_q_required)) == 1) {
  6988. asc_dvc->in_critical_cnt--;
  6989. DvcLeaveCritical(last_int_level);
  6990. return (sta);
  6991. }
  6992. }
  6993. } else {
  6994. if (asc_dvc->bug_fix_cntl) {
  6995. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  6996. if ((scsi_cmd == READ_6) ||
  6997. (scsi_cmd == READ_10)) {
  6998. addr =
  6999. le32_to_cpu(scsiq->q1.data_addr) +
  7000. le32_to_cpu(scsiq->q1.data_cnt);
  7001. extra_bytes =
  7002. (uchar)((ushort)addr & 0x0003);
  7003. if ((extra_bytes != 0)
  7004. &&
  7005. ((scsiq->q2.
  7006. tag_code &
  7007. ASC_TAG_FLAG_EXTRA_BYTES)
  7008. == 0)) {
  7009. data_cnt =
  7010. le32_to_cpu(scsiq->q1.
  7011. data_cnt);
  7012. if (((ushort)data_cnt & 0x01FF)
  7013. == 0) {
  7014. scsiq->q2.tag_code |=
  7015. ASC_TAG_FLAG_EXTRA_BYTES;
  7016. data_cnt -= (ASC_DCNT)
  7017. extra_bytes;
  7018. scsiq->q1.data_cnt =
  7019. cpu_to_le32
  7020. (data_cnt);
  7021. scsiq->q1.extra_bytes =
  7022. extra_bytes;
  7023. }
  7024. }
  7025. }
  7026. }
  7027. }
  7028. n_q_required = 1;
  7029. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, 1) >= 1) ||
  7030. ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  7031. if ((sta = AscSendScsiQueue(asc_dvc, scsiq,
  7032. n_q_required)) == 1) {
  7033. asc_dvc->in_critical_cnt--;
  7034. DvcLeaveCritical(last_int_level);
  7035. return (sta);
  7036. }
  7037. }
  7038. }
  7039. asc_dvc->in_critical_cnt--;
  7040. DvcLeaveCritical(last_int_level);
  7041. return (sta);
  7042. }
  7043. static int
  7044. AscSendScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar n_q_required)
  7045. {
  7046. PortAddr iop_base;
  7047. uchar free_q_head;
  7048. uchar next_qp;
  7049. uchar tid_no;
  7050. uchar target_ix;
  7051. int sta;
  7052. iop_base = asc_dvc->iop_base;
  7053. target_ix = scsiq->q2.target_ix;
  7054. tid_no = ASC_TIX_TO_TID(target_ix);
  7055. sta = 0;
  7056. free_q_head = (uchar)AscGetVarFreeQHead(iop_base);
  7057. if (n_q_required > 1) {
  7058. if ((next_qp = AscAllocMultipleFreeQueue(iop_base,
  7059. free_q_head, (uchar)
  7060. (n_q_required)))
  7061. != (uchar)ASC_QLINK_END) {
  7062. asc_dvc->last_q_shortage = 0;
  7063. scsiq->sg_head->queue_cnt = n_q_required - 1;
  7064. scsiq->q1.q_no = free_q_head;
  7065. if ((sta = AscPutReadySgListQueue(asc_dvc, scsiq,
  7066. free_q_head)) == 1) {
  7067. AscPutVarFreeQHead(iop_base, next_qp);
  7068. asc_dvc->cur_total_qng += (uchar)(n_q_required);
  7069. asc_dvc->cur_dvc_qng[tid_no]++;
  7070. }
  7071. return (sta);
  7072. }
  7073. } else if (n_q_required == 1) {
  7074. if ((next_qp = AscAllocFreeQueue(iop_base,
  7075. free_q_head)) !=
  7076. ASC_QLINK_END) {
  7077. scsiq->q1.q_no = free_q_head;
  7078. if ((sta = AscPutReadyQueue(asc_dvc, scsiq,
  7079. free_q_head)) == 1) {
  7080. AscPutVarFreeQHead(iop_base, next_qp);
  7081. asc_dvc->cur_total_qng++;
  7082. asc_dvc->cur_dvc_qng[tid_no]++;
  7083. }
  7084. return (sta);
  7085. }
  7086. }
  7087. return (sta);
  7088. }
  7089. static int AscSgListToQueue(int sg_list)
  7090. {
  7091. int n_sg_list_qs;
  7092. n_sg_list_qs = ((sg_list - 1) / ASC_SG_LIST_PER_Q);
  7093. if (((sg_list - 1) % ASC_SG_LIST_PER_Q) != 0)
  7094. n_sg_list_qs++;
  7095. return (n_sg_list_qs + 1);
  7096. }
  7097. static uint
  7098. AscGetNumOfFreeQueue(ASC_DVC_VAR *asc_dvc, uchar target_ix, uchar n_qs)
  7099. {
  7100. uint cur_used_qs;
  7101. uint cur_free_qs;
  7102. ASC_SCSI_BIT_ID_TYPE target_id;
  7103. uchar tid_no;
  7104. target_id = ASC_TIX_TO_TARGET_ID(target_ix);
  7105. tid_no = ASC_TIX_TO_TID(target_ix);
  7106. if ((asc_dvc->unit_not_ready & target_id) ||
  7107. (asc_dvc->queue_full_or_busy & target_id)) {
  7108. return (0);
  7109. }
  7110. if (n_qs == 1) {
  7111. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  7112. (uint) asc_dvc->last_q_shortage + (uint) ASC_MIN_FREE_Q;
  7113. } else {
  7114. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  7115. (uint) ASC_MIN_FREE_Q;
  7116. }
  7117. if ((uint) (cur_used_qs + n_qs) <= (uint) asc_dvc->max_total_qng) {
  7118. cur_free_qs = (uint) asc_dvc->max_total_qng - cur_used_qs;
  7119. if (asc_dvc->cur_dvc_qng[tid_no] >=
  7120. asc_dvc->max_dvc_qng[tid_no]) {
  7121. return (0);
  7122. }
  7123. return (cur_free_qs);
  7124. }
  7125. if (n_qs > 1) {
  7126. if ((n_qs > asc_dvc->last_q_shortage)
  7127. && (n_qs <= (asc_dvc->max_total_qng - ASC_MIN_FREE_Q))) {
  7128. asc_dvc->last_q_shortage = n_qs;
  7129. }
  7130. }
  7131. return (0);
  7132. }
  7133. static int AscPutReadyQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
  7134. {
  7135. ushort q_addr;
  7136. uchar tid_no;
  7137. uchar sdtr_data;
  7138. uchar syn_period_ix;
  7139. uchar syn_offset;
  7140. PortAddr iop_base;
  7141. iop_base = asc_dvc->iop_base;
  7142. if (((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) &&
  7143. ((asc_dvc->sdtr_done & scsiq->q1.target_id) == 0)) {
  7144. tid_no = ASC_TIX_TO_TID(scsiq->q2.target_ix);
  7145. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  7146. syn_period_ix =
  7147. (sdtr_data >> 4) & (asc_dvc->max_sdtr_index - 1);
  7148. syn_offset = sdtr_data & ASC_SYN_MAX_OFFSET;
  7149. AscMsgOutSDTR(asc_dvc,
  7150. asc_dvc->sdtr_period_tbl[syn_period_ix],
  7151. syn_offset);
  7152. scsiq->q1.cntl |= QC_MSG_OUT;
  7153. }
  7154. q_addr = ASC_QNO_TO_QADDR(q_no);
  7155. if ((scsiq->q1.target_id & asc_dvc->use_tagged_qng) == 0) {
  7156. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
  7157. }
  7158. scsiq->q1.status = QS_FREE;
  7159. AscMemWordCopyPtrToLram(iop_base,
  7160. q_addr + ASC_SCSIQ_CDB_BEG,
  7161. (uchar *)scsiq->cdbptr, scsiq->q2.cdb_len >> 1);
  7162. DvcPutScsiQ(iop_base,
  7163. q_addr + ASC_SCSIQ_CPY_BEG,
  7164. (uchar *)&scsiq->q1.cntl,
  7165. ((sizeof(ASC_SCSIQ_1) + sizeof(ASC_SCSIQ_2)) / 2) - 1);
  7166. AscWriteLramWord(iop_base,
  7167. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS),
  7168. (ushort)(((ushort)scsiq->q1.
  7169. q_no << 8) | (ushort)QS_READY));
  7170. return (1);
  7171. }
  7172. static int
  7173. AscPutReadySgListQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
  7174. {
  7175. int sta;
  7176. int i;
  7177. ASC_SG_HEAD *sg_head;
  7178. ASC_SG_LIST_Q scsi_sg_q;
  7179. ASC_DCNT saved_data_addr;
  7180. ASC_DCNT saved_data_cnt;
  7181. PortAddr iop_base;
  7182. ushort sg_list_dwords;
  7183. ushort sg_index;
  7184. ushort sg_entry_cnt;
  7185. ushort q_addr;
  7186. uchar next_qp;
  7187. iop_base = asc_dvc->iop_base;
  7188. sg_head = scsiq->sg_head;
  7189. saved_data_addr = scsiq->q1.data_addr;
  7190. saved_data_cnt = scsiq->q1.data_cnt;
  7191. scsiq->q1.data_addr = (ASC_PADDR) sg_head->sg_list[0].addr;
  7192. scsiq->q1.data_cnt = (ASC_DCNT) sg_head->sg_list[0].bytes;
  7193. #if CC_VERY_LONG_SG_LIST
  7194. /*
  7195. * If sg_head->entry_cnt is greater than ASC_MAX_SG_LIST
  7196. * then not all SG elements will fit in the allocated queues.
  7197. * The rest of the SG elements will be copied when the RISC
  7198. * completes the SG elements that fit and halts.
  7199. */
  7200. if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
  7201. /*
  7202. * Set sg_entry_cnt to be the number of SG elements that
  7203. * will fit in the allocated SG queues. It is minus 1, because
  7204. * the first SG element is handled above. ASC_MAX_SG_LIST is
  7205. * already inflated by 1 to account for this. For example it
  7206. * may be 50 which is 1 + 7 queues * 7 SG elements.
  7207. */
  7208. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  7209. /*
  7210. * Keep track of remaining number of SG elements that will
  7211. * need to be handled from a_isr.c.
  7212. */
  7213. scsiq->remain_sg_entry_cnt =
  7214. sg_head->entry_cnt - ASC_MAX_SG_LIST;
  7215. } else {
  7216. #endif /* CC_VERY_LONG_SG_LIST */
  7217. /*
  7218. * Set sg_entry_cnt to be the number of SG elements that
  7219. * will fit in the allocated SG queues. It is minus 1, because
  7220. * the first SG element is handled above.
  7221. */
  7222. sg_entry_cnt = sg_head->entry_cnt - 1;
  7223. #if CC_VERY_LONG_SG_LIST
  7224. }
  7225. #endif /* CC_VERY_LONG_SG_LIST */
  7226. if (sg_entry_cnt != 0) {
  7227. scsiq->q1.cntl |= QC_SG_HEAD;
  7228. q_addr = ASC_QNO_TO_QADDR(q_no);
  7229. sg_index = 1;
  7230. scsiq->q1.sg_queue_cnt = sg_head->queue_cnt;
  7231. scsi_sg_q.sg_head_qp = q_no;
  7232. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  7233. for (i = 0; i < sg_head->queue_cnt; i++) {
  7234. scsi_sg_q.seq_no = i + 1;
  7235. if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
  7236. sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
  7237. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  7238. if (i == 0) {
  7239. scsi_sg_q.sg_list_cnt =
  7240. ASC_SG_LIST_PER_Q;
  7241. scsi_sg_q.sg_cur_list_cnt =
  7242. ASC_SG_LIST_PER_Q;
  7243. } else {
  7244. scsi_sg_q.sg_list_cnt =
  7245. ASC_SG_LIST_PER_Q - 1;
  7246. scsi_sg_q.sg_cur_list_cnt =
  7247. ASC_SG_LIST_PER_Q - 1;
  7248. }
  7249. } else {
  7250. #if CC_VERY_LONG_SG_LIST
  7251. /*
  7252. * This is the last SG queue in the list of
  7253. * allocated SG queues. If there are more
  7254. * SG elements than will fit in the allocated
  7255. * queues, then set the QCSG_SG_XFER_MORE flag.
  7256. */
  7257. if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
  7258. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  7259. } else {
  7260. #endif /* CC_VERY_LONG_SG_LIST */
  7261. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  7262. #if CC_VERY_LONG_SG_LIST
  7263. }
  7264. #endif /* CC_VERY_LONG_SG_LIST */
  7265. sg_list_dwords = sg_entry_cnt << 1;
  7266. if (i == 0) {
  7267. scsi_sg_q.sg_list_cnt = sg_entry_cnt;
  7268. scsi_sg_q.sg_cur_list_cnt =
  7269. sg_entry_cnt;
  7270. } else {
  7271. scsi_sg_q.sg_list_cnt =
  7272. sg_entry_cnt - 1;
  7273. scsi_sg_q.sg_cur_list_cnt =
  7274. sg_entry_cnt - 1;
  7275. }
  7276. sg_entry_cnt = 0;
  7277. }
  7278. next_qp = AscReadLramByte(iop_base,
  7279. (ushort)(q_addr +
  7280. ASC_SCSIQ_B_FWD));
  7281. scsi_sg_q.q_no = next_qp;
  7282. q_addr = ASC_QNO_TO_QADDR(next_qp);
  7283. AscMemWordCopyPtrToLram(iop_base,
  7284. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  7285. (uchar *)&scsi_sg_q,
  7286. sizeof(ASC_SG_LIST_Q) >> 1);
  7287. AscMemDWordCopyPtrToLram(iop_base,
  7288. q_addr + ASC_SGQ_LIST_BEG,
  7289. (uchar *)&sg_head->
  7290. sg_list[sg_index],
  7291. sg_list_dwords);
  7292. sg_index += ASC_SG_LIST_PER_Q;
  7293. scsiq->next_sg_index = sg_index;
  7294. }
  7295. } else {
  7296. scsiq->q1.cntl &= ~QC_SG_HEAD;
  7297. }
  7298. sta = AscPutReadyQueue(asc_dvc, scsiq, q_no);
  7299. scsiq->q1.data_addr = saved_data_addr;
  7300. scsiq->q1.data_cnt = saved_data_cnt;
  7301. return (sta);
  7302. }
  7303. static int
  7304. AscSetRunChipSynRegAtID(PortAddr iop_base, uchar tid_no, uchar sdtr_data)
  7305. {
  7306. int sta = FALSE;
  7307. if (AscHostReqRiscHalt(iop_base)) {
  7308. sta = AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  7309. AscStartChip(iop_base);
  7310. return (sta);
  7311. }
  7312. return (sta);
  7313. }
  7314. static int AscSetChipSynRegAtID(PortAddr iop_base, uchar id, uchar sdtr_data)
  7315. {
  7316. ASC_SCSI_BIT_ID_TYPE org_id;
  7317. int i;
  7318. int sta = TRUE;
  7319. AscSetBank(iop_base, 1);
  7320. org_id = AscReadChipDvcID(iop_base);
  7321. for (i = 0; i <= ASC_MAX_TID; i++) {
  7322. if (org_id == (0x01 << i))
  7323. break;
  7324. }
  7325. org_id = (ASC_SCSI_BIT_ID_TYPE) i;
  7326. AscWriteChipDvcID(iop_base, id);
  7327. if (AscReadChipDvcID(iop_base) == (0x01 << id)) {
  7328. AscSetBank(iop_base, 0);
  7329. AscSetChipSyn(iop_base, sdtr_data);
  7330. if (AscGetChipSyn(iop_base) != sdtr_data) {
  7331. sta = FALSE;
  7332. }
  7333. } else {
  7334. sta = FALSE;
  7335. }
  7336. AscSetBank(iop_base, 1);
  7337. AscWriteChipDvcID(iop_base, org_id);
  7338. AscSetBank(iop_base, 0);
  7339. return (sta);
  7340. }
  7341. static ushort AscInitLram(ASC_DVC_VAR *asc_dvc)
  7342. {
  7343. uchar i;
  7344. ushort s_addr;
  7345. PortAddr iop_base;
  7346. ushort warn_code;
  7347. iop_base = asc_dvc->iop_base;
  7348. warn_code = 0;
  7349. AscMemWordSetLram(iop_base, ASC_QADR_BEG, 0,
  7350. (ushort)(((int)(asc_dvc->max_total_qng + 2 + 1) *
  7351. 64) >> 1)
  7352. );
  7353. i = ASC_MIN_ACTIVE_QNO;
  7354. s_addr = ASC_QADR_BEG + ASC_QBLK_SIZE;
  7355. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  7356. (uchar)(i + 1));
  7357. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  7358. (uchar)(asc_dvc->max_total_qng));
  7359. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  7360. (uchar)i);
  7361. i++;
  7362. s_addr += ASC_QBLK_SIZE;
  7363. for (; i < asc_dvc->max_total_qng; i++, s_addr += ASC_QBLK_SIZE) {
  7364. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  7365. (uchar)(i + 1));
  7366. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  7367. (uchar)(i - 1));
  7368. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  7369. (uchar)i);
  7370. }
  7371. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  7372. (uchar)ASC_QLINK_END);
  7373. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  7374. (uchar)(asc_dvc->max_total_qng - 1));
  7375. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  7376. (uchar)asc_dvc->max_total_qng);
  7377. i++;
  7378. s_addr += ASC_QBLK_SIZE;
  7379. for (; i <= (uchar)(asc_dvc->max_total_qng + 3);
  7380. i++, s_addr += ASC_QBLK_SIZE) {
  7381. AscWriteLramByte(iop_base,
  7382. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_FWD), i);
  7383. AscWriteLramByte(iop_base,
  7384. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_BWD), i);
  7385. AscWriteLramByte(iop_base,
  7386. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_QNO), i);
  7387. }
  7388. return (warn_code);
  7389. }
  7390. static ushort AscInitQLinkVar(ASC_DVC_VAR *asc_dvc)
  7391. {
  7392. PortAddr iop_base;
  7393. int i;
  7394. ushort lram_addr;
  7395. iop_base = asc_dvc->iop_base;
  7396. AscPutRiscVarFreeQHead(iop_base, 1);
  7397. AscPutRiscVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  7398. AscPutVarFreeQHead(iop_base, 1);
  7399. AscPutVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  7400. AscWriteLramByte(iop_base, ASCV_BUSY_QHEAD_B,
  7401. (uchar)((int)asc_dvc->max_total_qng + 1));
  7402. AscWriteLramByte(iop_base, ASCV_DISC1_QHEAD_B,
  7403. (uchar)((int)asc_dvc->max_total_qng + 2));
  7404. AscWriteLramByte(iop_base, (ushort)ASCV_TOTAL_READY_Q_B,
  7405. asc_dvc->max_total_qng);
  7406. AscWriteLramWord(iop_base, ASCV_ASCDVC_ERR_CODE_W, 0);
  7407. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  7408. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, 0);
  7409. AscWriteLramByte(iop_base, ASCV_SCSIBUSY_B, 0);
  7410. AscWriteLramByte(iop_base, ASCV_WTM_FLAG_B, 0);
  7411. AscPutQDoneInProgress(iop_base, 0);
  7412. lram_addr = ASC_QADR_BEG;
  7413. for (i = 0; i < 32; i++, lram_addr += 2) {
  7414. AscWriteLramWord(iop_base, lram_addr, 0);
  7415. }
  7416. return (0);
  7417. }
  7418. static int AscSetLibErrorCode(ASC_DVC_VAR *asc_dvc, ushort err_code)
  7419. {
  7420. if (asc_dvc->err_code == 0) {
  7421. asc_dvc->err_code = err_code;
  7422. AscWriteLramWord(asc_dvc->iop_base, ASCV_ASCDVC_ERR_CODE_W,
  7423. err_code);
  7424. }
  7425. return (err_code);
  7426. }
  7427. static uchar
  7428. AscMsgOutSDTR(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar sdtr_offset)
  7429. {
  7430. EXT_MSG sdtr_buf;
  7431. uchar sdtr_period_index;
  7432. PortAddr iop_base;
  7433. iop_base = asc_dvc->iop_base;
  7434. sdtr_buf.msg_type = EXTENDED_MESSAGE;
  7435. sdtr_buf.msg_len = MS_SDTR_LEN;
  7436. sdtr_buf.msg_req = EXTENDED_SDTR;
  7437. sdtr_buf.xfer_period = sdtr_period;
  7438. sdtr_offset &= ASC_SYN_MAX_OFFSET;
  7439. sdtr_buf.req_ack_offset = sdtr_offset;
  7440. if ((sdtr_period_index =
  7441. AscGetSynPeriodIndex(asc_dvc, sdtr_period)) <=
  7442. asc_dvc->max_sdtr_index) {
  7443. AscMemWordCopyPtrToLram(iop_base,
  7444. ASCV_MSGOUT_BEG,
  7445. (uchar *)&sdtr_buf,
  7446. sizeof(EXT_MSG) >> 1);
  7447. return ((sdtr_period_index << 4) | sdtr_offset);
  7448. } else {
  7449. sdtr_buf.req_ack_offset = 0;
  7450. AscMemWordCopyPtrToLram(iop_base,
  7451. ASCV_MSGOUT_BEG,
  7452. (uchar *)&sdtr_buf,
  7453. sizeof(EXT_MSG) >> 1);
  7454. return (0);
  7455. }
  7456. }
  7457. static uchar
  7458. AscCalSDTRData(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar syn_offset)
  7459. {
  7460. uchar byte;
  7461. uchar sdtr_period_ix;
  7462. sdtr_period_ix = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
  7463. if ((sdtr_period_ix > asc_dvc->max_sdtr_index)
  7464. ) {
  7465. return (0xFF);
  7466. }
  7467. byte = (sdtr_period_ix << 4) | (syn_offset & ASC_SYN_MAX_OFFSET);
  7468. return (byte);
  7469. }
  7470. static void AscSetChipSDTR(PortAddr iop_base, uchar sdtr_data, uchar tid_no)
  7471. {
  7472. AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  7473. AscPutMCodeSDTRDoneAtID(iop_base, tid_no, sdtr_data);
  7474. return;
  7475. }
  7476. static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *asc_dvc, uchar syn_time)
  7477. {
  7478. uchar *period_table;
  7479. int max_index;
  7480. int min_index;
  7481. int i;
  7482. period_table = asc_dvc->sdtr_period_tbl;
  7483. max_index = (int)asc_dvc->max_sdtr_index;
  7484. min_index = (int)asc_dvc->host_init_sdtr_index;
  7485. if ((syn_time <= period_table[max_index])) {
  7486. for (i = min_index; i < (max_index - 1); i++) {
  7487. if (syn_time <= period_table[i]) {
  7488. return ((uchar)i);
  7489. }
  7490. }
  7491. return ((uchar)max_index);
  7492. } else {
  7493. return ((uchar)(max_index + 1));
  7494. }
  7495. }
  7496. static uchar AscAllocFreeQueue(PortAddr iop_base, uchar free_q_head)
  7497. {
  7498. ushort q_addr;
  7499. uchar next_qp;
  7500. uchar q_status;
  7501. q_addr = ASC_QNO_TO_QADDR(free_q_head);
  7502. q_status = (uchar)AscReadLramByte(iop_base,
  7503. (ushort)(q_addr +
  7504. ASC_SCSIQ_B_STATUS));
  7505. next_qp = AscReadLramByte(iop_base, (ushort)(q_addr + ASC_SCSIQ_B_FWD));
  7506. if (((q_status & QS_READY) == 0) && (next_qp != ASC_QLINK_END)) {
  7507. return (next_qp);
  7508. }
  7509. return (ASC_QLINK_END);
  7510. }
  7511. static uchar
  7512. AscAllocMultipleFreeQueue(PortAddr iop_base, uchar free_q_head, uchar n_free_q)
  7513. {
  7514. uchar i;
  7515. for (i = 0; i < n_free_q; i++) {
  7516. if ((free_q_head = AscAllocFreeQueue(iop_base, free_q_head))
  7517. == ASC_QLINK_END) {
  7518. return (ASC_QLINK_END);
  7519. }
  7520. }
  7521. return (free_q_head);
  7522. }
  7523. static int AscHostReqRiscHalt(PortAddr iop_base)
  7524. {
  7525. int count = 0;
  7526. int sta = 0;
  7527. uchar saved_stop_code;
  7528. if (AscIsChipHalted(iop_base))
  7529. return (1);
  7530. saved_stop_code = AscReadLramByte(iop_base, ASCV_STOP_CODE_B);
  7531. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  7532. ASC_STOP_HOST_REQ_RISC_HALT | ASC_STOP_REQ_RISC_STOP);
  7533. do {
  7534. if (AscIsChipHalted(iop_base)) {
  7535. sta = 1;
  7536. break;
  7537. }
  7538. DvcSleepMilliSecond(100);
  7539. } while (count++ < 20);
  7540. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, saved_stop_code);
  7541. return (sta);
  7542. }
  7543. static int AscStopQueueExe(PortAddr iop_base)
  7544. {
  7545. int count = 0;
  7546. if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) == 0) {
  7547. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  7548. ASC_STOP_REQ_RISC_STOP);
  7549. do {
  7550. if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) &
  7551. ASC_STOP_ACK_RISC_STOP) {
  7552. return (1);
  7553. }
  7554. DvcSleepMilliSecond(100);
  7555. } while (count++ < 20);
  7556. }
  7557. return (0);
  7558. }
  7559. static void DvcDelayMicroSecond(ADV_DVC_VAR *asc_dvc, ushort micro_sec)
  7560. {
  7561. udelay(micro_sec);
  7562. }
  7563. static void DvcDelayNanoSecond(ASC_DVC_VAR *asc_dvc, ASC_DCNT nano_sec)
  7564. {
  7565. udelay((nano_sec + 999) / 1000);
  7566. }
  7567. static int AscStartChip(PortAddr iop_base)
  7568. {
  7569. AscSetChipControl(iop_base, 0);
  7570. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  7571. return (0);
  7572. }
  7573. return (1);
  7574. }
  7575. static int AscStopChip(PortAddr iop_base)
  7576. {
  7577. uchar cc_val;
  7578. cc_val =
  7579. AscGetChipControl(iop_base) &
  7580. (~(CC_SINGLE_STEP | CC_TEST | CC_DIAG));
  7581. AscSetChipControl(iop_base, (uchar)(cc_val | CC_HALT));
  7582. AscSetChipIH(iop_base, INS_HALT);
  7583. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  7584. if ((AscGetChipStatus(iop_base) & CSW_HALTED) == 0) {
  7585. return (0);
  7586. }
  7587. return (1);
  7588. }
  7589. static int AscIsChipHalted(PortAddr iop_base)
  7590. {
  7591. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  7592. if ((AscGetChipControl(iop_base) & CC_HALT) != 0) {
  7593. return (1);
  7594. }
  7595. }
  7596. return (0);
  7597. }
  7598. static void AscSetChipIH(PortAddr iop_base, ushort ins_code)
  7599. {
  7600. AscSetBank(iop_base, 1);
  7601. AscWriteChipIH(iop_base, ins_code);
  7602. AscSetBank(iop_base, 0);
  7603. return;
  7604. }
  7605. static void AscAckInterrupt(PortAddr iop_base)
  7606. {
  7607. uchar host_flag;
  7608. uchar risc_flag;
  7609. ushort loop;
  7610. loop = 0;
  7611. do {
  7612. risc_flag = AscReadLramByte(iop_base, ASCV_RISC_FLAG_B);
  7613. if (loop++ > 0x7FFF) {
  7614. break;
  7615. }
  7616. } while ((risc_flag & ASC_RISC_FLAG_GEN_INT) != 0);
  7617. host_flag =
  7618. AscReadLramByte(iop_base,
  7619. ASCV_HOST_FLAG_B) & (~ASC_HOST_FLAG_ACK_INT);
  7620. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  7621. (uchar)(host_flag | ASC_HOST_FLAG_ACK_INT));
  7622. AscSetChipStatus(iop_base, CIW_INT_ACK);
  7623. loop = 0;
  7624. while (AscGetChipStatus(iop_base) & CSW_INT_PENDING) {
  7625. AscSetChipStatus(iop_base, CIW_INT_ACK);
  7626. if (loop++ > 3) {
  7627. break;
  7628. }
  7629. }
  7630. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  7631. return;
  7632. }
  7633. static void AscDisableInterrupt(PortAddr iop_base)
  7634. {
  7635. ushort cfg;
  7636. cfg = AscGetChipCfgLsw(iop_base);
  7637. AscSetChipCfgLsw(iop_base, cfg & (~ASC_CFG0_HOST_INT_ON));
  7638. return;
  7639. }
  7640. static void AscEnableInterrupt(PortAddr iop_base)
  7641. {
  7642. ushort cfg;
  7643. cfg = AscGetChipCfgLsw(iop_base);
  7644. AscSetChipCfgLsw(iop_base, cfg | ASC_CFG0_HOST_INT_ON);
  7645. return;
  7646. }
  7647. static void AscSetBank(PortAddr iop_base, uchar bank)
  7648. {
  7649. uchar val;
  7650. val = AscGetChipControl(iop_base) &
  7651. (~
  7652. (CC_SINGLE_STEP | CC_TEST | CC_DIAG | CC_SCSI_RESET |
  7653. CC_CHIP_RESET));
  7654. if (bank == 1) {
  7655. val |= CC_BANK_ONE;
  7656. } else if (bank == 2) {
  7657. val |= CC_DIAG | CC_BANK_ONE;
  7658. } else {
  7659. val &= ~CC_BANK_ONE;
  7660. }
  7661. AscSetChipControl(iop_base, val);
  7662. return;
  7663. }
  7664. static int AscResetChipAndScsiBus(ASC_DVC_VAR *asc_dvc)
  7665. {
  7666. PortAddr iop_base;
  7667. int i = 10;
  7668. iop_base = asc_dvc->iop_base;
  7669. while ((AscGetChipStatus(iop_base) & CSW_SCSI_RESET_ACTIVE)
  7670. && (i-- > 0)) {
  7671. DvcSleepMilliSecond(100);
  7672. }
  7673. AscStopChip(iop_base);
  7674. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_SCSI_RESET | CC_HALT);
  7675. DvcDelayNanoSecond(asc_dvc, 60000);
  7676. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  7677. AscSetChipIH(iop_base, INS_HALT);
  7678. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_HALT);
  7679. AscSetChipControl(iop_base, CC_HALT);
  7680. DvcSleepMilliSecond(200);
  7681. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  7682. AscSetChipStatus(iop_base, 0);
  7683. return (AscIsChipHalted(iop_base));
  7684. }
  7685. static ASC_DCNT __devinit AscGetMaxDmaCount(ushort bus_type)
  7686. {
  7687. if (bus_type & ASC_IS_ISA)
  7688. return (ASC_MAX_ISA_DMA_COUNT);
  7689. else if (bus_type & (ASC_IS_EISA | ASC_IS_VL))
  7690. return (ASC_MAX_VL_DMA_COUNT);
  7691. return (ASC_MAX_PCI_DMA_COUNT);
  7692. }
  7693. #ifdef CONFIG_ISA
  7694. static ushort __devinit AscGetIsaDmaChannel(PortAddr iop_base)
  7695. {
  7696. ushort channel;
  7697. channel = AscGetChipCfgLsw(iop_base) & 0x0003;
  7698. if (channel == 0x03)
  7699. return (0);
  7700. else if (channel == 0x00)
  7701. return (7);
  7702. return (channel + 4);
  7703. }
  7704. static ushort __devinit AscSetIsaDmaChannel(PortAddr iop_base, ushort dma_channel)
  7705. {
  7706. ushort cfg_lsw;
  7707. uchar value;
  7708. if ((dma_channel >= 5) && (dma_channel <= 7)) {
  7709. if (dma_channel == 7)
  7710. value = 0x00;
  7711. else
  7712. value = dma_channel - 4;
  7713. cfg_lsw = AscGetChipCfgLsw(iop_base) & 0xFFFC;
  7714. cfg_lsw |= value;
  7715. AscSetChipCfgLsw(iop_base, cfg_lsw);
  7716. return (AscGetIsaDmaChannel(iop_base));
  7717. }
  7718. return (0);
  7719. }
  7720. static uchar __devinit AscSetIsaDmaSpeed(PortAddr iop_base, uchar speed_value)
  7721. {
  7722. speed_value &= 0x07;
  7723. AscSetBank(iop_base, 1);
  7724. AscWriteChipDmaSpeed(iop_base, speed_value);
  7725. AscSetBank(iop_base, 0);
  7726. return (AscGetIsaDmaSpeed(iop_base));
  7727. }
  7728. static uchar __devinit AscGetIsaDmaSpeed(PortAddr iop_base)
  7729. {
  7730. uchar speed_value;
  7731. AscSetBank(iop_base, 1);
  7732. speed_value = AscReadChipDmaSpeed(iop_base);
  7733. speed_value &= 0x07;
  7734. AscSetBank(iop_base, 0);
  7735. return (speed_value);
  7736. }
  7737. #endif /* CONFIG_ISA */
  7738. static int __devinit AscInitGetConfig(asc_board_t *boardp)
  7739. {
  7740. ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  7741. unsigned short warn_code = 0;
  7742. asc_dvc->init_state = ASC_INIT_STATE_BEG_GET_CFG;
  7743. if (asc_dvc->err_code != 0)
  7744. return asc_dvc->err_code;
  7745. if (AscFindSignature(asc_dvc->iop_base)) {
  7746. warn_code |= AscInitAscDvcVar(asc_dvc);
  7747. warn_code |= AscInitFromEEP(asc_dvc);
  7748. asc_dvc->init_state |= ASC_INIT_STATE_END_GET_CFG;
  7749. if (asc_dvc->scsi_reset_wait > ASC_MAX_SCSI_RESET_WAIT)
  7750. asc_dvc->scsi_reset_wait = ASC_MAX_SCSI_RESET_WAIT;
  7751. } else {
  7752. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  7753. }
  7754. switch (warn_code) {
  7755. case 0: /* No error */
  7756. break;
  7757. case ASC_WARN_IO_PORT_ROTATE:
  7758. ASC_PRINT1("AscInitGetConfig: board %d: I/O port address "
  7759. "modified\n", boardp->id);
  7760. break;
  7761. case ASC_WARN_AUTO_CONFIG:
  7762. ASC_PRINT1("AscInitGetConfig: board %d: I/O port increment "
  7763. "switch enabled\n", boardp->id);
  7764. break;
  7765. case ASC_WARN_EEPROM_CHKSUM:
  7766. ASC_PRINT1("AscInitGetConfig: board %d: EEPROM checksum "
  7767. "error\n", boardp->id);
  7768. break;
  7769. case ASC_WARN_IRQ_MODIFIED:
  7770. ASC_PRINT1("AscInitGetConfig: board %d: IRQ modified\n",
  7771. boardp->id);
  7772. break;
  7773. case ASC_WARN_CMD_QNG_CONFLICT:
  7774. ASC_PRINT1("AscInitGetConfig: board %d: tag queuing enabled "
  7775. "w/o disconnects\n", boardp->id);
  7776. break;
  7777. default:
  7778. ASC_PRINT2("AscInitGetConfig: board %d: unknown warning: "
  7779. "0x%x\n", boardp->id, warn_code);
  7780. break;
  7781. }
  7782. if (asc_dvc->err_code != 0) {
  7783. ASC_PRINT3("AscInitGetConfig: board %d error: init_state 0x%x, "
  7784. "err_code 0x%x\n", boardp->id, asc_dvc->init_state,
  7785. asc_dvc->err_code);
  7786. }
  7787. return asc_dvc->err_code;
  7788. }
  7789. static int __devinit AscInitSetConfig(struct pci_dev *pdev, asc_board_t *boardp)
  7790. {
  7791. ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  7792. PortAddr iop_base = asc_dvc->iop_base;
  7793. unsigned short cfg_msw;
  7794. unsigned short warn_code = 0;
  7795. asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
  7796. if (asc_dvc->err_code != 0)
  7797. return asc_dvc->err_code;
  7798. if (!AscFindSignature(asc_dvc->iop_base)) {
  7799. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  7800. return asc_dvc->err_code;
  7801. }
  7802. cfg_msw = AscGetChipCfgMsw(iop_base);
  7803. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  7804. cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  7805. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  7806. AscSetChipCfgMsw(iop_base, cfg_msw);
  7807. }
  7808. if ((asc_dvc->cfg->cmd_qng_enabled & asc_dvc->cfg->disc_enable) !=
  7809. asc_dvc->cfg->cmd_qng_enabled) {
  7810. asc_dvc->cfg->disc_enable = asc_dvc->cfg->cmd_qng_enabled;
  7811. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  7812. }
  7813. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  7814. warn_code |= ASC_WARN_AUTO_CONFIG;
  7815. }
  7816. if ((asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL)) != 0) {
  7817. if (AscSetChipIRQ(iop_base, asc_dvc->irq_no, asc_dvc->bus_type)
  7818. != asc_dvc->irq_no) {
  7819. asc_dvc->err_code |= ASC_IERR_SET_IRQ_NO;
  7820. }
  7821. }
  7822. #ifdef CONFIG_PCI
  7823. if (asc_dvc->bus_type & ASC_IS_PCI) {
  7824. cfg_msw &= 0xFFC0;
  7825. AscSetChipCfgMsw(iop_base, cfg_msw);
  7826. if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) {
  7827. } else {
  7828. if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
  7829. (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
  7830. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_IF_NOT_DWB;
  7831. asc_dvc->bug_fix_cntl |=
  7832. ASC_BUG_FIX_ASYN_USE_SYN;
  7833. }
  7834. }
  7835. } else
  7836. #endif /* CONFIG_PCI */
  7837. if (asc_dvc->bus_type == ASC_IS_ISAPNP) {
  7838. if (AscGetChipVersion(iop_base, asc_dvc->bus_type)
  7839. == ASC_CHIP_VER_ASYN_BUG) {
  7840. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN;
  7841. }
  7842. }
  7843. if (AscSetChipScsiID(iop_base, asc_dvc->cfg->chip_scsi_id) !=
  7844. asc_dvc->cfg->chip_scsi_id) {
  7845. asc_dvc->err_code |= ASC_IERR_SET_SCSI_ID;
  7846. }
  7847. #ifdef CONFIG_ISA
  7848. if (asc_dvc->bus_type & ASC_IS_ISA) {
  7849. AscSetIsaDmaChannel(iop_base, asc_dvc->cfg->isa_dma_channel);
  7850. AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed);
  7851. }
  7852. #endif /* CONFIG_ISA */
  7853. asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
  7854. switch (warn_code) {
  7855. case 0: /* No error. */
  7856. break;
  7857. case ASC_WARN_IO_PORT_ROTATE:
  7858. ASC_PRINT1("AscInitSetConfig: board %d: I/O port address "
  7859. "modified\n", boardp->id);
  7860. break;
  7861. case ASC_WARN_AUTO_CONFIG:
  7862. ASC_PRINT1("AscInitSetConfig: board %d: I/O port increment "
  7863. "switch enabled\n", boardp->id);
  7864. break;
  7865. case ASC_WARN_EEPROM_CHKSUM:
  7866. ASC_PRINT1("AscInitSetConfig: board %d: EEPROM checksum "
  7867. "error\n", boardp->id);
  7868. break;
  7869. case ASC_WARN_IRQ_MODIFIED:
  7870. ASC_PRINT1("AscInitSetConfig: board %d: IRQ modified\n",
  7871. boardp->id);
  7872. break;
  7873. case ASC_WARN_CMD_QNG_CONFLICT:
  7874. ASC_PRINT1("AscInitSetConfig: board %d: tag queuing w/o "
  7875. "disconnects\n",
  7876. boardp->id);
  7877. break;
  7878. default:
  7879. ASC_PRINT2("AscInitSetConfig: board %d: unknown warning: "
  7880. "0x%x\n", boardp->id, warn_code);
  7881. break;
  7882. }
  7883. if (asc_dvc->err_code != 0) {
  7884. ASC_PRINT3("AscInitSetConfig: board %d error: init_state 0x%x, "
  7885. "err_code 0x%x\n", boardp->id, asc_dvc->init_state,
  7886. asc_dvc->err_code);
  7887. }
  7888. return asc_dvc->err_code;
  7889. }
  7890. static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
  7891. {
  7892. ushort warn_code;
  7893. PortAddr iop_base;
  7894. iop_base = asc_dvc->iop_base;
  7895. warn_code = 0;
  7896. if ((asc_dvc->dvc_cntl & ASC_CNTL_RESET_SCSI) &&
  7897. !(asc_dvc->init_state & ASC_INIT_RESET_SCSI_DONE)) {
  7898. AscResetChipAndScsiBus(asc_dvc);
  7899. DvcSleepMilliSecond((ASC_DCNT)
  7900. ((ushort)asc_dvc->scsi_reset_wait * 1000));
  7901. }
  7902. asc_dvc->init_state |= ASC_INIT_STATE_BEG_LOAD_MC;
  7903. if (asc_dvc->err_code != 0)
  7904. return (UW_ERR);
  7905. if (!AscFindSignature(asc_dvc->iop_base)) {
  7906. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  7907. return (warn_code);
  7908. }
  7909. AscDisableInterrupt(iop_base);
  7910. warn_code |= AscInitLram(asc_dvc);
  7911. if (asc_dvc->err_code != 0)
  7912. return (UW_ERR);
  7913. ASC_DBG1(1, "AscInitAsc1000Driver: _asc_mcode_chksum 0x%lx\n",
  7914. (ulong)_asc_mcode_chksum);
  7915. if (AscLoadMicroCode(iop_base, 0, _asc_mcode_buf,
  7916. _asc_mcode_size) != _asc_mcode_chksum) {
  7917. asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
  7918. return (warn_code);
  7919. }
  7920. warn_code |= AscInitMicroCodeVar(asc_dvc);
  7921. asc_dvc->init_state |= ASC_INIT_STATE_END_LOAD_MC;
  7922. AscEnableInterrupt(iop_base);
  7923. return (warn_code);
  7924. }
  7925. static ushort __devinit AscInitAscDvcVar(ASC_DVC_VAR *asc_dvc)
  7926. {
  7927. int i;
  7928. PortAddr iop_base;
  7929. ushort warn_code;
  7930. uchar chip_version;
  7931. iop_base = asc_dvc->iop_base;
  7932. warn_code = 0;
  7933. asc_dvc->err_code = 0;
  7934. if ((asc_dvc->bus_type &
  7935. (ASC_IS_ISA | ASC_IS_PCI | ASC_IS_EISA | ASC_IS_VL)) == 0) {
  7936. asc_dvc->err_code |= ASC_IERR_NO_BUS_TYPE;
  7937. }
  7938. AscSetChipControl(iop_base, CC_HALT);
  7939. AscSetChipStatus(iop_base, 0);
  7940. asc_dvc->bug_fix_cntl = 0;
  7941. asc_dvc->pci_fix_asyn_xfer = 0;
  7942. asc_dvc->pci_fix_asyn_xfer_always = 0;
  7943. /* asc_dvc->init_state initalized in AscInitGetConfig(). */
  7944. asc_dvc->sdtr_done = 0;
  7945. asc_dvc->cur_total_qng = 0;
  7946. asc_dvc->is_in_int = 0;
  7947. asc_dvc->in_critical_cnt = 0;
  7948. asc_dvc->last_q_shortage = 0;
  7949. asc_dvc->use_tagged_qng = 0;
  7950. asc_dvc->no_scam = 0;
  7951. asc_dvc->unit_not_ready = 0;
  7952. asc_dvc->queue_full_or_busy = 0;
  7953. asc_dvc->redo_scam = 0;
  7954. asc_dvc->res2 = 0;
  7955. asc_dvc->host_init_sdtr_index = 0;
  7956. asc_dvc->cfg->can_tagged_qng = 0;
  7957. asc_dvc->cfg->cmd_qng_enabled = 0;
  7958. asc_dvc->dvc_cntl = ASC_DEF_DVC_CNTL;
  7959. asc_dvc->init_sdtr = 0;
  7960. asc_dvc->max_total_qng = ASC_DEF_MAX_TOTAL_QNG;
  7961. asc_dvc->scsi_reset_wait = 3;
  7962. asc_dvc->start_motor = ASC_SCSI_WIDTH_BIT_SET;
  7963. asc_dvc->max_dma_count = AscGetMaxDmaCount(asc_dvc->bus_type);
  7964. asc_dvc->cfg->sdtr_enable = ASC_SCSI_WIDTH_BIT_SET;
  7965. asc_dvc->cfg->disc_enable = ASC_SCSI_WIDTH_BIT_SET;
  7966. asc_dvc->cfg->chip_scsi_id = ASC_DEF_CHIP_SCSI_ID;
  7967. asc_dvc->cfg->lib_serial_no = ASC_LIB_SERIAL_NUMBER;
  7968. asc_dvc->cfg->lib_version = (ASC_LIB_VERSION_MAJOR << 8) |
  7969. ASC_LIB_VERSION_MINOR;
  7970. chip_version = AscGetChipVersion(iop_base, asc_dvc->bus_type);
  7971. asc_dvc->cfg->chip_version = chip_version;
  7972. asc_dvc->sdtr_period_tbl[0] = SYN_XFER_NS_0;
  7973. asc_dvc->sdtr_period_tbl[1] = SYN_XFER_NS_1;
  7974. asc_dvc->sdtr_period_tbl[2] = SYN_XFER_NS_2;
  7975. asc_dvc->sdtr_period_tbl[3] = SYN_XFER_NS_3;
  7976. asc_dvc->sdtr_period_tbl[4] = SYN_XFER_NS_4;
  7977. asc_dvc->sdtr_period_tbl[5] = SYN_XFER_NS_5;
  7978. asc_dvc->sdtr_period_tbl[6] = SYN_XFER_NS_6;
  7979. asc_dvc->sdtr_period_tbl[7] = SYN_XFER_NS_7;
  7980. asc_dvc->max_sdtr_index = 7;
  7981. if ((asc_dvc->bus_type & ASC_IS_PCI) &&
  7982. (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3150)) {
  7983. asc_dvc->bus_type = ASC_IS_PCI_ULTRA;
  7984. asc_dvc->sdtr_period_tbl[0] = SYN_ULTRA_XFER_NS_0;
  7985. asc_dvc->sdtr_period_tbl[1] = SYN_ULTRA_XFER_NS_1;
  7986. asc_dvc->sdtr_period_tbl[2] = SYN_ULTRA_XFER_NS_2;
  7987. asc_dvc->sdtr_period_tbl[3] = SYN_ULTRA_XFER_NS_3;
  7988. asc_dvc->sdtr_period_tbl[4] = SYN_ULTRA_XFER_NS_4;
  7989. asc_dvc->sdtr_period_tbl[5] = SYN_ULTRA_XFER_NS_5;
  7990. asc_dvc->sdtr_period_tbl[6] = SYN_ULTRA_XFER_NS_6;
  7991. asc_dvc->sdtr_period_tbl[7] = SYN_ULTRA_XFER_NS_7;
  7992. asc_dvc->sdtr_period_tbl[8] = SYN_ULTRA_XFER_NS_8;
  7993. asc_dvc->sdtr_period_tbl[9] = SYN_ULTRA_XFER_NS_9;
  7994. asc_dvc->sdtr_period_tbl[10] = SYN_ULTRA_XFER_NS_10;
  7995. asc_dvc->sdtr_period_tbl[11] = SYN_ULTRA_XFER_NS_11;
  7996. asc_dvc->sdtr_period_tbl[12] = SYN_ULTRA_XFER_NS_12;
  7997. asc_dvc->sdtr_period_tbl[13] = SYN_ULTRA_XFER_NS_13;
  7998. asc_dvc->sdtr_period_tbl[14] = SYN_ULTRA_XFER_NS_14;
  7999. asc_dvc->sdtr_period_tbl[15] = SYN_ULTRA_XFER_NS_15;
  8000. asc_dvc->max_sdtr_index = 15;
  8001. if (chip_version == ASC_CHIP_VER_PCI_ULTRA_3150) {
  8002. AscSetExtraControl(iop_base,
  8003. (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  8004. } else if (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3050) {
  8005. AscSetExtraControl(iop_base,
  8006. (SEC_ACTIVE_NEGATE |
  8007. SEC_ENABLE_FILTER));
  8008. }
  8009. }
  8010. if (asc_dvc->bus_type == ASC_IS_PCI) {
  8011. AscSetExtraControl(iop_base,
  8012. (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  8013. }
  8014. asc_dvc->cfg->isa_dma_speed = ASC_DEF_ISA_DMA_SPEED;
  8015. #ifdef CONFIG_ISA
  8016. if ((asc_dvc->bus_type & ASC_IS_ISA) != 0) {
  8017. if (chip_version >= ASC_CHIP_MIN_VER_ISA_PNP) {
  8018. AscSetChipIFC(iop_base, IFC_INIT_DEFAULT);
  8019. asc_dvc->bus_type = ASC_IS_ISAPNP;
  8020. }
  8021. asc_dvc->cfg->isa_dma_channel =
  8022. (uchar)AscGetIsaDmaChannel(iop_base);
  8023. }
  8024. #endif /* CONFIG_ISA */
  8025. for (i = 0; i <= ASC_MAX_TID; i++) {
  8026. asc_dvc->cur_dvc_qng[i] = 0;
  8027. asc_dvc->max_dvc_qng[i] = ASC_MAX_SCSI1_QNG;
  8028. asc_dvc->scsiq_busy_head[i] = (ASC_SCSI_Q *)0L;
  8029. asc_dvc->scsiq_busy_tail[i] = (ASC_SCSI_Q *)0L;
  8030. asc_dvc->cfg->max_tag_qng[i] = ASC_MAX_INRAM_TAG_QNG;
  8031. }
  8032. return (warn_code);
  8033. }
  8034. static ushort __devinit AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
  8035. {
  8036. ASCEEP_CONFIG eep_config_buf;
  8037. ASCEEP_CONFIG *eep_config;
  8038. PortAddr iop_base;
  8039. ushort chksum;
  8040. ushort warn_code;
  8041. ushort cfg_msw, cfg_lsw;
  8042. int i;
  8043. int write_eep = 0;
  8044. iop_base = asc_dvc->iop_base;
  8045. warn_code = 0;
  8046. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0x00FE);
  8047. AscStopQueueExe(iop_base);
  8048. if ((AscStopChip(iop_base) == FALSE) ||
  8049. (AscGetChipScsiCtrl(iop_base) != 0)) {
  8050. asc_dvc->init_state |= ASC_INIT_RESET_SCSI_DONE;
  8051. AscResetChipAndScsiBus(asc_dvc);
  8052. DvcSleepMilliSecond((ASC_DCNT)
  8053. ((ushort)asc_dvc->scsi_reset_wait * 1000));
  8054. }
  8055. if (AscIsChipHalted(iop_base) == FALSE) {
  8056. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  8057. return (warn_code);
  8058. }
  8059. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  8060. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  8061. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  8062. return (warn_code);
  8063. }
  8064. eep_config = (ASCEEP_CONFIG *)&eep_config_buf;
  8065. cfg_msw = AscGetChipCfgMsw(iop_base);
  8066. cfg_lsw = AscGetChipCfgLsw(iop_base);
  8067. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  8068. cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  8069. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  8070. AscSetChipCfgMsw(iop_base, cfg_msw);
  8071. }
  8072. chksum = AscGetEEPConfig(iop_base, eep_config, asc_dvc->bus_type);
  8073. ASC_DBG1(1, "AscInitFromEEP: chksum 0x%x\n", chksum);
  8074. if (chksum == 0) {
  8075. chksum = 0xaa55;
  8076. }
  8077. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  8078. warn_code |= ASC_WARN_AUTO_CONFIG;
  8079. if (asc_dvc->cfg->chip_version == 3) {
  8080. if (eep_config->cfg_lsw != cfg_lsw) {
  8081. warn_code |= ASC_WARN_EEPROM_RECOVER;
  8082. eep_config->cfg_lsw =
  8083. AscGetChipCfgLsw(iop_base);
  8084. }
  8085. if (eep_config->cfg_msw != cfg_msw) {
  8086. warn_code |= ASC_WARN_EEPROM_RECOVER;
  8087. eep_config->cfg_msw =
  8088. AscGetChipCfgMsw(iop_base);
  8089. }
  8090. }
  8091. }
  8092. eep_config->cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  8093. eep_config->cfg_lsw |= ASC_CFG0_HOST_INT_ON;
  8094. ASC_DBG1(1, "AscInitFromEEP: eep_config->chksum 0x%x\n",
  8095. eep_config->chksum);
  8096. if (chksum != eep_config->chksum) {
  8097. if (AscGetChipVersion(iop_base, asc_dvc->bus_type) ==
  8098. ASC_CHIP_VER_PCI_ULTRA_3050) {
  8099. ASC_DBG(1,
  8100. "AscInitFromEEP: chksum error ignored; EEPROM-less board\n");
  8101. eep_config->init_sdtr = 0xFF;
  8102. eep_config->disc_enable = 0xFF;
  8103. eep_config->start_motor = 0xFF;
  8104. eep_config->use_cmd_qng = 0;
  8105. eep_config->max_total_qng = 0xF0;
  8106. eep_config->max_tag_qng = 0x20;
  8107. eep_config->cntl = 0xBFFF;
  8108. ASC_EEP_SET_CHIP_ID(eep_config, 7);
  8109. eep_config->no_scam = 0;
  8110. eep_config->adapter_info[0] = 0;
  8111. eep_config->adapter_info[1] = 0;
  8112. eep_config->adapter_info[2] = 0;
  8113. eep_config->adapter_info[3] = 0;
  8114. eep_config->adapter_info[4] = 0;
  8115. /* Indicate EEPROM-less board. */
  8116. eep_config->adapter_info[5] = 0xBB;
  8117. } else {
  8118. ASC_PRINT
  8119. ("AscInitFromEEP: EEPROM checksum error; Will try to re-write EEPROM.\n");
  8120. write_eep = 1;
  8121. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  8122. }
  8123. }
  8124. asc_dvc->cfg->sdtr_enable = eep_config->init_sdtr;
  8125. asc_dvc->cfg->disc_enable = eep_config->disc_enable;
  8126. asc_dvc->cfg->cmd_qng_enabled = eep_config->use_cmd_qng;
  8127. asc_dvc->cfg->isa_dma_speed = ASC_EEP_GET_DMA_SPD(eep_config);
  8128. asc_dvc->start_motor = eep_config->start_motor;
  8129. asc_dvc->dvc_cntl = eep_config->cntl;
  8130. asc_dvc->no_scam = eep_config->no_scam;
  8131. asc_dvc->cfg->adapter_info[0] = eep_config->adapter_info[0];
  8132. asc_dvc->cfg->adapter_info[1] = eep_config->adapter_info[1];
  8133. asc_dvc->cfg->adapter_info[2] = eep_config->adapter_info[2];
  8134. asc_dvc->cfg->adapter_info[3] = eep_config->adapter_info[3];
  8135. asc_dvc->cfg->adapter_info[4] = eep_config->adapter_info[4];
  8136. asc_dvc->cfg->adapter_info[5] = eep_config->adapter_info[5];
  8137. if (!AscTestExternalLram(asc_dvc)) {
  8138. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) ==
  8139. ASC_IS_PCI_ULTRA)) {
  8140. eep_config->max_total_qng =
  8141. ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG;
  8142. eep_config->max_tag_qng =
  8143. ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG;
  8144. } else {
  8145. eep_config->cfg_msw |= 0x0800;
  8146. cfg_msw |= 0x0800;
  8147. AscSetChipCfgMsw(iop_base, cfg_msw);
  8148. eep_config->max_total_qng = ASC_MAX_PCI_INRAM_TOTAL_QNG;
  8149. eep_config->max_tag_qng = ASC_MAX_INRAM_TAG_QNG;
  8150. }
  8151. } else {
  8152. }
  8153. if (eep_config->max_total_qng < ASC_MIN_TOTAL_QNG) {
  8154. eep_config->max_total_qng = ASC_MIN_TOTAL_QNG;
  8155. }
  8156. if (eep_config->max_total_qng > ASC_MAX_TOTAL_QNG) {
  8157. eep_config->max_total_qng = ASC_MAX_TOTAL_QNG;
  8158. }
  8159. if (eep_config->max_tag_qng > eep_config->max_total_qng) {
  8160. eep_config->max_tag_qng = eep_config->max_total_qng;
  8161. }
  8162. if (eep_config->max_tag_qng < ASC_MIN_TAG_Q_PER_DVC) {
  8163. eep_config->max_tag_qng = ASC_MIN_TAG_Q_PER_DVC;
  8164. }
  8165. asc_dvc->max_total_qng = eep_config->max_total_qng;
  8166. if ((eep_config->use_cmd_qng & eep_config->disc_enable) !=
  8167. eep_config->use_cmd_qng) {
  8168. eep_config->disc_enable = eep_config->use_cmd_qng;
  8169. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  8170. }
  8171. if (asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL | ASC_IS_EISA)) {
  8172. asc_dvc->irq_no = AscGetChipIRQ(iop_base, asc_dvc->bus_type);
  8173. }
  8174. ASC_EEP_SET_CHIP_ID(eep_config,
  8175. ASC_EEP_GET_CHIP_ID(eep_config) & ASC_MAX_TID);
  8176. asc_dvc->cfg->chip_scsi_id = ASC_EEP_GET_CHIP_ID(eep_config);
  8177. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) &&
  8178. !(asc_dvc->dvc_cntl & ASC_CNTL_SDTR_ENABLE_ULTRA)) {
  8179. asc_dvc->host_init_sdtr_index = ASC_SDTR_ULTRA_PCI_10MB_INDEX;
  8180. }
  8181. for (i = 0; i <= ASC_MAX_TID; i++) {
  8182. asc_dvc->dos_int13_table[i] = eep_config->dos_int13_table[i];
  8183. asc_dvc->cfg->max_tag_qng[i] = eep_config->max_tag_qng;
  8184. asc_dvc->cfg->sdtr_period_offset[i] =
  8185. (uchar)(ASC_DEF_SDTR_OFFSET |
  8186. (asc_dvc->host_init_sdtr_index << 4));
  8187. }
  8188. eep_config->cfg_msw = AscGetChipCfgMsw(iop_base);
  8189. if (write_eep) {
  8190. if ((i =
  8191. AscSetEEPConfig(iop_base, eep_config,
  8192. asc_dvc->bus_type)) != 0) {
  8193. ASC_PRINT1
  8194. ("AscInitFromEEP: Failed to re-write EEPROM with %d errors.\n",
  8195. i);
  8196. } else {
  8197. ASC_PRINT
  8198. ("AscInitFromEEP: Successfully re-wrote EEPROM.\n");
  8199. }
  8200. }
  8201. return (warn_code);
  8202. }
  8203. static ushort AscInitMicroCodeVar(ASC_DVC_VAR *asc_dvc)
  8204. {
  8205. int i;
  8206. ushort warn_code;
  8207. PortAddr iop_base;
  8208. ASC_PADDR phy_addr;
  8209. ASC_DCNT phy_size;
  8210. iop_base = asc_dvc->iop_base;
  8211. warn_code = 0;
  8212. for (i = 0; i <= ASC_MAX_TID; i++) {
  8213. AscPutMCodeInitSDTRAtID(iop_base, i,
  8214. asc_dvc->cfg->sdtr_period_offset[i]
  8215. );
  8216. }
  8217. AscInitQLinkVar(asc_dvc);
  8218. AscWriteLramByte(iop_base, ASCV_DISC_ENABLE_B,
  8219. asc_dvc->cfg->disc_enable);
  8220. AscWriteLramByte(iop_base, ASCV_HOSTSCSI_ID_B,
  8221. ASC_TID_TO_TARGET_ID(asc_dvc->cfg->chip_scsi_id));
  8222. /* Align overrun buffer on an 8 byte boundary. */
  8223. phy_addr = virt_to_bus(asc_dvc->cfg->overrun_buf);
  8224. phy_addr = cpu_to_le32((phy_addr + 7) & ~0x7);
  8225. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_PADDR_D,
  8226. (uchar *)&phy_addr, 1);
  8227. phy_size = cpu_to_le32(ASC_OVERRUN_BSIZE - 8);
  8228. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_BSIZE_D,
  8229. (uchar *)&phy_size, 1);
  8230. asc_dvc->cfg->mcode_date =
  8231. AscReadLramWord(iop_base, (ushort)ASCV_MC_DATE_W);
  8232. asc_dvc->cfg->mcode_version =
  8233. AscReadLramWord(iop_base, (ushort)ASCV_MC_VER_W);
  8234. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  8235. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  8236. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  8237. return (warn_code);
  8238. }
  8239. if (AscStartChip(iop_base) != 1) {
  8240. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  8241. return (warn_code);
  8242. }
  8243. return (warn_code);
  8244. }
  8245. static int __devinit AscTestExternalLram(ASC_DVC_VAR *asc_dvc)
  8246. {
  8247. PortAddr iop_base;
  8248. ushort q_addr;
  8249. ushort saved_word;
  8250. int sta;
  8251. iop_base = asc_dvc->iop_base;
  8252. sta = 0;
  8253. q_addr = ASC_QNO_TO_QADDR(241);
  8254. saved_word = AscReadLramWord(iop_base, q_addr);
  8255. AscSetChipLramAddr(iop_base, q_addr);
  8256. AscSetChipLramData(iop_base, 0x55AA);
  8257. DvcSleepMilliSecond(10);
  8258. AscSetChipLramAddr(iop_base, q_addr);
  8259. if (AscGetChipLramData(iop_base) == 0x55AA) {
  8260. sta = 1;
  8261. AscWriteLramWord(iop_base, q_addr, saved_word);
  8262. }
  8263. return (sta);
  8264. }
  8265. static int __devinit AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg)
  8266. {
  8267. uchar read_back;
  8268. int retry;
  8269. retry = 0;
  8270. while (TRUE) {
  8271. AscSetChipEEPCmd(iop_base, cmd_reg);
  8272. DvcSleepMilliSecond(1);
  8273. read_back = AscGetChipEEPCmd(iop_base);
  8274. if (read_back == cmd_reg) {
  8275. return (1);
  8276. }
  8277. if (retry++ > ASC_EEP_MAX_RETRY) {
  8278. return (0);
  8279. }
  8280. }
  8281. }
  8282. static int __devinit AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg)
  8283. {
  8284. ushort read_back;
  8285. int retry;
  8286. retry = 0;
  8287. while (TRUE) {
  8288. AscSetChipEEPData(iop_base, data_reg);
  8289. DvcSleepMilliSecond(1);
  8290. read_back = AscGetChipEEPData(iop_base);
  8291. if (read_back == data_reg) {
  8292. return (1);
  8293. }
  8294. if (retry++ > ASC_EEP_MAX_RETRY) {
  8295. return (0);
  8296. }
  8297. }
  8298. }
  8299. static void __devinit AscWaitEEPRead(void)
  8300. {
  8301. DvcSleepMilliSecond(1);
  8302. return;
  8303. }
  8304. static void __devinit AscWaitEEPWrite(void)
  8305. {
  8306. DvcSleepMilliSecond(20);
  8307. return;
  8308. }
  8309. static ushort __devinit AscReadEEPWord(PortAddr iop_base, uchar addr)
  8310. {
  8311. ushort read_wval;
  8312. uchar cmd_reg;
  8313. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  8314. AscWaitEEPRead();
  8315. cmd_reg = addr | ASC_EEP_CMD_READ;
  8316. AscWriteEEPCmdReg(iop_base, cmd_reg);
  8317. AscWaitEEPRead();
  8318. read_wval = AscGetChipEEPData(iop_base);
  8319. AscWaitEEPRead();
  8320. return (read_wval);
  8321. }
  8322. static ushort __devinit
  8323. AscWriteEEPWord(PortAddr iop_base, uchar addr, ushort word_val)
  8324. {
  8325. ushort read_wval;
  8326. read_wval = AscReadEEPWord(iop_base, addr);
  8327. if (read_wval != word_val) {
  8328. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_ABLE);
  8329. AscWaitEEPRead();
  8330. AscWriteEEPDataReg(iop_base, word_val);
  8331. AscWaitEEPRead();
  8332. AscWriteEEPCmdReg(iop_base,
  8333. (uchar)((uchar)ASC_EEP_CMD_WRITE | addr));
  8334. AscWaitEEPWrite();
  8335. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  8336. AscWaitEEPRead();
  8337. return (AscReadEEPWord(iop_base, addr));
  8338. }
  8339. return (read_wval);
  8340. }
  8341. static ushort __devinit
  8342. AscGetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  8343. {
  8344. ushort wval;
  8345. ushort sum;
  8346. ushort *wbuf;
  8347. int cfg_beg;
  8348. int cfg_end;
  8349. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  8350. int s_addr;
  8351. wbuf = (ushort *)cfg_buf;
  8352. sum = 0;
  8353. /* Read two config words; Byte-swapping done by AscReadEEPWord(). */
  8354. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  8355. *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
  8356. sum += *wbuf;
  8357. }
  8358. if (bus_type & ASC_IS_VL) {
  8359. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  8360. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  8361. } else {
  8362. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  8363. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  8364. }
  8365. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  8366. wval = AscReadEEPWord(iop_base, (uchar)s_addr);
  8367. if (s_addr <= uchar_end_in_config) {
  8368. /*
  8369. * Swap all char fields - must unswap bytes already swapped
  8370. * by AscReadEEPWord().
  8371. */
  8372. *wbuf = le16_to_cpu(wval);
  8373. } else {
  8374. /* Don't swap word field at the end - cntl field. */
  8375. *wbuf = wval;
  8376. }
  8377. sum += wval; /* Checksum treats all EEPROM data as words. */
  8378. }
  8379. /*
  8380. * Read the checksum word which will be compared against 'sum'
  8381. * by the caller. Word field already swapped.
  8382. */
  8383. *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
  8384. return (sum);
  8385. }
  8386. static int __devinit
  8387. AscSetEEPConfigOnce(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  8388. {
  8389. int n_error;
  8390. ushort *wbuf;
  8391. ushort word;
  8392. ushort sum;
  8393. int s_addr;
  8394. int cfg_beg;
  8395. int cfg_end;
  8396. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  8397. wbuf = (ushort *)cfg_buf;
  8398. n_error = 0;
  8399. sum = 0;
  8400. /* Write two config words; AscWriteEEPWord() will swap bytes. */
  8401. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  8402. sum += *wbuf;
  8403. if (*wbuf != AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
  8404. n_error++;
  8405. }
  8406. }
  8407. if (bus_type & ASC_IS_VL) {
  8408. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  8409. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  8410. } else {
  8411. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  8412. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  8413. }
  8414. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  8415. if (s_addr <= uchar_end_in_config) {
  8416. /*
  8417. * This is a char field. Swap char fields before they are
  8418. * swapped again by AscWriteEEPWord().
  8419. */
  8420. word = cpu_to_le16(*wbuf);
  8421. if (word !=
  8422. AscWriteEEPWord(iop_base, (uchar)s_addr, word)) {
  8423. n_error++;
  8424. }
  8425. } else {
  8426. /* Don't swap word field at the end - cntl field. */
  8427. if (*wbuf !=
  8428. AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
  8429. n_error++;
  8430. }
  8431. }
  8432. sum += *wbuf; /* Checksum calculated from word values. */
  8433. }
  8434. /* Write checksum word. It will be swapped by AscWriteEEPWord(). */
  8435. *wbuf = sum;
  8436. if (sum != AscWriteEEPWord(iop_base, (uchar)s_addr, sum)) {
  8437. n_error++;
  8438. }
  8439. /* Read EEPROM back again. */
  8440. wbuf = (ushort *)cfg_buf;
  8441. /*
  8442. * Read two config words; Byte-swapping done by AscReadEEPWord().
  8443. */
  8444. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  8445. if (*wbuf != AscReadEEPWord(iop_base, (uchar)s_addr)) {
  8446. n_error++;
  8447. }
  8448. }
  8449. if (bus_type & ASC_IS_VL) {
  8450. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  8451. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  8452. } else {
  8453. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  8454. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  8455. }
  8456. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  8457. if (s_addr <= uchar_end_in_config) {
  8458. /*
  8459. * Swap all char fields. Must unswap bytes already swapped
  8460. * by AscReadEEPWord().
  8461. */
  8462. word =
  8463. le16_to_cpu(AscReadEEPWord
  8464. (iop_base, (uchar)s_addr));
  8465. } else {
  8466. /* Don't swap word field at the end - cntl field. */
  8467. word = AscReadEEPWord(iop_base, (uchar)s_addr);
  8468. }
  8469. if (*wbuf != word) {
  8470. n_error++;
  8471. }
  8472. }
  8473. /* Read checksum; Byte swapping not needed. */
  8474. if (AscReadEEPWord(iop_base, (uchar)s_addr) != sum) {
  8475. n_error++;
  8476. }
  8477. return (n_error);
  8478. }
  8479. static int __devinit
  8480. AscSetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  8481. {
  8482. int retry;
  8483. int n_error;
  8484. retry = 0;
  8485. while (TRUE) {
  8486. if ((n_error = AscSetEEPConfigOnce(iop_base, cfg_buf,
  8487. bus_type)) == 0) {
  8488. break;
  8489. }
  8490. if (++retry > ASC_EEP_MAX_RETRY) {
  8491. break;
  8492. }
  8493. }
  8494. return (n_error);
  8495. }
  8496. static void AscAsyncFix(ASC_DVC_VAR *asc_dvc, struct scsi_device *sdev)
  8497. {
  8498. char type = sdev->type;
  8499. ASC_SCSI_BIT_ID_TYPE tid_bits = 1 << sdev->id;
  8500. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_ASYN_USE_SYN) {
  8501. if (!(asc_dvc->init_sdtr & tid_bits)) {
  8502. if ((type == TYPE_ROM) &&
  8503. (strncmp(sdev->vendor, "HP ", 3) == 0)) {
  8504. asc_dvc->pci_fix_asyn_xfer_always |= tid_bits;
  8505. }
  8506. asc_dvc->pci_fix_asyn_xfer |= tid_bits;
  8507. if ((type == TYPE_PROCESSOR) ||
  8508. (type == TYPE_SCANNER) || (type == TYPE_ROM) ||
  8509. (type == TYPE_TAPE)) {
  8510. asc_dvc->pci_fix_asyn_xfer &= ~tid_bits;
  8511. }
  8512. if (asc_dvc->pci_fix_asyn_xfer & tid_bits) {
  8513. AscSetRunChipSynRegAtID(asc_dvc->iop_base,
  8514. sdev->id,
  8515. ASYN_SDTR_DATA_FIX_PCI_REV_AB);
  8516. }
  8517. }
  8518. }
  8519. }
  8520. static uchar AscReadLramByte(PortAddr iop_base, ushort addr)
  8521. {
  8522. uchar byte_data;
  8523. ushort word_data;
  8524. if (isodd_word(addr)) {
  8525. AscSetChipLramAddr(iop_base, addr - 1);
  8526. word_data = AscGetChipLramData(iop_base);
  8527. byte_data = (uchar)((word_data >> 8) & 0xFF);
  8528. } else {
  8529. AscSetChipLramAddr(iop_base, addr);
  8530. word_data = AscGetChipLramData(iop_base);
  8531. byte_data = (uchar)(word_data & 0xFF);
  8532. }
  8533. return (byte_data);
  8534. }
  8535. static ushort AscReadLramWord(PortAddr iop_base, ushort addr)
  8536. {
  8537. ushort word_data;
  8538. AscSetChipLramAddr(iop_base, addr);
  8539. word_data = AscGetChipLramData(iop_base);
  8540. return (word_data);
  8541. }
  8542. #if CC_VERY_LONG_SG_LIST
  8543. static ASC_DCNT AscReadLramDWord(PortAddr iop_base, ushort addr)
  8544. {
  8545. ushort val_low, val_high;
  8546. ASC_DCNT dword_data;
  8547. AscSetChipLramAddr(iop_base, addr);
  8548. val_low = AscGetChipLramData(iop_base);
  8549. val_high = AscGetChipLramData(iop_base);
  8550. dword_data = ((ASC_DCNT) val_high << 16) | (ASC_DCNT) val_low;
  8551. return (dword_data);
  8552. }
  8553. #endif /* CC_VERY_LONG_SG_LIST */
  8554. static void AscWriteLramWord(PortAddr iop_base, ushort addr, ushort word_val)
  8555. {
  8556. AscSetChipLramAddr(iop_base, addr);
  8557. AscSetChipLramData(iop_base, word_val);
  8558. return;
  8559. }
  8560. static void AscWriteLramByte(PortAddr iop_base, ushort addr, uchar byte_val)
  8561. {
  8562. ushort word_data;
  8563. if (isodd_word(addr)) {
  8564. addr--;
  8565. word_data = AscReadLramWord(iop_base, addr);
  8566. word_data &= 0x00FF;
  8567. word_data |= (((ushort)byte_val << 8) & 0xFF00);
  8568. } else {
  8569. word_data = AscReadLramWord(iop_base, addr);
  8570. word_data &= 0xFF00;
  8571. word_data |= ((ushort)byte_val & 0x00FF);
  8572. }
  8573. AscWriteLramWord(iop_base, addr, word_data);
  8574. return;
  8575. }
  8576. /*
  8577. * Copy 2 bytes to LRAM.
  8578. *
  8579. * The source data is assumed to be in little-endian order in memory
  8580. * and is maintained in little-endian order when written to LRAM.
  8581. */
  8582. static void
  8583. AscMemWordCopyPtrToLram(PortAddr iop_base,
  8584. ushort s_addr, uchar *s_buffer, int words)
  8585. {
  8586. int i;
  8587. AscSetChipLramAddr(iop_base, s_addr);
  8588. for (i = 0; i < 2 * words; i += 2) {
  8589. /*
  8590. * On a little-endian system the second argument below
  8591. * produces a little-endian ushort which is written to
  8592. * LRAM in little-endian order. On a big-endian system
  8593. * the second argument produces a big-endian ushort which
  8594. * is "transparently" byte-swapped by outpw() and written
  8595. * in little-endian order to LRAM.
  8596. */
  8597. outpw(iop_base + IOP_RAM_DATA,
  8598. ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]);
  8599. }
  8600. return;
  8601. }
  8602. /*
  8603. * Copy 4 bytes to LRAM.
  8604. *
  8605. * The source data is assumed to be in little-endian order in memory
  8606. * and is maintained in little-endian order when writen to LRAM.
  8607. */
  8608. static void
  8609. AscMemDWordCopyPtrToLram(PortAddr iop_base,
  8610. ushort s_addr, uchar *s_buffer, int dwords)
  8611. {
  8612. int i;
  8613. AscSetChipLramAddr(iop_base, s_addr);
  8614. for (i = 0; i < 4 * dwords; i += 4) {
  8615. outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]); /* LSW */
  8616. outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 3] << 8) | s_buffer[i + 2]); /* MSW */
  8617. }
  8618. return;
  8619. }
  8620. /*
  8621. * Copy 2 bytes from LRAM.
  8622. *
  8623. * The source data is assumed to be in little-endian order in LRAM
  8624. * and is maintained in little-endian order when written to memory.
  8625. */
  8626. static void
  8627. AscMemWordCopyPtrFromLram(PortAddr iop_base,
  8628. ushort s_addr, uchar *d_buffer, int words)
  8629. {
  8630. int i;
  8631. ushort word;
  8632. AscSetChipLramAddr(iop_base, s_addr);
  8633. for (i = 0; i < 2 * words; i += 2) {
  8634. word = inpw(iop_base + IOP_RAM_DATA);
  8635. d_buffer[i] = word & 0xff;
  8636. d_buffer[i + 1] = (word >> 8) & 0xff;
  8637. }
  8638. return;
  8639. }
  8640. static ASC_DCNT AscMemSumLramWord(PortAddr iop_base, ushort s_addr, int words)
  8641. {
  8642. ASC_DCNT sum;
  8643. int i;
  8644. sum = 0L;
  8645. for (i = 0; i < words; i++, s_addr += 2) {
  8646. sum += AscReadLramWord(iop_base, s_addr);
  8647. }
  8648. return (sum);
  8649. }
  8650. static void
  8651. AscMemWordSetLram(PortAddr iop_base, ushort s_addr, ushort set_wval, int words)
  8652. {
  8653. int i;
  8654. AscSetChipLramAddr(iop_base, s_addr);
  8655. for (i = 0; i < words; i++) {
  8656. AscSetChipLramData(iop_base, set_wval);
  8657. }
  8658. return;
  8659. }
  8660. /*
  8661. * --- Adv Library Functions
  8662. */
  8663. /* a_mcode.h */
  8664. /* Microcode buffer is kept after initialization for error recovery. */
  8665. static unsigned char _adv_asc3550_buf[] = {
  8666. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0x16, 0x18, 0xe4, 0x00, 0xfc,
  8667. 0x01, 0x00, 0x48, 0xe4, 0xbe, 0x18, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00,
  8668. 0x00, 0xfa, 0xff, 0xff, 0x28, 0x0e, 0x9e, 0xe7, 0xff, 0x00, 0x82, 0xe7,
  8669. 0x00, 0xea, 0x00, 0xf6, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0, 0x01, 0xf6,
  8670. 0x01, 0xfa, 0x08, 0x00, 0x03, 0x00, 0x04, 0x00, 0x18, 0xf4, 0x10, 0x00,
  8671. 0x00, 0xec, 0x85, 0xf0, 0xbc, 0x00, 0xd5, 0xf0, 0x8e, 0x0c, 0x38, 0x54,
  8672. 0x00, 0xe6, 0x1e, 0xf0, 0x86, 0xf0, 0xb4, 0x00, 0x98, 0x57, 0xd0, 0x01,
  8673. 0x0c, 0x1c, 0x3e, 0x1c, 0x0c, 0x00, 0xbb, 0x00, 0xaa, 0x18, 0x02, 0x80,
  8674. 0x32, 0xf0, 0x01, 0xfc, 0x88, 0x0c, 0xc6, 0x12, 0x02, 0x13, 0x18, 0x40,
  8675. 0x00, 0x57, 0x01, 0xea, 0x3c, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
  8676. 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
  8677. 0x3e, 0x01, 0xda, 0x0f, 0x22, 0x10, 0x08, 0x12, 0x02, 0x4a, 0xb9, 0x54,
  8678. 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4, 0x20, 0x00, 0x32, 0x00,
  8679. 0x3e, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
  8680. 0x70, 0x01, 0x72, 0x01, 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x62, 0x0a,
  8681. 0x92, 0x0c, 0x2c, 0x10, 0x2e, 0x10, 0x06, 0x13, 0x4c, 0x1c, 0xbb, 0x55,
  8682. 0x3c, 0x56, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0xb1, 0xf0,
  8683. 0x03, 0xf7, 0x06, 0xf7, 0x03, 0xfc, 0x0f, 0x00, 0x40, 0x00, 0xbe, 0x00,
  8684. 0x00, 0x01, 0xb0, 0x08, 0x30, 0x13, 0x64, 0x15, 0x32, 0x1c, 0x38, 0x1c,
  8685. 0x4e, 0x1c, 0x10, 0x44, 0x02, 0x48, 0x00, 0x4c, 0x04, 0xea, 0x5d, 0xf0,
  8686. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00,
  8687. 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01, 0x4e, 0x0b, 0x1e, 0x0e, 0x0c, 0x10,
  8688. 0x0a, 0x12, 0x04, 0x13, 0x40, 0x13, 0x30, 0x1c, 0x00, 0x4e, 0xbd, 0x56,
  8689. 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xa7, 0xf0,
  8690. 0xb8, 0xf0, 0x0e, 0xf7, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00,
  8691. 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00,
  8692. 0xde, 0x03, 0x56, 0x0a, 0x14, 0x0e, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10,
  8693. 0x36, 0x10, 0x0a, 0x13, 0x12, 0x13, 0x52, 0x13, 0x10, 0x15, 0x14, 0x15,
  8694. 0xac, 0x16, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44,
  8695. 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x83, 0x55,
  8696. 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0, 0x0c, 0xf0,
  8697. 0x5c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8, 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa,
  8698. 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00, 0x0a, 0x00, 0x0d, 0x00, 0x1c, 0x00,
  8699. 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01,
  8700. 0x26, 0x01, 0x79, 0x01, 0x7a, 0x01, 0xc0, 0x01, 0xc2, 0x01, 0x7c, 0x02,
  8701. 0x5a, 0x03, 0xea, 0x04, 0xe8, 0x07, 0x68, 0x08, 0x69, 0x08, 0xba, 0x08,
  8702. 0xe9, 0x09, 0x06, 0x0b, 0x3a, 0x0e, 0x00, 0x10, 0x1a, 0x10, 0xed, 0x10,
  8703. 0xf1, 0x10, 0x06, 0x12, 0x0c, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x82, 0x13,
  8704. 0x42, 0x14, 0xd6, 0x14, 0x8a, 0x15, 0xc6, 0x17, 0xd2, 0x17, 0x6b, 0x18,
  8705. 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40, 0x0e, 0x47, 0x48, 0x47,
  8706. 0x41, 0x48, 0x89, 0x48, 0x80, 0x4c, 0x00, 0x54, 0x44, 0x55, 0xe5, 0x55,
  8707. 0x14, 0x56, 0x77, 0x57, 0xbf, 0x57, 0x40, 0x5c, 0x06, 0x80, 0x08, 0x90,
  8708. 0x03, 0xa1, 0xfe, 0x9c, 0xf0, 0x29, 0x02, 0xfe, 0xb8, 0x0c, 0xff, 0x10,
  8709. 0x00, 0x00, 0xd0, 0xfe, 0xcc, 0x18, 0x00, 0xcf, 0xfe, 0x80, 0x01, 0xff,
  8710. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  8711. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x48, 0x00, 0x4f, 0xff, 0x04, 0x00,
  8712. 0x00, 0x10, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  8713. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x0f,
  8714. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  8715. 0xfe, 0x04, 0xf7, 0xcf, 0x2a, 0x67, 0x0b, 0x01, 0xfe, 0xce, 0x0e, 0xfe,
  8716. 0x04, 0xf7, 0xcf, 0x67, 0x0b, 0x3c, 0x2a, 0xfe, 0x3d, 0xf0, 0xfe, 0x02,
  8717. 0x02, 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x91, 0xf0, 0xfe, 0xf0, 0x01, 0xfe,
  8718. 0x90, 0xf0, 0xfe, 0xf0, 0x01, 0xfe, 0x8f, 0xf0, 0x9c, 0x05, 0x51, 0x3b,
  8719. 0x02, 0xfe, 0xd4, 0x0c, 0x01, 0xfe, 0x44, 0x0d, 0xfe, 0xdd, 0x12, 0xfe,
  8720. 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x05, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
  8721. 0x47, 0x18, 0xfe, 0xa6, 0x00, 0xb5, 0xfe, 0x48, 0xf0, 0xfe, 0x86, 0x02,
  8722. 0xfe, 0x49, 0xf0, 0xfe, 0xa0, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xbe, 0x02,
  8723. 0xfe, 0x46, 0xf0, 0xfe, 0x50, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x56, 0x02,
  8724. 0xfe, 0x43, 0xf0, 0xfe, 0x44, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x48, 0x02,
  8725. 0xfe, 0x45, 0xf0, 0xfe, 0x4c, 0x02, 0x17, 0x0b, 0xa0, 0x17, 0x06, 0x18,
  8726. 0x96, 0x02, 0x29, 0xfe, 0x00, 0x1c, 0xde, 0xfe, 0x02, 0x1c, 0xdd, 0xfe,
  8727. 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x20, 0x17, 0xfe, 0xe7, 0x10,
  8728. 0xfe, 0x06, 0xfc, 0xc7, 0x0a, 0x6b, 0x01, 0x9e, 0x02, 0x29, 0x14, 0x4d,
  8729. 0x37, 0x97, 0x01, 0xfe, 0x64, 0x0f, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xbd,
  8730. 0x10, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
  8731. 0x58, 0x1c, 0x17, 0x06, 0x18, 0x96, 0x2a, 0x25, 0x29, 0xfe, 0x3d, 0xf0,
  8732. 0xfe, 0x02, 0x02, 0x21, 0xfe, 0x94, 0x02, 0xfe, 0x5a, 0x1c, 0xea, 0xfe,
  8733. 0x14, 0x1c, 0x14, 0xfe, 0x30, 0x00, 0x37, 0x97, 0x01, 0xfe, 0x54, 0x0f,
  8734. 0x17, 0x06, 0x18, 0x96, 0x02, 0xd0, 0x1e, 0x20, 0x07, 0x10, 0x34, 0xfe,
  8735. 0x69, 0x10, 0x17, 0x06, 0x18, 0x96, 0xfe, 0x04, 0xec, 0x20, 0x46, 0x3d,
  8736. 0x12, 0x20, 0xfe, 0x05, 0xf6, 0xc7, 0x01, 0xfe, 0x52, 0x16, 0x09, 0x4a,
  8737. 0x4c, 0x35, 0x11, 0x2d, 0x3c, 0x8a, 0x01, 0xe6, 0x02, 0x29, 0x0a, 0x40,
  8738. 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x01, 0x6f, 0xfe, 0x18, 0x10, 0xfe, 0x41,
  8739. 0x58, 0x0a, 0x99, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x64, 0xfe, 0x0c, 0x03,
  8740. 0x01, 0xe6, 0x02, 0x29, 0x2a, 0x46, 0xfe, 0x02, 0xe8, 0x27, 0xf8, 0xfe,
  8741. 0x9e, 0x43, 0xf7, 0xfe, 0x27, 0xf0, 0xfe, 0xdc, 0x01, 0xfe, 0x07, 0x4b,
  8742. 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x40, 0x1c, 0x25, 0xd2, 0xfe, 0x26, 0xf0,
  8743. 0xfe, 0x56, 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x44, 0x03, 0xfe, 0x11, 0xf0,
  8744. 0x9c, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 0xf0, 0xfe, 0x64, 0x03, 0xeb, 0x0f,
  8745. 0xfe, 0x11, 0x00, 0x02, 0x5a, 0x2a, 0xfe, 0x48, 0x1c, 0xeb, 0x09, 0x04,
  8746. 0x1d, 0xfe, 0x18, 0x13, 0x23, 0x1e, 0x98, 0xac, 0x12, 0x98, 0x0a, 0x40,
  8747. 0x01, 0x0e, 0xac, 0x75, 0x01, 0xfe, 0xbc, 0x15, 0x11, 0xca, 0x25, 0xd2,
  8748. 0xfe, 0x01, 0xf0, 0xd2, 0xfe, 0x82, 0xf0, 0xfe, 0x92, 0x03, 0xec, 0x11,
  8749. 0xfe, 0xe4, 0x00, 0x65, 0xfe, 0xa4, 0x03, 0x25, 0x32, 0x1f, 0xfe, 0xb4,
  8750. 0x03, 0x01, 0x43, 0xfe, 0x06, 0xf0, 0xfe, 0xc4, 0x03, 0x8d, 0x81, 0xfe,
  8751. 0x0a, 0xf0, 0xfe, 0x7a, 0x06, 0x02, 0x22, 0x05, 0x6b, 0x28, 0x16, 0xfe,
  8752. 0xf6, 0x04, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02, 0xd1,
  8753. 0xeb, 0x2a, 0x67, 0x1a, 0xfe, 0x67, 0x1b, 0xf8, 0xf7, 0xfe, 0x48, 0x1c,
  8754. 0x70, 0x01, 0x6e, 0x87, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x16, 0xd3,
  8755. 0x0a, 0xca, 0x01, 0x0e, 0x74, 0x60, 0x59, 0x76, 0x27, 0x05, 0x6b, 0x28,
  8756. 0xfe, 0x10, 0x12, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02,
  8757. 0xd1, 0xbc, 0x7d, 0xbd, 0x7f, 0x25, 0x22, 0x65, 0xfe, 0x3c, 0x04, 0x1f,
  8758. 0xfe, 0x38, 0x04, 0x68, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
  8759. 0x12, 0x2b, 0xff, 0x02, 0x00, 0x10, 0x01, 0x08, 0x1f, 0xfe, 0xe0, 0x04,
  8760. 0x2b, 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd5, 0xfe, 0x4c, 0x44, 0xfe,
  8761. 0x4c, 0x12, 0x60, 0xfe, 0x44, 0x48, 0x13, 0x2c, 0xfe, 0x4c, 0x54, 0x64,
  8762. 0xd3, 0x46, 0x76, 0x27, 0xfa, 0xef, 0xfe, 0x62, 0x13, 0x09, 0x04, 0x1d,
  8763. 0xfe, 0x2a, 0x13, 0x2f, 0x07, 0x7e, 0xa5, 0xfe, 0x20, 0x10, 0x13, 0x2c,
  8764. 0xfe, 0x4c, 0x54, 0x64, 0xd3, 0xfa, 0xef, 0x86, 0x09, 0x04, 0x1d, 0xfe,
  8765. 0x08, 0x13, 0x2f, 0x07, 0x7e, 0x6e, 0x09, 0x04, 0x1d, 0xfe, 0x1c, 0x12,
  8766. 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe,
  8767. 0x70, 0x0c, 0x02, 0x22, 0x2b, 0x11, 0xfe, 0xe6, 0x00, 0xfe, 0x1c, 0x90,
  8768. 0xf9, 0x03, 0x14, 0x92, 0x01, 0x33, 0x02, 0x29, 0xfe, 0x42, 0x5b, 0x67,
  8769. 0x1a, 0xfe, 0x46, 0x59, 0xf8, 0xf7, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4,
  8770. 0x4f, 0x09, 0x04, 0x0b, 0xfe, 0x78, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x1a,
  8771. 0xfe, 0x70, 0x12, 0x49, 0x04, 0x06, 0xfe, 0x60, 0x13, 0x05, 0xfe, 0xa2,
  8772. 0x00, 0x28, 0x16, 0xfe, 0x80, 0x05, 0xfe, 0x31, 0xe4, 0x6a, 0x49, 0x04,
  8773. 0x0b, 0xfe, 0x4a, 0x13, 0x05, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x42, 0x12,
  8774. 0x5e, 0x01, 0x08, 0x25, 0x32, 0xf1, 0x01, 0x08, 0x26, 0xfe, 0x98, 0x05,
  8775. 0x11, 0xfe, 0xe3, 0x00, 0x23, 0x49, 0xfe, 0x4a, 0xf0, 0xfe, 0x6a, 0x05,
  8776. 0xfe, 0x49, 0xf0, 0xfe, 0x64, 0x05, 0x83, 0x24, 0xfe, 0x21, 0x00, 0xa1,
  8777. 0x24, 0xfe, 0x22, 0x00, 0xa0, 0x24, 0x4c, 0xfe, 0x09, 0x48, 0x01, 0x08,
  8778. 0x26, 0xfe, 0x98, 0x05, 0xfe, 0xe2, 0x08, 0x49, 0x04, 0xc5, 0x3b, 0x01,
  8779. 0x86, 0x24, 0x06, 0x12, 0xcc, 0x37, 0xfe, 0x27, 0x01, 0x09, 0x04, 0x1d,
  8780. 0xfe, 0x22, 0x12, 0x47, 0x01, 0xa7, 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b,
  8781. 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe, 0x70, 0x0c, 0x02, 0x22, 0x05, 0xfe,
  8782. 0x9c, 0x00, 0x28, 0xfe, 0x3e, 0x12, 0x05, 0x50, 0x28, 0xfe, 0x36, 0x13,
  8783. 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x08, 0x06, 0x0a, 0x06, 0x49, 0x04, 0x19,
  8784. 0xfe, 0x02, 0x12, 0x5f, 0x01, 0xfe, 0xaa, 0x14, 0x1f, 0xfe, 0xfe, 0x05,
  8785. 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x50, 0xb4, 0x0c,
  8786. 0x50, 0x05, 0xc6, 0x28, 0xfe, 0x62, 0x12, 0x05, 0x3f, 0x28, 0xfe, 0x5a,
  8787. 0x13, 0x01, 0xfe, 0x14, 0x18, 0x01, 0xfe, 0x66, 0x18, 0xfe, 0x43, 0x48,
  8788. 0xb7, 0x19, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d,
  8789. 0x85, 0xb7, 0x69, 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x72, 0x06, 0x49, 0x04,
  8790. 0x1b, 0xdf, 0x89, 0x0a, 0x4d, 0x01, 0xfe, 0xd8, 0x14, 0x1f, 0xfe, 0x68,
  8791. 0x06, 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x3f, 0xb4,
  8792. 0x0c, 0x3f, 0x17, 0x06, 0x01, 0xa7, 0xec, 0x72, 0x70, 0x01, 0x6e, 0x87,
  8793. 0x11, 0xfe, 0xe2, 0x00, 0x01, 0x08, 0x25, 0x32, 0xfe, 0x0a, 0xf0, 0xfe,
  8794. 0xa6, 0x06, 0x8c, 0xfe, 0x5c, 0x07, 0xfe, 0x06, 0xf0, 0xfe, 0x64, 0x07,
  8795. 0x8d, 0x81, 0x02, 0x22, 0x09, 0x04, 0x0b, 0xfe, 0x2e, 0x12, 0x15, 0x1a,
  8796. 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00,
  8797. 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08, 0x15, 0x00, 0x02, 0xfe, 0x32,
  8798. 0x08, 0x61, 0x04, 0x1b, 0xfe, 0x38, 0x12, 0x09, 0x04, 0x1b, 0x6e, 0x15,
  8799. 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01,
  8800. 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x06, 0x01, 0x08, 0x15, 0x00, 0x02,
  8801. 0xd9, 0x66, 0x4c, 0xfe, 0x3a, 0x55, 0x5f, 0xfe, 0x9a, 0x81, 0x4b, 0x1d,
  8802. 0xba, 0xfe, 0x32, 0x07, 0x0a, 0x1d, 0xfe, 0x09, 0x6f, 0xaf, 0xfe, 0xca,
  8803. 0x45, 0xfe, 0x32, 0x12, 0x62, 0x2c, 0x85, 0x66, 0x7b, 0x01, 0x08, 0x25,
  8804. 0x32, 0xfe, 0x0a, 0xf0, 0xfe, 0x32, 0x07, 0x8d, 0x81, 0x8c, 0xfe, 0x5c,
  8805. 0x07, 0x02, 0x22, 0x01, 0x43, 0x02, 0xfe, 0x8a, 0x06, 0x15, 0x19, 0x02,
  8806. 0xfe, 0x8a, 0x06, 0xfe, 0x9c, 0xf7, 0xd4, 0xfe, 0x2c, 0x90, 0xfe, 0xae,
  8807. 0x90, 0x77, 0xfe, 0xca, 0x07, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x4a, 0x6a,
  8808. 0x35, 0x1e, 0x20, 0x07, 0x10, 0xfe, 0x0e, 0x12, 0x74, 0xfe, 0x80, 0x80,
  8809. 0x37, 0x20, 0x63, 0x27, 0xfe, 0x06, 0x10, 0xfe, 0x83, 0xe7, 0xc4, 0xa1,
  8810. 0xfe, 0x03, 0x40, 0x09, 0x4a, 0x4f, 0x35, 0x01, 0xa8, 0xad, 0xfe, 0x1f,
  8811. 0x40, 0x12, 0x58, 0x01, 0xa5, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
  8812. 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x83, 0xfb, 0xfe, 0x8a, 0x90, 0x0c, 0x52,
  8813. 0x18, 0x53, 0xfe, 0x0c, 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe,
  8814. 0xc2, 0x50, 0x0c, 0x39, 0x18, 0x3a, 0xfe, 0x4a, 0x10, 0x09, 0x04, 0x6a,
  8815. 0xfe, 0x2a, 0x12, 0xfe, 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x54, 0x18,
  8816. 0x55, 0x09, 0x04, 0x4f, 0x85, 0x01, 0xa8, 0xfe, 0x1f, 0x80, 0x12, 0x58,
  8817. 0xfe, 0x44, 0x90, 0xfe, 0xc6, 0x90, 0x0c, 0x56, 0x18, 0x57, 0xfb, 0xfe,
  8818. 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90,
  8819. 0x0c, 0x39, 0x18, 0x3a, 0x0c, 0x38, 0x18, 0x4e, 0x09, 0x4a, 0x19, 0x35,
  8820. 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x48, 0x08, 0xfe, 0x9e, 0xf0,
  8821. 0xfe, 0x5c, 0x08, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0xfe, 0x80,
  8822. 0x08, 0xb9, 0xfe, 0x9e, 0x08, 0x8c, 0xfe, 0x74, 0x08, 0xfe, 0x06, 0xf0,
  8823. 0xfe, 0x7a, 0x08, 0x8d, 0x81, 0x02, 0x22, 0x01, 0x43, 0xfe, 0xc9, 0x10,
  8824. 0x15, 0x19, 0xfe, 0xc9, 0x10, 0x61, 0x04, 0x06, 0xfe, 0x10, 0x12, 0x61,
  8825. 0x04, 0x0b, 0x45, 0x09, 0x04, 0x0b, 0xfe, 0x68, 0x12, 0xfe, 0x2e, 0x1c,
  8826. 0x02, 0xfe, 0x24, 0x0a, 0x61, 0x04, 0x06, 0x45, 0x61, 0x04, 0x0b, 0xfe,
  8827. 0x52, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0x1e, 0x09, 0xfe,
  8828. 0xac, 0xf0, 0xfe, 0xbe, 0x08, 0xfe, 0x8a, 0x10, 0xaa, 0xfe, 0xf3, 0x10,
  8829. 0xfe, 0xad, 0xf0, 0xfe, 0xca, 0x08, 0x02, 0xfe, 0x24, 0x0a, 0xab, 0xfe,
  8830. 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0x9d, 0xe9, 0x1c, 0xfe, 0x00, 0xfe, 0xfe,
  8831. 0x1c, 0x12, 0xb5, 0xfe, 0xd2, 0xf0, 0x9d, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
  8832. 0x16, 0x9d, 0x05, 0xcb, 0x1c, 0x06, 0x16, 0x9d, 0xb8, 0x6d, 0xb9, 0x6d,
  8833. 0xaa, 0xab, 0xfe, 0xb1, 0x10, 0x70, 0x5e, 0x2b, 0x14, 0x92, 0x01, 0x33,
  8834. 0x0f, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x5a, 0x0f, 0x7c, 0x02, 0x5a,
  8835. 0xfe, 0x74, 0x18, 0x1c, 0xfe, 0x00, 0xf8, 0x16, 0x6d, 0x67, 0x1b, 0x01,
  8836. 0xfe, 0x44, 0x0d, 0x3b, 0x01, 0xe6, 0x1e, 0x27, 0x74, 0x67, 0x1a, 0x02,
  8837. 0x6d, 0x09, 0x04, 0x0b, 0x21, 0xfe, 0x06, 0x0a, 0x09, 0x04, 0x6a, 0xfe,
  8838. 0x82, 0x12, 0x09, 0x04, 0x19, 0xfe, 0x66, 0x13, 0x1e, 0x58, 0xac, 0xfc,
  8839. 0xfe, 0x83, 0x80, 0xfe, 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91,
  8840. 0xfe, 0x86, 0x91, 0x63, 0x27, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x77,
  8841. 0xd7, 0x05, 0x54, 0x31, 0x55, 0x0c, 0x7b, 0x18, 0x7c, 0xbe, 0x54, 0xbf,
  8842. 0x55, 0x01, 0xa8, 0xad, 0x63, 0x27, 0x12, 0x58, 0xc0, 0x38, 0xc1, 0x4e,
  8843. 0x79, 0x56, 0x68, 0x57, 0xf4, 0xf5, 0xfe, 0x04, 0xfa, 0x38, 0xfe, 0x05,
  8844. 0xfa, 0x4e, 0x01, 0xa5, 0xa2, 0x23, 0x0c, 0x7b, 0x0c, 0x7c, 0x79, 0x56,
  8845. 0x68, 0x57, 0xfe, 0x12, 0x10, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x79, 0x39,
  8846. 0x68, 0x3a, 0x09, 0x04, 0xfe, 0xf7, 0x00, 0x35, 0x05, 0x52, 0x31, 0x53,
  8847. 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59,
  8848. 0x02, 0x6d, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x09, 0x04, 0xfe, 0xf7, 0x00,
  8849. 0x35, 0xfe, 0x3a, 0x55, 0xfe, 0x19, 0x81, 0x5f, 0xfe, 0x10, 0x90, 0xfe,
  8850. 0x92, 0x90, 0xfe, 0xd7, 0x10, 0x2f, 0x07, 0x9b, 0x16, 0xfe, 0xc6, 0x08,
  8851. 0x11, 0x9b, 0x09, 0x04, 0x0b, 0xfe, 0x14, 0x13, 0x05, 0x39, 0x31, 0x3a,
  8852. 0x77, 0xfe, 0xc6, 0x08, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x6d,
  8853. 0x23, 0x47, 0xfe, 0x19, 0x80, 0xde, 0x09, 0x04, 0x0b, 0xfe, 0x1a, 0x12,
  8854. 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xe9, 0xb5, 0xfe, 0xd1, 0xf0, 0xd9,
  8855. 0x14, 0x7a, 0x01, 0x33, 0x0f, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe,
  8856. 0x6c, 0x19, 0xbe, 0x39, 0xfe, 0xed, 0x19, 0xbf, 0x3a, 0xfe, 0x0c, 0x51,
  8857. 0xfe, 0x8e, 0x51, 0xe9, 0x1c, 0xfe, 0x00, 0xff, 0x34, 0xfe, 0x74, 0x10,
  8858. 0xb5, 0xfe, 0xd2, 0xf0, 0xfe, 0xb2, 0x0a, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
  8859. 0x84, 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0x08, 0x13, 0x0f, 0xfe, 0x16, 0x00,
  8860. 0x02, 0x5a, 0xfe, 0xd1, 0xf0, 0xfe, 0xc4, 0x0a, 0x14, 0x7a, 0x01, 0x33,
  8861. 0x0f, 0xfe, 0x17, 0x00, 0xfe, 0x42, 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xca,
  8862. 0x0a, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xd6, 0x0a, 0x0f, 0xfe,
  8863. 0x22, 0x00, 0x02, 0x5a, 0xfe, 0xcb, 0xf0, 0xfe, 0xe2, 0x0a, 0x0f, 0xfe,
  8864. 0x24, 0x00, 0x02, 0x5a, 0xfe, 0xd0, 0xf0, 0xfe, 0xec, 0x0a, 0x0f, 0x93,
  8865. 0xdc, 0xfe, 0xcf, 0xf0, 0xfe, 0xf6, 0x0a, 0x0f, 0x4c, 0xfe, 0x10, 0x10,
  8866. 0xfe, 0xcc, 0xf0, 0xd9, 0x61, 0x04, 0x19, 0x3b, 0x0f, 0xfe, 0x12, 0x00,
  8867. 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x0c, 0x0b, 0xfe, 0x9e, 0xf0,
  8868. 0xfe, 0x20, 0x0b, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0x22, 0xb9,
  8869. 0x22, 0x2a, 0xec, 0x65, 0xfe, 0x2c, 0x0b, 0x25, 0x32, 0x8c, 0xfe, 0x48,
  8870. 0x0b, 0x8d, 0x81, 0xb8, 0xd4, 0xb9, 0xd4, 0x02, 0x22, 0x01, 0x43, 0xfe,
  8871. 0xdb, 0x10, 0x11, 0xfe, 0xe8, 0x00, 0xaa, 0xab, 0x70, 0xbc, 0x7d, 0xbd,
  8872. 0x7f, 0xfe, 0x89, 0xf0, 0x22, 0x30, 0x2e, 0xd8, 0xbc, 0x7d, 0xbd, 0x7f,
  8873. 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd6, 0xb1, 0x45, 0x0f, 0xfe, 0x42,
  8874. 0x00, 0x02, 0x5a, 0x78, 0x06, 0xfe, 0x81, 0x49, 0x16, 0xfe, 0x38, 0x0c,
  8875. 0x09, 0x04, 0x0b, 0xfe, 0x44, 0x13, 0x0f, 0x00, 0x4b, 0x0b, 0xfe, 0x54,
  8876. 0x12, 0x4b, 0xfe, 0x28, 0x00, 0x21, 0xfe, 0xa6, 0x0c, 0x0a, 0x40, 0x01,
  8877. 0x0e, 0x07, 0x00, 0x5d, 0x3e, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01,
  8878. 0xe7, 0x01, 0xe8, 0x0a, 0x99, 0x01, 0xfe, 0x32, 0x0e, 0x59, 0x11, 0x2d,
  8879. 0x01, 0x6f, 0x02, 0x29, 0x0f, 0xfe, 0x44, 0x00, 0x4b, 0x0b, 0xdf, 0x3e,
  8880. 0x0b, 0xfe, 0xb4, 0x10, 0x01, 0x86, 0x3e, 0x0b, 0xfe, 0xaa, 0x10, 0x01,
  8881. 0x86, 0xfe, 0x19, 0x82, 0xfe, 0x34, 0x46, 0xa3, 0x3e, 0x0b, 0x0f, 0xfe,
  8882. 0x43, 0x00, 0xfe, 0x96, 0x10, 0x09, 0x4a, 0x0b, 0x35, 0x01, 0xe7, 0x01,
  8883. 0xe8, 0x59, 0x11, 0x2d, 0x01, 0x6f, 0x67, 0x0b, 0x59, 0x3c, 0x8a, 0x02,
  8884. 0xfe, 0x2a, 0x03, 0x09, 0x04, 0x0b, 0x84, 0x3e, 0x0b, 0x0f, 0x00, 0xfe,
  8885. 0x5c, 0x10, 0x61, 0x04, 0x1b, 0xfe, 0x58, 0x12, 0x09, 0x04, 0x1b, 0xfe,
  8886. 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x5c, 0x0c, 0xfe,
  8887. 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x62, 0x0c, 0x09, 0x4a, 0x1b, 0x35,
  8888. 0xfe, 0xa9, 0x10, 0x0f, 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0b, 0x5f,
  8889. 0x5c, 0x0f, 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x0f, 0xfe, 0x47, 0x00,
  8890. 0xa1, 0x0f, 0xfe, 0x41, 0x00, 0xa0, 0x0f, 0xfe, 0x24, 0x00, 0x87, 0xaa,
  8891. 0xab, 0x70, 0x05, 0x6b, 0x28, 0x21, 0xd1, 0x5f, 0xfe, 0x04, 0xe6, 0x1b,
  8892. 0xfe, 0x9d, 0x41, 0xfe, 0x1c, 0x42, 0x59, 0x01, 0xda, 0x02, 0x29, 0xea,
  8893. 0x14, 0x0b, 0x37, 0x95, 0xa9, 0x14, 0xfe, 0x31, 0x00, 0x37, 0x97, 0x01,
  8894. 0xfe, 0x54, 0x0f, 0x02, 0xd0, 0x3c, 0xfe, 0x06, 0xec, 0xc9, 0xee, 0x3e,
  8895. 0x1d, 0xfe, 0xce, 0x45, 0x34, 0x3c, 0xfe, 0x06, 0xea, 0xc9, 0xfe, 0x47,
  8896. 0x4b, 0x89, 0xfe, 0x75, 0x57, 0x05, 0x51, 0xfe, 0x98, 0x56, 0xfe, 0x38,
  8897. 0x12, 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x44, 0x48, 0x46, 0x09, 0x04, 0x1d,
  8898. 0xfe, 0x1a, 0x13, 0x0a, 0x40, 0x01, 0x0e, 0x47, 0xfe, 0x41, 0x58, 0x0a,
  8899. 0x99, 0x01, 0x0e, 0xfe, 0x49, 0x54, 0x8e, 0xfe, 0x2a, 0x0d, 0x02, 0xfe,
  8900. 0x2a, 0x03, 0x0a, 0x51, 0xfe, 0xee, 0x14, 0xee, 0x3e, 0x1d, 0xfe, 0xce,
  8901. 0x45, 0x34, 0x3c, 0xfe, 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x29, 0x1e,
  8902. 0x20, 0x07, 0x10, 0xfe, 0x9e, 0x12, 0x23, 0x12, 0x4d, 0x12, 0x94, 0x12,
  8903. 0xce, 0x1e, 0x2d, 0x47, 0x37, 0x2d, 0xb1, 0xe0, 0xfe, 0xbc, 0xf0, 0xfe,
  8904. 0xec, 0x0d, 0x13, 0x06, 0x12, 0x4d, 0x01, 0xfe, 0xe2, 0x15, 0x05, 0xfe,
  8905. 0x38, 0x01, 0x31, 0xfe, 0x3a, 0x01, 0x77, 0xfe, 0xf0, 0x0d, 0xfe, 0x02,
  8906. 0xec, 0xce, 0x62, 0x00, 0x5d, 0xfe, 0x04, 0xec, 0x20, 0x46, 0xfe, 0x05,
  8907. 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x52, 0x16, 0xfb, 0xfe, 0x48, 0xf4,
  8908. 0x0d, 0xfe, 0x18, 0x13, 0xaf, 0xfe, 0x02, 0xea, 0xce, 0x62, 0x7a, 0xfe,
  8909. 0xc5, 0x13, 0x14, 0x1b, 0x37, 0x95, 0xa9, 0x5c, 0x05, 0xfe, 0x38, 0x01,
  8910. 0x1c, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x05, 0xfe, 0x3a, 0x01,
  8911. 0x0c, 0xfe, 0x62, 0x01, 0x3d, 0x12, 0x20, 0x24, 0x06, 0x12, 0x2d, 0x11,
  8912. 0x2d, 0x8a, 0x13, 0x06, 0x03, 0x23, 0x03, 0x1e, 0x4d, 0xfe, 0xf7, 0x12,
  8913. 0x1e, 0x94, 0xac, 0x12, 0x94, 0x07, 0x7a, 0xfe, 0x71, 0x13, 0xfe, 0x24,
  8914. 0x1c, 0x14, 0x1a, 0x37, 0x95, 0xa9, 0xfe, 0xd9, 0x10, 0xb6, 0xfe, 0x03,
  8915. 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xb6, 0xfe, 0x03, 0xdc,
  8916. 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x23,
  8917. 0xfe, 0x00, 0xcc, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x75, 0x03, 0x09, 0x04,
  8918. 0x4c, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
  8919. 0xfe, 0x1e, 0x80, 0xe1, 0xfe, 0x1d, 0x80, 0xa4, 0xfe, 0x0c, 0x90, 0xfe,
  8920. 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xa3, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
  8921. 0x0b, 0xfe, 0x3c, 0x50, 0xa0, 0x01, 0xfe, 0x82, 0x16, 0x2f, 0x07, 0x2d,
  8922. 0xe0, 0x01, 0xfe, 0xbc, 0x15, 0x09, 0x04, 0x1d, 0x45, 0x01, 0xe7, 0x01,
  8923. 0xe8, 0x11, 0xfe, 0xe9, 0x00, 0x09, 0x04, 0x4c, 0xfe, 0x2c, 0x13, 0x01,
  8924. 0xfe, 0x14, 0x16, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
  8925. 0x0c, 0xfe, 0x64, 0x01, 0x18, 0xfe, 0x66, 0x01, 0x09, 0x04, 0x4f, 0xfe,
  8926. 0x12, 0x12, 0xfe, 0x03, 0x80, 0x74, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
  8927. 0x40, 0x12, 0x20, 0x63, 0x27, 0x11, 0xc8, 0x59, 0x1e, 0x20, 0xed, 0x76,
  8928. 0x20, 0x03, 0xfe, 0x08, 0x1c, 0x05, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
  8929. 0x05, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x05, 0xfe, 0xb0, 0x00, 0xfe,
  8930. 0x08, 0x58, 0x05, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
  8931. 0x24, 0x69, 0x12, 0xc9, 0x23, 0x0c, 0x50, 0x0c, 0x3f, 0x13, 0x40, 0x48,
  8932. 0x5f, 0x17, 0x1d, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x21, 0xfe, 0x08,
  8933. 0x0f, 0x3e, 0x10, 0x13, 0x42, 0x48, 0x17, 0x4c, 0xfe, 0x90, 0x4d, 0xfe,
  8934. 0x91, 0x54, 0x21, 0xfe, 0x1e, 0x0f, 0x24, 0x10, 0x12, 0x20, 0x78, 0x2c,
  8935. 0x46, 0x1e, 0x20, 0xed, 0x76, 0x20, 0x11, 0xc8, 0xf6, 0xfe, 0xd6, 0xf0,
  8936. 0xfe, 0x32, 0x0f, 0xea, 0x70, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
  8937. 0x18, 0x1c, 0x03, 0x3c, 0xfe, 0x0c, 0x14, 0xee, 0xfe, 0x07, 0xe6, 0x1d,
  8938. 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x03, 0x01, 0x86, 0x78, 0x2c, 0x46,
  8939. 0xfa, 0xef, 0xfe, 0x42, 0x13, 0x2f, 0x07, 0x2d, 0xfe, 0x34, 0x13, 0x0a,
  8940. 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x36, 0x12, 0xf0, 0xfe, 0x45, 0x48, 0x01,
  8941. 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13, 0x3d, 0x75, 0x07, 0x10,
  8942. 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x6f, 0xfe, 0x0e,
  8943. 0x10, 0x07, 0x7e, 0x45, 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x6c, 0x0f, 0x03,
  8944. 0xfe, 0x44, 0x58, 0x74, 0xfe, 0x01, 0xec, 0x97, 0xfe, 0x9e, 0x40, 0xfe,
  8945. 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1b, 0x76, 0x27, 0x01, 0xda, 0xfe,
  8946. 0xdd, 0x10, 0x2a, 0xbc, 0x7d, 0xbd, 0x7f, 0x30, 0x2e, 0xd5, 0x07, 0x1b,
  8947. 0xfe, 0x48, 0x12, 0x07, 0x0b, 0xfe, 0x56, 0x12, 0x07, 0x1a, 0xfe, 0x30,
  8948. 0x12, 0x07, 0xc2, 0x16, 0xfe, 0x3e, 0x11, 0x07, 0xfe, 0x23, 0x00, 0x16,
  8949. 0xfe, 0x4a, 0x11, 0x07, 0x06, 0x16, 0xfe, 0xa8, 0x11, 0x07, 0x19, 0xfe,
  8950. 0x12, 0x12, 0x07, 0x00, 0x16, 0x22, 0x14, 0xc2, 0x01, 0x33, 0x9f, 0x2b,
  8951. 0x01, 0x08, 0x8c, 0x43, 0x03, 0x2b, 0xfe, 0x62, 0x08, 0x0a, 0xca, 0x01,
  8952. 0xfe, 0x32, 0x0e, 0x11, 0x7e, 0x02, 0x29, 0x2b, 0x2f, 0x07, 0x9b, 0xfe,
  8953. 0xd9, 0x13, 0x79, 0x39, 0x68, 0x3a, 0x77, 0xfe, 0xfc, 0x10, 0x09, 0x04,
  8954. 0x6a, 0xfe, 0x72, 0x12, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x8e, 0xfe,
  8955. 0xc6, 0x10, 0x1e, 0x58, 0xfe, 0x26, 0x13, 0x05, 0x7b, 0x31, 0x7c, 0x77,
  8956. 0xfe, 0x82, 0x0c, 0x0c, 0x54, 0x18, 0x55, 0x23, 0x0c, 0x7b, 0x0c, 0x7c,
  8957. 0x01, 0xa8, 0x24, 0x69, 0x73, 0x12, 0x58, 0x01, 0xa5, 0xc0, 0x38, 0xc1,
  8958. 0x4e, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x38, 0xfe,
  8959. 0x05, 0xfa, 0x4e, 0xfe, 0x91, 0x10, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x40,
  8960. 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x56, 0x18, 0x57, 0x83, 0xc0, 0x38, 0xc1,
  8961. 0x4e, 0xf4, 0xf5, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x00, 0x56, 0xfe, 0xa1,
  8962. 0x56, 0x0c, 0x52, 0x18, 0x53, 0x09, 0x04, 0x6a, 0xfe, 0x1e, 0x12, 0x1e,
  8963. 0x58, 0xfe, 0x1f, 0x40, 0x05, 0x54, 0x31, 0x55, 0xfe, 0x2c, 0x50, 0xfe,
  8964. 0xae, 0x50, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x44, 0x50, 0xfe, 0xc6, 0x50,
  8965. 0x05, 0x52, 0x31, 0x53, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x05, 0x39,
  8966. 0x31, 0x3a, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x5c, 0x24, 0x06,
  8967. 0x12, 0xcd, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x1f, 0x44, 0x30, 0x2e, 0xd5,
  8968. 0x07, 0x06, 0x21, 0x44, 0x2f, 0x07, 0x9b, 0x21, 0x5b, 0x01, 0x6e, 0x1c,
  8969. 0x3d, 0x16, 0x44, 0x09, 0x04, 0x0b, 0xe2, 0x79, 0x39, 0x68, 0x3a, 0xfe,
  8970. 0x0a, 0x55, 0x34, 0xfe, 0x8b, 0x55, 0xbe, 0x39, 0xbf, 0x3a, 0xfe, 0x0c,
  8971. 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x5b, 0xfe, 0x19, 0x81, 0xaf, 0xfe, 0x19,
  8972. 0x41, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e,
  8973. 0xd8, 0x4b, 0x1a, 0xfe, 0xa6, 0x12, 0x4b, 0x0b, 0x3b, 0x02, 0x44, 0x01,
  8974. 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e, 0xd6, 0x07, 0x1a, 0x21, 0x44,
  8975. 0x01, 0x08, 0x1f, 0xa2, 0x30, 0x2e, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49,
  8976. 0x60, 0x05, 0xfe, 0x9c, 0x00, 0x28, 0x84, 0x49, 0x04, 0x19, 0x34, 0x9f,
  8977. 0xfe, 0xbb, 0x45, 0x4b, 0x00, 0x45, 0x3e, 0x06, 0x78, 0x3d, 0xfe, 0xda,
  8978. 0x14, 0x01, 0x6e, 0x87, 0xfe, 0x4b, 0x45, 0xe2, 0x2f, 0x07, 0x9a, 0xe1,
  8979. 0x05, 0xc6, 0x28, 0x84, 0x05, 0x3f, 0x28, 0x34, 0x5e, 0x02, 0x5b, 0xfe,
  8980. 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17, 0x05, 0x50, 0xb4, 0x0c,
  8981. 0x50, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe, 0xaa, 0x14, 0x02,
  8982. 0x5c, 0x01, 0x08, 0x25, 0x32, 0x1f, 0x44, 0x30, 0x2e, 0xd6, 0x07, 0x06,
  8983. 0x21, 0x44, 0x01, 0xfe, 0x8e, 0x13, 0xfe, 0x42, 0x58, 0xfe, 0x82, 0x14,
  8984. 0xfe, 0xa4, 0x14, 0x87, 0xfe, 0x4a, 0xf4, 0x0b, 0x16, 0x44, 0xfe, 0x4a,
  8985. 0xf4, 0x06, 0xfe, 0x0c, 0x12, 0x2f, 0x07, 0x9a, 0x85, 0x02, 0x5b, 0x05,
  8986. 0x3f, 0xb4, 0x0c, 0x3f, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe,
  8987. 0xd8, 0x14, 0x02, 0x5c, 0x13, 0x06, 0x65, 0xfe, 0xca, 0x12, 0x26, 0xfe,
  8988. 0xe0, 0x12, 0x72, 0xf1, 0x01, 0x08, 0x23, 0x72, 0x03, 0x8f, 0xfe, 0xdc,
  8989. 0x12, 0x25, 0xfe, 0xdc, 0x12, 0x1f, 0xfe, 0xca, 0x12, 0x5e, 0x2b, 0x01,
  8990. 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
  8991. 0x1c, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13,
  8992. 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d, 0xfe, 0x30, 0x56,
  8993. 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
  8994. 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0xfe, 0x0b, 0x58,
  8995. 0x03, 0x0a, 0x50, 0x01, 0x82, 0x0a, 0x3f, 0x01, 0x82, 0x03, 0xfc, 0x1c,
  8996. 0x10, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x19, 0x48, 0xfe, 0x00,
  8997. 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c, 0x63, 0x27,
  8998. 0x0c, 0x52, 0x18, 0x53, 0xbe, 0x56, 0xbf, 0x57, 0x03, 0xfe, 0x62, 0x08,
  8999. 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x74, 0x03, 0x01,
  9000. 0xfe, 0x14, 0x18, 0xfe, 0x42, 0x48, 0x5f, 0x60, 0x89, 0x01, 0x08, 0x1f,
  9001. 0xfe, 0xa2, 0x14, 0x30, 0x2e, 0xd8, 0x01, 0x08, 0x1f, 0xfe, 0xa2, 0x14,
  9002. 0x30, 0x2e, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x05, 0xc6, 0x28, 0xfe,
  9003. 0xcc, 0x12, 0x49, 0x04, 0x1b, 0xfe, 0xc4, 0x13, 0x23, 0x62, 0x1b, 0xe2,
  9004. 0x4b, 0xc3, 0x64, 0xfe, 0xe8, 0x13, 0x3b, 0x13, 0x06, 0x17, 0xc3, 0x78,
  9005. 0xdb, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xa1, 0xff, 0x02, 0x83,
  9006. 0x55, 0x62, 0x1a, 0xa4, 0xbb, 0xfe, 0x30, 0x00, 0x8e, 0xe4, 0x17, 0x2c,
  9007. 0x13, 0x06, 0xfe, 0x56, 0x10, 0x62, 0x0b, 0xe1, 0xbb, 0xfe, 0x64, 0x00,
  9008. 0x8e, 0xe4, 0x0a, 0xfe, 0x64, 0x00, 0x17, 0x93, 0x13, 0x06, 0xfe, 0x28,
  9009. 0x10, 0x62, 0x06, 0xfe, 0x60, 0x13, 0xbb, 0xfe, 0xc8, 0x00, 0x8e, 0xe4,
  9010. 0x0a, 0xfe, 0xc8, 0x00, 0x17, 0x4d, 0x13, 0x06, 0x83, 0xbb, 0xfe, 0x90,
  9011. 0x01, 0xba, 0xfe, 0x4e, 0x14, 0x89, 0xfe, 0x12, 0x10, 0xfe, 0x43, 0xf4,
  9012. 0x94, 0xfe, 0x56, 0xf0, 0xfe, 0x60, 0x14, 0xfe, 0x04, 0xf4, 0x6c, 0xfe,
  9013. 0x43, 0xf4, 0x93, 0xfe, 0xf3, 0x10, 0xf9, 0x01, 0xfe, 0x22, 0x13, 0x1c,
  9014. 0x3d, 0xfe, 0x10, 0x13, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x69, 0xba,
  9015. 0xfe, 0x9c, 0x14, 0xb7, 0x69, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe,
  9016. 0x4d, 0xe4, 0x19, 0xba, 0xfe, 0x9c, 0x14, 0xb7, 0x19, 0x83, 0x60, 0x23,
  9017. 0xfe, 0x4d, 0xf4, 0x00, 0xdf, 0x89, 0x13, 0x06, 0xfe, 0xb4, 0x56, 0xfe,
  9018. 0xc3, 0x58, 0x03, 0x60, 0x13, 0x0b, 0x03, 0x15, 0x06, 0x01, 0x08, 0x26,
  9019. 0xe5, 0x15, 0x0b, 0x01, 0x08, 0x26, 0xe5, 0x15, 0x1a, 0x01, 0x08, 0x26,
  9020. 0xe5, 0x72, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x03, 0x15, 0x06, 0x01, 0x08,
  9021. 0x26, 0xa6, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xa6, 0x15, 0x06, 0x01, 0x08,
  9022. 0x26, 0xa6, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x26, 0xa6, 0x72, 0xfe, 0x89,
  9023. 0x4a, 0x01, 0x08, 0x03, 0x60, 0x03, 0x1e, 0xcc, 0x07, 0x06, 0xfe, 0x44,
  9024. 0x13, 0xad, 0x12, 0xcc, 0xfe, 0x49, 0xf4, 0x00, 0x3b, 0x72, 0x9f, 0x5e,
  9025. 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xf1, 0x01, 0x08, 0x2f, 0x07, 0xfe,
  9026. 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1f, 0xfe, 0x5a, 0x15, 0x23, 0x12, 0xcd,
  9027. 0x01, 0x43, 0x1e, 0xcd, 0x07, 0x06, 0x45, 0x09, 0x4a, 0x06, 0x35, 0x03,
  9028. 0x0a, 0x42, 0x01, 0x0e, 0xed, 0x88, 0x07, 0x10, 0xa4, 0x0a, 0x80, 0x01,
  9029. 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a, 0x80, 0x01, 0x0e, 0x88,
  9030. 0xfe, 0x80, 0xe7, 0x10, 0x07, 0x10, 0x84, 0xfe, 0x45, 0x58, 0x01, 0xe3,
  9031. 0x88, 0x03, 0x0a, 0x42, 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03,
  9032. 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x80, 0x80, 0xf2, 0xfe, 0x49, 0xe4, 0x10,
  9033. 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x0a, 0x51, 0x01, 0x82, 0x03, 0x17,
  9034. 0x10, 0x71, 0x66, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde,
  9035. 0xfe, 0x24, 0x1c, 0xfe, 0x1d, 0xf7, 0x1d, 0x90, 0xfe, 0xf6, 0x15, 0x01,
  9036. 0xfe, 0xfc, 0x16, 0xe0, 0x91, 0x1d, 0x66, 0xfe, 0x2c, 0x01, 0xfe, 0x2f,
  9037. 0x19, 0x03, 0xae, 0x21, 0xfe, 0xe6, 0x15, 0xfe, 0xda, 0x10, 0x17, 0x10,
  9038. 0x71, 0x05, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x19, 0xfe, 0x18, 0x58,
  9039. 0x05, 0xfe, 0x66, 0x01, 0xfe, 0x19, 0x58, 0x91, 0x19, 0xfe, 0x3c, 0x90,
  9040. 0xfe, 0x30, 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x66, 0xfe, 0x38, 0x00, 0xfe,
  9041. 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x19, 0x90, 0xfe, 0x40, 0x16, 0xfe, 0xb6,
  9042. 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x18, 0x16, 0xfe, 0x9c, 0x10, 0x17,
  9043. 0x10, 0x71, 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe,
  9044. 0x1d, 0xf7, 0x38, 0x90, 0xfe, 0x62, 0x16, 0xfe, 0x94, 0x14, 0xfe, 0x10,
  9045. 0x13, 0x91, 0x38, 0x66, 0x1b, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00,
  9046. 0x03, 0xae, 0x21, 0xfe, 0x56, 0x16, 0xfe, 0x6c, 0x10, 0x17, 0x10, 0x71,
  9047. 0xfe, 0x30, 0xbc, 0xfe, 0xb2, 0xbc, 0x91, 0xc5, 0x66, 0x1b, 0xfe, 0x0f,
  9048. 0x79, 0xfe, 0x1c, 0xf7, 0xc5, 0x90, 0xfe, 0x9a, 0x16, 0xfe, 0x5c, 0x14,
  9049. 0x34, 0x03, 0xae, 0x21, 0xfe, 0x86, 0x16, 0xfe, 0x42, 0x10, 0xfe, 0x02,
  9050. 0xf6, 0x10, 0x71, 0xfe, 0x18, 0xfe, 0x54, 0xfe, 0x19, 0xfe, 0x55, 0xfc,
  9051. 0xfe, 0x1d, 0xf7, 0x4f, 0x90, 0xfe, 0xc0, 0x16, 0xfe, 0x36, 0x14, 0xfe,
  9052. 0x1c, 0x13, 0x91, 0x4f, 0x47, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe,
  9053. 0x80, 0xe7, 0x10, 0xfe, 0x81, 0xe7, 0x10, 0x11, 0xfe, 0xdd, 0x00, 0x63,
  9054. 0x27, 0x03, 0x63, 0x27, 0xfe, 0x12, 0x45, 0x21, 0xfe, 0xb0, 0x16, 0x14,
  9055. 0x06, 0x37, 0x95, 0xa9, 0x02, 0x29, 0xfe, 0x39, 0xf0, 0xfe, 0x04, 0x17,
  9056. 0x23, 0x03, 0xfe, 0x7e, 0x18, 0x1c, 0x1a, 0x5d, 0x13, 0x0d, 0x03, 0x71,
  9057. 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x78, 0x2c,
  9058. 0x46, 0x2f, 0x07, 0x2d, 0xfe, 0x3c, 0x13, 0xfe, 0x82, 0x14, 0xfe, 0x42,
  9059. 0x13, 0x3c, 0x8a, 0x0a, 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x3e, 0x12, 0xf0,
  9060. 0xfe, 0x45, 0x48, 0x01, 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13,
  9061. 0x3d, 0x75, 0x07, 0x10, 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x01, 0x6f,
  9062. 0xfe, 0x16, 0x10, 0x07, 0x7e, 0x85, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12,
  9063. 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x24, 0x17, 0x17, 0x0b, 0x03, 0xfe, 0x9c,
  9064. 0xe7, 0x0b, 0x0f, 0xfe, 0x15, 0x00, 0x59, 0x76, 0x27, 0x01, 0xda, 0x17,
  9065. 0x06, 0x03, 0x3c, 0x8a, 0x09, 0x4a, 0x1d, 0x35, 0x11, 0x2d, 0x01, 0x6f,
  9066. 0x17, 0x06, 0x03, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x79, 0xc7, 0x68,
  9067. 0xc8, 0xfe, 0x48, 0x55, 0x34, 0xfe, 0xc9, 0x55, 0x03, 0x1e, 0x98, 0x73,
  9068. 0x12, 0x98, 0x03, 0x0a, 0x99, 0x01, 0x0e, 0xf0, 0x0a, 0x40, 0x01, 0x0e,
  9069. 0xfe, 0x49, 0x44, 0x16, 0xfe, 0xf0, 0x17, 0x73, 0x75, 0x03, 0x0a, 0x42,
  9070. 0x01, 0x0e, 0x07, 0x10, 0x45, 0x0a, 0x51, 0x01, 0x9e, 0x0a, 0x40, 0x01,
  9071. 0x0e, 0x73, 0x75, 0x03, 0xfe, 0x4e, 0xe4, 0x1a, 0x64, 0xfe, 0x24, 0x18,
  9072. 0x05, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0x5b, 0xfe, 0x4e, 0xe4, 0xc2,
  9073. 0x64, 0xfe, 0x36, 0x18, 0x05, 0xfe, 0x92, 0x00, 0xfe, 0x02, 0xe6, 0x1b,
  9074. 0xdc, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x64, 0xfe, 0x48, 0x18, 0x05,
  9075. 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x19, 0xfe, 0x08, 0x10, 0x05, 0xfe,
  9076. 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x2c, 0xfe, 0x4e, 0x45, 0xfe, 0x0c, 0x12,
  9077. 0xaf, 0xff, 0x04, 0x68, 0x54, 0xde, 0x1c, 0x69, 0x03, 0x07, 0x7a, 0xfe,
  9078. 0x5a, 0xf0, 0xfe, 0x74, 0x18, 0x24, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10,
  9079. 0x07, 0x1b, 0xfe, 0x5a, 0xf0, 0xfe, 0x82, 0x18, 0x24, 0xc3, 0xfe, 0x26,
  9080. 0x10, 0x07, 0x1a, 0x5d, 0x24, 0x2c, 0xdc, 0x07, 0x0b, 0x5d, 0x24, 0x93,
  9081. 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x5d, 0x24, 0x4d, 0x9f, 0xad, 0x03, 0x14,
  9082. 0xfe, 0x09, 0x00, 0x01, 0x33, 0xfe, 0x04, 0xfe, 0x7d, 0x05, 0x7f, 0xf9,
  9083. 0x03, 0x25, 0xfe, 0xca, 0x18, 0xfe, 0x14, 0xf0, 0x08, 0x65, 0xfe, 0xc6,
  9084. 0x18, 0x03, 0xff, 0x1a, 0x00, 0x00,
  9085. };
  9086. static unsigned short _adv_asc3550_size = sizeof(_adv_asc3550_buf); /* 0x13AD */
  9087. static ADV_DCNT _adv_asc3550_chksum = 0x04D52DDDUL; /* Expanded little-endian checksum. */
  9088. /* Microcode buffer is kept after initialization for error recovery. */
  9089. static unsigned char _adv_asc38C0800_buf[] = {
  9090. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0xfc, 0x00, 0x16, 0x18, 0xe4,
  9091. 0x01, 0x00, 0x48, 0xe4, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0xce, 0x19,
  9092. 0x00, 0xfa, 0xff, 0xff, 0x1c, 0x0f, 0x00, 0xf6, 0x9e, 0xe7, 0xff, 0x00,
  9093. 0x82, 0xe7, 0x00, 0xea, 0x01, 0xfa, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0,
  9094. 0x01, 0xf6, 0x03, 0x00, 0x04, 0x00, 0x10, 0x00, 0x1e, 0xf0, 0x85, 0xf0,
  9095. 0x18, 0xf4, 0x08, 0x00, 0xbc, 0x00, 0x38, 0x54, 0x00, 0xec, 0xd5, 0xf0,
  9096. 0x82, 0x0d, 0x00, 0xe6, 0x86, 0xf0, 0xb1, 0xf0, 0x98, 0x57, 0x01, 0xfc,
  9097. 0xb4, 0x00, 0xd4, 0x01, 0x0c, 0x1c, 0x3e, 0x1c, 0x3c, 0x00, 0xbb, 0x00,
  9098. 0x00, 0x10, 0xba, 0x19, 0x02, 0x80, 0x32, 0xf0, 0x7c, 0x0d, 0x02, 0x13,
  9099. 0xba, 0x13, 0x18, 0x40, 0x00, 0x57, 0x01, 0xea, 0x02, 0xfc, 0x03, 0xfc,
  9100. 0x3e, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x74, 0x01, 0x76, 0x01, 0xb9, 0x54,
  9101. 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
  9102. 0x3e, 0x01, 0x7a, 0x01, 0xca, 0x08, 0xce, 0x10, 0x16, 0x11, 0x04, 0x12,
  9103. 0x08, 0x12, 0x02, 0x4a, 0xbb, 0x55, 0x3c, 0x56, 0x03, 0x58, 0x1b, 0x80,
  9104. 0x30, 0xe4, 0x4b, 0xe4, 0x5d, 0xf0, 0x02, 0xfa, 0x20, 0x00, 0x32, 0x00,
  9105. 0x40, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
  9106. 0x70, 0x01, 0x72, 0x01, 0x78, 0x01, 0x7c, 0x01, 0x62, 0x0a, 0x86, 0x0d,
  9107. 0x06, 0x13, 0x4c, 0x1c, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0,
  9108. 0x03, 0xf7, 0x0c, 0x00, 0x0f, 0x00, 0x47, 0x00, 0xbe, 0x00, 0x00, 0x01,
  9109. 0x20, 0x11, 0x5c, 0x16, 0x32, 0x1c, 0x38, 0x1c, 0x4e, 0x1c, 0x10, 0x44,
  9110. 0x00, 0x4c, 0x04, 0xea, 0x5c, 0xf0, 0xa7, 0xf0, 0x04, 0xf6, 0x03, 0xfa,
  9111. 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0xcc, 0x00, 0x20, 0x01,
  9112. 0x4e, 0x01, 0x4a, 0x0b, 0x42, 0x0c, 0x12, 0x0f, 0x0c, 0x10, 0x22, 0x11,
  9113. 0x0a, 0x12, 0x04, 0x13, 0x30, 0x1c, 0x02, 0x48, 0x00, 0x4e, 0x42, 0x54,
  9114. 0x44, 0x55, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0,
  9115. 0x59, 0xf0, 0xb8, 0xf0, 0x4b, 0xf4, 0x06, 0xf7, 0x0e, 0xf7, 0x04, 0xfc,
  9116. 0x05, 0xfc, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00, 0xa4, 0x00,
  9117. 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00, 0xe2, 0x03,
  9118. 0x08, 0x0f, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10, 0x0a, 0x13, 0x0c, 0x13,
  9119. 0x12, 0x13, 0x24, 0x14, 0x34, 0x14, 0x04, 0x16, 0x08, 0x16, 0xa4, 0x17,
  9120. 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44,
  9121. 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x3a, 0x55, 0x83, 0x55,
  9122. 0xe5, 0x55, 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0,
  9123. 0x0c, 0xf0, 0x04, 0xf8, 0x05, 0xf8, 0x07, 0x00, 0x0a, 0x00, 0x1c, 0x00,
  9124. 0x1e, 0x00, 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00,
  9125. 0x22, 0x01, 0x26, 0x01, 0x79, 0x01, 0x7e, 0x01, 0xc4, 0x01, 0xc6, 0x01,
  9126. 0x80, 0x02, 0x5e, 0x03, 0xee, 0x04, 0x9a, 0x06, 0xf8, 0x07, 0x62, 0x08,
  9127. 0x68, 0x08, 0x69, 0x08, 0xd6, 0x08, 0xe9, 0x09, 0xfa, 0x0b, 0x2e, 0x0f,
  9128. 0x12, 0x10, 0x1a, 0x10, 0xed, 0x10, 0xf1, 0x10, 0x2a, 0x11, 0x06, 0x12,
  9129. 0x0c, 0x12, 0x3e, 0x12, 0x10, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x46, 0x14,
  9130. 0x76, 0x14, 0x82, 0x14, 0x36, 0x15, 0xca, 0x15, 0x6b, 0x18, 0xbe, 0x18,
  9131. 0xca, 0x18, 0xe6, 0x19, 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40,
  9132. 0x0e, 0x47, 0xfe, 0x9c, 0xf0, 0x2b, 0x02, 0xfe, 0xac, 0x0d, 0xff, 0x10,
  9133. 0x00, 0x00, 0xd7, 0xfe, 0xe8, 0x19, 0x00, 0xd6, 0xfe, 0x84, 0x01, 0xff,
  9134. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  9135. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x5b, 0xff, 0x04, 0x00,
  9136. 0x00, 0x11, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  9137. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x11,
  9138. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  9139. 0xfe, 0x04, 0xf7, 0xd6, 0x2c, 0x99, 0x0a, 0x01, 0xfe, 0xc2, 0x0f, 0xfe,
  9140. 0x04, 0xf7, 0xd6, 0x99, 0x0a, 0x42, 0x2c, 0xfe, 0x3d, 0xf0, 0xfe, 0x06,
  9141. 0x02, 0xfe, 0x20, 0xf0, 0xa7, 0xfe, 0x91, 0xf0, 0xfe, 0xf4, 0x01, 0xfe,
  9142. 0x90, 0xf0, 0xfe, 0xf4, 0x01, 0xfe, 0x8f, 0xf0, 0xa7, 0x03, 0x5d, 0x4d,
  9143. 0x02, 0xfe, 0xc8, 0x0d, 0x01, 0xfe, 0x38, 0x0e, 0xfe, 0xdd, 0x12, 0xfe,
  9144. 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
  9145. 0x41, 0x14, 0xfe, 0xa6, 0x00, 0xc2, 0xfe, 0x48, 0xf0, 0xfe, 0x8a, 0x02,
  9146. 0xfe, 0x49, 0xf0, 0xfe, 0xa4, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc2, 0x02,
  9147. 0xfe, 0x46, 0xf0, 0xfe, 0x54, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x5a, 0x02,
  9148. 0xfe, 0x43, 0xf0, 0xfe, 0x48, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x4c, 0x02,
  9149. 0xfe, 0x45, 0xf0, 0xfe, 0x50, 0x02, 0x18, 0x0a, 0xaa, 0x18, 0x06, 0x14,
  9150. 0xa1, 0x02, 0x2b, 0xfe, 0x00, 0x1c, 0xe7, 0xfe, 0x02, 0x1c, 0xe6, 0xfe,
  9151. 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x18, 0x18, 0xfe, 0xe7, 0x10,
  9152. 0xfe, 0x06, 0xfc, 0xce, 0x09, 0x70, 0x01, 0xa8, 0x02, 0x2b, 0x15, 0x59,
  9153. 0x39, 0xa2, 0x01, 0xfe, 0x58, 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xbd,
  9154. 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
  9155. 0x58, 0x1c, 0x18, 0x06, 0x14, 0xa1, 0x2c, 0x1c, 0x2b, 0xfe, 0x3d, 0xf0,
  9156. 0xfe, 0x06, 0x02, 0x23, 0xfe, 0x98, 0x02, 0xfe, 0x5a, 0x1c, 0xf8, 0xfe,
  9157. 0x14, 0x1c, 0x15, 0xfe, 0x30, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10,
  9158. 0x18, 0x06, 0x14, 0xa1, 0x02, 0xd7, 0x22, 0x20, 0x07, 0x11, 0x35, 0xfe,
  9159. 0x69, 0x10, 0x18, 0x06, 0x14, 0xa1, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0x43,
  9160. 0x13, 0x20, 0xfe, 0x05, 0xf6, 0xce, 0x01, 0xfe, 0x4a, 0x17, 0x08, 0x54,
  9161. 0x58, 0x37, 0x12, 0x2f, 0x42, 0x92, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b,
  9162. 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66, 0x01, 0x73, 0xfe, 0x18, 0x10,
  9163. 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x6b, 0xfe,
  9164. 0x10, 0x03, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b, 0x2c, 0x4f, 0xfe, 0x02,
  9165. 0xe8, 0x2a, 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe,
  9166. 0x27, 0xf0, 0xfe, 0xe0, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xa7,
  9167. 0xfe, 0x40, 0x1c, 0x1c, 0xd9, 0xfe, 0x26, 0xf0, 0xfe, 0x5a, 0x03, 0xfe,
  9168. 0xa0, 0xf0, 0xfe, 0x48, 0x03, 0xfe, 0x11, 0xf0, 0xa7, 0xfe, 0xef, 0x10,
  9169. 0xfe, 0x9f, 0xf0, 0xfe, 0x68, 0x03, 0xf9, 0x10, 0xfe, 0x11, 0x00, 0x02,
  9170. 0x65, 0x2c, 0xfe, 0x48, 0x1c, 0xf9, 0x08, 0x05, 0x1b, 0xfe, 0x18, 0x13,
  9171. 0x21, 0x22, 0xa3, 0xb7, 0x13, 0xa3, 0x09, 0x46, 0x01, 0x0e, 0xb7, 0x78,
  9172. 0x01, 0xfe, 0xb4, 0x16, 0x12, 0xd1, 0x1c, 0xd9, 0xfe, 0x01, 0xf0, 0xd9,
  9173. 0xfe, 0x82, 0xf0, 0xfe, 0x96, 0x03, 0xfa, 0x12, 0xfe, 0xe4, 0x00, 0x27,
  9174. 0xfe, 0xa8, 0x03, 0x1c, 0x34, 0x1d, 0xfe, 0xb8, 0x03, 0x01, 0x4b, 0xfe,
  9175. 0x06, 0xf0, 0xfe, 0xc8, 0x03, 0x95, 0x86, 0xfe, 0x0a, 0xf0, 0xfe, 0x8a,
  9176. 0x06, 0x02, 0x24, 0x03, 0x70, 0x28, 0x17, 0xfe, 0xfa, 0x04, 0x15, 0x6d,
  9177. 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02, 0xd8, 0xf9, 0x2c, 0x99, 0x19,
  9178. 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c,
  9179. 0x74, 0x01, 0xaf, 0x8c, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x17, 0xda,
  9180. 0x09, 0xd1, 0x01, 0x0e, 0x8d, 0x51, 0x64, 0x79, 0x2a, 0x03, 0x70, 0x28,
  9181. 0xfe, 0x10, 0x12, 0x15, 0x6d, 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02,
  9182. 0xd8, 0xc7, 0x81, 0xc8, 0x83, 0x1c, 0x24, 0x27, 0xfe, 0x40, 0x04, 0x1d,
  9183. 0xfe, 0x3c, 0x04, 0x3b, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
  9184. 0x12, 0x2d, 0xff, 0x02, 0x00, 0x10, 0x01, 0x0b, 0x1d, 0xfe, 0xe4, 0x04,
  9185. 0x2d, 0x01, 0x0b, 0x1d, 0x24, 0x33, 0x31, 0xde, 0xfe, 0x4c, 0x44, 0xfe,
  9186. 0x4c, 0x12, 0x51, 0xfe, 0x44, 0x48, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b,
  9187. 0xda, 0x4f, 0x79, 0x2a, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x62,
  9188. 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x2a, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x52,
  9189. 0x13, 0xfe, 0x20, 0x10, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b, 0xda, 0xfe,
  9190. 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x40, 0x13, 0x08, 0x05, 0x1b, 0xfe,
  9191. 0x08, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x30, 0x13, 0x08, 0x05, 0x1b, 0xfe,
  9192. 0x1c, 0x12, 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00,
  9193. 0x01, 0x36, 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x2d, 0x12, 0xfe, 0xe6,
  9194. 0x00, 0xfe, 0x1c, 0x90, 0xfe, 0x40, 0x5c, 0x04, 0x15, 0x9d, 0x01, 0x36,
  9195. 0x02, 0x2b, 0xfe, 0x42, 0x5b, 0x99, 0x19, 0xfe, 0x46, 0x59, 0xfe, 0xbf,
  9196. 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4, 0x5b, 0x08,
  9197. 0x05, 0x0a, 0xfe, 0x84, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x19, 0xfe, 0x7c,
  9198. 0x12, 0x53, 0x05, 0x06, 0xfe, 0x6c, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x28,
  9199. 0x17, 0xfe, 0x90, 0x05, 0xfe, 0x31, 0xe4, 0x5a, 0x53, 0x05, 0x0a, 0xfe,
  9200. 0x56, 0x13, 0x03, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x4e, 0x12, 0x67, 0xff,
  9201. 0x02, 0x00, 0x10, 0x27, 0xfe, 0x48, 0x05, 0x1c, 0x34, 0xfe, 0x89, 0x48,
  9202. 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x56, 0x05, 0x26, 0xfe, 0xa8, 0x05,
  9203. 0x12, 0xfe, 0xe3, 0x00, 0x21, 0x53, 0xfe, 0x4a, 0xf0, 0xfe, 0x76, 0x05,
  9204. 0xfe, 0x49, 0xf0, 0xfe, 0x70, 0x05, 0x88, 0x25, 0xfe, 0x21, 0x00, 0xab,
  9205. 0x25, 0xfe, 0x22, 0x00, 0xaa, 0x25, 0x58, 0xfe, 0x09, 0x48, 0xff, 0x02,
  9206. 0x00, 0x10, 0x27, 0xfe, 0x86, 0x05, 0x26, 0xfe, 0xa8, 0x05, 0xfe, 0xe2,
  9207. 0x08, 0x53, 0x05, 0xcb, 0x4d, 0x01, 0xb0, 0x25, 0x06, 0x13, 0xd3, 0x39,
  9208. 0xfe, 0x27, 0x01, 0x08, 0x05, 0x1b, 0xfe, 0x22, 0x12, 0x41, 0x01, 0xb2,
  9209. 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00, 0x01, 0x36,
  9210. 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0xeb,
  9211. 0x03, 0x5c, 0x28, 0xfe, 0x36, 0x13, 0x41, 0x01, 0xb2, 0x26, 0xfe, 0x18,
  9212. 0x06, 0x09, 0x06, 0x53, 0x05, 0x1f, 0xfe, 0x02, 0x12, 0x50, 0x01, 0xfe,
  9213. 0x9e, 0x15, 0x1d, 0xfe, 0x0e, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12, 0xfe,
  9214. 0xe5, 0x00, 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x03, 0xcd, 0x28, 0xfe, 0x62,
  9215. 0x12, 0x03, 0x45, 0x28, 0xfe, 0x5a, 0x13, 0x01, 0xfe, 0x0c, 0x19, 0x01,
  9216. 0xfe, 0x76, 0x19, 0xfe, 0x43, 0x48, 0xc4, 0xcc, 0x0f, 0x71, 0xff, 0x02,
  9217. 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0x8b, 0xc4, 0x6e, 0x41, 0x01, 0xb2,
  9218. 0x26, 0xfe, 0x82, 0x06, 0x53, 0x05, 0x1a, 0xe9, 0x91, 0x09, 0x59, 0x01,
  9219. 0xfe, 0xcc, 0x15, 0x1d, 0xfe, 0x78, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12,
  9220. 0xfe, 0xe5, 0x00, 0x03, 0x45, 0xc1, 0x0c, 0x45, 0x18, 0x06, 0x01, 0xb2,
  9221. 0xfa, 0x76, 0x74, 0x01, 0xaf, 0x8c, 0x12, 0xfe, 0xe2, 0x00, 0x27, 0xdb,
  9222. 0x1c, 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0xb6, 0x06, 0x94, 0xfe, 0x6c, 0x07,
  9223. 0xfe, 0x06, 0xf0, 0xfe, 0x74, 0x07, 0x95, 0x86, 0x02, 0x24, 0x08, 0x05,
  9224. 0x0a, 0xfe, 0x2e, 0x12, 0x16, 0x19, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b,
  9225. 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0xfe, 0x99, 0xa4, 0x01,
  9226. 0x0b, 0x16, 0x00, 0x02, 0xfe, 0x42, 0x08, 0x68, 0x05, 0x1a, 0xfe, 0x38,
  9227. 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x30, 0x13, 0x16, 0xfe, 0x1b, 0x00, 0x01,
  9228. 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01,
  9229. 0x0b, 0x16, 0x06, 0x01, 0x0b, 0x16, 0x00, 0x02, 0xe2, 0x6c, 0x58, 0xbe,
  9230. 0x50, 0xfe, 0x9a, 0x81, 0x55, 0x1b, 0x7a, 0xfe, 0x42, 0x07, 0x09, 0x1b,
  9231. 0xfe, 0x09, 0x6f, 0xba, 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 0x69, 0x6d,
  9232. 0x8b, 0x6c, 0x7f, 0x27, 0xfe, 0x54, 0x07, 0x1c, 0x34, 0xfe, 0x0a, 0xf0,
  9233. 0xfe, 0x42, 0x07, 0x95, 0x86, 0x94, 0xfe, 0x6c, 0x07, 0x02, 0x24, 0x01,
  9234. 0x4b, 0x02, 0xdb, 0x16, 0x1f, 0x02, 0xdb, 0xfe, 0x9c, 0xf7, 0xdc, 0xfe,
  9235. 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x56, 0xfe, 0xda, 0x07, 0x0c, 0x60, 0x14,
  9236. 0x61, 0x08, 0x54, 0x5a, 0x37, 0x22, 0x20, 0x07, 0x11, 0xfe, 0x0e, 0x12,
  9237. 0x8d, 0xfe, 0x80, 0x80, 0x39, 0x20, 0x6a, 0x2a, 0xfe, 0x06, 0x10, 0xfe,
  9238. 0x83, 0xe7, 0xfe, 0x48, 0x00, 0xab, 0xfe, 0x03, 0x40, 0x08, 0x54, 0x5b,
  9239. 0x37, 0x01, 0xb3, 0xb8, 0xfe, 0x1f, 0x40, 0x13, 0x62, 0x01, 0xef, 0xfe,
  9240. 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x88,
  9241. 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90, 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x0c,
  9242. 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x0c, 0x3d,
  9243. 0x14, 0x3e, 0xfe, 0x4a, 0x10, 0x08, 0x05, 0x5a, 0xfe, 0x2a, 0x12, 0xfe,
  9244. 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x60, 0x14, 0x61, 0x08, 0x05, 0x5b,
  9245. 0x8b, 0x01, 0xb3, 0xfe, 0x1f, 0x80, 0x13, 0x62, 0xfe, 0x44, 0x90, 0xfe,
  9246. 0xc6, 0x90, 0x0c, 0x3f, 0x14, 0x40, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90,
  9247. 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90, 0x0c, 0x3d,
  9248. 0x14, 0x3e, 0x0c, 0x2e, 0x14, 0x3c, 0x21, 0x0c, 0x49, 0x0c, 0x63, 0x08,
  9249. 0x54, 0x1f, 0x37, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27, 0xdd, 0xfe, 0x9e,
  9250. 0xf0, 0xfe, 0x76, 0x08, 0xbc, 0x17, 0x34, 0x2c, 0x77, 0xe6, 0xc5, 0xfe,
  9251. 0x9a, 0x08, 0xc6, 0xfe, 0xb8, 0x08, 0x94, 0xfe, 0x8e, 0x08, 0xfe, 0x06,
  9252. 0xf0, 0xfe, 0x94, 0x08, 0x95, 0x86, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xc9,
  9253. 0x10, 0x16, 0x1f, 0xfe, 0xc9, 0x10, 0x68, 0x05, 0x06, 0xfe, 0x10, 0x12,
  9254. 0x68, 0x05, 0x0a, 0x4e, 0x08, 0x05, 0x0a, 0xfe, 0x90, 0x12, 0xfe, 0x2e,
  9255. 0x1c, 0x02, 0xfe, 0x18, 0x0b, 0x68, 0x05, 0x06, 0x4e, 0x68, 0x05, 0x0a,
  9256. 0xfe, 0x7a, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0xd2, 0x09,
  9257. 0xfe, 0xac, 0xf0, 0xfe, 0x00, 0x09, 0x02, 0xfe, 0xde, 0x09, 0xfe, 0xb7,
  9258. 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0x02, 0xf6, 0x1a, 0x50, 0xfe, 0x70, 0x18,
  9259. 0xfe, 0xf1, 0x18, 0xfe, 0x40, 0x55, 0xfe, 0xe1, 0x55, 0xfe, 0x10, 0x58,
  9260. 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x1c, 0x85, 0xfe,
  9261. 0x8c, 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0xac, 0xf0, 0xfe, 0xf0, 0x08, 0xb5,
  9262. 0xfe, 0xcb, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0x0c, 0x09, 0x02, 0xfe, 0x18,
  9263. 0x0b, 0xb6, 0xfe, 0xbf, 0x10, 0xfe, 0x2b, 0xf0, 0x85, 0xf4, 0x1e, 0xfe,
  9264. 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xc2, 0xfe, 0xd2, 0xf0, 0x85, 0xfe, 0x76,
  9265. 0x18, 0x1e, 0x19, 0x17, 0x85, 0x03, 0xd2, 0x1e, 0x06, 0x17, 0x85, 0xc5,
  9266. 0x4a, 0xc6, 0x4a, 0xb5, 0xb6, 0xfe, 0x89, 0x10, 0x74, 0x67, 0x2d, 0x15,
  9267. 0x9d, 0x01, 0x36, 0x10, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x65, 0x10,
  9268. 0x80, 0x02, 0x65, 0xfe, 0x98, 0x80, 0xfe, 0x19, 0xe4, 0x0a, 0xfe, 0x1a,
  9269. 0x12, 0x51, 0xfe, 0x19, 0x82, 0xfe, 0x6c, 0x18, 0xfe, 0x44, 0x54, 0xbe,
  9270. 0xfe, 0x19, 0x81, 0xfe, 0x74, 0x18, 0x8f, 0x90, 0x17, 0xfe, 0xce, 0x08,
  9271. 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xec, 0x03, 0x2e, 0x29, 0x3c, 0x0c, 0x3f,
  9272. 0x14, 0x40, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x6c, 0x18, 0xfe, 0xed, 0x18,
  9273. 0xfe, 0x44, 0x54, 0xfe, 0xe5, 0x54, 0x3a, 0x3f, 0x3b, 0x40, 0x03, 0x49,
  9274. 0x29, 0x63, 0x8f, 0xfe, 0xe3, 0x54, 0xfe, 0x74, 0x18, 0xfe, 0xf5, 0x18,
  9275. 0x8f, 0xfe, 0xe3, 0x54, 0x90, 0xc0, 0x56, 0xfe, 0xce, 0x08, 0x02, 0x4a,
  9276. 0xfe, 0x37, 0xf0, 0xfe, 0xda, 0x09, 0xfe, 0x8b, 0xf0, 0xfe, 0x60, 0x09,
  9277. 0x02, 0x4a, 0x08, 0x05, 0x0a, 0x23, 0xfe, 0xfa, 0x0a, 0x3a, 0x49, 0x3b,
  9278. 0x63, 0x56, 0xfe, 0x3e, 0x0a, 0x0f, 0xfe, 0xc0, 0x07, 0x41, 0x98, 0x00,
  9279. 0xad, 0xfe, 0x01, 0x59, 0xfe, 0x52, 0xf0, 0xfe, 0x0c, 0x0a, 0x8f, 0x7a,
  9280. 0xfe, 0x24, 0x0a, 0x3a, 0x49, 0x8f, 0xfe, 0xe3, 0x54, 0x57, 0x49, 0x7d,
  9281. 0x63, 0xfe, 0x14, 0x58, 0xfe, 0x95, 0x58, 0x02, 0x4a, 0x3a, 0x49, 0x3b,
  9282. 0x63, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0xbe, 0x57, 0x49, 0x57, 0x63,
  9283. 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xfe, 0x82, 0x12, 0x08, 0x05, 0x1f, 0xfe,
  9284. 0x66, 0x13, 0x22, 0x62, 0xb7, 0xfe, 0x03, 0xa1, 0xfe, 0x83, 0x80, 0xfe,
  9285. 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91, 0xfe, 0x86, 0x91, 0x6a,
  9286. 0x2a, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x56, 0xe0, 0x03, 0x60, 0x29,
  9287. 0x61, 0x0c, 0x7f, 0x14, 0x80, 0x57, 0x60, 0x7d, 0x61, 0x01, 0xb3, 0xb8,
  9288. 0x6a, 0x2a, 0x13, 0x62, 0x9b, 0x2e, 0x9c, 0x3c, 0x3a, 0x3f, 0x3b, 0x40,
  9289. 0x90, 0xc0, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0x01, 0xef,
  9290. 0xfe, 0x36, 0x10, 0x21, 0x0c, 0x7f, 0x0c, 0x80, 0x3a, 0x3f, 0x3b, 0x40,
  9291. 0xe4, 0x08, 0x05, 0x1f, 0x17, 0xe0, 0x3a, 0x3d, 0x3b, 0x3e, 0x08, 0x05,
  9292. 0xfe, 0xf7, 0x00, 0x37, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x10, 0x58, 0xfe,
  9293. 0x91, 0x58, 0x57, 0x49, 0x7d, 0x63, 0x02, 0xfe, 0xf4, 0x09, 0x08, 0x05,
  9294. 0x1f, 0x17, 0xe0, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37, 0xbe, 0xfe, 0x19,
  9295. 0x81, 0x50, 0xfe, 0x10, 0x90, 0xfe, 0x92, 0x90, 0xfe, 0xd3, 0x10, 0x32,
  9296. 0x07, 0xa6, 0x17, 0xfe, 0x08, 0x09, 0x12, 0xa6, 0x08, 0x05, 0x0a, 0xfe,
  9297. 0x14, 0x13, 0x03, 0x3d, 0x29, 0x3e, 0x56, 0xfe, 0x08, 0x09, 0xfe, 0x0c,
  9298. 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x4a, 0x21, 0x41, 0xfe, 0x19, 0x80, 0xe7,
  9299. 0x08, 0x05, 0x0a, 0xfe, 0x1a, 0x12, 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41,
  9300. 0xf4, 0xc2, 0xfe, 0xd1, 0xf0, 0xe2, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe,
  9301. 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19, 0x57, 0x3d, 0xfe, 0xed,
  9302. 0x19, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xf4, 0x1e, 0xfe,
  9303. 0x00, 0xff, 0x35, 0xfe, 0x74, 0x10, 0xc2, 0xfe, 0xd2, 0xf0, 0xfe, 0xa6,
  9304. 0x0b, 0xfe, 0x76, 0x18, 0x1e, 0x19, 0x8a, 0x03, 0xd2, 0x1e, 0x06, 0xfe,
  9305. 0x08, 0x13, 0x10, 0xfe, 0x16, 0x00, 0x02, 0x65, 0xfe, 0xd1, 0xf0, 0xfe,
  9306. 0xb8, 0x0b, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe, 0x17, 0x00, 0xfe, 0x42,
  9307. 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xbe, 0x0b, 0xfe, 0x3c, 0x10, 0xfe, 0xcd,
  9308. 0xf0, 0xfe, 0xca, 0x0b, 0x10, 0xfe, 0x22, 0x00, 0x02, 0x65, 0xfe, 0xcb,
  9309. 0xf0, 0xfe, 0xd6, 0x0b, 0x10, 0xfe, 0x24, 0x00, 0x02, 0x65, 0xfe, 0xd0,
  9310. 0xf0, 0xfe, 0xe0, 0x0b, 0x10, 0x9e, 0xe5, 0xfe, 0xcf, 0xf0, 0xfe, 0xea,
  9311. 0x0b, 0x10, 0x58, 0xfe, 0x10, 0x10, 0xfe, 0xcc, 0xf0, 0xe2, 0x68, 0x05,
  9312. 0x1f, 0x4d, 0x10, 0xfe, 0x12, 0x00, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27,
  9313. 0xfe, 0x00, 0x0c, 0xfe, 0x9e, 0xf0, 0xfe, 0x14, 0x0c, 0xbc, 0x17, 0x34,
  9314. 0x2c, 0x77, 0xe6, 0xc5, 0x24, 0xc6, 0x24, 0x2c, 0xfa, 0x27, 0xfe, 0x20,
  9315. 0x0c, 0x1c, 0x34, 0x94, 0xfe, 0x3c, 0x0c, 0x95, 0x86, 0xc5, 0xdc, 0xc6,
  9316. 0xdc, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xdb, 0x10, 0x12, 0xfe, 0xe8, 0x00,
  9317. 0xb5, 0xb6, 0x74, 0xc7, 0x81, 0xc8, 0x83, 0xfe, 0x89, 0xf0, 0x24, 0x33,
  9318. 0x31, 0xe1, 0xc7, 0x81, 0xc8, 0x83, 0x27, 0xfe, 0x66, 0x0c, 0x1d, 0x24,
  9319. 0x33, 0x31, 0xdf, 0xbc, 0x4e, 0x10, 0xfe, 0x42, 0x00, 0x02, 0x65, 0x7c,
  9320. 0x06, 0xfe, 0x81, 0x49, 0x17, 0xfe, 0x2c, 0x0d, 0x08, 0x05, 0x0a, 0xfe,
  9321. 0x44, 0x13, 0x10, 0x00, 0x55, 0x0a, 0xfe, 0x54, 0x12, 0x55, 0xfe, 0x28,
  9322. 0x00, 0x23, 0xfe, 0x9a, 0x0d, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66,
  9323. 0x44, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01, 0xf5, 0x01, 0xf6, 0x09,
  9324. 0xa4, 0x01, 0xfe, 0x26, 0x0f, 0x64, 0x12, 0x2f, 0x01, 0x73, 0x02, 0x2b,
  9325. 0x10, 0xfe, 0x44, 0x00, 0x55, 0x0a, 0xe9, 0x44, 0x0a, 0xfe, 0xb4, 0x10,
  9326. 0x01, 0xb0, 0x44, 0x0a, 0xfe, 0xaa, 0x10, 0x01, 0xb0, 0xfe, 0x19, 0x82,
  9327. 0xfe, 0x34, 0x46, 0xac, 0x44, 0x0a, 0x10, 0xfe, 0x43, 0x00, 0xfe, 0x96,
  9328. 0x10, 0x08, 0x54, 0x0a, 0x37, 0x01, 0xf5, 0x01, 0xf6, 0x64, 0x12, 0x2f,
  9329. 0x01, 0x73, 0x99, 0x0a, 0x64, 0x42, 0x92, 0x02, 0xfe, 0x2e, 0x03, 0x08,
  9330. 0x05, 0x0a, 0x8a, 0x44, 0x0a, 0x10, 0x00, 0xfe, 0x5c, 0x10, 0x68, 0x05,
  9331. 0x1a, 0xfe, 0x58, 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x50, 0x13, 0xfe, 0x1c,
  9332. 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x50, 0x0d, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d,
  9333. 0xf0, 0xfe, 0x56, 0x0d, 0x08, 0x54, 0x1a, 0x37, 0xfe, 0xa9, 0x10, 0x10,
  9334. 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0a, 0x50, 0xfe, 0x2e, 0x10, 0x10,
  9335. 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x10, 0x6f, 0xab, 0x10, 0xfe, 0x41,
  9336. 0x00, 0xaa, 0x10, 0xfe, 0x24, 0x00, 0x8c, 0xb5, 0xb6, 0x74, 0x03, 0x70,
  9337. 0x28, 0x23, 0xd8, 0x50, 0xfe, 0x04, 0xe6, 0x1a, 0xfe, 0x9d, 0x41, 0xfe,
  9338. 0x1c, 0x42, 0x64, 0x01, 0xe3, 0x02, 0x2b, 0xf8, 0x15, 0x0a, 0x39, 0xa0,
  9339. 0xb4, 0x15, 0xfe, 0x31, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10, 0x02,
  9340. 0xd7, 0x42, 0xfe, 0x06, 0xec, 0xd0, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45,
  9341. 0x35, 0x42, 0xfe, 0x06, 0xea, 0xd0, 0xfe, 0x47, 0x4b, 0x91, 0xfe, 0x75,
  9342. 0x57, 0x03, 0x5d, 0xfe, 0x98, 0x56, 0xfe, 0x38, 0x12, 0x09, 0x48, 0x01,
  9343. 0x0e, 0xfe, 0x44, 0x48, 0x4f, 0x08, 0x05, 0x1b, 0xfe, 0x1a, 0x13, 0x09,
  9344. 0x46, 0x01, 0x0e, 0x41, 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe,
  9345. 0x49, 0x54, 0x96, 0xfe, 0x1e, 0x0e, 0x02, 0xfe, 0x2e, 0x03, 0x09, 0x5d,
  9346. 0xfe, 0xee, 0x14, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe,
  9347. 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x2b, 0x22, 0x20, 0x07, 0x11, 0xfe,
  9348. 0x9e, 0x12, 0x21, 0x13, 0x59, 0x13, 0x9f, 0x13, 0xd5, 0x22, 0x2f, 0x41,
  9349. 0x39, 0x2f, 0xbc, 0xad, 0xfe, 0xbc, 0xf0, 0xfe, 0xe0, 0x0e, 0x0f, 0x06,
  9350. 0x13, 0x59, 0x01, 0xfe, 0xda, 0x16, 0x03, 0xfe, 0x38, 0x01, 0x29, 0xfe,
  9351. 0x3a, 0x01, 0x56, 0xfe, 0xe4, 0x0e, 0xfe, 0x02, 0xec, 0xd5, 0x69, 0x00,
  9352. 0x66, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01,
  9353. 0x01, 0xfe, 0x4a, 0x17, 0xfe, 0x08, 0x90, 0xfe, 0x48, 0xf4, 0x0d, 0xfe,
  9354. 0x18, 0x13, 0xba, 0xfe, 0x02, 0xea, 0xd5, 0x69, 0x7e, 0xfe, 0xc5, 0x13,
  9355. 0x15, 0x1a, 0x39, 0xa0, 0xb4, 0xfe, 0x2e, 0x10, 0x03, 0xfe, 0x38, 0x01,
  9356. 0x1e, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x03, 0xfe, 0x3a, 0x01,
  9357. 0x0c, 0xfe, 0x62, 0x01, 0x43, 0x13, 0x20, 0x25, 0x06, 0x13, 0x2f, 0x12,
  9358. 0x2f, 0x92, 0x0f, 0x06, 0x04, 0x21, 0x04, 0x22, 0x59, 0xfe, 0xf7, 0x12,
  9359. 0x22, 0x9f, 0xb7, 0x13, 0x9f, 0x07, 0x7e, 0xfe, 0x71, 0x13, 0xfe, 0x24,
  9360. 0x1c, 0x15, 0x19, 0x39, 0xa0, 0xb4, 0xfe, 0xd9, 0x10, 0xc3, 0xfe, 0x03,
  9361. 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xc3, 0xfe, 0x03, 0xdc,
  9362. 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x21,
  9363. 0xfe, 0x00, 0xcc, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x78, 0x04, 0x08, 0x05,
  9364. 0x58, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
  9365. 0xfe, 0x1e, 0x80, 0xed, 0xfe, 0x1d, 0x80, 0xae, 0xfe, 0x0c, 0x90, 0xfe,
  9366. 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xac, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
  9367. 0x0a, 0xfe, 0x3c, 0x50, 0xaa, 0x01, 0xfe, 0x7a, 0x17, 0x32, 0x07, 0x2f,
  9368. 0xad, 0x01, 0xfe, 0xb4, 0x16, 0x08, 0x05, 0x1b, 0x4e, 0x01, 0xf5, 0x01,
  9369. 0xf6, 0x12, 0xfe, 0xe9, 0x00, 0x08, 0x05, 0x58, 0xfe, 0x2c, 0x13, 0x01,
  9370. 0xfe, 0x0c, 0x17, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
  9371. 0x0c, 0xfe, 0x64, 0x01, 0x14, 0xfe, 0x66, 0x01, 0x08, 0x05, 0x5b, 0xfe,
  9372. 0x12, 0x12, 0xfe, 0x03, 0x80, 0x8d, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
  9373. 0x40, 0x13, 0x20, 0x6a, 0x2a, 0x12, 0xcf, 0x64, 0x22, 0x20, 0xfb, 0x79,
  9374. 0x20, 0x04, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
  9375. 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe,
  9376. 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
  9377. 0x25, 0x6e, 0x13, 0xd0, 0x21, 0x0c, 0x5c, 0x0c, 0x45, 0x0f, 0x46, 0x52,
  9378. 0x50, 0x18, 0x1b, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xfe, 0xfc,
  9379. 0x0f, 0x44, 0x11, 0x0f, 0x48, 0x52, 0x18, 0x58, 0xfe, 0x90, 0x4d, 0xfe,
  9380. 0x91, 0x54, 0x23, 0xe4, 0x25, 0x11, 0x13, 0x20, 0x7c, 0x6f, 0x4f, 0x22,
  9381. 0x20, 0xfb, 0x79, 0x20, 0x12, 0xcf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
  9382. 0xfe, 0x26, 0x10, 0xf8, 0x74, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
  9383. 0x18, 0x1c, 0x04, 0x42, 0xfe, 0x0c, 0x14, 0xfc, 0xfe, 0x07, 0xe6, 0x1b,
  9384. 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x04, 0x01, 0xb0, 0x7c, 0x6f, 0x4f,
  9385. 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42, 0x13, 0x32, 0x07, 0x2f,
  9386. 0xfe, 0x34, 0x13, 0x09, 0x48, 0x01, 0x0e, 0xbb, 0xfe, 0x36, 0x12, 0xfe,
  9387. 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe,
  9388. 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11, 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe,
  9389. 0x80, 0x5c, 0x01, 0x73, 0xfe, 0x0e, 0x10, 0x07, 0x82, 0x4e, 0xfe, 0x14,
  9390. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x60, 0x10, 0x04, 0xfe, 0x44, 0x58, 0x8d,
  9391. 0xfe, 0x01, 0xec, 0xa2, 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe,
  9392. 0x9c, 0xe7, 0x1a, 0x79, 0x2a, 0x01, 0xe3, 0xfe, 0xdd, 0x10, 0x2c, 0xc7,
  9393. 0x81, 0xc8, 0x83, 0x33, 0x31, 0xde, 0x07, 0x1a, 0xfe, 0x48, 0x12, 0x07,
  9394. 0x0a, 0xfe, 0x56, 0x12, 0x07, 0x19, 0xfe, 0x30, 0x12, 0x07, 0xc9, 0x17,
  9395. 0xfe, 0x32, 0x12, 0x07, 0xfe, 0x23, 0x00, 0x17, 0xeb, 0x07, 0x06, 0x17,
  9396. 0xfe, 0x9c, 0x12, 0x07, 0x1f, 0xfe, 0x12, 0x12, 0x07, 0x00, 0x17, 0x24,
  9397. 0x15, 0xc9, 0x01, 0x36, 0xa9, 0x2d, 0x01, 0x0b, 0x94, 0x4b, 0x04, 0x2d,
  9398. 0xdd, 0x09, 0xd1, 0x01, 0xfe, 0x26, 0x0f, 0x12, 0x82, 0x02, 0x2b, 0x2d,
  9399. 0x32, 0x07, 0xa6, 0xfe, 0xd9, 0x13, 0x3a, 0x3d, 0x3b, 0x3e, 0x56, 0xfe,
  9400. 0xf0, 0x11, 0x08, 0x05, 0x5a, 0xfe, 0x72, 0x12, 0x9b, 0x2e, 0x9c, 0x3c,
  9401. 0x90, 0xc0, 0x96, 0xfe, 0xba, 0x11, 0x22, 0x62, 0xfe, 0x26, 0x13, 0x03,
  9402. 0x7f, 0x29, 0x80, 0x56, 0xfe, 0x76, 0x0d, 0x0c, 0x60, 0x14, 0x61, 0x21,
  9403. 0x0c, 0x7f, 0x0c, 0x80, 0x01, 0xb3, 0x25, 0x6e, 0x77, 0x13, 0x62, 0x01,
  9404. 0xef, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe,
  9405. 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0xfe, 0x91, 0x10, 0x03, 0x3f,
  9406. 0x29, 0x40, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x3f, 0x14, 0x40,
  9407. 0x88, 0x9b, 0x2e, 0x9c, 0x3c, 0x90, 0xc0, 0x03, 0x5e, 0x29, 0x5f, 0xfe,
  9408. 0x00, 0x56, 0xfe, 0xa1, 0x56, 0x0c, 0x5e, 0x14, 0x5f, 0x08, 0x05, 0x5a,
  9409. 0xfe, 0x1e, 0x12, 0x22, 0x62, 0xfe, 0x1f, 0x40, 0x03, 0x60, 0x29, 0x61,
  9410. 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x03, 0x3f, 0x29, 0x40, 0xfe, 0x44,
  9411. 0x50, 0xfe, 0xc6, 0x50, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x08, 0x50, 0xfe,
  9412. 0x8a, 0x50, 0x03, 0x3d, 0x29, 0x3e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50,
  9413. 0x02, 0x89, 0x25, 0x06, 0x13, 0xd4, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1d,
  9414. 0x4c, 0x33, 0x31, 0xde, 0x07, 0x06, 0x23, 0x4c, 0x32, 0x07, 0xa6, 0x23,
  9415. 0x72, 0x01, 0xaf, 0x1e, 0x43, 0x17, 0x4c, 0x08, 0x05, 0x0a, 0xee, 0x3a,
  9416. 0x3d, 0x3b, 0x3e, 0xfe, 0x0a, 0x55, 0x35, 0xfe, 0x8b, 0x55, 0x57, 0x3d,
  9417. 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x72, 0xfe, 0x19,
  9418. 0x81, 0xba, 0xfe, 0x19, 0x41, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1c, 0x34,
  9419. 0x1d, 0xe8, 0x33, 0x31, 0xe1, 0x55, 0x19, 0xfe, 0xa6, 0x12, 0x55, 0x0a,
  9420. 0x4d, 0x02, 0x4c, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0xe8, 0x33, 0x31, 0xdf,
  9421. 0x07, 0x19, 0x23, 0x4c, 0x01, 0x0b, 0x1d, 0xe8, 0x33, 0x31, 0xfe, 0xe8,
  9422. 0x09, 0xfe, 0xc2, 0x49, 0x51, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0x8a, 0x53,
  9423. 0x05, 0x1f, 0x35, 0xa9, 0xfe, 0xbb, 0x45, 0x55, 0x00, 0x4e, 0x44, 0x06,
  9424. 0x7c, 0x43, 0xfe, 0xda, 0x14, 0x01, 0xaf, 0x8c, 0xfe, 0x4b, 0x45, 0xee,
  9425. 0x32, 0x07, 0xa5, 0xed, 0x03, 0xcd, 0x28, 0x8a, 0x03, 0x45, 0x28, 0x35,
  9426. 0x67, 0x02, 0x72, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17,
  9427. 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01,
  9428. 0xfe, 0x9e, 0x15, 0x02, 0x89, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0x4c, 0x33,
  9429. 0x31, 0xdf, 0x07, 0x06, 0x23, 0x4c, 0x01, 0xf1, 0xfe, 0x42, 0x58, 0xf1,
  9430. 0xfe, 0xa4, 0x14, 0x8c, 0xfe, 0x4a, 0xf4, 0x0a, 0x17, 0x4c, 0xfe, 0x4a,
  9431. 0xf4, 0x06, 0xea, 0x32, 0x07, 0xa5, 0x8b, 0x02, 0x72, 0x03, 0x45, 0xc1,
  9432. 0x0c, 0x45, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01, 0xfe, 0xcc, 0x15,
  9433. 0x02, 0x89, 0x0f, 0x06, 0x27, 0xfe, 0xbe, 0x13, 0x26, 0xfe, 0xd4, 0x13,
  9434. 0x76, 0xfe, 0x89, 0x48, 0x01, 0x0b, 0x21, 0x76, 0x04, 0x7b, 0xfe, 0xd0,
  9435. 0x13, 0x1c, 0xfe, 0xd0, 0x13, 0x1d, 0xfe, 0xbe, 0x13, 0x67, 0x2d, 0x01,
  9436. 0x0b, 0xfe, 0xd5, 0x10, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
  9437. 0x1e, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x04, 0x0f,
  9438. 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0xfe, 0x30, 0x56,
  9439. 0xfe, 0x00, 0x5c, 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
  9440. 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0xfe, 0x0b, 0x58,
  9441. 0x04, 0x09, 0x5c, 0x01, 0x87, 0x09, 0x45, 0x01, 0x87, 0x04, 0xfe, 0x03,
  9442. 0xa1, 0x1e, 0x11, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x1f, 0x52,
  9443. 0xfe, 0x00, 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c,
  9444. 0x6a, 0x2a, 0x0c, 0x5e, 0x14, 0x5f, 0x57, 0x3f, 0x7d, 0x40, 0x04, 0xdd,
  9445. 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x8d, 0x04, 0x01,
  9446. 0xfe, 0x0c, 0x19, 0xfe, 0x42, 0x48, 0x50, 0x51, 0x91, 0x01, 0x0b, 0x1d,
  9447. 0xfe, 0x96, 0x15, 0x33, 0x31, 0xe1, 0x01, 0x0b, 0x1d, 0xfe, 0x96, 0x15,
  9448. 0x33, 0x31, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0xcd, 0x28, 0xfe,
  9449. 0xcc, 0x12, 0x53, 0x05, 0x1a, 0xfe, 0xc4, 0x13, 0x21, 0x69, 0x1a, 0xee,
  9450. 0x55, 0xca, 0x6b, 0xfe, 0xdc, 0x14, 0x4d, 0x0f, 0x06, 0x18, 0xca, 0x7c,
  9451. 0x30, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xab, 0xff, 0x02, 0x83,
  9452. 0x55, 0x69, 0x19, 0xae, 0x98, 0xfe, 0x30, 0x00, 0x96, 0xf2, 0x18, 0x6d,
  9453. 0x0f, 0x06, 0xfe, 0x56, 0x10, 0x69, 0x0a, 0xed, 0x98, 0xfe, 0x64, 0x00,
  9454. 0x96, 0xf2, 0x09, 0xfe, 0x64, 0x00, 0x18, 0x9e, 0x0f, 0x06, 0xfe, 0x28,
  9455. 0x10, 0x69, 0x06, 0xfe, 0x60, 0x13, 0x98, 0xfe, 0xc8, 0x00, 0x96, 0xf2,
  9456. 0x09, 0xfe, 0xc8, 0x00, 0x18, 0x59, 0x0f, 0x06, 0x88, 0x98, 0xfe, 0x90,
  9457. 0x01, 0x7a, 0xfe, 0x42, 0x15, 0x91, 0xe4, 0xfe, 0x43, 0xf4, 0x9f, 0xfe,
  9458. 0x56, 0xf0, 0xfe, 0x54, 0x15, 0xfe, 0x04, 0xf4, 0x71, 0xfe, 0x43, 0xf4,
  9459. 0x9e, 0xfe, 0xf3, 0x10, 0xfe, 0x40, 0x5c, 0x01, 0xfe, 0x16, 0x14, 0x1e,
  9460. 0x43, 0xec, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x6e, 0x7a, 0xfe, 0x90,
  9461. 0x15, 0xc4, 0x6e, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4,
  9462. 0xcc, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0xcc, 0x88, 0x51, 0x21, 0xfe, 0x4d,
  9463. 0xf4, 0x00, 0xe9, 0x91, 0x0f, 0x06, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58,
  9464. 0x04, 0x51, 0x0f, 0x0a, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xf3, 0x16,
  9465. 0x0a, 0x01, 0x0b, 0x26, 0xf3, 0x16, 0x19, 0x01, 0x0b, 0x26, 0xf3, 0x76,
  9466. 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
  9467. 0x16, 0x19, 0x01, 0x0b, 0x26, 0xb1, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
  9468. 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x26, 0xb1, 0x76, 0xfe, 0x89, 0x4a, 0x01,
  9469. 0x0b, 0x04, 0x51, 0x04, 0x22, 0xd3, 0x07, 0x06, 0xfe, 0x48, 0x13, 0xb8,
  9470. 0x13, 0xd3, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x76, 0xa9, 0x67, 0xfe, 0x01,
  9471. 0xec, 0xfe, 0x27, 0x01, 0xfe, 0x89, 0x48, 0xff, 0x02, 0x00, 0x10, 0x27,
  9472. 0xfe, 0x2e, 0x16, 0x32, 0x07, 0xfe, 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1d,
  9473. 0xfe, 0x52, 0x16, 0x21, 0x13, 0xd4, 0x01, 0x4b, 0x22, 0xd4, 0x07, 0x06,
  9474. 0x4e, 0x08, 0x54, 0x06, 0x37, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfb, 0x8e,
  9475. 0x07, 0x11, 0xae, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0x09, 0x5d, 0x01, 0xa8,
  9476. 0x04, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0xfe, 0x80, 0xe7, 0x11, 0x07, 0x11,
  9477. 0x8a, 0xfe, 0x45, 0x58, 0x01, 0xf0, 0x8e, 0x04, 0x09, 0x48, 0x01, 0x0e,
  9478. 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfe, 0x80,
  9479. 0x80, 0xfe, 0x80, 0x4c, 0xfe, 0x49, 0xe4, 0x11, 0xae, 0x09, 0x84, 0x01,
  9480. 0x0e, 0xfe, 0x80, 0x4c, 0x09, 0x5d, 0x01, 0x87, 0x04, 0x18, 0x11, 0x75,
  9481. 0x6c, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24,
  9482. 0x1c, 0xfe, 0x1d, 0xf7, 0x1b, 0x97, 0xfe, 0xee, 0x16, 0x01, 0xfe, 0xf4,
  9483. 0x17, 0xad, 0x9a, 0x1b, 0x6c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x04,
  9484. 0xb9, 0x23, 0xfe, 0xde, 0x16, 0xfe, 0xda, 0x10, 0x18, 0x11, 0x75, 0x03,
  9485. 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x1f, 0xfe, 0x18, 0x58, 0x03, 0xfe,
  9486. 0x66, 0x01, 0xfe, 0x19, 0x58, 0x9a, 0x1f, 0xfe, 0x3c, 0x90, 0xfe, 0x30,
  9487. 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x6c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79,
  9488. 0xfe, 0x1c, 0xf7, 0x1f, 0x97, 0xfe, 0x38, 0x17, 0xfe, 0xb6, 0x14, 0x35,
  9489. 0x04, 0xb9, 0x23, 0xfe, 0x10, 0x17, 0xfe, 0x9c, 0x10, 0x18, 0x11, 0x75,
  9490. 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7,
  9491. 0x2e, 0x97, 0xfe, 0x5a, 0x17, 0xfe, 0x94, 0x14, 0xec, 0x9a, 0x2e, 0x6c,
  9492. 0x1a, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x04, 0xb9, 0x23, 0xfe,
  9493. 0x4e, 0x17, 0xfe, 0x6c, 0x10, 0x18, 0x11, 0x75, 0xfe, 0x30, 0xbc, 0xfe,
  9494. 0xb2, 0xbc, 0x9a, 0xcb, 0x6c, 0x1a, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7,
  9495. 0xcb, 0x97, 0xfe, 0x92, 0x17, 0xfe, 0x5c, 0x14, 0x35, 0x04, 0xb9, 0x23,
  9496. 0xfe, 0x7e, 0x17, 0xfe, 0x42, 0x10, 0xfe, 0x02, 0xf6, 0x11, 0x75, 0xfe,
  9497. 0x18, 0xfe, 0x60, 0xfe, 0x19, 0xfe, 0x61, 0xfe, 0x03, 0xa1, 0xfe, 0x1d,
  9498. 0xf7, 0x5b, 0x97, 0xfe, 0xb8, 0x17, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13,
  9499. 0x9a, 0x5b, 0x41, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7,
  9500. 0x11, 0xfe, 0x81, 0xe7, 0x11, 0x12, 0xfe, 0xdd, 0x00, 0x6a, 0x2a, 0x04,
  9501. 0x6a, 0x2a, 0xfe, 0x12, 0x45, 0x23, 0xfe, 0xa8, 0x17, 0x15, 0x06, 0x39,
  9502. 0xa0, 0xb4, 0x02, 0x2b, 0xfe, 0x39, 0xf0, 0xfe, 0xfc, 0x17, 0x21, 0x04,
  9503. 0xfe, 0x7e, 0x18, 0x1e, 0x19, 0x66, 0x0f, 0x0d, 0x04, 0x75, 0x03, 0xd2,
  9504. 0x1e, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x7c, 0x6f, 0x4f, 0x32,
  9505. 0x07, 0x2f, 0xfe, 0x3c, 0x13, 0xf1, 0xfe, 0x42, 0x13, 0x42, 0x92, 0x09,
  9506. 0x48, 0x01, 0x0e, 0xbb, 0xeb, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
  9507. 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11,
  9508. 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x4c, 0x01, 0x73, 0xfe, 0x16,
  9509. 0x10, 0x07, 0x82, 0x8b, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xfe, 0x14,
  9510. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x1c, 0x18, 0x18, 0x0a, 0x04, 0xfe, 0x9c,
  9511. 0xe7, 0x0a, 0x10, 0xfe, 0x15, 0x00, 0x64, 0x79, 0x2a, 0x01, 0xe3, 0x18,
  9512. 0x06, 0x04, 0x42, 0x92, 0x08, 0x54, 0x1b, 0x37, 0x12, 0x2f, 0x01, 0x73,
  9513. 0x18, 0x06, 0x04, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x3a, 0xce, 0x3b,
  9514. 0xcf, 0xfe, 0x48, 0x55, 0x35, 0xfe, 0xc9, 0x55, 0x04, 0x22, 0xa3, 0x77,
  9515. 0x13, 0xa3, 0x04, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0x41, 0x48, 0x09, 0x46,
  9516. 0x01, 0x0e, 0xfe, 0x49, 0x44, 0x17, 0xfe, 0xe8, 0x18, 0x77, 0x78, 0x04,
  9517. 0x09, 0x48, 0x01, 0x0e, 0x07, 0x11, 0x4e, 0x09, 0x5d, 0x01, 0xa8, 0x09,
  9518. 0x46, 0x01, 0x0e, 0x77, 0x78, 0x04, 0xfe, 0x4e, 0xe4, 0x19, 0x6b, 0xfe,
  9519. 0x1c, 0x19, 0x03, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10,
  9520. 0xfe, 0x4e, 0xe4, 0xc9, 0x6b, 0xfe, 0x2e, 0x19, 0x03, 0xfe, 0x92, 0x00,
  9521. 0xfe, 0x02, 0xe6, 0x1a, 0xe5, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x6b,
  9522. 0xfe, 0x40, 0x19, 0x03, 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x1f, 0xfe,
  9523. 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x6d, 0xfe, 0x4e,
  9524. 0x45, 0xea, 0xba, 0xff, 0x04, 0x68, 0x54, 0xe7, 0x1e, 0x6e, 0xfe, 0x08,
  9525. 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c, 0xfe, 0x1a, 0xf4, 0xfe, 0x00,
  9526. 0x04, 0xea, 0xfe, 0x48, 0xf4, 0x19, 0x7a, 0xfe, 0x74, 0x19, 0x0f, 0x19,
  9527. 0x04, 0x07, 0x7e, 0xfe, 0x5a, 0xf0, 0xfe, 0x84, 0x19, 0x25, 0xfe, 0x09,
  9528. 0x00, 0xfe, 0x34, 0x10, 0x07, 0x1a, 0xfe, 0x5a, 0xf0, 0xfe, 0x92, 0x19,
  9529. 0x25, 0xca, 0xfe, 0x26, 0x10, 0x07, 0x19, 0x66, 0x25, 0x6d, 0xe5, 0x07,
  9530. 0x0a, 0x66, 0x25, 0x9e, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x66, 0x25, 0x59,
  9531. 0xa9, 0xb8, 0x04, 0x15, 0xfe, 0x09, 0x00, 0x01, 0x36, 0xfe, 0x04, 0xfe,
  9532. 0x81, 0x03, 0x83, 0xfe, 0x40, 0x5c, 0x04, 0x1c, 0xf7, 0xfe, 0x14, 0xf0,
  9533. 0x0b, 0x27, 0xfe, 0xd6, 0x19, 0x1c, 0xf7, 0x7b, 0xf7, 0xfe, 0x82, 0xf0,
  9534. 0xfe, 0xda, 0x19, 0x04, 0xff, 0xcc, 0x00, 0x00,
  9535. };
  9536. static unsigned short _adv_asc38C0800_size = sizeof(_adv_asc38C0800_buf); /* 0x14E1 */
  9537. static ADV_DCNT _adv_asc38C0800_chksum = 0x050D3FD8UL; /* Expanded little-endian checksum. */
  9538. /* Microcode buffer is kept after initialization for error recovery. */
  9539. static unsigned char _adv_asc38C1600_buf[] = {
  9540. 0x00, 0x00, 0x00, 0xf2, 0x00, 0x16, 0x00, 0xfc, 0x00, 0x10, 0x00, 0xf0,
  9541. 0x18, 0xe4, 0x01, 0x00, 0x04, 0x1e, 0x48, 0xe4, 0x03, 0xf6, 0xf7, 0x13,
  9542. 0x2e, 0x1e, 0x02, 0x00, 0x07, 0x17, 0xc0, 0x5f, 0x00, 0xfa, 0xff, 0xff,
  9543. 0x04, 0x00, 0x00, 0xf6, 0x09, 0xe7, 0x82, 0xe7, 0x85, 0xf0, 0x86, 0xf0,
  9544. 0x4e, 0x10, 0x9e, 0xe7, 0xff, 0x00, 0x55, 0xf0, 0x01, 0xf6, 0x03, 0x00,
  9545. 0x98, 0x57, 0x01, 0xe6, 0x00, 0xea, 0x00, 0xec, 0x01, 0xfa, 0x18, 0xf4,
  9546. 0x08, 0x00, 0xf0, 0x1d, 0x38, 0x54, 0x32, 0xf0, 0x10, 0x00, 0xc2, 0x0e,
  9547. 0x1e, 0xf0, 0xd5, 0xf0, 0xbc, 0x00, 0x4b, 0xe4, 0x00, 0xe6, 0xb1, 0xf0,
  9548. 0xb4, 0x00, 0x02, 0x13, 0x3e, 0x1c, 0xc8, 0x47, 0x3e, 0x00, 0xd8, 0x01,
  9549. 0x06, 0x13, 0x0c, 0x1c, 0x5e, 0x1e, 0x00, 0x57, 0xc8, 0x57, 0x01, 0xfc,
  9550. 0xbc, 0x0e, 0xa2, 0x12, 0xb9, 0x54, 0x00, 0x80, 0x62, 0x0a, 0x5a, 0x12,
  9551. 0xc8, 0x15, 0x3e, 0x1e, 0x18, 0x40, 0xbd, 0x56, 0x03, 0xe6, 0x01, 0xea,
  9552. 0x5c, 0xf0, 0x0f, 0x00, 0x20, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
  9553. 0x04, 0x13, 0xbb, 0x55, 0x3c, 0x56, 0x3e, 0x57, 0x03, 0x58, 0x4a, 0xe4,
  9554. 0x40, 0x00, 0xb6, 0x00, 0xbb, 0x00, 0xc0, 0x00, 0x00, 0x01, 0x01, 0x01,
  9555. 0x3e, 0x01, 0x58, 0x0a, 0x44, 0x10, 0x0a, 0x12, 0x4c, 0x1c, 0x4e, 0x1c,
  9556. 0x02, 0x4a, 0x30, 0xe4, 0x05, 0xe6, 0x0c, 0x00, 0x3c, 0x00, 0x80, 0x00,
  9557. 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01,
  9558. 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x7c, 0x01, 0xc6, 0x0e, 0x0c, 0x10,
  9559. 0xac, 0x12, 0xae, 0x12, 0x16, 0x1a, 0x32, 0x1c, 0x6e, 0x1e, 0x02, 0x48,
  9560. 0x3a, 0x55, 0xc9, 0x57, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x06, 0xf7,
  9561. 0x03, 0xfc, 0x06, 0x00, 0x1e, 0x00, 0xbe, 0x00, 0xe1, 0x00, 0x0c, 0x12,
  9562. 0x18, 0x1a, 0x70, 0x1a, 0x30, 0x1c, 0x38, 0x1c, 0x10, 0x44, 0x00, 0x4c,
  9563. 0xb0, 0x57, 0x40, 0x5c, 0x4d, 0xe4, 0x04, 0xea, 0x5d, 0xf0, 0xa7, 0xf0,
  9564. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x09, 0x00, 0x19, 0x00, 0x32, 0x00,
  9565. 0x33, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0x9e, 0x00, 0xcc, 0x00,
  9566. 0x20, 0x01, 0x4e, 0x01, 0x79, 0x01, 0x3c, 0x09, 0x68, 0x0d, 0x02, 0x10,
  9567. 0x04, 0x10, 0x3a, 0x10, 0x08, 0x12, 0x0a, 0x13, 0x40, 0x16, 0x50, 0x16,
  9568. 0x00, 0x17, 0x4a, 0x19, 0x00, 0x4e, 0x00, 0x54, 0x01, 0x58, 0x00, 0xdc,
  9569. 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xb8, 0xf0, 0x48, 0xf4, 0x0e, 0xf7,
  9570. 0x0a, 0x00, 0x9b, 0x00, 0x9c, 0x00, 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00,
  9571. 0xd0, 0x00, 0xe7, 0x00, 0xf0, 0x03, 0x69, 0x08, 0xe9, 0x09, 0x5c, 0x0c,
  9572. 0xb6, 0x12, 0xbc, 0x19, 0xd8, 0x1b, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c,
  9573. 0x42, 0x1d, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46,
  9574. 0x89, 0x48, 0x68, 0x54, 0x83, 0x55, 0x83, 0x59, 0x31, 0xe4, 0x02, 0xe6,
  9575. 0x07, 0xf0, 0x08, 0xf0, 0x0b, 0xf0, 0x0c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8,
  9576. 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa, 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00,
  9577. 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0x22, 0x01,
  9578. 0x26, 0x01, 0x60, 0x01, 0x7a, 0x01, 0x82, 0x01, 0xc8, 0x01, 0xca, 0x01,
  9579. 0x86, 0x02, 0x6a, 0x03, 0x18, 0x05, 0xb2, 0x07, 0x68, 0x08, 0x10, 0x0d,
  9580. 0x06, 0x10, 0x0a, 0x10, 0x0e, 0x10, 0x12, 0x10, 0x60, 0x10, 0xed, 0x10,
  9581. 0xf3, 0x10, 0x06, 0x12, 0x10, 0x12, 0x1e, 0x12, 0x0c, 0x13, 0x0e, 0x13,
  9582. 0x10, 0x13, 0xfe, 0x9c, 0xf0, 0x35, 0x05, 0xfe, 0xec, 0x0e, 0xff, 0x10,
  9583. 0x00, 0x00, 0xe9, 0xfe, 0x34, 0x1f, 0x00, 0xe8, 0xfe, 0x88, 0x01, 0xff,
  9584. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  9585. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x65, 0xff, 0x04, 0x00,
  9586. 0x00, 0x1a, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  9587. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x13,
  9588. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  9589. 0xfe, 0x04, 0xf7, 0xe8, 0x37, 0x7d, 0x0d, 0x01, 0xfe, 0x4a, 0x11, 0xfe,
  9590. 0x04, 0xf7, 0xe8, 0x7d, 0x0d, 0x51, 0x37, 0xfe, 0x3d, 0xf0, 0xfe, 0x0c,
  9591. 0x02, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x91, 0xf0, 0xfe, 0xf8, 0x01, 0xfe,
  9592. 0x90, 0xf0, 0xfe, 0xf8, 0x01, 0xfe, 0x8f, 0xf0, 0xbc, 0x03, 0x67, 0x4d,
  9593. 0x05, 0xfe, 0x08, 0x0f, 0x01, 0xfe, 0x78, 0x0f, 0xfe, 0xdd, 0x12, 0x05,
  9594. 0xfe, 0x0e, 0x03, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd1,
  9595. 0x12, 0x3e, 0x22, 0xfe, 0xa6, 0x00, 0xac, 0xfe, 0x48, 0xf0, 0xfe, 0x90,
  9596. 0x02, 0xfe, 0x49, 0xf0, 0xfe, 0xaa, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc8,
  9597. 0x02, 0xfe, 0x46, 0xf0, 0xfe, 0x5a, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x60,
  9598. 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x4e, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x52,
  9599. 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x56, 0x02, 0x1c, 0x0d, 0xa2, 0x1c, 0x07,
  9600. 0x22, 0xb7, 0x05, 0x35, 0xfe, 0x00, 0x1c, 0xfe, 0xf1, 0x10, 0xfe, 0x02,
  9601. 0x1c, 0xf5, 0xfe, 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0x5f, 0xfe, 0xe7,
  9602. 0x10, 0xfe, 0x06, 0xfc, 0xde, 0x0a, 0x81, 0x01, 0xa3, 0x05, 0x35, 0x1f,
  9603. 0x95, 0x47, 0xb8, 0x01, 0xfe, 0xe4, 0x11, 0x0a, 0x81, 0x01, 0x5c, 0xfe,
  9604. 0xbd, 0x10, 0x0a, 0x81, 0x01, 0x5c, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c,
  9605. 0xfe, 0x58, 0x1c, 0x1c, 0x07, 0x22, 0xb7, 0x37, 0x2a, 0x35, 0xfe, 0x3d,
  9606. 0xf0, 0xfe, 0x0c, 0x02, 0x2b, 0xfe, 0x9e, 0x02, 0xfe, 0x5a, 0x1c, 0xfe,
  9607. 0x12, 0x1c, 0xfe, 0x14, 0x1c, 0x1f, 0xfe, 0x30, 0x00, 0x47, 0xb8, 0x01,
  9608. 0xfe, 0xd4, 0x11, 0x1c, 0x07, 0x22, 0xb7, 0x05, 0xe9, 0x21, 0x2c, 0x09,
  9609. 0x1a, 0x31, 0xfe, 0x69, 0x10, 0x1c, 0x07, 0x22, 0xb7, 0xfe, 0x04, 0xec,
  9610. 0x2c, 0x60, 0x01, 0xfe, 0x1e, 0x1e, 0x20, 0x2c, 0xfe, 0x05, 0xf6, 0xde,
  9611. 0x01, 0xfe, 0x62, 0x1b, 0x01, 0x0c, 0x61, 0x4a, 0x44, 0x15, 0x56, 0x51,
  9612. 0x01, 0xfe, 0x9e, 0x1e, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x0a, 0x57,
  9613. 0x01, 0x18, 0x09, 0x00, 0x36, 0x01, 0x85, 0xfe, 0x18, 0x10, 0xfe, 0x41,
  9614. 0x58, 0x0a, 0xba, 0x01, 0x18, 0xfe, 0xc8, 0x54, 0x7b, 0xfe, 0x1c, 0x03,
  9615. 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x37, 0x60, 0xfe, 0x02, 0xe8, 0x30,
  9616. 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe, 0x27, 0xf0,
  9617. 0xfe, 0xe4, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x40,
  9618. 0x1c, 0x2a, 0xeb, 0xfe, 0x26, 0xf0, 0xfe, 0x66, 0x03, 0xfe, 0xa0, 0xf0,
  9619. 0xfe, 0x54, 0x03, 0xfe, 0x11, 0xf0, 0xbc, 0xfe, 0xef, 0x10, 0xfe, 0x9f,
  9620. 0xf0, 0xfe, 0x74, 0x03, 0xfe, 0x46, 0x1c, 0x19, 0xfe, 0x11, 0x00, 0x05,
  9621. 0x70, 0x37, 0xfe, 0x48, 0x1c, 0xfe, 0x46, 0x1c, 0x01, 0x0c, 0x06, 0x28,
  9622. 0xfe, 0x18, 0x13, 0x26, 0x21, 0xb9, 0xc7, 0x20, 0xb9, 0x0a, 0x57, 0x01,
  9623. 0x18, 0xc7, 0x89, 0x01, 0xfe, 0xc8, 0x1a, 0x15, 0xe1, 0x2a, 0xeb, 0xfe,
  9624. 0x01, 0xf0, 0xeb, 0xfe, 0x82, 0xf0, 0xfe, 0xa4, 0x03, 0xfe, 0x9c, 0x32,
  9625. 0x15, 0xfe, 0xe4, 0x00, 0x2f, 0xfe, 0xb6, 0x03, 0x2a, 0x3c, 0x16, 0xfe,
  9626. 0xc6, 0x03, 0x01, 0x41, 0xfe, 0x06, 0xf0, 0xfe, 0xd6, 0x03, 0xaf, 0xa0,
  9627. 0xfe, 0x0a, 0xf0, 0xfe, 0xa2, 0x07, 0x05, 0x29, 0x03, 0x81, 0x1e, 0x1b,
  9628. 0xfe, 0x24, 0x05, 0x1f, 0x63, 0x01, 0x42, 0x8f, 0xfe, 0x70, 0x02, 0x05,
  9629. 0xea, 0xfe, 0x46, 0x1c, 0x37, 0x7d, 0x1d, 0xfe, 0x67, 0x1b, 0xfe, 0xbf,
  9630. 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c, 0x75, 0x01, 0xa6, 0x86, 0x0a,
  9631. 0x57, 0x01, 0x18, 0x09, 0x00, 0x1b, 0xec, 0x0a, 0xe1, 0x01, 0x18, 0x77,
  9632. 0x50, 0x40, 0x8d, 0x30, 0x03, 0x81, 0x1e, 0xf8, 0x1f, 0x63, 0x01, 0x42,
  9633. 0x8f, 0xfe, 0x70, 0x02, 0x05, 0xea, 0xd7, 0x99, 0xd8, 0x9c, 0x2a, 0x29,
  9634. 0x2f, 0xfe, 0x4e, 0x04, 0x16, 0xfe, 0x4a, 0x04, 0x7e, 0xfe, 0xa0, 0x00,
  9635. 0xfe, 0x9b, 0x57, 0xfe, 0x54, 0x12, 0x32, 0xff, 0x02, 0x00, 0x10, 0x01,
  9636. 0x08, 0x16, 0xfe, 0x02, 0x05, 0x32, 0x01, 0x08, 0x16, 0x29, 0x27, 0x25,
  9637. 0xee, 0xfe, 0x4c, 0x44, 0xfe, 0x58, 0x12, 0x50, 0xfe, 0x44, 0x48, 0x13,
  9638. 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x60, 0x8d, 0x30, 0x01, 0xfe, 0x4e,
  9639. 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x7c, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xfe,
  9640. 0x32, 0x13, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x68, 0x13, 0xfe, 0x26, 0x10,
  9641. 0x13, 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x01, 0xfe, 0x4e, 0x1e, 0xfe,
  9642. 0x48, 0x47, 0xfe, 0x54, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xa5, 0x01, 0x43,
  9643. 0x09, 0x9b, 0xfe, 0x40, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xf9, 0x1f, 0x7f,
  9644. 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42, 0x8f,
  9645. 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x32, 0x15, 0xfe, 0xe6, 0x00, 0x0f, 0xfe,
  9646. 0x1c, 0x90, 0x04, 0xfe, 0x9c, 0x93, 0x3a, 0x0b, 0x0e, 0x8b, 0x02, 0x1f,
  9647. 0x7f, 0x01, 0x42, 0x05, 0x35, 0xfe, 0x42, 0x5b, 0x7d, 0x1d, 0xfe, 0x46,
  9648. 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0x0f, 0xfe, 0x87, 0x80, 0x04,
  9649. 0xfe, 0x87, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xd0, 0x65, 0x01, 0x0c,
  9650. 0x06, 0x0d, 0xfe, 0x98, 0x13, 0x0f, 0xfe, 0x20, 0x80, 0x04, 0xfe, 0xa0,
  9651. 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x1d, 0xfe, 0x84, 0x12, 0x01, 0x38, 0x06,
  9652. 0x07, 0xfe, 0x70, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x1e, 0x1b, 0xfe, 0xda,
  9653. 0x05, 0xd0, 0x54, 0x01, 0x38, 0x06, 0x0d, 0xfe, 0x58, 0x13, 0x03, 0xfe,
  9654. 0xa0, 0x00, 0x1e, 0xfe, 0x50, 0x12, 0x5e, 0xff, 0x02, 0x00, 0x10, 0x2f,
  9655. 0xfe, 0x90, 0x05, 0x2a, 0x3c, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe,
  9656. 0x9e, 0x05, 0x17, 0xfe, 0xf4, 0x05, 0x15, 0xfe, 0xe3, 0x00, 0x26, 0x01,
  9657. 0x38, 0xfe, 0x4a, 0xf0, 0xfe, 0xc0, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0xba,
  9658. 0x05, 0x71, 0x2e, 0xfe, 0x21, 0x00, 0xf1, 0x2e, 0xfe, 0x22, 0x00, 0xa2,
  9659. 0x2e, 0x4a, 0xfe, 0x09, 0x48, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe, 0xd0,
  9660. 0x05, 0x17, 0xfe, 0xf4, 0x05, 0xfe, 0xe2, 0x08, 0x01, 0x38, 0x06, 0xfe,
  9661. 0x1c, 0x00, 0x4d, 0x01, 0xa7, 0x2e, 0x07, 0x20, 0xe4, 0x47, 0xfe, 0x27,
  9662. 0x01, 0x01, 0x0c, 0x06, 0x28, 0xfe, 0x24, 0x12, 0x3e, 0x01, 0x84, 0x1f,
  9663. 0x7f, 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42,
  9664. 0x8f, 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x03, 0xe6, 0x1e, 0xfe, 0xca, 0x13,
  9665. 0x03, 0xb6, 0x1e, 0xfe, 0x40, 0x12, 0x03, 0x66, 0x1e, 0xfe, 0x38, 0x13,
  9666. 0x3e, 0x01, 0x84, 0x17, 0xfe, 0x72, 0x06, 0x0a, 0x07, 0x01, 0x38, 0x06,
  9667. 0x24, 0xfe, 0x02, 0x12, 0x4f, 0x01, 0xfe, 0x56, 0x19, 0x16, 0xfe, 0x68,
  9668. 0x06, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x66, 0x8a, 0x10, 0x66,
  9669. 0x03, 0x9a, 0x1e, 0xfe, 0x70, 0x12, 0x03, 0x55, 0x1e, 0xfe, 0x68, 0x13,
  9670. 0x01, 0xc6, 0x09, 0x12, 0x48, 0xfe, 0x92, 0x06, 0x2e, 0x12, 0x01, 0xfe,
  9671. 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0x13, 0x58, 0xff, 0x02, 0x00,
  9672. 0x57, 0x52, 0xad, 0x23, 0x3f, 0x4e, 0x62, 0x49, 0x3e, 0x01, 0x84, 0x17,
  9673. 0xfe, 0xea, 0x06, 0x01, 0x38, 0x06, 0x12, 0xf7, 0x45, 0x0a, 0x95, 0x01,
  9674. 0xfe, 0x84, 0x19, 0x16, 0xfe, 0xe0, 0x06, 0x15, 0x82, 0x01, 0x41, 0x15,
  9675. 0xe2, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x1c, 0x07, 0x01, 0x84, 0xfe, 0xae,
  9676. 0x10, 0x03, 0x6f, 0x1e, 0xfe, 0x9e, 0x13, 0x3e, 0x01, 0x84, 0x03, 0x9a,
  9677. 0x1e, 0xfe, 0x1a, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfc, 0x01, 0xc6, 0x01,
  9678. 0xfe, 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0xf0, 0x45, 0x0a, 0x95,
  9679. 0x03, 0xb6, 0x1e, 0xf8, 0x01, 0x38, 0x06, 0x24, 0x36, 0xfe, 0x02, 0xf6,
  9680. 0x07, 0x71, 0x78, 0x8c, 0x00, 0x4d, 0x62, 0x49, 0x3e, 0x2d, 0x93, 0x4e,
  9681. 0xd0, 0x0d, 0x17, 0xfe, 0x9a, 0x07, 0x01, 0xfe, 0xc0, 0x19, 0x16, 0xfe,
  9682. 0x90, 0x07, 0x26, 0x20, 0x9e, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x21,
  9683. 0x9e, 0x09, 0x07, 0xfb, 0x03, 0xe6, 0xfe, 0x58, 0x57, 0x10, 0xe6, 0x05,
  9684. 0xfe, 0x2a, 0x06, 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x1c, 0x07, 0x01, 0x84,
  9685. 0xfe, 0x9c, 0x32, 0x5f, 0x75, 0x01, 0xa6, 0x86, 0x15, 0xfe, 0xe2, 0x00,
  9686. 0x2f, 0xed, 0x2a, 0x3c, 0xfe, 0x0a, 0xf0, 0xfe, 0xce, 0x07, 0xae, 0xfe,
  9687. 0x96, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x9e, 0x08, 0xaf, 0xa0, 0x05, 0x29,
  9688. 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x2e, 0x12, 0x14, 0x1d, 0x01, 0x08, 0x14,
  9689. 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0xfe,
  9690. 0x99, 0xa4, 0x01, 0x08, 0x14, 0x00, 0x05, 0xfe, 0xc6, 0x09, 0x01, 0x76,
  9691. 0x06, 0x12, 0xfe, 0x3a, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x30, 0x13,
  9692. 0x14, 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00,
  9693. 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x07, 0x01, 0x08, 0x14, 0x00,
  9694. 0x05, 0xef, 0x7c, 0x4a, 0x78, 0x4f, 0x0f, 0xfe, 0x9a, 0x81, 0x04, 0xfe,
  9695. 0x9a, 0x83, 0xfe, 0xcb, 0x47, 0x0b, 0x0e, 0x2d, 0x28, 0x48, 0xfe, 0x6c,
  9696. 0x08, 0x0a, 0x28, 0xfe, 0x09, 0x6f, 0xca, 0xfe, 0xca, 0x45, 0xfe, 0x32,
  9697. 0x12, 0x53, 0x63, 0x4e, 0x7c, 0x97, 0x2f, 0xfe, 0x7e, 0x08, 0x2a, 0x3c,
  9698. 0xfe, 0x0a, 0xf0, 0xfe, 0x6c, 0x08, 0xaf, 0xa0, 0xae, 0xfe, 0x96, 0x08,
  9699. 0x05, 0x29, 0x01, 0x41, 0x05, 0xed, 0x14, 0x24, 0x05, 0xed, 0xfe, 0x9c,
  9700. 0xf7, 0x9f, 0x01, 0xfe, 0xae, 0x1e, 0xfe, 0x18, 0x58, 0x01, 0xfe, 0xbe,
  9701. 0x1e, 0xfe, 0x99, 0x58, 0xfe, 0x78, 0x18, 0xfe, 0xf9, 0x18, 0x8e, 0xfe,
  9702. 0x16, 0x09, 0x10, 0x6a, 0x22, 0x6b, 0x01, 0x0c, 0x61, 0x54, 0x44, 0x21,
  9703. 0x2c, 0x09, 0x1a, 0xf8, 0x77, 0x01, 0xfe, 0x7e, 0x1e, 0x47, 0x2c, 0x7a,
  9704. 0x30, 0xf0, 0xfe, 0x83, 0xe7, 0xfe, 0x3f, 0x00, 0x71, 0xfe, 0x03, 0x40,
  9705. 0x01, 0x0c, 0x61, 0x65, 0x44, 0x01, 0xc2, 0xc8, 0xfe, 0x1f, 0x40, 0x20,
  9706. 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
  9707. 0x44, 0x51, 0xfe, 0xc6, 0x51, 0xfe, 0x10, 0x10, 0x01, 0xfe, 0xce, 0x1e,
  9708. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x01, 0xfe, 0xee, 0x1e,
  9709. 0x01, 0xfe, 0xfe, 0x1e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x10, 0x4b,
  9710. 0x22, 0x4c, 0xfe, 0x8a, 0x10, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x50, 0x12,
  9711. 0x01, 0xfe, 0xae, 0x1e, 0x01, 0xfe, 0xbe, 0x1e, 0x10, 0x6a, 0x22, 0x6b,
  9712. 0x01, 0x0c, 0x06, 0x65, 0x4e, 0x01, 0xc2, 0x0f, 0xfe, 0x1f, 0x80, 0x04,
  9713. 0xfe, 0x9f, 0x83, 0x33, 0x0b, 0x0e, 0x20, 0x6e, 0x0f, 0xfe, 0x44, 0x90,
  9714. 0x04, 0xfe, 0xc4, 0x93, 0x3a, 0x0b, 0xfe, 0xc6, 0x90, 0x04, 0xfe, 0xc6,
  9715. 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x6c, 0x22, 0x6d, 0x01, 0xfe, 0xce, 0x1e,
  9716. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x0f, 0xfe, 0x40, 0x90,
  9717. 0x04, 0xfe, 0xc0, 0x93, 0x3a, 0x0b, 0xfe, 0xc2, 0x90, 0x04, 0xfe, 0xc2,
  9718. 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x4b, 0x22, 0x4c, 0x10, 0x64, 0x22, 0x34,
  9719. 0x01, 0x0c, 0x61, 0x24, 0x44, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe,
  9720. 0xde, 0x09, 0xfe, 0x9e, 0xf0, 0xfe, 0xf2, 0x09, 0xfe, 0x01, 0x48, 0x1b,
  9721. 0x3c, 0x37, 0x88, 0xf5, 0xd4, 0xfe, 0x1e, 0x0a, 0xd5, 0xfe, 0x42, 0x0a,
  9722. 0xd2, 0xfe, 0x1e, 0x0a, 0xd3, 0xfe, 0x42, 0x0a, 0xae, 0xfe, 0x12, 0x0a,
  9723. 0xfe, 0x06, 0xf0, 0xfe, 0x18, 0x0a, 0xaf, 0xa0, 0x05, 0x29, 0x01, 0x41,
  9724. 0xfe, 0xc1, 0x10, 0x14, 0x24, 0xfe, 0xc1, 0x10, 0x01, 0x76, 0x06, 0x07,
  9725. 0xfe, 0x14, 0x12, 0x01, 0x76, 0x06, 0x0d, 0x5d, 0x01, 0x0c, 0x06, 0x0d,
  9726. 0xfe, 0x74, 0x12, 0xfe, 0x2e, 0x1c, 0x05, 0xfe, 0x1a, 0x0c, 0x01, 0x76,
  9727. 0x06, 0x07, 0x5d, 0x01, 0x76, 0x06, 0x0d, 0x41, 0xfe, 0x2c, 0x1c, 0xfe,
  9728. 0xaa, 0xf0, 0xfe, 0xce, 0x0a, 0xfe, 0xac, 0xf0, 0xfe, 0x66, 0x0a, 0xfe,
  9729. 0x92, 0x10, 0xc4, 0xf6, 0xfe, 0xad, 0xf0, 0xfe, 0x72, 0x0a, 0x05, 0xfe,
  9730. 0x1a, 0x0c, 0xc5, 0xfe, 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0xbf, 0xfe, 0x6b,
  9731. 0x18, 0x23, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xac, 0xfe, 0xd2, 0xf0,
  9732. 0xbf, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x1b, 0xbf, 0x03, 0xe3, 0x23, 0x07,
  9733. 0x1b, 0xbf, 0xd4, 0x5b, 0xd5, 0x5b, 0xd2, 0x5b, 0xd3, 0x5b, 0xc4, 0xc5,
  9734. 0xfe, 0xa9, 0x10, 0x75, 0x5e, 0x32, 0x1f, 0x7f, 0x01, 0x42, 0x19, 0xfe,
  9735. 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x70, 0x19, 0x98, 0x05, 0x70, 0xfe, 0x74,
  9736. 0x18, 0x23, 0xfe, 0x00, 0xf8, 0x1b, 0x5b, 0x7d, 0x12, 0x01, 0xfe, 0x78,
  9737. 0x0f, 0x4d, 0x01, 0xfe, 0x96, 0x1a, 0x21, 0x30, 0x77, 0x7d, 0x1d, 0x05,
  9738. 0x5b, 0x01, 0x0c, 0x06, 0x0d, 0x2b, 0xfe, 0xe2, 0x0b, 0x01, 0x0c, 0x06,
  9739. 0x54, 0xfe, 0xa6, 0x12, 0x01, 0x0c, 0x06, 0x24, 0xfe, 0x88, 0x13, 0x21,
  9740. 0x6e, 0xc7, 0x01, 0xfe, 0x1e, 0x1f, 0x0f, 0xfe, 0x83, 0x80, 0x04, 0xfe,
  9741. 0x83, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xfe, 0xc8, 0x44, 0xfe, 0x42,
  9742. 0x13, 0x0f, 0xfe, 0x04, 0x91, 0x04, 0xfe, 0x84, 0x93, 0xfe, 0xca, 0x57,
  9743. 0x0b, 0xfe, 0x86, 0x91, 0x04, 0xfe, 0x86, 0x93, 0xfe, 0xcb, 0x57, 0x0b,
  9744. 0x0e, 0x7a, 0x30, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x8e, 0x40, 0x03,
  9745. 0x6a, 0x3b, 0x6b, 0x10, 0x97, 0x22, 0x98, 0xd9, 0x6a, 0xda, 0x6b, 0x01,
  9746. 0xc2, 0xc8, 0x7a, 0x30, 0x20, 0x6e, 0xdb, 0x64, 0xdc, 0x34, 0x91, 0x6c,
  9747. 0x7e, 0x6d, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xfe, 0x04, 0xfa, 0x64,
  9748. 0xfe, 0x05, 0xfa, 0x34, 0x01, 0xfe, 0x6a, 0x16, 0xa3, 0x26, 0x10, 0x97,
  9749. 0x10, 0x98, 0x91, 0x6c, 0x7e, 0x6d, 0xfe, 0x14, 0x10, 0x01, 0x0c, 0x06,
  9750. 0x24, 0x1b, 0x40, 0x91, 0x4b, 0x7e, 0x4c, 0x01, 0x0c, 0x06, 0xfe, 0xf7,
  9751. 0x00, 0x44, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58,
  9752. 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x05, 0x5b, 0x01, 0x0c, 0x06, 0x24,
  9753. 0x1b, 0x40, 0x01, 0x0c, 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x78, 0x01, 0xfe,
  9754. 0x8e, 0x1e, 0x4f, 0x0f, 0xfe, 0x10, 0x90, 0x04, 0xfe, 0x90, 0x93, 0x3a,
  9755. 0x0b, 0xfe, 0x92, 0x90, 0x04, 0xfe, 0x92, 0x93, 0x79, 0x0b, 0x0e, 0xfe,
  9756. 0xbd, 0x10, 0x01, 0x43, 0x09, 0xbb, 0x1b, 0xfe, 0x6e, 0x0a, 0x15, 0xbb,
  9757. 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x14, 0x13, 0x03, 0x4b, 0x3b, 0x4c, 0x8e,
  9758. 0xfe, 0x6e, 0x0a, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x05, 0x5b, 0x26,
  9759. 0x3e, 0x0f, 0xfe, 0x19, 0x80, 0x04, 0xfe, 0x99, 0x83, 0x33, 0x0b, 0x0e,
  9760. 0xfe, 0xe5, 0x10, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1a, 0x12, 0xfe, 0x6c,
  9761. 0x19, 0xfe, 0x19, 0x41, 0xfe, 0x6b, 0x18, 0xac, 0xfe, 0xd1, 0xf0, 0xef,
  9762. 0x1f, 0x92, 0x01, 0x42, 0x19, 0xfe, 0x44, 0x00, 0xfe, 0x90, 0x10, 0xfe,
  9763. 0x6c, 0x19, 0xd9, 0x4b, 0xfe, 0xed, 0x19, 0xda, 0x4c, 0xfe, 0x0c, 0x51,
  9764. 0xfe, 0x8e, 0x51, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xff, 0x31, 0xfe,
  9765. 0x76, 0x10, 0xac, 0xfe, 0xd2, 0xf0, 0xfe, 0xba, 0x0c, 0xfe, 0x76, 0x18,
  9766. 0x23, 0x1d, 0x5d, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0x08, 0x13, 0x19, 0xfe,
  9767. 0x16, 0x00, 0x05, 0x70, 0xfe, 0xd1, 0xf0, 0xfe, 0xcc, 0x0c, 0x1f, 0x92,
  9768. 0x01, 0x42, 0x19, 0xfe, 0x17, 0x00, 0x5c, 0xfe, 0xce, 0xf0, 0xfe, 0xd2,
  9769. 0x0c, 0xfe, 0x3e, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xde, 0x0c, 0x19, 0xfe,
  9770. 0x22, 0x00, 0x05, 0x70, 0xfe, 0xcb, 0xf0, 0xfe, 0xea, 0x0c, 0x19, 0xfe,
  9771. 0x24, 0x00, 0x05, 0x70, 0xfe, 0xd0, 0xf0, 0xfe, 0xf4, 0x0c, 0x19, 0x94,
  9772. 0xfe, 0x1c, 0x10, 0xfe, 0xcf, 0xf0, 0xfe, 0xfe, 0x0c, 0x19, 0x4a, 0xf3,
  9773. 0xfe, 0xcc, 0xf0, 0xef, 0x01, 0x76, 0x06, 0x24, 0x4d, 0x19, 0xfe, 0x12,
  9774. 0x00, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe, 0x16, 0x0d, 0xfe, 0x9e,
  9775. 0xf0, 0xfe, 0x2a, 0x0d, 0xfe, 0x01, 0x48, 0x1b, 0x3c, 0x37, 0x88, 0xf5,
  9776. 0xd4, 0x29, 0xd5, 0x29, 0xd2, 0x29, 0xd3, 0x29, 0x37, 0xfe, 0x9c, 0x32,
  9777. 0x2f, 0xfe, 0x3e, 0x0d, 0x2a, 0x3c, 0xae, 0xfe, 0x62, 0x0d, 0xaf, 0xa0,
  9778. 0xd4, 0x9f, 0xd5, 0x9f, 0xd2, 0x9f, 0xd3, 0x9f, 0x05, 0x29, 0x01, 0x41,
  9779. 0xfe, 0xd3, 0x10, 0x15, 0xfe, 0xe8, 0x00, 0xc4, 0xc5, 0x75, 0xd7, 0x99,
  9780. 0xd8, 0x9c, 0xfe, 0x89, 0xf0, 0x29, 0x27, 0x25, 0xbe, 0xd7, 0x99, 0xd8,
  9781. 0x9c, 0x2f, 0xfe, 0x8c, 0x0d, 0x16, 0x29, 0x27, 0x25, 0xbd, 0xfe, 0x01,
  9782. 0x48, 0xa4, 0x19, 0xfe, 0x42, 0x00, 0x05, 0x70, 0x90, 0x07, 0xfe, 0x81,
  9783. 0x49, 0x1b, 0xfe, 0x64, 0x0e, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x44, 0x13,
  9784. 0x19, 0x00, 0x2d, 0x0d, 0xfe, 0x54, 0x12, 0x2d, 0xfe, 0x28, 0x00, 0x2b,
  9785. 0xfe, 0xda, 0x0e, 0x0a, 0x57, 0x01, 0x18, 0x09, 0x00, 0x36, 0x46, 0xfe,
  9786. 0x28, 0x00, 0xfe, 0xfa, 0x10, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00,
  9787. 0x1d, 0x0a, 0xba, 0x01, 0xfe, 0x58, 0x10, 0x40, 0x15, 0x56, 0x01, 0x85,
  9788. 0x05, 0x35, 0x19, 0xfe, 0x44, 0x00, 0x2d, 0x0d, 0xf7, 0x46, 0x0d, 0xfe,
  9789. 0xcc, 0x10, 0x01, 0xa7, 0x46, 0x0d, 0xfe, 0xc2, 0x10, 0x01, 0xa7, 0x0f,
  9790. 0xfe, 0x19, 0x82, 0x04, 0xfe, 0x99, 0x83, 0xfe, 0xcc, 0x47, 0x0b, 0x0e,
  9791. 0xfe, 0x34, 0x46, 0xa5, 0x46, 0x0d, 0x19, 0xfe, 0x43, 0x00, 0xfe, 0xa2,
  9792. 0x10, 0x01, 0x0c, 0x61, 0x0d, 0x44, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe,
  9793. 0x00, 0x1d, 0x40, 0x15, 0x56, 0x01, 0x85, 0x7d, 0x0d, 0x40, 0x51, 0x01,
  9794. 0xfe, 0x9e, 0x1e, 0x05, 0xfe, 0x3a, 0x03, 0x01, 0x0c, 0x06, 0x0d, 0x5d,
  9795. 0x46, 0x0d, 0x19, 0x00, 0xfe, 0x62, 0x10, 0x01, 0x76, 0x06, 0x12, 0xfe,
  9796. 0x5c, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x52, 0x13, 0xfe, 0x1c, 0x1c,
  9797. 0xfe, 0x9d, 0xf0, 0xfe, 0x8e, 0x0e, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0,
  9798. 0xfe, 0x94, 0x0e, 0x01, 0x0c, 0x61, 0x12, 0x44, 0xfe, 0x9f, 0x10, 0x19,
  9799. 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0d, 0x4f, 0xfe, 0x2e, 0x10, 0x19,
  9800. 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x19, 0xfe, 0x47, 0x00, 0xf1, 0x19,
  9801. 0xfe, 0x41, 0x00, 0xa2, 0x19, 0xfe, 0x24, 0x00, 0x86, 0xc4, 0xc5, 0x75,
  9802. 0x03, 0x81, 0x1e, 0x2b, 0xea, 0x4f, 0xfe, 0x04, 0xe6, 0x12, 0xfe, 0x9d,
  9803. 0x41, 0xfe, 0x1c, 0x42, 0x40, 0x01, 0xf4, 0x05, 0x35, 0xfe, 0x12, 0x1c,
  9804. 0x1f, 0x0d, 0x47, 0xb5, 0xc3, 0x1f, 0xfe, 0x31, 0x00, 0x47, 0xb8, 0x01,
  9805. 0xfe, 0xd4, 0x11, 0x05, 0xe9, 0x51, 0xfe, 0x06, 0xec, 0xe0, 0xfe, 0x0e,
  9806. 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0x06, 0xea, 0xe0,
  9807. 0xfe, 0x47, 0x4b, 0x45, 0xfe, 0x75, 0x57, 0x03, 0x67, 0xfe, 0x98, 0x56,
  9808. 0xfe, 0x38, 0x12, 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x44, 0x48, 0x60, 0x01,
  9809. 0x0c, 0x06, 0x28, 0xfe, 0x18, 0x13, 0x0a, 0x57, 0x01, 0x18, 0x3e, 0xfe,
  9810. 0x41, 0x58, 0x0a, 0xba, 0xfe, 0xfa, 0x14, 0xfe, 0x49, 0x54, 0xb0, 0xfe,
  9811. 0x5e, 0x0f, 0x05, 0xfe, 0x3a, 0x03, 0x0a, 0x67, 0xfe, 0xe0, 0x14, 0xfe,
  9812. 0x0e, 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0xce, 0x47,
  9813. 0xfe, 0xad, 0x13, 0x05, 0x35, 0x21, 0x2c, 0x09, 0x1a, 0xfe, 0x98, 0x12,
  9814. 0x26, 0x20, 0x96, 0x20, 0xe7, 0xfe, 0x08, 0x1c, 0xfe, 0x7c, 0x19, 0xfe,
  9815. 0xfd, 0x19, 0xfe, 0x0a, 0x1c, 0x03, 0xe5, 0xfe, 0x48, 0x55, 0xa5, 0x3b,
  9816. 0xfe, 0x62, 0x01, 0xfe, 0xc9, 0x55, 0x31, 0xfe, 0x74, 0x10, 0x01, 0xfe,
  9817. 0xf0, 0x1a, 0x03, 0xfe, 0x38, 0x01, 0x3b, 0xfe, 0x3a, 0x01, 0x8e, 0xfe,
  9818. 0x1e, 0x10, 0xfe, 0x02, 0xec, 0xe7, 0x53, 0x00, 0x36, 0xfe, 0x04, 0xec,
  9819. 0x2c, 0x60, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x62, 0x1b,
  9820. 0x01, 0xfe, 0xce, 0x1e, 0xb2, 0x11, 0xfe, 0x18, 0x13, 0xca, 0xfe, 0x02,
  9821. 0xea, 0xe7, 0x53, 0x92, 0xfe, 0xc3, 0x13, 0x1f, 0x12, 0x47, 0xb5, 0xc3,
  9822. 0xfe, 0x2a, 0x10, 0x03, 0xfe, 0x38, 0x01, 0x23, 0xfe, 0xf0, 0xff, 0x10,
  9823. 0xe5, 0x03, 0xfe, 0x3a, 0x01, 0x10, 0xfe, 0x62, 0x01, 0x01, 0xfe, 0x1e,
  9824. 0x1e, 0x20, 0x2c, 0x15, 0x56, 0x01, 0xfe, 0x9e, 0x1e, 0x13, 0x07, 0x02,
  9825. 0x26, 0x02, 0x21, 0x96, 0xc7, 0x20, 0x96, 0x09, 0x92, 0xfe, 0x79, 0x13,
  9826. 0x1f, 0x1d, 0x47, 0xb5, 0xc3, 0xfe, 0xe1, 0x10, 0xcf, 0xfe, 0x03, 0xdc,
  9827. 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xcf, 0xfe, 0x03, 0xdc, 0xfe,
  9828. 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x26, 0xfe,
  9829. 0x00, 0xcc, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x89, 0x02, 0x01, 0x0c, 0x06,
  9830. 0x4a, 0xfe, 0x4e, 0x13, 0x0f, 0xfe, 0x1c, 0x80, 0x04, 0xfe, 0x9c, 0x83,
  9831. 0x33, 0x0b, 0x0e, 0x09, 0x07, 0xfe, 0x3a, 0x13, 0x0f, 0xfe, 0x1e, 0x80,
  9832. 0x04, 0xfe, 0x9e, 0x83, 0x33, 0x0b, 0x0e, 0xfe, 0x2a, 0x13, 0x0f, 0xfe,
  9833. 0x1d, 0x80, 0x04, 0xfe, 0x9d, 0x83, 0xfe, 0xf9, 0x13, 0x0e, 0xfe, 0x1c,
  9834. 0x13, 0x01, 0xfe, 0xee, 0x1e, 0xac, 0xfe, 0x14, 0x13, 0x01, 0xfe, 0xfe,
  9835. 0x1e, 0xfe, 0x81, 0x58, 0xfa, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4,
  9836. 0x0d, 0xfe, 0x3c, 0x50, 0xa2, 0x01, 0xfe, 0x92, 0x1b, 0x01, 0x43, 0x09,
  9837. 0x56, 0xfb, 0x01, 0xfe, 0xc8, 0x1a, 0x01, 0x0c, 0x06, 0x28, 0xa4, 0x01,
  9838. 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x15, 0xfe, 0xe9, 0x00, 0x01,
  9839. 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13, 0x01, 0xfe, 0x22, 0x1b, 0xfe, 0x1e,
  9840. 0x1c, 0x0f, 0xfe, 0x14, 0x90, 0x04, 0xfe, 0x94, 0x93, 0x3a, 0x0b, 0xfe,
  9841. 0x96, 0x90, 0x04, 0xfe, 0x96, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0xfe, 0x64,
  9842. 0x01, 0x22, 0xfe, 0x66, 0x01, 0x01, 0x0c, 0x06, 0x65, 0xf9, 0x0f, 0xfe,
  9843. 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x0e, 0x77, 0xfe, 0x01,
  9844. 0xec, 0x2c, 0xfe, 0x80, 0x40, 0x20, 0x2c, 0x7a, 0x30, 0x15, 0xdf, 0x40,
  9845. 0x21, 0x2c, 0xfe, 0x00, 0x40, 0x8d, 0x2c, 0x02, 0xfe, 0x08, 0x1c, 0x03,
  9846. 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58, 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07,
  9847. 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00,
  9848. 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c, 0x2e, 0x49, 0x20, 0xe0, 0x26, 0x10,
  9849. 0x66, 0x10, 0x55, 0x10, 0x6f, 0x13, 0x57, 0x52, 0x4f, 0x1c, 0x28, 0xfe,
  9850. 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe, 0x88, 0x11, 0x46, 0x1a, 0x13,
  9851. 0x5a, 0x52, 0x1c, 0x4a, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe,
  9852. 0x9e, 0x11, 0x2e, 0x1a, 0x20, 0x2c, 0x90, 0x34, 0x60, 0x21, 0x2c, 0xfe,
  9853. 0x00, 0x40, 0x8d, 0x2c, 0x15, 0xdf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
  9854. 0xfe, 0xb2, 0x11, 0xfe, 0x12, 0x1c, 0x75, 0xfe, 0x14, 0x1c, 0xfe, 0x10,
  9855. 0x1c, 0xfe, 0x18, 0x1c, 0x02, 0x51, 0xfe, 0x0c, 0x14, 0xfe, 0x0e, 0x47,
  9856. 0xfe, 0x07, 0xe6, 0x28, 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x02, 0x01,
  9857. 0xa7, 0x90, 0x34, 0x60, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42,
  9858. 0x13, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x34, 0x13, 0x0a, 0x5a, 0x01,
  9859. 0x18, 0xcb, 0xfe, 0x36, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
  9860. 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f, 0x89,
  9861. 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x5c, 0x01, 0x85,
  9862. 0xf2, 0x09, 0x9b, 0xa4, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0xec,
  9863. 0x11, 0x02, 0xfe, 0x44, 0x58, 0x77, 0xfe, 0x01, 0xec, 0xb8, 0xfe, 0x9e,
  9864. 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x12, 0x8d, 0x30, 0x01,
  9865. 0xf4, 0xfe, 0xdd, 0x10, 0x37, 0xd7, 0x99, 0xd8, 0x9c, 0x27, 0x25, 0xee,
  9866. 0x09, 0x12, 0xfe, 0x48, 0x12, 0x09, 0x0d, 0xfe, 0x56, 0x12, 0x09, 0x1d,
  9867. 0xfe, 0x30, 0x12, 0x09, 0xdd, 0x1b, 0xfe, 0xc4, 0x13, 0x09, 0xfe, 0x23,
  9868. 0x00, 0x1b, 0xfe, 0xd0, 0x13, 0x09, 0x07, 0x1b, 0xfe, 0x34, 0x14, 0x09,
  9869. 0x24, 0xfe, 0x12, 0x12, 0x09, 0x00, 0x1b, 0x29, 0x1f, 0xdd, 0x01, 0x42,
  9870. 0xa1, 0x32, 0x01, 0x08, 0xae, 0x41, 0x02, 0x32, 0xfe, 0x62, 0x08, 0x0a,
  9871. 0xe1, 0x01, 0xfe, 0x58, 0x10, 0x15, 0x9b, 0x05, 0x35, 0x32, 0x01, 0x43,
  9872. 0x09, 0xbb, 0xfe, 0xd7, 0x13, 0x91, 0x4b, 0x7e, 0x4c, 0x8e, 0xfe, 0x80,
  9873. 0x13, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x72, 0x12, 0xdb, 0x64, 0xdc, 0x34,
  9874. 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xb0, 0xfe, 0x4a, 0x13, 0x21, 0x6e,
  9875. 0xfe, 0x26, 0x13, 0x03, 0x97, 0x3b, 0x98, 0x8e, 0xfe, 0xb6, 0x0e, 0x10,
  9876. 0x6a, 0x22, 0x6b, 0x26, 0x10, 0x97, 0x10, 0x98, 0x01, 0xc2, 0x2e, 0x49,
  9877. 0x88, 0x20, 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
  9878. 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x64, 0xfe, 0x05, 0xfa,
  9879. 0x34, 0xfe, 0x8f, 0x10, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x40, 0x56, 0xfe,
  9880. 0xe1, 0x56, 0x10, 0x6c, 0x22, 0x6d, 0x71, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
  9881. 0x44, 0x55, 0xfe, 0xe5, 0x55, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x00, 0x56,
  9882. 0xfe, 0xa1, 0x56, 0x10, 0x68, 0x22, 0x69, 0x01, 0x0c, 0x06, 0x54, 0xf9,
  9883. 0x21, 0x6e, 0xfe, 0x1f, 0x40, 0x03, 0x6a, 0x3b, 0x6b, 0xfe, 0x2c, 0x50,
  9884. 0xfe, 0xae, 0x50, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x44, 0x50, 0xfe, 0xc6,
  9885. 0x50, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03,
  9886. 0x4b, 0x3b, 0x4c, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x05, 0x73, 0x2e,
  9887. 0x07, 0x20, 0x9e, 0x05, 0x72, 0x32, 0x01, 0x08, 0x16, 0x3d, 0x27, 0x25,
  9888. 0xee, 0x09, 0x07, 0x2b, 0x3d, 0x01, 0x43, 0x09, 0xbb, 0x2b, 0x72, 0x01,
  9889. 0xa6, 0x23, 0x3f, 0x1b, 0x3d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1e, 0x13,
  9890. 0x91, 0x4b, 0x7e, 0x4c, 0xfe, 0x0a, 0x55, 0x31, 0xfe, 0x8b, 0x55, 0xd9,
  9891. 0x4b, 0xda, 0x4c, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x05, 0x72, 0x01,
  9892. 0xfe, 0x8e, 0x1e, 0xca, 0xfe, 0x19, 0x41, 0x05, 0x72, 0x32, 0x01, 0x08,
  9893. 0x2a, 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbe, 0x2d, 0x1d, 0xc0, 0x2d, 0x0d,
  9894. 0x83, 0x2d, 0x7f, 0x1b, 0xfe, 0x66, 0x15, 0x05, 0x3d, 0x01, 0x08, 0x2a,
  9895. 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbd, 0x09, 0x1d, 0x2b, 0x3d, 0x01, 0x08,
  9896. 0x16, 0xc0, 0x27, 0x25, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x50, 0x03,
  9897. 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa1, 0xfe, 0xbb, 0x45,
  9898. 0x2d, 0x00, 0xa4, 0x46, 0x07, 0x90, 0x3f, 0x01, 0xfe, 0xf8, 0x15, 0x01,
  9899. 0xa6, 0x86, 0xfe, 0x4b, 0x45, 0xfe, 0x20, 0x13, 0x01, 0x43, 0x09, 0x82,
  9900. 0xfe, 0x16, 0x13, 0x03, 0x9a, 0x1e, 0x5d, 0x03, 0x55, 0x1e, 0x31, 0x5e,
  9901. 0x05, 0x72, 0xfe, 0xc0, 0x5d, 0x01, 0xa7, 0xfe, 0x03, 0x17, 0x03, 0x66,
  9902. 0x8a, 0x10, 0x66, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01, 0xfe, 0x56,
  9903. 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d, 0x27, 0x25, 0xbd,
  9904. 0x09, 0x07, 0x2b, 0x3d, 0x01, 0xfe, 0xbe, 0x16, 0xfe, 0x42, 0x58, 0xfe,
  9905. 0xe8, 0x14, 0x01, 0xa6, 0x86, 0xfe, 0x4a, 0xf4, 0x0d, 0x1b, 0x3d, 0xfe,
  9906. 0x4a, 0xf4, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05,
  9907. 0x72, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73,
  9908. 0x01, 0xfe, 0x84, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d,
  9909. 0x27, 0x25, 0xbd, 0x09, 0x12, 0x2b, 0x3d, 0x01, 0xfe, 0xe8, 0x17, 0x8b,
  9910. 0xfe, 0xaa, 0x14, 0xfe, 0xb6, 0x14, 0x86, 0xa8, 0xb2, 0x0d, 0x1b, 0x3d,
  9911. 0xb2, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05, 0x72,
  9912. 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01,
  9913. 0xfe, 0xc0, 0x19, 0x05, 0x73, 0x13, 0x07, 0x2f, 0xfe, 0xcc, 0x15, 0x17,
  9914. 0xfe, 0xe2, 0x15, 0x5f, 0xcc, 0x01, 0x08, 0x26, 0x5f, 0x02, 0x8f, 0xfe,
  9915. 0xde, 0x15, 0x2a, 0xfe, 0xde, 0x15, 0x16, 0xfe, 0xcc, 0x15, 0x5e, 0x32,
  9916. 0x01, 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
  9917. 0xad, 0x23, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02,
  9918. 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0x23, 0x3f, 0xfe, 0x30,
  9919. 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
  9920. 0xad, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xfe, 0x00, 0x5e,
  9921. 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0xfe, 0x0b, 0x58,
  9922. 0x02, 0x0a, 0x66, 0x01, 0x5c, 0x0a, 0x55, 0x01, 0x5c, 0x0a, 0x6f, 0x01,
  9923. 0x5c, 0x02, 0x01, 0xfe, 0x1e, 0x1f, 0x23, 0x1a, 0xff, 0x03, 0x00, 0x54,
  9924. 0xfe, 0x00, 0xf4, 0x24, 0x52, 0x0f, 0xfe, 0x00, 0x7c, 0x04, 0xfe, 0x07,
  9925. 0x7c, 0x3a, 0x0b, 0x0e, 0xfe, 0x00, 0x71, 0xfe, 0xf9, 0x18, 0xfe, 0x7a,
  9926. 0x19, 0xfe, 0xfb, 0x19, 0xfe, 0x1a, 0xf7, 0x00, 0xfe, 0x1b, 0xf7, 0x00,
  9927. 0x7a, 0x30, 0x10, 0x68, 0x22, 0x69, 0xd9, 0x6c, 0xda, 0x6d, 0x02, 0xfe,
  9928. 0x62, 0x08, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x77,
  9929. 0x02, 0x01, 0xc6, 0xfe, 0x42, 0x48, 0x4f, 0x50, 0x45, 0x01, 0x08, 0x16,
  9930. 0xfe, 0xe0, 0x17, 0x27, 0x25, 0xbe, 0x01, 0x08, 0x16, 0xfe, 0xe0, 0x17,
  9931. 0x27, 0x25, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0x9a, 0x1e, 0xfe,
  9932. 0xda, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfe, 0xd0, 0x13, 0x26, 0x53, 0x12,
  9933. 0x48, 0xfe, 0x08, 0x17, 0xd1, 0x12, 0x53, 0x12, 0xfe, 0x1e, 0x13, 0x2d,
  9934. 0xb4, 0x7b, 0xfe, 0x26, 0x17, 0x4d, 0x13, 0x07, 0x1c, 0xb4, 0x90, 0x04,
  9935. 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xf1, 0xff, 0x02, 0x83, 0x55,
  9936. 0x53, 0x1d, 0xfe, 0x12, 0x13, 0xd6, 0xfe, 0x30, 0x00, 0xb0, 0xfe, 0x80,
  9937. 0x17, 0x1c, 0x63, 0x13, 0x07, 0xfe, 0x56, 0x10, 0x53, 0x0d, 0xfe, 0x16,
  9938. 0x13, 0xd6, 0xfe, 0x64, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0x64,
  9939. 0x00, 0x1c, 0x94, 0x13, 0x07, 0xfe, 0x28, 0x10, 0x53, 0x07, 0xfe, 0x60,
  9940. 0x13, 0xd6, 0xfe, 0xc8, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0xc8,
  9941. 0x00, 0x1c, 0x95, 0x13, 0x07, 0x71, 0xd6, 0xfe, 0x90, 0x01, 0x48, 0xfe,
  9942. 0x8c, 0x17, 0x45, 0xf3, 0xfe, 0x43, 0xf4, 0x96, 0xfe, 0x56, 0xf0, 0xfe,
  9943. 0x9e, 0x17, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x43, 0xf4, 0x94, 0xf6, 0x8b,
  9944. 0x01, 0xfe, 0x24, 0x16, 0x23, 0x3f, 0xfc, 0xa8, 0x8c, 0x49, 0x48, 0xfe,
  9945. 0xda, 0x17, 0x62, 0x49, 0xfe, 0x1c, 0x10, 0xa8, 0x8c, 0x80, 0x48, 0xfe,
  9946. 0xda, 0x17, 0x62, 0x80, 0x71, 0x50, 0x26, 0xfe, 0x4d, 0xf4, 0x00, 0xf7,
  9947. 0x45, 0x13, 0x07, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58, 0x02, 0x50, 0x13,
  9948. 0x0d, 0x02, 0x50, 0x3e, 0x78, 0x4f, 0x45, 0x01, 0x08, 0x16, 0xa9, 0x27,
  9949. 0x25, 0xbe, 0xfe, 0x03, 0xea, 0xfe, 0x7e, 0x01, 0x01, 0x08, 0x16, 0xa9,
  9950. 0x27, 0x25, 0xfe, 0xe9, 0x0a, 0x01, 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe,
  9951. 0xe9, 0x0a, 0xfe, 0x05, 0xea, 0xfe, 0x7f, 0x01, 0x01, 0x08, 0x16, 0xa9,
  9952. 0x27, 0x25, 0xfe, 0x69, 0x09, 0xfe, 0x02, 0xea, 0xfe, 0x80, 0x01, 0x01,
  9953. 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe, 0xe8, 0x08, 0x47, 0xfe, 0x81, 0x01,
  9954. 0x03, 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa2, 0x78, 0xf2,
  9955. 0x53, 0x07, 0x36, 0xfe, 0x34, 0xf4, 0x3f, 0xa1, 0x78, 0x03, 0x9a, 0x1e,
  9956. 0x83, 0x01, 0x38, 0x06, 0x12, 0x31, 0xf0, 0x4f, 0x45, 0xfe, 0x90, 0x10,
  9957. 0xfe, 0x40, 0x5a, 0x23, 0x3f, 0xfb, 0x8c, 0x49, 0x48, 0xfe, 0xaa, 0x18,
  9958. 0x62, 0x49, 0x71, 0x8c, 0x80, 0x48, 0xfe, 0xaa, 0x18, 0x62, 0x80, 0xfe,
  9959. 0xb4, 0x56, 0xfe, 0x40, 0x5d, 0x01, 0xc6, 0x01, 0xfe, 0xac, 0x1d, 0xfe,
  9960. 0x02, 0x17, 0xfe, 0xc8, 0x45, 0xfe, 0x5a, 0xf0, 0xfe, 0xc0, 0x18, 0xfe,
  9961. 0x43, 0x48, 0x2d, 0x93, 0x36, 0xfe, 0x34, 0xf4, 0xfe, 0x00, 0x11, 0xfe,
  9962. 0x40, 0x10, 0x2d, 0xb4, 0x36, 0xfe, 0x34, 0xf4, 0x04, 0xfe, 0x34, 0x10,
  9963. 0x2d, 0xfe, 0x0b, 0x00, 0x36, 0x46, 0x63, 0xfe, 0x28, 0x10, 0xfe, 0xc0,
  9964. 0x49, 0xff, 0x02, 0x00, 0x54, 0xb2, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0xfa,
  9965. 0x18, 0x45, 0xfe, 0x1c, 0xf4, 0x3f, 0xf3, 0xfe, 0x40, 0xf4, 0x96, 0xfe,
  9966. 0x56, 0xf0, 0xfe, 0x0c, 0x19, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x40, 0xf4,
  9967. 0x94, 0xf6, 0x3e, 0x2d, 0x93, 0x4e, 0xd0, 0x0d, 0x21, 0xfe, 0x7f, 0x01,
  9968. 0xfe, 0xc8, 0x46, 0xfe, 0x24, 0x13, 0x8c, 0x00, 0x5d, 0x26, 0x21, 0xfe,
  9969. 0x7e, 0x01, 0xfe, 0xc8, 0x45, 0xfe, 0x14, 0x13, 0x21, 0xfe, 0x80, 0x01,
  9970. 0xfe, 0x48, 0x45, 0xfa, 0x21, 0xfe, 0x81, 0x01, 0xfe, 0xc8, 0x44, 0x4e,
  9971. 0x26, 0x02, 0x13, 0x07, 0x02, 0x78, 0x45, 0x50, 0x13, 0x0d, 0x02, 0x14,
  9972. 0x07, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x14, 0x0d, 0x01, 0x08, 0x17,
  9973. 0xfe, 0x82, 0x19, 0x14, 0x1d, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x5f,
  9974. 0xfe, 0x89, 0x49, 0x01, 0x08, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
  9975. 0x14, 0x1d, 0x01, 0x08, 0x17, 0xc1, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
  9976. 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0xc1, 0x5f, 0xfe, 0x89, 0x4a, 0x01,
  9977. 0x08, 0x02, 0x50, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0x74, 0x14, 0x7f,
  9978. 0x01, 0x08, 0x17, 0x74, 0x14, 0x12, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x89,
  9979. 0x49, 0x01, 0x08, 0x17, 0x74, 0x14, 0x00, 0x01, 0x08, 0x17, 0x74, 0xfe,
  9980. 0x89, 0x4a, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x09, 0x49, 0x01, 0x08, 0x17,
  9981. 0x74, 0x5f, 0xcc, 0x01, 0x08, 0x02, 0x21, 0xe4, 0x09, 0x07, 0xfe, 0x4c,
  9982. 0x13, 0xc8, 0x20, 0xe4, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x5f, 0xa1, 0x5e,
  9983. 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f,
  9984. 0xfe, 0x3e, 0x1a, 0x01, 0x43, 0x09, 0xfe, 0xe3, 0x00, 0xfe, 0x22, 0x13,
  9985. 0x16, 0xfe, 0x64, 0x1a, 0x26, 0x20, 0x9e, 0x01, 0x41, 0x21, 0x9e, 0x09,
  9986. 0x07, 0x5d, 0x01, 0x0c, 0x61, 0x07, 0x44, 0x02, 0x0a, 0x5a, 0x01, 0x18,
  9987. 0xfe, 0x00, 0x40, 0xaa, 0x09, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01,
  9988. 0x18, 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x9d, 0x01, 0x18, 0xaa,
  9989. 0xfe, 0x80, 0xe7, 0x1a, 0x09, 0x1a, 0x5d, 0xfe, 0x45, 0x58, 0x01, 0xfe,
  9990. 0xb2, 0x16, 0xaa, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0xaa, 0x0a, 0x67, 0x01,
  9991. 0xa3, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x01, 0xfe, 0x7e, 0x1e, 0xfe, 0x80,
  9992. 0x4c, 0xfe, 0x49, 0xe4, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01, 0x18,
  9993. 0xfe, 0x80, 0x4c, 0x0a, 0x67, 0x01, 0x5c, 0x02, 0x1c, 0x1a, 0x87, 0x7c,
  9994. 0xe5, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24, 0x1c, 0xfe, 0x1d,
  9995. 0xf7, 0x28, 0xb1, 0xfe, 0x04, 0x1b, 0x01, 0xfe, 0x2a, 0x1c, 0xfa, 0xb3,
  9996. 0x28, 0x7c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x02, 0xc9, 0x2b, 0xfe,
  9997. 0xf4, 0x1a, 0xfe, 0xfa, 0x10, 0x1c, 0x1a, 0x87, 0x03, 0xfe, 0x64, 0x01,
  9998. 0xfe, 0x00, 0xf4, 0x24, 0xfe, 0x18, 0x58, 0x03, 0xfe, 0x66, 0x01, 0xfe,
  9999. 0x19, 0x58, 0xb3, 0x24, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4, 0x07,
  10000. 0xfe, 0x3c, 0x50, 0x7c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c,
  10001. 0xf7, 0x24, 0xb1, 0xfe, 0x50, 0x1b, 0xfe, 0xd4, 0x14, 0x31, 0x02, 0xc9,
  10002. 0x2b, 0xfe, 0x26, 0x1b, 0xfe, 0xba, 0x10, 0x1c, 0x1a, 0x87, 0xfe, 0x83,
  10003. 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x54, 0xb1,
  10004. 0xfe, 0x72, 0x1b, 0xfe, 0xb2, 0x14, 0xfc, 0xb3, 0x54, 0x7c, 0x12, 0xfe,
  10005. 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x02, 0xc9, 0x2b, 0xfe, 0x66, 0x1b,
  10006. 0xfe, 0x8a, 0x10, 0x1c, 0x1a, 0x87, 0x8b, 0x0f, 0xfe, 0x30, 0x90, 0x04,
  10007. 0xfe, 0xb0, 0x93, 0x3a, 0x0b, 0xfe, 0x18, 0x58, 0xfe, 0x32, 0x90, 0x04,
  10008. 0xfe, 0xb2, 0x93, 0x3a, 0x0b, 0xfe, 0x19, 0x58, 0x0e, 0xa8, 0xb3, 0x4a,
  10009. 0x7c, 0x12, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x4a, 0xb1, 0xfe, 0xc6,
  10010. 0x1b, 0xfe, 0x5e, 0x14, 0x31, 0x02, 0xc9, 0x2b, 0xfe, 0x96, 0x1b, 0x5c,
  10011. 0xfe, 0x02, 0xf6, 0x1a, 0x87, 0xfe, 0x18, 0xfe, 0x6a, 0xfe, 0x19, 0xfe,
  10012. 0x6b, 0x01, 0xfe, 0x1e, 0x1f, 0xfe, 0x1d, 0xf7, 0x65, 0xb1, 0xfe, 0xee,
  10013. 0x1b, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13, 0xb3, 0x65, 0x3e, 0xfe, 0x83,
  10014. 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x1a, 0xfe, 0x81, 0xe7, 0x1a,
  10015. 0x15, 0xfe, 0xdd, 0x00, 0x7a, 0x30, 0x02, 0x7a, 0x30, 0xfe, 0x12, 0x45,
  10016. 0x2b, 0xfe, 0xdc, 0x1b, 0x1f, 0x07, 0x47, 0xb5, 0xc3, 0x05, 0x35, 0xfe,
  10017. 0x39, 0xf0, 0x75, 0x26, 0x02, 0xfe, 0x7e, 0x18, 0x23, 0x1d, 0x36, 0x13,
  10018. 0x11, 0x02, 0x87, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0xef, 0x12, 0xfe, 0xe1,
  10019. 0x10, 0x90, 0x34, 0x60, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x3c, 0x13,
  10020. 0xfe, 0x82, 0x14, 0xfe, 0x42, 0x13, 0x51, 0xfe, 0x06, 0x83, 0x0a, 0x5a,
  10021. 0x01, 0x18, 0xcb, 0xfe, 0x3e, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48,
  10022. 0x01, 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f,
  10023. 0x89, 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x4c, 0x01,
  10024. 0x85, 0xfe, 0x16, 0x10, 0x09, 0x9b, 0x4e, 0xfe, 0x40, 0x14, 0xfe, 0x24,
  10025. 0x12, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x52, 0x1c, 0x1c, 0x0d,
  10026. 0x02, 0xfe, 0x9c, 0xe7, 0x0d, 0x19, 0xfe, 0x15, 0x00, 0x40, 0x8d, 0x30,
  10027. 0x01, 0xf4, 0x1c, 0x07, 0x02, 0x51, 0xfe, 0x06, 0x83, 0xfe, 0x18, 0x80,
  10028. 0x61, 0x28, 0x44, 0x15, 0x56, 0x01, 0x85, 0x1c, 0x07, 0x02, 0xfe, 0x38,
  10029. 0x90, 0xfe, 0xba, 0x90, 0x91, 0xde, 0x7e, 0xdf, 0xfe, 0x48, 0x55, 0x31,
  10030. 0xfe, 0xc9, 0x55, 0x02, 0x21, 0xb9, 0x88, 0x20, 0xb9, 0x02, 0x0a, 0xba,
  10031. 0x01, 0x18, 0xfe, 0x41, 0x48, 0x0a, 0x57, 0x01, 0x18, 0xfe, 0x49, 0x44,
  10032. 0x1b, 0xfe, 0x1e, 0x1d, 0x88, 0x89, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x09,
  10033. 0x1a, 0xa4, 0x0a, 0x67, 0x01, 0xa3, 0x0a, 0x57, 0x01, 0x18, 0x88, 0x89,
  10034. 0x02, 0xfe, 0x4e, 0xe4, 0x1d, 0x7b, 0xfe, 0x52, 0x1d, 0x03, 0xfe, 0x90,
  10035. 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe, 0x4e, 0xe4, 0xdd, 0x7b,
  10036. 0xfe, 0x64, 0x1d, 0x03, 0xfe, 0x92, 0x00, 0xd1, 0x12, 0xfe, 0x1a, 0x10,
  10037. 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x7b, 0xfe, 0x76, 0x1d, 0x03, 0xfe,
  10038. 0x94, 0x00, 0xd1, 0x24, 0xfe, 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xd1,
  10039. 0x63, 0xfe, 0x4e, 0x45, 0x83, 0xca, 0xff, 0x04, 0x68, 0x54, 0xfe, 0xf1,
  10040. 0x10, 0x23, 0x49, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c,
  10041. 0xfe, 0x1a, 0xf4, 0xfe, 0x00, 0x04, 0x83, 0xb2, 0x1d, 0x48, 0xfe, 0xaa,
  10042. 0x1d, 0x13, 0x1d, 0x02, 0x09, 0x92, 0xfe, 0x5a, 0xf0, 0xfe, 0xba, 0x1d,
  10043. 0x2e, 0x93, 0xfe, 0x34, 0x10, 0x09, 0x12, 0xfe, 0x5a, 0xf0, 0xfe, 0xc8,
  10044. 0x1d, 0x2e, 0xb4, 0xfe, 0x26, 0x10, 0x09, 0x1d, 0x36, 0x2e, 0x63, 0xfe,
  10045. 0x1a, 0x10, 0x09, 0x0d, 0x36, 0x2e, 0x94, 0xf2, 0x09, 0x07, 0x36, 0x2e,
  10046. 0x95, 0xa1, 0xc8, 0x02, 0x1f, 0x93, 0x01, 0x42, 0xfe, 0x04, 0xfe, 0x99,
  10047. 0x03, 0x9c, 0x8b, 0x02, 0x2a, 0xfe, 0x1c, 0x1e, 0xfe, 0x14, 0xf0, 0x08,
  10048. 0x2f, 0xfe, 0x0c, 0x1e, 0x2a, 0xfe, 0x1c, 0x1e, 0x8f, 0xfe, 0x1c, 0x1e,
  10049. 0xfe, 0x82, 0xf0, 0xfe, 0x10, 0x1e, 0x02, 0x0f, 0x3f, 0x04, 0xfe, 0x80,
  10050. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x18, 0x80, 0x04, 0xfe, 0x98,
  10051. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x02, 0x80, 0x04, 0xfe, 0x82,
  10052. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x80, 0x04, 0xfe, 0x86,
  10053. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x1b, 0x80, 0x04, 0xfe, 0x9b,
  10054. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x04, 0x80, 0x04, 0xfe, 0x84,
  10055. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x80, 0x80, 0x04, 0xfe, 0x80,
  10056. 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x19, 0x81, 0x04,
  10057. 0xfe, 0x99, 0x83, 0xfe, 0xca, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06,
  10058. 0x83, 0x04, 0xfe, 0x86, 0x83, 0xfe, 0xce, 0x47, 0x0b, 0x0e, 0x02, 0x0f,
  10059. 0xfe, 0x2c, 0x90, 0x04, 0xfe, 0xac, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  10060. 0xfe, 0xae, 0x90, 0x04, 0xfe, 0xae, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  10061. 0xfe, 0x08, 0x90, 0x04, 0xfe, 0x88, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  10062. 0xfe, 0x8a, 0x90, 0x04, 0xfe, 0x8a, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  10063. 0xfe, 0x0c, 0x90, 0x04, 0xfe, 0x8c, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  10064. 0xfe, 0x8e, 0x90, 0x04, 0xfe, 0x8e, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  10065. 0xfe, 0x3c, 0x90, 0x04, 0xfe, 0xbc, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x8b,
  10066. 0x0f, 0xfe, 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x77, 0x0e,
  10067. 0xa8, 0x02, 0xff, 0x66, 0x00, 0x00,
  10068. };
  10069. static unsigned short _adv_asc38C1600_size = sizeof(_adv_asc38C1600_buf); /* 0x1673 */
  10070. static ADV_DCNT _adv_asc38C1600_chksum = 0x0604EF77UL; /* Expanded little-endian checksum. */
  10071. /*
  10072. * EEPROM Configuration.
  10073. *
  10074. * All drivers should use this structure to set the default EEPROM
  10075. * configuration. The BIOS now uses this structure when it is built.
  10076. * Additional structure information can be found in a_condor.h where
  10077. * the structure is defined.
  10078. *
  10079. * The *_Field_IsChar structs are needed to correct for endianness.
  10080. * These values are read from the board 16 bits at a time directly
  10081. * into the structs. Because some fields are char, the values will be
  10082. * in the wrong order. The *_Field_IsChar tells when to flip the
  10083. * bytes. Data read and written to PCI memory is automatically swapped
  10084. * on big-endian platforms so char fields read as words are actually being
  10085. * unswapped on big-endian platforms.
  10086. */
  10087. static ADVEEP_3550_CONFIG Default_3550_EEPROM_Config __devinitdata = {
  10088. ADV_EEPROM_BIOS_ENABLE, /* cfg_lsw */
  10089. 0x0000, /* cfg_msw */
  10090. 0xFFFF, /* disc_enable */
  10091. 0xFFFF, /* wdtr_able */
  10092. 0xFFFF, /* sdtr_able */
  10093. 0xFFFF, /* start_motor */
  10094. 0xFFFF, /* tagqng_able */
  10095. 0xFFFF, /* bios_scan */
  10096. 0, /* scam_tolerant */
  10097. 7, /* adapter_scsi_id */
  10098. 0, /* bios_boot_delay */
  10099. 3, /* scsi_reset_delay */
  10100. 0, /* bios_id_lun */
  10101. 0, /* termination */
  10102. 0, /* reserved1 */
  10103. 0xFFE7, /* bios_ctrl */
  10104. 0xFFFF, /* ultra_able */
  10105. 0, /* reserved2 */
  10106. ASC_DEF_MAX_HOST_QNG, /* max_host_qng */
  10107. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  10108. 0, /* dvc_cntl */
  10109. 0, /* bug_fix */
  10110. 0, /* serial_number_word1 */
  10111. 0, /* serial_number_word2 */
  10112. 0, /* serial_number_word3 */
  10113. 0, /* check_sum */
  10114. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  10115. , /* oem_name[16] */
  10116. 0, /* dvc_err_code */
  10117. 0, /* adv_err_code */
  10118. 0, /* adv_err_addr */
  10119. 0, /* saved_dvc_err_code */
  10120. 0, /* saved_adv_err_code */
  10121. 0, /* saved_adv_err_addr */
  10122. 0 /* num_of_err */
  10123. };
  10124. static ADVEEP_3550_CONFIG ADVEEP_3550_Config_Field_IsChar __devinitdata = {
  10125. 0, /* cfg_lsw */
  10126. 0, /* cfg_msw */
  10127. 0, /* -disc_enable */
  10128. 0, /* wdtr_able */
  10129. 0, /* sdtr_able */
  10130. 0, /* start_motor */
  10131. 0, /* tagqng_able */
  10132. 0, /* bios_scan */
  10133. 0, /* scam_tolerant */
  10134. 1, /* adapter_scsi_id */
  10135. 1, /* bios_boot_delay */
  10136. 1, /* scsi_reset_delay */
  10137. 1, /* bios_id_lun */
  10138. 1, /* termination */
  10139. 1, /* reserved1 */
  10140. 0, /* bios_ctrl */
  10141. 0, /* ultra_able */
  10142. 0, /* reserved2 */
  10143. 1, /* max_host_qng */
  10144. 1, /* max_dvc_qng */
  10145. 0, /* dvc_cntl */
  10146. 0, /* bug_fix */
  10147. 0, /* serial_number_word1 */
  10148. 0, /* serial_number_word2 */
  10149. 0, /* serial_number_word3 */
  10150. 0, /* check_sum */
  10151. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  10152. , /* oem_name[16] */
  10153. 0, /* dvc_err_code */
  10154. 0, /* adv_err_code */
  10155. 0, /* adv_err_addr */
  10156. 0, /* saved_dvc_err_code */
  10157. 0, /* saved_adv_err_code */
  10158. 0, /* saved_adv_err_addr */
  10159. 0 /* num_of_err */
  10160. };
  10161. static ADVEEP_38C0800_CONFIG Default_38C0800_EEPROM_Config __devinitdata = {
  10162. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  10163. 0x0000, /* 01 cfg_msw */
  10164. 0xFFFF, /* 02 disc_enable */
  10165. 0xFFFF, /* 03 wdtr_able */
  10166. 0x4444, /* 04 sdtr_speed1 */
  10167. 0xFFFF, /* 05 start_motor */
  10168. 0xFFFF, /* 06 tagqng_able */
  10169. 0xFFFF, /* 07 bios_scan */
  10170. 0, /* 08 scam_tolerant */
  10171. 7, /* 09 adapter_scsi_id */
  10172. 0, /* bios_boot_delay */
  10173. 3, /* 10 scsi_reset_delay */
  10174. 0, /* bios_id_lun */
  10175. 0, /* 11 termination_se */
  10176. 0, /* termination_lvd */
  10177. 0xFFE7, /* 12 bios_ctrl */
  10178. 0x4444, /* 13 sdtr_speed2 */
  10179. 0x4444, /* 14 sdtr_speed3 */
  10180. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  10181. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  10182. 0, /* 16 dvc_cntl */
  10183. 0x4444, /* 17 sdtr_speed4 */
  10184. 0, /* 18 serial_number_word1 */
  10185. 0, /* 19 serial_number_word2 */
  10186. 0, /* 20 serial_number_word3 */
  10187. 0, /* 21 check_sum */
  10188. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  10189. , /* 22-29 oem_name[16] */
  10190. 0, /* 30 dvc_err_code */
  10191. 0, /* 31 adv_err_code */
  10192. 0, /* 32 adv_err_addr */
  10193. 0, /* 33 saved_dvc_err_code */
  10194. 0, /* 34 saved_adv_err_code */
  10195. 0, /* 35 saved_adv_err_addr */
  10196. 0, /* 36 reserved */
  10197. 0, /* 37 reserved */
  10198. 0, /* 38 reserved */
  10199. 0, /* 39 reserved */
  10200. 0, /* 40 reserved */
  10201. 0, /* 41 reserved */
  10202. 0, /* 42 reserved */
  10203. 0, /* 43 reserved */
  10204. 0, /* 44 reserved */
  10205. 0, /* 45 reserved */
  10206. 0, /* 46 reserved */
  10207. 0, /* 47 reserved */
  10208. 0, /* 48 reserved */
  10209. 0, /* 49 reserved */
  10210. 0, /* 50 reserved */
  10211. 0, /* 51 reserved */
  10212. 0, /* 52 reserved */
  10213. 0, /* 53 reserved */
  10214. 0, /* 54 reserved */
  10215. 0, /* 55 reserved */
  10216. 0, /* 56 cisptr_lsw */
  10217. 0, /* 57 cisprt_msw */
  10218. PCI_VENDOR_ID_ASP, /* 58 subsysvid */
  10219. PCI_DEVICE_ID_38C0800_REV1, /* 59 subsysid */
  10220. 0, /* 60 reserved */
  10221. 0, /* 61 reserved */
  10222. 0, /* 62 reserved */
  10223. 0 /* 63 reserved */
  10224. };
  10225. static ADVEEP_38C0800_CONFIG ADVEEP_38C0800_Config_Field_IsChar __devinitdata = {
  10226. 0, /* 00 cfg_lsw */
  10227. 0, /* 01 cfg_msw */
  10228. 0, /* 02 disc_enable */
  10229. 0, /* 03 wdtr_able */
  10230. 0, /* 04 sdtr_speed1 */
  10231. 0, /* 05 start_motor */
  10232. 0, /* 06 tagqng_able */
  10233. 0, /* 07 bios_scan */
  10234. 0, /* 08 scam_tolerant */
  10235. 1, /* 09 adapter_scsi_id */
  10236. 1, /* bios_boot_delay */
  10237. 1, /* 10 scsi_reset_delay */
  10238. 1, /* bios_id_lun */
  10239. 1, /* 11 termination_se */
  10240. 1, /* termination_lvd */
  10241. 0, /* 12 bios_ctrl */
  10242. 0, /* 13 sdtr_speed2 */
  10243. 0, /* 14 sdtr_speed3 */
  10244. 1, /* 15 max_host_qng */
  10245. 1, /* max_dvc_qng */
  10246. 0, /* 16 dvc_cntl */
  10247. 0, /* 17 sdtr_speed4 */
  10248. 0, /* 18 serial_number_word1 */
  10249. 0, /* 19 serial_number_word2 */
  10250. 0, /* 20 serial_number_word3 */
  10251. 0, /* 21 check_sum */
  10252. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  10253. , /* 22-29 oem_name[16] */
  10254. 0, /* 30 dvc_err_code */
  10255. 0, /* 31 adv_err_code */
  10256. 0, /* 32 adv_err_addr */
  10257. 0, /* 33 saved_dvc_err_code */
  10258. 0, /* 34 saved_adv_err_code */
  10259. 0, /* 35 saved_adv_err_addr */
  10260. 0, /* 36 reserved */
  10261. 0, /* 37 reserved */
  10262. 0, /* 38 reserved */
  10263. 0, /* 39 reserved */
  10264. 0, /* 40 reserved */
  10265. 0, /* 41 reserved */
  10266. 0, /* 42 reserved */
  10267. 0, /* 43 reserved */
  10268. 0, /* 44 reserved */
  10269. 0, /* 45 reserved */
  10270. 0, /* 46 reserved */
  10271. 0, /* 47 reserved */
  10272. 0, /* 48 reserved */
  10273. 0, /* 49 reserved */
  10274. 0, /* 50 reserved */
  10275. 0, /* 51 reserved */
  10276. 0, /* 52 reserved */
  10277. 0, /* 53 reserved */
  10278. 0, /* 54 reserved */
  10279. 0, /* 55 reserved */
  10280. 0, /* 56 cisptr_lsw */
  10281. 0, /* 57 cisprt_msw */
  10282. 0, /* 58 subsysvid */
  10283. 0, /* 59 subsysid */
  10284. 0, /* 60 reserved */
  10285. 0, /* 61 reserved */
  10286. 0, /* 62 reserved */
  10287. 0 /* 63 reserved */
  10288. };
  10289. static ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config __devinitdata = {
  10290. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  10291. 0x0000, /* 01 cfg_msw */
  10292. 0xFFFF, /* 02 disc_enable */
  10293. 0xFFFF, /* 03 wdtr_able */
  10294. 0x5555, /* 04 sdtr_speed1 */
  10295. 0xFFFF, /* 05 start_motor */
  10296. 0xFFFF, /* 06 tagqng_able */
  10297. 0xFFFF, /* 07 bios_scan */
  10298. 0, /* 08 scam_tolerant */
  10299. 7, /* 09 adapter_scsi_id */
  10300. 0, /* bios_boot_delay */
  10301. 3, /* 10 scsi_reset_delay */
  10302. 0, /* bios_id_lun */
  10303. 0, /* 11 termination_se */
  10304. 0, /* termination_lvd */
  10305. 0xFFE7, /* 12 bios_ctrl */
  10306. 0x5555, /* 13 sdtr_speed2 */
  10307. 0x5555, /* 14 sdtr_speed3 */
  10308. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  10309. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  10310. 0, /* 16 dvc_cntl */
  10311. 0x5555, /* 17 sdtr_speed4 */
  10312. 0, /* 18 serial_number_word1 */
  10313. 0, /* 19 serial_number_word2 */
  10314. 0, /* 20 serial_number_word3 */
  10315. 0, /* 21 check_sum */
  10316. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  10317. , /* 22-29 oem_name[16] */
  10318. 0, /* 30 dvc_err_code */
  10319. 0, /* 31 adv_err_code */
  10320. 0, /* 32 adv_err_addr */
  10321. 0, /* 33 saved_dvc_err_code */
  10322. 0, /* 34 saved_adv_err_code */
  10323. 0, /* 35 saved_adv_err_addr */
  10324. 0, /* 36 reserved */
  10325. 0, /* 37 reserved */
  10326. 0, /* 38 reserved */
  10327. 0, /* 39 reserved */
  10328. 0, /* 40 reserved */
  10329. 0, /* 41 reserved */
  10330. 0, /* 42 reserved */
  10331. 0, /* 43 reserved */
  10332. 0, /* 44 reserved */
  10333. 0, /* 45 reserved */
  10334. 0, /* 46 reserved */
  10335. 0, /* 47 reserved */
  10336. 0, /* 48 reserved */
  10337. 0, /* 49 reserved */
  10338. 0, /* 50 reserved */
  10339. 0, /* 51 reserved */
  10340. 0, /* 52 reserved */
  10341. 0, /* 53 reserved */
  10342. 0, /* 54 reserved */
  10343. 0, /* 55 reserved */
  10344. 0, /* 56 cisptr_lsw */
  10345. 0, /* 57 cisprt_msw */
  10346. PCI_VENDOR_ID_ASP, /* 58 subsysvid */
  10347. PCI_DEVICE_ID_38C1600_REV1, /* 59 subsysid */
  10348. 0, /* 60 reserved */
  10349. 0, /* 61 reserved */
  10350. 0, /* 62 reserved */
  10351. 0 /* 63 reserved */
  10352. };
  10353. static ADVEEP_38C1600_CONFIG ADVEEP_38C1600_Config_Field_IsChar __devinitdata = {
  10354. 0, /* 00 cfg_lsw */
  10355. 0, /* 01 cfg_msw */
  10356. 0, /* 02 disc_enable */
  10357. 0, /* 03 wdtr_able */
  10358. 0, /* 04 sdtr_speed1 */
  10359. 0, /* 05 start_motor */
  10360. 0, /* 06 tagqng_able */
  10361. 0, /* 07 bios_scan */
  10362. 0, /* 08 scam_tolerant */
  10363. 1, /* 09 adapter_scsi_id */
  10364. 1, /* bios_boot_delay */
  10365. 1, /* 10 scsi_reset_delay */
  10366. 1, /* bios_id_lun */
  10367. 1, /* 11 termination_se */
  10368. 1, /* termination_lvd */
  10369. 0, /* 12 bios_ctrl */
  10370. 0, /* 13 sdtr_speed2 */
  10371. 0, /* 14 sdtr_speed3 */
  10372. 1, /* 15 max_host_qng */
  10373. 1, /* max_dvc_qng */
  10374. 0, /* 16 dvc_cntl */
  10375. 0, /* 17 sdtr_speed4 */
  10376. 0, /* 18 serial_number_word1 */
  10377. 0, /* 19 serial_number_word2 */
  10378. 0, /* 20 serial_number_word3 */
  10379. 0, /* 21 check_sum */
  10380. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  10381. , /* 22-29 oem_name[16] */
  10382. 0, /* 30 dvc_err_code */
  10383. 0, /* 31 adv_err_code */
  10384. 0, /* 32 adv_err_addr */
  10385. 0, /* 33 saved_dvc_err_code */
  10386. 0, /* 34 saved_adv_err_code */
  10387. 0, /* 35 saved_adv_err_addr */
  10388. 0, /* 36 reserved */
  10389. 0, /* 37 reserved */
  10390. 0, /* 38 reserved */
  10391. 0, /* 39 reserved */
  10392. 0, /* 40 reserved */
  10393. 0, /* 41 reserved */
  10394. 0, /* 42 reserved */
  10395. 0, /* 43 reserved */
  10396. 0, /* 44 reserved */
  10397. 0, /* 45 reserved */
  10398. 0, /* 46 reserved */
  10399. 0, /* 47 reserved */
  10400. 0, /* 48 reserved */
  10401. 0, /* 49 reserved */
  10402. 0, /* 50 reserved */
  10403. 0, /* 51 reserved */
  10404. 0, /* 52 reserved */
  10405. 0, /* 53 reserved */
  10406. 0, /* 54 reserved */
  10407. 0, /* 55 reserved */
  10408. 0, /* 56 cisptr_lsw */
  10409. 0, /* 57 cisprt_msw */
  10410. 0, /* 58 subsysvid */
  10411. 0, /* 59 subsysid */
  10412. 0, /* 60 reserved */
  10413. 0, /* 61 reserved */
  10414. 0, /* 62 reserved */
  10415. 0 /* 63 reserved */
  10416. };
  10417. #ifdef CONFIG_PCI
  10418. /*
  10419. * Initialize the ADV_DVC_VAR structure.
  10420. *
  10421. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  10422. *
  10423. * For a non-fatal error return a warning code. If there are no warnings
  10424. * then 0 is returned.
  10425. */
  10426. static int __devinit
  10427. AdvInitGetConfig(struct pci_dev *pdev, asc_board_t *boardp)
  10428. {
  10429. ADV_DVC_VAR *asc_dvc = &boardp->dvc_var.adv_dvc_var;
  10430. unsigned short warn_code = 0;
  10431. AdvPortAddr iop_base = asc_dvc->iop_base;
  10432. u16 cmd;
  10433. int status;
  10434. asc_dvc->err_code = 0;
  10435. /*
  10436. * Save the state of the PCI Configuration Command Register
  10437. * "Parity Error Response Control" Bit. If the bit is clear (0),
  10438. * in AdvInitAsc3550/38C0800Driver() tell the microcode to ignore
  10439. * DMA parity errors.
  10440. */
  10441. asc_dvc->cfg->control_flag = 0;
  10442. pci_read_config_word(pdev, PCI_COMMAND, &cmd);
  10443. if ((cmd & PCI_COMMAND_PARITY) == 0)
  10444. asc_dvc->cfg->control_flag |= CONTROL_FLAG_IGNORE_PERR;
  10445. asc_dvc->cfg->lib_version = (ADV_LIB_VERSION_MAJOR << 8) |
  10446. ADV_LIB_VERSION_MINOR;
  10447. asc_dvc->cfg->chip_version =
  10448. AdvGetChipVersion(iop_base, asc_dvc->bus_type);
  10449. ASC_DBG2(1, "AdvInitGetConfig: iopb_chip_id_1: 0x%x 0x%x\n",
  10450. (ushort)AdvReadByteRegister(iop_base, IOPB_CHIP_ID_1),
  10451. (ushort)ADV_CHIP_ID_BYTE);
  10452. ASC_DBG2(1, "AdvInitGetConfig: iopw_chip_id_0: 0x%x 0x%x\n",
  10453. (ushort)AdvReadWordRegister(iop_base, IOPW_CHIP_ID_0),
  10454. (ushort)ADV_CHIP_ID_WORD);
  10455. /*
  10456. * Reset the chip to start and allow register writes.
  10457. */
  10458. if (AdvFindSignature(iop_base) == 0) {
  10459. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  10460. return ADV_ERROR;
  10461. } else {
  10462. /*
  10463. * The caller must set 'chip_type' to a valid setting.
  10464. */
  10465. if (asc_dvc->chip_type != ADV_CHIP_ASC3550 &&
  10466. asc_dvc->chip_type != ADV_CHIP_ASC38C0800 &&
  10467. asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
  10468. asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
  10469. return ADV_ERROR;
  10470. }
  10471. /*
  10472. * Reset Chip.
  10473. */
  10474. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  10475. ADV_CTRL_REG_CMD_RESET);
  10476. DvcSleepMilliSecond(100);
  10477. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  10478. ADV_CTRL_REG_CMD_WR_IO_REG);
  10479. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  10480. status = AdvInitFrom38C1600EEP(asc_dvc);
  10481. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  10482. status = AdvInitFrom38C0800EEP(asc_dvc);
  10483. } else {
  10484. status = AdvInitFrom3550EEP(asc_dvc);
  10485. }
  10486. warn_code |= status;
  10487. }
  10488. if (warn_code != 0) {
  10489. ASC_PRINT2("AdvInitGetConfig: board %d: warning: 0x%x\n",
  10490. boardp->id, warn_code);
  10491. }
  10492. if (asc_dvc->err_code) {
  10493. ASC_PRINT2("AdvInitGetConfig: board %d error: err_code 0x%x\n",
  10494. boardp->id, asc_dvc->err_code);
  10495. }
  10496. return asc_dvc->err_code;
  10497. }
  10498. #endif
  10499. static void AdvBuildCarrierFreelist(struct adv_dvc_var *asc_dvc)
  10500. {
  10501. ADV_CARR_T *carrp;
  10502. ADV_SDCNT buf_size;
  10503. ADV_PADDR carr_paddr;
  10504. BUG_ON(!asc_dvc->carrier_buf);
  10505. carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
  10506. asc_dvc->carr_freelist = NULL;
  10507. if (carrp == asc_dvc->carrier_buf) {
  10508. buf_size = ADV_CARRIER_BUFSIZE;
  10509. } else {
  10510. buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
  10511. }
  10512. do {
  10513. /* Get physical address of the carrier 'carrp'. */
  10514. ADV_DCNT contig_len = sizeof(ADV_CARR_T);
  10515. carr_paddr = cpu_to_le32(DvcGetPhyAddr(asc_dvc, NULL,
  10516. (uchar *)carrp,
  10517. (ADV_SDCNT *)&contig_len,
  10518. ADV_IS_CARRIER_FLAG));
  10519. buf_size -= sizeof(ADV_CARR_T);
  10520. /*
  10521. * If the current carrier is not physically contiguous, then
  10522. * maybe there was a page crossing. Try the next carrier
  10523. * aligned start address.
  10524. */
  10525. if (contig_len < sizeof(ADV_CARR_T)) {
  10526. carrp++;
  10527. continue;
  10528. }
  10529. carrp->carr_pa = carr_paddr;
  10530. carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
  10531. /*
  10532. * Insert the carrier at the beginning of the freelist.
  10533. */
  10534. carrp->next_vpa =
  10535. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  10536. asc_dvc->carr_freelist = carrp;
  10537. carrp++;
  10538. } while (buf_size > 0);
  10539. }
  10540. /*
  10541. * Load the Microcode
  10542. *
  10543. * Write the microcode image to RISC memory starting at address 0.
  10544. *
  10545. * The microcode is stored compressed in the following format:
  10546. *
  10547. * 254 word (508 byte) table indexed by byte code followed
  10548. * by the following byte codes:
  10549. *
  10550. * 1-Byte Code:
  10551. * 00: Emit word 0 in table.
  10552. * 01: Emit word 1 in table.
  10553. * .
  10554. * FD: Emit word 253 in table.
  10555. *
  10556. * Multi-Byte Code:
  10557. * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
  10558. * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
  10559. *
  10560. * Returns 0 or an error if the checksum doesn't match
  10561. */
  10562. static int AdvLoadMicrocode(AdvPortAddr iop_base, unsigned char *buf, int size,
  10563. int memsize, int chksum)
  10564. {
  10565. int i, j, end, len = 0;
  10566. ADV_DCNT sum;
  10567. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  10568. for (i = 253 * 2; i < size; i++) {
  10569. if (buf[i] == 0xff) {
  10570. unsigned short word = (buf[i + 3] << 8) | buf[i + 2];
  10571. for (j = 0; j < buf[i + 1]; j++) {
  10572. AdvWriteWordAutoIncLram(iop_base, word);
  10573. len += 2;
  10574. }
  10575. i += 3;
  10576. } else if (buf[i] == 0xfe) {
  10577. unsigned short word = (buf[i + 2] << 8) | buf[i + 1];
  10578. AdvWriteWordAutoIncLram(iop_base, word);
  10579. i += 2;
  10580. len += 2;
  10581. } else {
  10582. unsigned char off = buf[i] * 2;
  10583. unsigned short word = (buf[off + 1] << 8) | buf[off];
  10584. AdvWriteWordAutoIncLram(iop_base, word);
  10585. len += 2;
  10586. }
  10587. }
  10588. end = len;
  10589. while (len < memsize) {
  10590. AdvWriteWordAutoIncLram(iop_base, 0);
  10591. len += 2;
  10592. }
  10593. /* Verify the microcode checksum. */
  10594. sum = 0;
  10595. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  10596. for (len = 0; len < end; len += 2) {
  10597. sum += AdvReadWordAutoIncLram(iop_base);
  10598. }
  10599. if (sum != chksum)
  10600. return ASC_IERR_MCODE_CHKSUM;
  10601. return 0;
  10602. }
  10603. /*
  10604. * Initialize the ASC-3550.
  10605. *
  10606. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  10607. *
  10608. * For a non-fatal error return a warning code. If there are no warnings
  10609. * then 0 is returned.
  10610. *
  10611. * Needed after initialization for error recovery.
  10612. */
  10613. static int AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
  10614. {
  10615. AdvPortAddr iop_base;
  10616. ushort warn_code;
  10617. int begin_addr;
  10618. int end_addr;
  10619. ushort code_sum;
  10620. int word;
  10621. int i;
  10622. ushort scsi_cfg1;
  10623. uchar tid;
  10624. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  10625. ushort wdtr_able = 0, sdtr_able, tagqng_able;
  10626. uchar max_cmd[ADV_MAX_TID + 1];
  10627. /* If there is already an error, don't continue. */
  10628. if (asc_dvc->err_code != 0)
  10629. return ADV_ERROR;
  10630. /*
  10631. * The caller must set 'chip_type' to ADV_CHIP_ASC3550.
  10632. */
  10633. if (asc_dvc->chip_type != ADV_CHIP_ASC3550) {
  10634. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  10635. return ADV_ERROR;
  10636. }
  10637. warn_code = 0;
  10638. iop_base = asc_dvc->iop_base;
  10639. /*
  10640. * Save the RISC memory BIOS region before writing the microcode.
  10641. * The BIOS may already be loaded and using its RISC LRAM region
  10642. * so its region must be saved and restored.
  10643. *
  10644. * Note: This code makes the assumption, which is currently true,
  10645. * that a chip reset does not clear RISC LRAM.
  10646. */
  10647. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  10648. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  10649. bios_mem[i]);
  10650. }
  10651. /*
  10652. * Save current per TID negotiated values.
  10653. */
  10654. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] == 0x55AA) {
  10655. ushort bios_version, major, minor;
  10656. bios_version =
  10657. bios_mem[(ASC_MC_BIOS_VERSION - ASC_MC_BIOSMEM) / 2];
  10658. major = (bios_version >> 12) & 0xF;
  10659. minor = (bios_version >> 8) & 0xF;
  10660. if (major < 3 || (major == 3 && minor == 1)) {
  10661. /* BIOS 3.1 and earlier location of 'wdtr_able' variable. */
  10662. AdvReadWordLram(iop_base, 0x120, wdtr_able);
  10663. } else {
  10664. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  10665. }
  10666. }
  10667. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  10668. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  10669. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  10670. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  10671. max_cmd[tid]);
  10672. }
  10673. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc3550_buf,
  10674. _adv_asc3550_size, ADV_3550_MEMSIZE,
  10675. _adv_asc3550_chksum);
  10676. if (asc_dvc->err_code)
  10677. return ADV_ERROR;
  10678. /*
  10679. * Restore the RISC memory BIOS region.
  10680. */
  10681. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  10682. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  10683. bios_mem[i]);
  10684. }
  10685. /*
  10686. * Calculate and write the microcode code checksum to the microcode
  10687. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  10688. */
  10689. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  10690. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  10691. code_sum = 0;
  10692. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  10693. for (word = begin_addr; word < end_addr; word += 2) {
  10694. code_sum += AdvReadWordAutoIncLram(iop_base);
  10695. }
  10696. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  10697. /*
  10698. * Read and save microcode version and date.
  10699. */
  10700. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  10701. asc_dvc->cfg->mcode_date);
  10702. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  10703. asc_dvc->cfg->mcode_version);
  10704. /*
  10705. * Set the chip type to indicate the ASC3550.
  10706. */
  10707. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC3550);
  10708. /*
  10709. * If the PCI Configuration Command Register "Parity Error Response
  10710. * Control" Bit was clear (0), then set the microcode variable
  10711. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  10712. * to ignore DMA parity errors.
  10713. */
  10714. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  10715. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  10716. word |= CONTROL_FLAG_IGNORE_PERR;
  10717. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  10718. }
  10719. /*
  10720. * For ASC-3550, setting the START_CTL_EMFU [3:2] bits sets a FIFO
  10721. * threshold of 128 bytes. This register is only accessible to the host.
  10722. */
  10723. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  10724. START_CTL_EMFU | READ_CMD_MRM);
  10725. /*
  10726. * Microcode operating variables for WDTR, SDTR, and command tag
  10727. * queuing will be set in slave_configure() based on what a
  10728. * device reports it is capable of in Inquiry byte 7.
  10729. *
  10730. * If SCSI Bus Resets have been disabled, then directly set
  10731. * SDTR and WDTR from the EEPROM configuration. This will allow
  10732. * the BIOS and warm boot to work without a SCSI bus hang on
  10733. * the Inquiry caused by host and target mismatched DTR values.
  10734. * Without the SCSI Bus Reset, before an Inquiry a device can't
  10735. * be assumed to be in Asynchronous, Narrow mode.
  10736. */
  10737. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  10738. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  10739. asc_dvc->wdtr_able);
  10740. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  10741. asc_dvc->sdtr_able);
  10742. }
  10743. /*
  10744. * Set microcode operating variables for SDTR_SPEED1, SDTR_SPEED2,
  10745. * SDTR_SPEED3, and SDTR_SPEED4 based on the ULTRA EEPROM per TID
  10746. * bitmask. These values determine the maximum SDTR speed negotiated
  10747. * with a device.
  10748. *
  10749. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  10750. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  10751. * without determining here whether the device supports SDTR.
  10752. *
  10753. * 4-bit speed SDTR speed name
  10754. * =========== ===============
  10755. * 0000b (0x0) SDTR disabled
  10756. * 0001b (0x1) 5 Mhz
  10757. * 0010b (0x2) 10 Mhz
  10758. * 0011b (0x3) 20 Mhz (Ultra)
  10759. * 0100b (0x4) 40 Mhz (LVD/Ultra2)
  10760. * 0101b (0x5) 80 Mhz (LVD2/Ultra3)
  10761. * 0110b (0x6) Undefined
  10762. * .
  10763. * 1111b (0xF) Undefined
  10764. */
  10765. word = 0;
  10766. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  10767. if (ADV_TID_TO_TIDMASK(tid) & asc_dvc->ultra_able) {
  10768. /* Set Ultra speed for TID 'tid'. */
  10769. word |= (0x3 << (4 * (tid % 4)));
  10770. } else {
  10771. /* Set Fast speed for TID 'tid'. */
  10772. word |= (0x2 << (4 * (tid % 4)));
  10773. }
  10774. if (tid == 3) { /* Check if done with sdtr_speed1. */
  10775. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, word);
  10776. word = 0;
  10777. } else if (tid == 7) { /* Check if done with sdtr_speed2. */
  10778. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, word);
  10779. word = 0;
  10780. } else if (tid == 11) { /* Check if done with sdtr_speed3. */
  10781. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, word);
  10782. word = 0;
  10783. } else if (tid == 15) { /* Check if done with sdtr_speed4. */
  10784. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, word);
  10785. /* End of loop. */
  10786. }
  10787. }
  10788. /*
  10789. * Set microcode operating variable for the disconnect per TID bitmask.
  10790. */
  10791. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  10792. asc_dvc->cfg->disc_enable);
  10793. /*
  10794. * Set SCSI_CFG0 Microcode Default Value.
  10795. *
  10796. * The microcode will set the SCSI_CFG0 register using this value
  10797. * after it is started below.
  10798. */
  10799. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  10800. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  10801. asc_dvc->chip_scsi_id);
  10802. /*
  10803. * Determine SCSI_CFG1 Microcode Default Value.
  10804. *
  10805. * The microcode will set the SCSI_CFG1 register using this value
  10806. * after it is started below.
  10807. */
  10808. /* Read current SCSI_CFG1 Register value. */
  10809. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  10810. /*
  10811. * If all three connectors are in use, return an error.
  10812. */
  10813. if ((scsi_cfg1 & CABLE_ILLEGAL_A) == 0 ||
  10814. (scsi_cfg1 & CABLE_ILLEGAL_B) == 0) {
  10815. asc_dvc->err_code |= ASC_IERR_ILLEGAL_CONNECTION;
  10816. return ADV_ERROR;
  10817. }
  10818. /*
  10819. * If the internal narrow cable is reversed all of the SCSI_CTRL
  10820. * register signals will be set. Check for and return an error if
  10821. * this condition is found.
  10822. */
  10823. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  10824. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  10825. return ADV_ERROR;
  10826. }
  10827. /*
  10828. * If this is a differential board and a single-ended device
  10829. * is attached to one of the connectors, return an error.
  10830. */
  10831. if ((scsi_cfg1 & DIFF_MODE) && (scsi_cfg1 & DIFF_SENSE) == 0) {
  10832. asc_dvc->err_code |= ASC_IERR_SINGLE_END_DEVICE;
  10833. return ADV_ERROR;
  10834. }
  10835. /*
  10836. * If automatic termination control is enabled, then set the
  10837. * termination value based on a table listed in a_condor.h.
  10838. *
  10839. * If manual termination was specified with an EEPROM setting
  10840. * then 'termination' was set-up in AdvInitFrom3550EEPROM() and
  10841. * is ready to be 'ored' into SCSI_CFG1.
  10842. */
  10843. if (asc_dvc->cfg->termination == 0) {
  10844. /*
  10845. * The software always controls termination by setting TERM_CTL_SEL.
  10846. * If TERM_CTL_SEL were set to 0, the hardware would set termination.
  10847. */
  10848. asc_dvc->cfg->termination |= TERM_CTL_SEL;
  10849. switch (scsi_cfg1 & CABLE_DETECT) {
  10850. /* TERM_CTL_H: on, TERM_CTL_L: on */
  10851. case 0x3:
  10852. case 0x7:
  10853. case 0xB:
  10854. case 0xD:
  10855. case 0xE:
  10856. case 0xF:
  10857. asc_dvc->cfg->termination |= (TERM_CTL_H | TERM_CTL_L);
  10858. break;
  10859. /* TERM_CTL_H: on, TERM_CTL_L: off */
  10860. case 0x1:
  10861. case 0x5:
  10862. case 0x9:
  10863. case 0xA:
  10864. case 0xC:
  10865. asc_dvc->cfg->termination |= TERM_CTL_H;
  10866. break;
  10867. /* TERM_CTL_H: off, TERM_CTL_L: off */
  10868. case 0x2:
  10869. case 0x6:
  10870. break;
  10871. }
  10872. }
  10873. /*
  10874. * Clear any set TERM_CTL_H and TERM_CTL_L bits.
  10875. */
  10876. scsi_cfg1 &= ~TERM_CTL;
  10877. /*
  10878. * Invert the TERM_CTL_H and TERM_CTL_L bits and then
  10879. * set 'scsi_cfg1'. The TERM_POL bit does not need to be
  10880. * referenced, because the hardware internally inverts
  10881. * the Termination High and Low bits if TERM_POL is set.
  10882. */
  10883. scsi_cfg1 |= (TERM_CTL_SEL | (~asc_dvc->cfg->termination & TERM_CTL));
  10884. /*
  10885. * Set SCSI_CFG1 Microcode Default Value
  10886. *
  10887. * Set filter value and possibly modified termination control
  10888. * bits in the Microcode SCSI_CFG1 Register Value.
  10889. *
  10890. * The microcode will set the SCSI_CFG1 register using this value
  10891. * after it is started below.
  10892. */
  10893. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1,
  10894. FLTR_DISABLE | scsi_cfg1);
  10895. /*
  10896. * Set MEM_CFG Microcode Default Value
  10897. *
  10898. * The microcode will set the MEM_CFG register using this value
  10899. * after it is started below.
  10900. *
  10901. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  10902. * are defined.
  10903. *
  10904. * ASC-3550 has 8KB internal memory.
  10905. */
  10906. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  10907. BIOS_EN | RAM_SZ_8KB);
  10908. /*
  10909. * Set SEL_MASK Microcode Default Value
  10910. *
  10911. * The microcode will set the SEL_MASK register using this value
  10912. * after it is started below.
  10913. */
  10914. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  10915. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  10916. AdvBuildCarrierFreelist(asc_dvc);
  10917. /*
  10918. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  10919. */
  10920. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  10921. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  10922. return ADV_ERROR;
  10923. }
  10924. asc_dvc->carr_freelist = (ADV_CARR_T *)
  10925. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  10926. /*
  10927. * The first command issued will be placed in the stopper carrier.
  10928. */
  10929. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  10930. /*
  10931. * Set RISC ICQ physical address start value.
  10932. */
  10933. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  10934. /*
  10935. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  10936. */
  10937. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  10938. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  10939. return ADV_ERROR;
  10940. }
  10941. asc_dvc->carr_freelist = (ADV_CARR_T *)
  10942. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  10943. /*
  10944. * The first command completed by the RISC will be placed in
  10945. * the stopper.
  10946. *
  10947. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  10948. * completed the RISC will set the ASC_RQ_STOPPER bit.
  10949. */
  10950. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  10951. /*
  10952. * Set RISC IRQ physical address start value.
  10953. */
  10954. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  10955. asc_dvc->carr_pending_cnt = 0;
  10956. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  10957. (ADV_INTR_ENABLE_HOST_INTR |
  10958. ADV_INTR_ENABLE_GLOBAL_INTR));
  10959. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  10960. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  10961. /* finally, finally, gentlemen, start your engine */
  10962. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  10963. /*
  10964. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  10965. * Resets should be performed. The RISC has to be running
  10966. * to issue a SCSI Bus Reset.
  10967. */
  10968. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  10969. /*
  10970. * If the BIOS Signature is present in memory, restore the
  10971. * BIOS Handshake Configuration Table and do not perform
  10972. * a SCSI Bus Reset.
  10973. */
  10974. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  10975. 0x55AA) {
  10976. /*
  10977. * Restore per TID negotiated values.
  10978. */
  10979. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  10980. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  10981. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  10982. tagqng_able);
  10983. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  10984. AdvWriteByteLram(iop_base,
  10985. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  10986. max_cmd[tid]);
  10987. }
  10988. } else {
  10989. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  10990. warn_code = ASC_WARN_BUSRESET_ERROR;
  10991. }
  10992. }
  10993. }
  10994. return warn_code;
  10995. }
  10996. /*
  10997. * Initialize the ASC-38C0800.
  10998. *
  10999. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  11000. *
  11001. * For a non-fatal error return a warning code. If there are no warnings
  11002. * then 0 is returned.
  11003. *
  11004. * Needed after initialization for error recovery.
  11005. */
  11006. static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
  11007. {
  11008. AdvPortAddr iop_base;
  11009. ushort warn_code;
  11010. int begin_addr;
  11011. int end_addr;
  11012. ushort code_sum;
  11013. int word;
  11014. int i;
  11015. ushort scsi_cfg1;
  11016. uchar byte;
  11017. uchar tid;
  11018. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  11019. ushort wdtr_able, sdtr_able, tagqng_able;
  11020. uchar max_cmd[ADV_MAX_TID + 1];
  11021. /* If there is already an error, don't continue. */
  11022. if (asc_dvc->err_code != 0)
  11023. return ADV_ERROR;
  11024. /*
  11025. * The caller must set 'chip_type' to ADV_CHIP_ASC38C0800.
  11026. */
  11027. if (asc_dvc->chip_type != ADV_CHIP_ASC38C0800) {
  11028. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  11029. return ADV_ERROR;
  11030. }
  11031. warn_code = 0;
  11032. iop_base = asc_dvc->iop_base;
  11033. /*
  11034. * Save the RISC memory BIOS region before writing the microcode.
  11035. * The BIOS may already be loaded and using its RISC LRAM region
  11036. * so its region must be saved and restored.
  11037. *
  11038. * Note: This code makes the assumption, which is currently true,
  11039. * that a chip reset does not clear RISC LRAM.
  11040. */
  11041. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  11042. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  11043. bios_mem[i]);
  11044. }
  11045. /*
  11046. * Save current per TID negotiated values.
  11047. */
  11048. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  11049. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  11050. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  11051. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  11052. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  11053. max_cmd[tid]);
  11054. }
  11055. /*
  11056. * RAM BIST (RAM Built-In Self Test)
  11057. *
  11058. * Address : I/O base + offset 0x38h register (byte).
  11059. * Function: Bit 7-6(RW) : RAM mode
  11060. * Normal Mode : 0x00
  11061. * Pre-test Mode : 0x40
  11062. * RAM Test Mode : 0x80
  11063. * Bit 5 : unused
  11064. * Bit 4(RO) : Done bit
  11065. * Bit 3-0(RO) : Status
  11066. * Host Error : 0x08
  11067. * Int_RAM Error : 0x04
  11068. * RISC Error : 0x02
  11069. * SCSI Error : 0x01
  11070. * No Error : 0x00
  11071. *
  11072. * Note: RAM BIST code should be put right here, before loading the
  11073. * microcode and after saving the RISC memory BIOS region.
  11074. */
  11075. /*
  11076. * LRAM Pre-test
  11077. *
  11078. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  11079. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  11080. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  11081. * to NORMAL_MODE, return an error too.
  11082. */
  11083. for (i = 0; i < 2; i++) {
  11084. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  11085. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  11086. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  11087. if ((byte & RAM_TEST_DONE) == 0
  11088. || (byte & 0x0F) != PRE_TEST_VALUE) {
  11089. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  11090. return ADV_ERROR;
  11091. }
  11092. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  11093. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  11094. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  11095. != NORMAL_VALUE) {
  11096. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  11097. return ADV_ERROR;
  11098. }
  11099. }
  11100. /*
  11101. * LRAM Test - It takes about 1.5 ms to run through the test.
  11102. *
  11103. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  11104. * If Done bit not set or Status not 0, save register byte, set the
  11105. * err_code, and return an error.
  11106. */
  11107. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  11108. DvcSleepMilliSecond(10); /* Wait for 10ms before checking status. */
  11109. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  11110. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
  11111. /* Get here if Done bit not set or Status not 0. */
  11112. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  11113. asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
  11114. return ADV_ERROR;
  11115. }
  11116. /* We need to reset back to normal mode after LRAM test passes. */
  11117. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  11118. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C0800_buf,
  11119. _adv_asc38C0800_size, ADV_38C0800_MEMSIZE,
  11120. _adv_asc38C0800_chksum);
  11121. if (asc_dvc->err_code)
  11122. return ADV_ERROR;
  11123. /*
  11124. * Restore the RISC memory BIOS region.
  11125. */
  11126. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  11127. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  11128. bios_mem[i]);
  11129. }
  11130. /*
  11131. * Calculate and write the microcode code checksum to the microcode
  11132. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  11133. */
  11134. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  11135. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  11136. code_sum = 0;
  11137. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  11138. for (word = begin_addr; word < end_addr; word += 2) {
  11139. code_sum += AdvReadWordAutoIncLram(iop_base);
  11140. }
  11141. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  11142. /*
  11143. * Read microcode version and date.
  11144. */
  11145. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  11146. asc_dvc->cfg->mcode_date);
  11147. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  11148. asc_dvc->cfg->mcode_version);
  11149. /*
  11150. * Set the chip type to indicate the ASC38C0800.
  11151. */
  11152. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C0800);
  11153. /*
  11154. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  11155. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  11156. * cable detection and then we are able to read C_DET[3:0].
  11157. *
  11158. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  11159. * Microcode Default Value' section below.
  11160. */
  11161. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  11162. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
  11163. scsi_cfg1 | DIS_TERM_DRV);
  11164. /*
  11165. * If the PCI Configuration Command Register "Parity Error Response
  11166. * Control" Bit was clear (0), then set the microcode variable
  11167. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  11168. * to ignore DMA parity errors.
  11169. */
  11170. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  11171. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  11172. word |= CONTROL_FLAG_IGNORE_PERR;
  11173. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  11174. }
  11175. /*
  11176. * For ASC-38C0800, set FIFO_THRESH_80B [6:4] bits and START_CTL_TH [3:2]
  11177. * bits for the default FIFO threshold.
  11178. *
  11179. * Note: ASC-38C0800 FIFO threshold has been changed to 256 bytes.
  11180. *
  11181. * For DMA Errata #4 set the BC_THRESH_ENB bit.
  11182. */
  11183. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  11184. BC_THRESH_ENB | FIFO_THRESH_80B | START_CTL_TH |
  11185. READ_CMD_MRM);
  11186. /*
  11187. * Microcode operating variables for WDTR, SDTR, and command tag
  11188. * queuing will be set in slave_configure() based on what a
  11189. * device reports it is capable of in Inquiry byte 7.
  11190. *
  11191. * If SCSI Bus Resets have been disabled, then directly set
  11192. * SDTR and WDTR from the EEPROM configuration. This will allow
  11193. * the BIOS and warm boot to work without a SCSI bus hang on
  11194. * the Inquiry caused by host and target mismatched DTR values.
  11195. * Without the SCSI Bus Reset, before an Inquiry a device can't
  11196. * be assumed to be in Asynchronous, Narrow mode.
  11197. */
  11198. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  11199. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  11200. asc_dvc->wdtr_able);
  11201. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  11202. asc_dvc->sdtr_able);
  11203. }
  11204. /*
  11205. * Set microcode operating variables for DISC and SDTR_SPEED1,
  11206. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  11207. * configuration values.
  11208. *
  11209. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  11210. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  11211. * without determining here whether the device supports SDTR.
  11212. */
  11213. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  11214. asc_dvc->cfg->disc_enable);
  11215. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  11216. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  11217. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  11218. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  11219. /*
  11220. * Set SCSI_CFG0 Microcode Default Value.
  11221. *
  11222. * The microcode will set the SCSI_CFG0 register using this value
  11223. * after it is started below.
  11224. */
  11225. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  11226. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  11227. asc_dvc->chip_scsi_id);
  11228. /*
  11229. * Determine SCSI_CFG1 Microcode Default Value.
  11230. *
  11231. * The microcode will set the SCSI_CFG1 register using this value
  11232. * after it is started below.
  11233. */
  11234. /* Read current SCSI_CFG1 Register value. */
  11235. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  11236. /*
  11237. * If the internal narrow cable is reversed all of the SCSI_CTRL
  11238. * register signals will be set. Check for and return an error if
  11239. * this condition is found.
  11240. */
  11241. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  11242. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  11243. return ADV_ERROR;
  11244. }
  11245. /*
  11246. * All kind of combinations of devices attached to one of four
  11247. * connectors are acceptable except HVD device attached. For example,
  11248. * LVD device can be attached to SE connector while SE device attached
  11249. * to LVD connector. If LVD device attached to SE connector, it only
  11250. * runs up to Ultra speed.
  11251. *
  11252. * If an HVD device is attached to one of LVD connectors, return an
  11253. * error. However, there is no way to detect HVD device attached to
  11254. * SE connectors.
  11255. */
  11256. if (scsi_cfg1 & HVD) {
  11257. asc_dvc->err_code = ASC_IERR_HVD_DEVICE;
  11258. return ADV_ERROR;
  11259. }
  11260. /*
  11261. * If either SE or LVD automatic termination control is enabled, then
  11262. * set the termination value based on a table listed in a_condor.h.
  11263. *
  11264. * If manual termination was specified with an EEPROM setting then
  11265. * 'termination' was set-up in AdvInitFrom38C0800EEPROM() and is ready
  11266. * to be 'ored' into SCSI_CFG1.
  11267. */
  11268. if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
  11269. /* SE automatic termination control is enabled. */
  11270. switch (scsi_cfg1 & C_DET_SE) {
  11271. /* TERM_SE_HI: on, TERM_SE_LO: on */
  11272. case 0x1:
  11273. case 0x2:
  11274. case 0x3:
  11275. asc_dvc->cfg->termination |= TERM_SE;
  11276. break;
  11277. /* TERM_SE_HI: on, TERM_SE_LO: off */
  11278. case 0x0:
  11279. asc_dvc->cfg->termination |= TERM_SE_HI;
  11280. break;
  11281. }
  11282. }
  11283. if ((asc_dvc->cfg->termination & TERM_LVD) == 0) {
  11284. /* LVD automatic termination control is enabled. */
  11285. switch (scsi_cfg1 & C_DET_LVD) {
  11286. /* TERM_LVD_HI: on, TERM_LVD_LO: on */
  11287. case 0x4:
  11288. case 0x8:
  11289. case 0xC:
  11290. asc_dvc->cfg->termination |= TERM_LVD;
  11291. break;
  11292. /* TERM_LVD_HI: off, TERM_LVD_LO: off */
  11293. case 0x0:
  11294. break;
  11295. }
  11296. }
  11297. /*
  11298. * Clear any set TERM_SE and TERM_LVD bits.
  11299. */
  11300. scsi_cfg1 &= (~TERM_SE & ~TERM_LVD);
  11301. /*
  11302. * Invert the TERM_SE and TERM_LVD bits and then set 'scsi_cfg1'.
  11303. */
  11304. scsi_cfg1 |= (~asc_dvc->cfg->termination & 0xF0);
  11305. /*
  11306. * Clear BIG_ENDIAN, DIS_TERM_DRV, Terminator Polarity and HVD/LVD/SE
  11307. * bits and set possibly modified termination control bits in the
  11308. * Microcode SCSI_CFG1 Register Value.
  11309. */
  11310. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL & ~HVD_LVD_SE);
  11311. /*
  11312. * Set SCSI_CFG1 Microcode Default Value
  11313. *
  11314. * Set possibly modified termination control and reset DIS_TERM_DRV
  11315. * bits in the Microcode SCSI_CFG1 Register Value.
  11316. *
  11317. * The microcode will set the SCSI_CFG1 register using this value
  11318. * after it is started below.
  11319. */
  11320. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  11321. /*
  11322. * Set MEM_CFG Microcode Default Value
  11323. *
  11324. * The microcode will set the MEM_CFG register using this value
  11325. * after it is started below.
  11326. *
  11327. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  11328. * are defined.
  11329. *
  11330. * ASC-38C0800 has 16KB internal memory.
  11331. */
  11332. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  11333. BIOS_EN | RAM_SZ_16KB);
  11334. /*
  11335. * Set SEL_MASK Microcode Default Value
  11336. *
  11337. * The microcode will set the SEL_MASK register using this value
  11338. * after it is started below.
  11339. */
  11340. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  11341. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  11342. AdvBuildCarrierFreelist(asc_dvc);
  11343. /*
  11344. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  11345. */
  11346. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  11347. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  11348. return ADV_ERROR;
  11349. }
  11350. asc_dvc->carr_freelist = (ADV_CARR_T *)
  11351. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  11352. /*
  11353. * The first command issued will be placed in the stopper carrier.
  11354. */
  11355. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  11356. /*
  11357. * Set RISC ICQ physical address start value.
  11358. * carr_pa is LE, must be native before write
  11359. */
  11360. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  11361. /*
  11362. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  11363. */
  11364. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  11365. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  11366. return ADV_ERROR;
  11367. }
  11368. asc_dvc->carr_freelist = (ADV_CARR_T *)
  11369. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  11370. /*
  11371. * The first command completed by the RISC will be placed in
  11372. * the stopper.
  11373. *
  11374. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  11375. * completed the RISC will set the ASC_RQ_STOPPER bit.
  11376. */
  11377. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  11378. /*
  11379. * Set RISC IRQ physical address start value.
  11380. *
  11381. * carr_pa is LE, must be native before write *
  11382. */
  11383. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  11384. asc_dvc->carr_pending_cnt = 0;
  11385. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  11386. (ADV_INTR_ENABLE_HOST_INTR |
  11387. ADV_INTR_ENABLE_GLOBAL_INTR));
  11388. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  11389. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  11390. /* finally, finally, gentlemen, start your engine */
  11391. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  11392. /*
  11393. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  11394. * Resets should be performed. The RISC has to be running
  11395. * to issue a SCSI Bus Reset.
  11396. */
  11397. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  11398. /*
  11399. * If the BIOS Signature is present in memory, restore the
  11400. * BIOS Handshake Configuration Table and do not perform
  11401. * a SCSI Bus Reset.
  11402. */
  11403. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  11404. 0x55AA) {
  11405. /*
  11406. * Restore per TID negotiated values.
  11407. */
  11408. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  11409. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  11410. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  11411. tagqng_able);
  11412. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  11413. AdvWriteByteLram(iop_base,
  11414. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  11415. max_cmd[tid]);
  11416. }
  11417. } else {
  11418. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  11419. warn_code = ASC_WARN_BUSRESET_ERROR;
  11420. }
  11421. }
  11422. }
  11423. return warn_code;
  11424. }
  11425. /*
  11426. * Initialize the ASC-38C1600.
  11427. *
  11428. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  11429. *
  11430. * For a non-fatal error return a warning code. If there are no warnings
  11431. * then 0 is returned.
  11432. *
  11433. * Needed after initialization for error recovery.
  11434. */
  11435. static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
  11436. {
  11437. AdvPortAddr iop_base;
  11438. ushort warn_code;
  11439. int begin_addr;
  11440. int end_addr;
  11441. ushort code_sum;
  11442. long word;
  11443. int i;
  11444. ushort scsi_cfg1;
  11445. uchar byte;
  11446. uchar tid;
  11447. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  11448. ushort wdtr_able, sdtr_able, ppr_able, tagqng_able;
  11449. uchar max_cmd[ASC_MAX_TID + 1];
  11450. /* If there is already an error, don't continue. */
  11451. if (asc_dvc->err_code != 0) {
  11452. return ADV_ERROR;
  11453. }
  11454. /*
  11455. * The caller must set 'chip_type' to ADV_CHIP_ASC38C1600.
  11456. */
  11457. if (asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
  11458. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  11459. return ADV_ERROR;
  11460. }
  11461. warn_code = 0;
  11462. iop_base = asc_dvc->iop_base;
  11463. /*
  11464. * Save the RISC memory BIOS region before writing the microcode.
  11465. * The BIOS may already be loaded and using its RISC LRAM region
  11466. * so its region must be saved and restored.
  11467. *
  11468. * Note: This code makes the assumption, which is currently true,
  11469. * that a chip reset does not clear RISC LRAM.
  11470. */
  11471. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  11472. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  11473. bios_mem[i]);
  11474. }
  11475. /*
  11476. * Save current per TID negotiated values.
  11477. */
  11478. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  11479. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  11480. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  11481. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  11482. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  11483. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  11484. max_cmd[tid]);
  11485. }
  11486. /*
  11487. * RAM BIST (Built-In Self Test)
  11488. *
  11489. * Address : I/O base + offset 0x38h register (byte).
  11490. * Function: Bit 7-6(RW) : RAM mode
  11491. * Normal Mode : 0x00
  11492. * Pre-test Mode : 0x40
  11493. * RAM Test Mode : 0x80
  11494. * Bit 5 : unused
  11495. * Bit 4(RO) : Done bit
  11496. * Bit 3-0(RO) : Status
  11497. * Host Error : 0x08
  11498. * Int_RAM Error : 0x04
  11499. * RISC Error : 0x02
  11500. * SCSI Error : 0x01
  11501. * No Error : 0x00
  11502. *
  11503. * Note: RAM BIST code should be put right here, before loading the
  11504. * microcode and after saving the RISC memory BIOS region.
  11505. */
  11506. /*
  11507. * LRAM Pre-test
  11508. *
  11509. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  11510. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  11511. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  11512. * to NORMAL_MODE, return an error too.
  11513. */
  11514. for (i = 0; i < 2; i++) {
  11515. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  11516. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  11517. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  11518. if ((byte & RAM_TEST_DONE) == 0
  11519. || (byte & 0x0F) != PRE_TEST_VALUE) {
  11520. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  11521. return ADV_ERROR;
  11522. }
  11523. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  11524. DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
  11525. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  11526. != NORMAL_VALUE) {
  11527. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  11528. return ADV_ERROR;
  11529. }
  11530. }
  11531. /*
  11532. * LRAM Test - It takes about 1.5 ms to run through the test.
  11533. *
  11534. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  11535. * If Done bit not set or Status not 0, save register byte, set the
  11536. * err_code, and return an error.
  11537. */
  11538. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  11539. DvcSleepMilliSecond(10); /* Wait for 10ms before checking status. */
  11540. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  11541. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
  11542. /* Get here if Done bit not set or Status not 0. */
  11543. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  11544. asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
  11545. return ADV_ERROR;
  11546. }
  11547. /* We need to reset back to normal mode after LRAM test passes. */
  11548. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  11549. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C1600_buf,
  11550. _adv_asc38C1600_size, ADV_38C1600_MEMSIZE,
  11551. _adv_asc38C1600_chksum);
  11552. if (asc_dvc->err_code)
  11553. return ADV_ERROR;
  11554. /*
  11555. * Restore the RISC memory BIOS region.
  11556. */
  11557. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  11558. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  11559. bios_mem[i]);
  11560. }
  11561. /*
  11562. * Calculate and write the microcode code checksum to the microcode
  11563. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  11564. */
  11565. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  11566. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  11567. code_sum = 0;
  11568. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  11569. for (word = begin_addr; word < end_addr; word += 2) {
  11570. code_sum += AdvReadWordAutoIncLram(iop_base);
  11571. }
  11572. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  11573. /*
  11574. * Read microcode version and date.
  11575. */
  11576. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  11577. asc_dvc->cfg->mcode_date);
  11578. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  11579. asc_dvc->cfg->mcode_version);
  11580. /*
  11581. * Set the chip type to indicate the ASC38C1600.
  11582. */
  11583. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C1600);
  11584. /*
  11585. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  11586. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  11587. * cable detection and then we are able to read C_DET[3:0].
  11588. *
  11589. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  11590. * Microcode Default Value' section below.
  11591. */
  11592. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  11593. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
  11594. scsi_cfg1 | DIS_TERM_DRV);
  11595. /*
  11596. * If the PCI Configuration Command Register "Parity Error Response
  11597. * Control" Bit was clear (0), then set the microcode variable
  11598. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  11599. * to ignore DMA parity errors.
  11600. */
  11601. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  11602. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  11603. word |= CONTROL_FLAG_IGNORE_PERR;
  11604. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  11605. }
  11606. /*
  11607. * If the BIOS control flag AIPP (Asynchronous Information
  11608. * Phase Protection) disable bit is not set, then set the firmware
  11609. * 'control_flag' CONTROL_FLAG_ENABLE_AIPP bit to enable
  11610. * AIPP checking and encoding.
  11611. */
  11612. if ((asc_dvc->bios_ctrl & BIOS_CTRL_AIPP_DIS) == 0) {
  11613. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  11614. word |= CONTROL_FLAG_ENABLE_AIPP;
  11615. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  11616. }
  11617. /*
  11618. * For ASC-38C1600 use DMA_CFG0 default values: FIFO_THRESH_80B [6:4],
  11619. * and START_CTL_TH [3:2].
  11620. */
  11621. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  11622. FIFO_THRESH_80B | START_CTL_TH | READ_CMD_MRM);
  11623. /*
  11624. * Microcode operating variables for WDTR, SDTR, and command tag
  11625. * queuing will be set in slave_configure() based on what a
  11626. * device reports it is capable of in Inquiry byte 7.
  11627. *
  11628. * If SCSI Bus Resets have been disabled, then directly set
  11629. * SDTR and WDTR from the EEPROM configuration. This will allow
  11630. * the BIOS and warm boot to work without a SCSI bus hang on
  11631. * the Inquiry caused by host and target mismatched DTR values.
  11632. * Without the SCSI Bus Reset, before an Inquiry a device can't
  11633. * be assumed to be in Asynchronous, Narrow mode.
  11634. */
  11635. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  11636. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  11637. asc_dvc->wdtr_able);
  11638. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  11639. asc_dvc->sdtr_able);
  11640. }
  11641. /*
  11642. * Set microcode operating variables for DISC and SDTR_SPEED1,
  11643. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  11644. * configuration values.
  11645. *
  11646. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  11647. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  11648. * without determining here whether the device supports SDTR.
  11649. */
  11650. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  11651. asc_dvc->cfg->disc_enable);
  11652. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  11653. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  11654. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  11655. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  11656. /*
  11657. * Set SCSI_CFG0 Microcode Default Value.
  11658. *
  11659. * The microcode will set the SCSI_CFG0 register using this value
  11660. * after it is started below.
  11661. */
  11662. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  11663. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  11664. asc_dvc->chip_scsi_id);
  11665. /*
  11666. * Calculate SCSI_CFG1 Microcode Default Value.
  11667. *
  11668. * The microcode will set the SCSI_CFG1 register using this value
  11669. * after it is started below.
  11670. *
  11671. * Each ASC-38C1600 function has only two cable detect bits.
  11672. * The bus mode override bits are in IOPB_SOFT_OVER_WR.
  11673. */
  11674. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  11675. /*
  11676. * If the cable is reversed all of the SCSI_CTRL register signals
  11677. * will be set. Check for and return an error if this condition is
  11678. * found.
  11679. */
  11680. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  11681. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  11682. return ADV_ERROR;
  11683. }
  11684. /*
  11685. * Each ASC-38C1600 function has two connectors. Only an HVD device
  11686. * can not be connected to either connector. An LVD device or SE device
  11687. * may be connected to either connecor. If an SE device is connected,
  11688. * then at most Ultra speed (20 Mhz) can be used on both connectors.
  11689. *
  11690. * If an HVD device is attached, return an error.
  11691. */
  11692. if (scsi_cfg1 & HVD) {
  11693. asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
  11694. return ADV_ERROR;
  11695. }
  11696. /*
  11697. * Each function in the ASC-38C1600 uses only the SE cable detect and
  11698. * termination because there are two connectors for each function. Each
  11699. * function may use either LVD or SE mode. Corresponding the SE automatic
  11700. * termination control EEPROM bits are used for each function. Each
  11701. * function has its own EEPROM. If SE automatic control is enabled for
  11702. * the function, then set the termination value based on a table listed
  11703. * in a_condor.h.
  11704. *
  11705. * If manual termination is specified in the EEPROM for the function,
  11706. * then 'termination' was set-up in AscInitFrom38C1600EEPROM() and is
  11707. * ready to be 'ored' into SCSI_CFG1.
  11708. */
  11709. if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
  11710. struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
  11711. /* SE automatic termination control is enabled. */
  11712. switch (scsi_cfg1 & C_DET_SE) {
  11713. /* TERM_SE_HI: on, TERM_SE_LO: on */
  11714. case 0x1:
  11715. case 0x2:
  11716. case 0x3:
  11717. asc_dvc->cfg->termination |= TERM_SE;
  11718. break;
  11719. case 0x0:
  11720. if (PCI_FUNC(pdev->devfn) == 0) {
  11721. /* Function 0 - TERM_SE_HI: off, TERM_SE_LO: off */
  11722. } else {
  11723. /* Function 1 - TERM_SE_HI: on, TERM_SE_LO: off */
  11724. asc_dvc->cfg->termination |= TERM_SE_HI;
  11725. }
  11726. break;
  11727. }
  11728. }
  11729. /*
  11730. * Clear any set TERM_SE bits.
  11731. */
  11732. scsi_cfg1 &= ~TERM_SE;
  11733. /*
  11734. * Invert the TERM_SE bits and then set 'scsi_cfg1'.
  11735. */
  11736. scsi_cfg1 |= (~asc_dvc->cfg->termination & TERM_SE);
  11737. /*
  11738. * Clear Big Endian and Terminator Polarity bits and set possibly
  11739. * modified termination control bits in the Microcode SCSI_CFG1
  11740. * Register Value.
  11741. *
  11742. * Big Endian bit is not used even on big endian machines.
  11743. */
  11744. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL);
  11745. /*
  11746. * Set SCSI_CFG1 Microcode Default Value
  11747. *
  11748. * Set possibly modified termination control bits in the Microcode
  11749. * SCSI_CFG1 Register Value.
  11750. *
  11751. * The microcode will set the SCSI_CFG1 register using this value
  11752. * after it is started below.
  11753. */
  11754. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  11755. /*
  11756. * Set MEM_CFG Microcode Default Value
  11757. *
  11758. * The microcode will set the MEM_CFG register using this value
  11759. * after it is started below.
  11760. *
  11761. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  11762. * are defined.
  11763. *
  11764. * ASC-38C1600 has 32KB internal memory.
  11765. *
  11766. * XXX - Since ASC38C1600 Rev.3 has a Local RAM failure issue, we come
  11767. * out a special 16K Adv Library and Microcode version. After the issue
  11768. * resolved, we should turn back to the 32K support. Both a_condor.h and
  11769. * mcode.sas files also need to be updated.
  11770. *
  11771. * AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  11772. * BIOS_EN | RAM_SZ_32KB);
  11773. */
  11774. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  11775. BIOS_EN | RAM_SZ_16KB);
  11776. /*
  11777. * Set SEL_MASK Microcode Default Value
  11778. *
  11779. * The microcode will set the SEL_MASK register using this value
  11780. * after it is started below.
  11781. */
  11782. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  11783. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  11784. AdvBuildCarrierFreelist(asc_dvc);
  11785. /*
  11786. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  11787. */
  11788. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  11789. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  11790. return ADV_ERROR;
  11791. }
  11792. asc_dvc->carr_freelist = (ADV_CARR_T *)
  11793. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  11794. /*
  11795. * The first command issued will be placed in the stopper carrier.
  11796. */
  11797. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  11798. /*
  11799. * Set RISC ICQ physical address start value. Initialize the
  11800. * COMMA register to the same value otherwise the RISC will
  11801. * prematurely detect a command is available.
  11802. */
  11803. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  11804. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  11805. le32_to_cpu(asc_dvc->icq_sp->carr_pa));
  11806. /*
  11807. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  11808. */
  11809. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  11810. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  11811. return ADV_ERROR;
  11812. }
  11813. asc_dvc->carr_freelist = (ADV_CARR_T *)
  11814. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  11815. /*
  11816. * The first command completed by the RISC will be placed in
  11817. * the stopper.
  11818. *
  11819. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  11820. * completed the RISC will set the ASC_RQ_STOPPER bit.
  11821. */
  11822. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  11823. /*
  11824. * Set RISC IRQ physical address start value.
  11825. */
  11826. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  11827. asc_dvc->carr_pending_cnt = 0;
  11828. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  11829. (ADV_INTR_ENABLE_HOST_INTR |
  11830. ADV_INTR_ENABLE_GLOBAL_INTR));
  11831. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  11832. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  11833. /* finally, finally, gentlemen, start your engine */
  11834. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  11835. /*
  11836. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  11837. * Resets should be performed. The RISC has to be running
  11838. * to issue a SCSI Bus Reset.
  11839. */
  11840. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  11841. /*
  11842. * If the BIOS Signature is present in memory, restore the
  11843. * per TID microcode operating variables.
  11844. */
  11845. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  11846. 0x55AA) {
  11847. /*
  11848. * Restore per TID negotiated values.
  11849. */
  11850. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  11851. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  11852. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  11853. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  11854. tagqng_able);
  11855. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  11856. AdvWriteByteLram(iop_base,
  11857. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  11858. max_cmd[tid]);
  11859. }
  11860. } else {
  11861. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  11862. warn_code = ASC_WARN_BUSRESET_ERROR;
  11863. }
  11864. }
  11865. }
  11866. return warn_code;
  11867. }
  11868. /*
  11869. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  11870. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  11871. * all of this is done.
  11872. *
  11873. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  11874. *
  11875. * For a non-fatal error return a warning code. If there are no warnings
  11876. * then 0 is returned.
  11877. *
  11878. * Note: Chip is stopped on entry.
  11879. */
  11880. static int __devinit AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
  11881. {
  11882. AdvPortAddr iop_base;
  11883. ushort warn_code;
  11884. ADVEEP_3550_CONFIG eep_config;
  11885. iop_base = asc_dvc->iop_base;
  11886. warn_code = 0;
  11887. /*
  11888. * Read the board's EEPROM configuration.
  11889. *
  11890. * Set default values if a bad checksum is found.
  11891. */
  11892. if (AdvGet3550EEPConfig(iop_base, &eep_config) != eep_config.check_sum) {
  11893. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  11894. /*
  11895. * Set EEPROM default values.
  11896. */
  11897. memcpy(&eep_config, &Default_3550_EEPROM_Config,
  11898. sizeof(ADVEEP_3550_CONFIG));
  11899. /*
  11900. * Assume the 6 byte board serial number that was read from
  11901. * EEPROM is correct even if the EEPROM checksum failed.
  11902. */
  11903. eep_config.serial_number_word3 =
  11904. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  11905. eep_config.serial_number_word2 =
  11906. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  11907. eep_config.serial_number_word1 =
  11908. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  11909. AdvSet3550EEPConfig(iop_base, &eep_config);
  11910. }
  11911. /*
  11912. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  11913. * EEPROM configuration that was read.
  11914. *
  11915. * This is the mapping of EEPROM fields to Adv Library fields.
  11916. */
  11917. asc_dvc->wdtr_able = eep_config.wdtr_able;
  11918. asc_dvc->sdtr_able = eep_config.sdtr_able;
  11919. asc_dvc->ultra_able = eep_config.ultra_able;
  11920. asc_dvc->tagqng_able = eep_config.tagqng_able;
  11921. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  11922. asc_dvc->max_host_qng = eep_config.max_host_qng;
  11923. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  11924. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  11925. asc_dvc->start_motor = eep_config.start_motor;
  11926. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  11927. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  11928. asc_dvc->no_scam = eep_config.scam_tolerant;
  11929. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  11930. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  11931. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  11932. /*
  11933. * Set the host maximum queuing (max. 253, min. 16) and the per device
  11934. * maximum queuing (max. 63, min. 4).
  11935. */
  11936. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  11937. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11938. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  11939. /* If the value is zero, assume it is uninitialized. */
  11940. if (eep_config.max_host_qng == 0) {
  11941. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11942. } else {
  11943. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  11944. }
  11945. }
  11946. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  11947. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  11948. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  11949. /* If the value is zero, assume it is uninitialized. */
  11950. if (eep_config.max_dvc_qng == 0) {
  11951. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  11952. } else {
  11953. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  11954. }
  11955. }
  11956. /*
  11957. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  11958. * set 'max_dvc_qng' to 'max_host_qng'.
  11959. */
  11960. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  11961. eep_config.max_dvc_qng = eep_config.max_host_qng;
  11962. }
  11963. /*
  11964. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  11965. * values based on possibly adjusted EEPROM values.
  11966. */
  11967. asc_dvc->max_host_qng = eep_config.max_host_qng;
  11968. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  11969. /*
  11970. * If the EEPROM 'termination' field is set to automatic (0), then set
  11971. * the ADV_DVC_CFG 'termination' field to automatic also.
  11972. *
  11973. * If the termination is specified with a non-zero 'termination'
  11974. * value check that a legal value is set and set the ADV_DVC_CFG
  11975. * 'termination' field appropriately.
  11976. */
  11977. if (eep_config.termination == 0) {
  11978. asc_dvc->cfg->termination = 0; /* auto termination */
  11979. } else {
  11980. /* Enable manual control with low off / high off. */
  11981. if (eep_config.termination == 1) {
  11982. asc_dvc->cfg->termination = TERM_CTL_SEL;
  11983. /* Enable manual control with low off / high on. */
  11984. } else if (eep_config.termination == 2) {
  11985. asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H;
  11986. /* Enable manual control with low on / high on. */
  11987. } else if (eep_config.termination == 3) {
  11988. asc_dvc->cfg->termination =
  11989. TERM_CTL_SEL | TERM_CTL_H | TERM_CTL_L;
  11990. } else {
  11991. /*
  11992. * The EEPROM 'termination' field contains a bad value. Use
  11993. * automatic termination instead.
  11994. */
  11995. asc_dvc->cfg->termination = 0;
  11996. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  11997. }
  11998. }
  11999. return warn_code;
  12000. }
  12001. /*
  12002. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  12003. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  12004. * all of this is done.
  12005. *
  12006. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  12007. *
  12008. * For a non-fatal error return a warning code. If there are no warnings
  12009. * then 0 is returned.
  12010. *
  12011. * Note: Chip is stopped on entry.
  12012. */
  12013. static int __devinit AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
  12014. {
  12015. AdvPortAddr iop_base;
  12016. ushort warn_code;
  12017. ADVEEP_38C0800_CONFIG eep_config;
  12018. uchar tid, termination;
  12019. ushort sdtr_speed = 0;
  12020. iop_base = asc_dvc->iop_base;
  12021. warn_code = 0;
  12022. /*
  12023. * Read the board's EEPROM configuration.
  12024. *
  12025. * Set default values if a bad checksum is found.
  12026. */
  12027. if (AdvGet38C0800EEPConfig(iop_base, &eep_config) !=
  12028. eep_config.check_sum) {
  12029. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  12030. /*
  12031. * Set EEPROM default values.
  12032. */
  12033. memcpy(&eep_config, &Default_38C0800_EEPROM_Config,
  12034. sizeof(ADVEEP_38C0800_CONFIG));
  12035. /*
  12036. * Assume the 6 byte board serial number that was read from
  12037. * EEPROM is correct even if the EEPROM checksum failed.
  12038. */
  12039. eep_config.serial_number_word3 =
  12040. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  12041. eep_config.serial_number_word2 =
  12042. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  12043. eep_config.serial_number_word1 =
  12044. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  12045. AdvSet38C0800EEPConfig(iop_base, &eep_config);
  12046. }
  12047. /*
  12048. * Set ADV_DVC_VAR and ADV_DVC_CFG variables from the
  12049. * EEPROM configuration that was read.
  12050. *
  12051. * This is the mapping of EEPROM fields to Adv Library fields.
  12052. */
  12053. asc_dvc->wdtr_able = eep_config.wdtr_able;
  12054. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  12055. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  12056. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  12057. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  12058. asc_dvc->tagqng_able = eep_config.tagqng_able;
  12059. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  12060. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12061. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12062. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  12063. asc_dvc->start_motor = eep_config.start_motor;
  12064. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  12065. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  12066. asc_dvc->no_scam = eep_config.scam_tolerant;
  12067. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  12068. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  12069. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  12070. /*
  12071. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  12072. * are set, then set an 'sdtr_able' bit for it.
  12073. */
  12074. asc_dvc->sdtr_able = 0;
  12075. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  12076. if (tid == 0) {
  12077. sdtr_speed = asc_dvc->sdtr_speed1;
  12078. } else if (tid == 4) {
  12079. sdtr_speed = asc_dvc->sdtr_speed2;
  12080. } else if (tid == 8) {
  12081. sdtr_speed = asc_dvc->sdtr_speed3;
  12082. } else if (tid == 12) {
  12083. sdtr_speed = asc_dvc->sdtr_speed4;
  12084. }
  12085. if (sdtr_speed & ADV_MAX_TID) {
  12086. asc_dvc->sdtr_able |= (1 << tid);
  12087. }
  12088. sdtr_speed >>= 4;
  12089. }
  12090. /*
  12091. * Set the host maximum queuing (max. 253, min. 16) and the per device
  12092. * maximum queuing (max. 63, min. 4).
  12093. */
  12094. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  12095. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12096. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  12097. /* If the value is zero, assume it is uninitialized. */
  12098. if (eep_config.max_host_qng == 0) {
  12099. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12100. } else {
  12101. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  12102. }
  12103. }
  12104. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  12105. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12106. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  12107. /* If the value is zero, assume it is uninitialized. */
  12108. if (eep_config.max_dvc_qng == 0) {
  12109. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12110. } else {
  12111. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  12112. }
  12113. }
  12114. /*
  12115. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  12116. * set 'max_dvc_qng' to 'max_host_qng'.
  12117. */
  12118. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  12119. eep_config.max_dvc_qng = eep_config.max_host_qng;
  12120. }
  12121. /*
  12122. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  12123. * values based on possibly adjusted EEPROM values.
  12124. */
  12125. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12126. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12127. /*
  12128. * If the EEPROM 'termination' field is set to automatic (0), then set
  12129. * the ADV_DVC_CFG 'termination' field to automatic also.
  12130. *
  12131. * If the termination is specified with a non-zero 'termination'
  12132. * value check that a legal value is set and set the ADV_DVC_CFG
  12133. * 'termination' field appropriately.
  12134. */
  12135. if (eep_config.termination_se == 0) {
  12136. termination = 0; /* auto termination for SE */
  12137. } else {
  12138. /* Enable manual control with low off / high off. */
  12139. if (eep_config.termination_se == 1) {
  12140. termination = 0;
  12141. /* Enable manual control with low off / high on. */
  12142. } else if (eep_config.termination_se == 2) {
  12143. termination = TERM_SE_HI;
  12144. /* Enable manual control with low on / high on. */
  12145. } else if (eep_config.termination_se == 3) {
  12146. termination = TERM_SE;
  12147. } else {
  12148. /*
  12149. * The EEPROM 'termination_se' field contains a bad value.
  12150. * Use automatic termination instead.
  12151. */
  12152. termination = 0;
  12153. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12154. }
  12155. }
  12156. if (eep_config.termination_lvd == 0) {
  12157. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  12158. } else {
  12159. /* Enable manual control with low off / high off. */
  12160. if (eep_config.termination_lvd == 1) {
  12161. asc_dvc->cfg->termination = termination;
  12162. /* Enable manual control with low off / high on. */
  12163. } else if (eep_config.termination_lvd == 2) {
  12164. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  12165. /* Enable manual control with low on / high on. */
  12166. } else if (eep_config.termination_lvd == 3) {
  12167. asc_dvc->cfg->termination = termination | TERM_LVD;
  12168. } else {
  12169. /*
  12170. * The EEPROM 'termination_lvd' field contains a bad value.
  12171. * Use automatic termination instead.
  12172. */
  12173. asc_dvc->cfg->termination = termination;
  12174. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12175. }
  12176. }
  12177. return warn_code;
  12178. }
  12179. /*
  12180. * Read the board's EEPROM configuration. Set fields in ASC_DVC_VAR and
  12181. * ASC_DVC_CFG based on the EEPROM settings. The chip is stopped while
  12182. * all of this is done.
  12183. *
  12184. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  12185. *
  12186. * For a non-fatal error return a warning code. If there are no warnings
  12187. * then 0 is returned.
  12188. *
  12189. * Note: Chip is stopped on entry.
  12190. */
  12191. static int __devinit AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
  12192. {
  12193. AdvPortAddr iop_base;
  12194. ushort warn_code;
  12195. ADVEEP_38C1600_CONFIG eep_config;
  12196. uchar tid, termination;
  12197. ushort sdtr_speed = 0;
  12198. iop_base = asc_dvc->iop_base;
  12199. warn_code = 0;
  12200. /*
  12201. * Read the board's EEPROM configuration.
  12202. *
  12203. * Set default values if a bad checksum is found.
  12204. */
  12205. if (AdvGet38C1600EEPConfig(iop_base, &eep_config) !=
  12206. eep_config.check_sum) {
  12207. struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
  12208. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  12209. /*
  12210. * Set EEPROM default values.
  12211. */
  12212. memcpy(&eep_config, &Default_38C1600_EEPROM_Config,
  12213. sizeof(ADVEEP_38C1600_CONFIG));
  12214. if (PCI_FUNC(pdev->devfn) != 0) {
  12215. u8 ints;
  12216. /*
  12217. * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60
  12218. * and old Mac system booting problem. The Expansion
  12219. * ROM must be disabled in Function 1 for these systems
  12220. */
  12221. eep_config.cfg_lsw &= ~ADV_EEPROM_BIOS_ENABLE;
  12222. /*
  12223. * Clear the INTAB (bit 11) if the GPIO 0 input
  12224. * indicates the Function 1 interrupt line is wired
  12225. * to INTB.
  12226. *
  12227. * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input:
  12228. * 1 - Function 1 interrupt line wired to INT A.
  12229. * 0 - Function 1 interrupt line wired to INT B.
  12230. *
  12231. * Note: Function 0 is always wired to INTA.
  12232. * Put all 5 GPIO bits in input mode and then read
  12233. * their input values.
  12234. */
  12235. AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, 0);
  12236. ints = AdvReadByteRegister(iop_base, IOPB_GPIO_DATA);
  12237. if ((ints & 0x01) == 0)
  12238. eep_config.cfg_lsw &= ~ADV_EEPROM_INTAB;
  12239. }
  12240. /*
  12241. * Assume the 6 byte board serial number that was read from
  12242. * EEPROM is correct even if the EEPROM checksum failed.
  12243. */
  12244. eep_config.serial_number_word3 =
  12245. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  12246. eep_config.serial_number_word2 =
  12247. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  12248. eep_config.serial_number_word1 =
  12249. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  12250. AdvSet38C1600EEPConfig(iop_base, &eep_config);
  12251. }
  12252. /*
  12253. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  12254. * EEPROM configuration that was read.
  12255. *
  12256. * This is the mapping of EEPROM fields to Adv Library fields.
  12257. */
  12258. asc_dvc->wdtr_able = eep_config.wdtr_able;
  12259. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  12260. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  12261. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  12262. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  12263. asc_dvc->ppr_able = 0;
  12264. asc_dvc->tagqng_able = eep_config.tagqng_able;
  12265. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  12266. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12267. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12268. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ASC_MAX_TID);
  12269. asc_dvc->start_motor = eep_config.start_motor;
  12270. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  12271. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  12272. asc_dvc->no_scam = eep_config.scam_tolerant;
  12273. /*
  12274. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  12275. * are set, then set an 'sdtr_able' bit for it.
  12276. */
  12277. asc_dvc->sdtr_able = 0;
  12278. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  12279. if (tid == 0) {
  12280. sdtr_speed = asc_dvc->sdtr_speed1;
  12281. } else if (tid == 4) {
  12282. sdtr_speed = asc_dvc->sdtr_speed2;
  12283. } else if (tid == 8) {
  12284. sdtr_speed = asc_dvc->sdtr_speed3;
  12285. } else if (tid == 12) {
  12286. sdtr_speed = asc_dvc->sdtr_speed4;
  12287. }
  12288. if (sdtr_speed & ASC_MAX_TID) {
  12289. asc_dvc->sdtr_able |= (1 << tid);
  12290. }
  12291. sdtr_speed >>= 4;
  12292. }
  12293. /*
  12294. * Set the host maximum queuing (max. 253, min. 16) and the per device
  12295. * maximum queuing (max. 63, min. 4).
  12296. */
  12297. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  12298. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12299. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  12300. /* If the value is zero, assume it is uninitialized. */
  12301. if (eep_config.max_host_qng == 0) {
  12302. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12303. } else {
  12304. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  12305. }
  12306. }
  12307. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  12308. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12309. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  12310. /* If the value is zero, assume it is uninitialized. */
  12311. if (eep_config.max_dvc_qng == 0) {
  12312. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12313. } else {
  12314. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  12315. }
  12316. }
  12317. /*
  12318. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  12319. * set 'max_dvc_qng' to 'max_host_qng'.
  12320. */
  12321. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  12322. eep_config.max_dvc_qng = eep_config.max_host_qng;
  12323. }
  12324. /*
  12325. * Set ASC_DVC_VAR 'max_host_qng' and ASC_DVC_VAR 'max_dvc_qng'
  12326. * values based on possibly adjusted EEPROM values.
  12327. */
  12328. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12329. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12330. /*
  12331. * If the EEPROM 'termination' field is set to automatic (0), then set
  12332. * the ASC_DVC_CFG 'termination' field to automatic also.
  12333. *
  12334. * If the termination is specified with a non-zero 'termination'
  12335. * value check that a legal value is set and set the ASC_DVC_CFG
  12336. * 'termination' field appropriately.
  12337. */
  12338. if (eep_config.termination_se == 0) {
  12339. termination = 0; /* auto termination for SE */
  12340. } else {
  12341. /* Enable manual control with low off / high off. */
  12342. if (eep_config.termination_se == 1) {
  12343. termination = 0;
  12344. /* Enable manual control with low off / high on. */
  12345. } else if (eep_config.termination_se == 2) {
  12346. termination = TERM_SE_HI;
  12347. /* Enable manual control with low on / high on. */
  12348. } else if (eep_config.termination_se == 3) {
  12349. termination = TERM_SE;
  12350. } else {
  12351. /*
  12352. * The EEPROM 'termination_se' field contains a bad value.
  12353. * Use automatic termination instead.
  12354. */
  12355. termination = 0;
  12356. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12357. }
  12358. }
  12359. if (eep_config.termination_lvd == 0) {
  12360. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  12361. } else {
  12362. /* Enable manual control with low off / high off. */
  12363. if (eep_config.termination_lvd == 1) {
  12364. asc_dvc->cfg->termination = termination;
  12365. /* Enable manual control with low off / high on. */
  12366. } else if (eep_config.termination_lvd == 2) {
  12367. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  12368. /* Enable manual control with low on / high on. */
  12369. } else if (eep_config.termination_lvd == 3) {
  12370. asc_dvc->cfg->termination = termination | TERM_LVD;
  12371. } else {
  12372. /*
  12373. * The EEPROM 'termination_lvd' field contains a bad value.
  12374. * Use automatic termination instead.
  12375. */
  12376. asc_dvc->cfg->termination = termination;
  12377. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12378. }
  12379. }
  12380. return warn_code;
  12381. }
  12382. /*
  12383. * Read EEPROM configuration into the specified buffer.
  12384. *
  12385. * Return a checksum based on the EEPROM configuration read.
  12386. */
  12387. static ushort __devinit
  12388. AdvGet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  12389. {
  12390. ushort wval, chksum;
  12391. ushort *wbuf;
  12392. int eep_addr;
  12393. ushort *charfields;
  12394. charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
  12395. wbuf = (ushort *)cfg_buf;
  12396. chksum = 0;
  12397. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  12398. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  12399. wval = AdvReadEEPWord(iop_base, eep_addr);
  12400. chksum += wval; /* Checksum is calculated from word values. */
  12401. if (*charfields++) {
  12402. *wbuf = le16_to_cpu(wval);
  12403. } else {
  12404. *wbuf = wval;
  12405. }
  12406. }
  12407. /* Read checksum word. */
  12408. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  12409. wbuf++;
  12410. charfields++;
  12411. /* Read rest of EEPROM not covered by the checksum. */
  12412. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  12413. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  12414. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  12415. if (*charfields++) {
  12416. *wbuf = le16_to_cpu(*wbuf);
  12417. }
  12418. }
  12419. return chksum;
  12420. }
  12421. /*
  12422. * Read EEPROM configuration into the specified buffer.
  12423. *
  12424. * Return a checksum based on the EEPROM configuration read.
  12425. */
  12426. static ushort __devinit
  12427. AdvGet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
  12428. {
  12429. ushort wval, chksum;
  12430. ushort *wbuf;
  12431. int eep_addr;
  12432. ushort *charfields;
  12433. charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
  12434. wbuf = (ushort *)cfg_buf;
  12435. chksum = 0;
  12436. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  12437. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  12438. wval = AdvReadEEPWord(iop_base, eep_addr);
  12439. chksum += wval; /* Checksum is calculated from word values. */
  12440. if (*charfields++) {
  12441. *wbuf = le16_to_cpu(wval);
  12442. } else {
  12443. *wbuf = wval;
  12444. }
  12445. }
  12446. /* Read checksum word. */
  12447. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  12448. wbuf++;
  12449. charfields++;
  12450. /* Read rest of EEPROM not covered by the checksum. */
  12451. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  12452. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  12453. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  12454. if (*charfields++) {
  12455. *wbuf = le16_to_cpu(*wbuf);
  12456. }
  12457. }
  12458. return chksum;
  12459. }
  12460. /*
  12461. * Read EEPROM configuration into the specified buffer.
  12462. *
  12463. * Return a checksum based on the EEPROM configuration read.
  12464. */
  12465. static ushort __devinit
  12466. AdvGet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
  12467. {
  12468. ushort wval, chksum;
  12469. ushort *wbuf;
  12470. int eep_addr;
  12471. ushort *charfields;
  12472. charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
  12473. wbuf = (ushort *)cfg_buf;
  12474. chksum = 0;
  12475. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  12476. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  12477. wval = AdvReadEEPWord(iop_base, eep_addr);
  12478. chksum += wval; /* Checksum is calculated from word values. */
  12479. if (*charfields++) {
  12480. *wbuf = le16_to_cpu(wval);
  12481. } else {
  12482. *wbuf = wval;
  12483. }
  12484. }
  12485. /* Read checksum word. */
  12486. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  12487. wbuf++;
  12488. charfields++;
  12489. /* Read rest of EEPROM not covered by the checksum. */
  12490. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  12491. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  12492. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  12493. if (*charfields++) {
  12494. *wbuf = le16_to_cpu(*wbuf);
  12495. }
  12496. }
  12497. return chksum;
  12498. }
  12499. /*
  12500. * Read the EEPROM from specified location
  12501. */
  12502. static ushort __devinit AdvReadEEPWord(AdvPortAddr iop_base, int eep_word_addr)
  12503. {
  12504. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  12505. ASC_EEP_CMD_READ | eep_word_addr);
  12506. AdvWaitEEPCmd(iop_base);
  12507. return AdvReadWordRegister(iop_base, IOPW_EE_DATA);
  12508. }
  12509. /*
  12510. * Wait for EEPROM command to complete
  12511. */
  12512. static void __devinit AdvWaitEEPCmd(AdvPortAddr iop_base)
  12513. {
  12514. int eep_delay_ms;
  12515. for (eep_delay_ms = 0; eep_delay_ms < ADV_EEP_DELAY_MS; eep_delay_ms++) {
  12516. if (AdvReadWordRegister(iop_base, IOPW_EE_CMD) &
  12517. ASC_EEP_CMD_DONE) {
  12518. break;
  12519. }
  12520. DvcSleepMilliSecond(1);
  12521. }
  12522. if ((AdvReadWordRegister(iop_base, IOPW_EE_CMD) & ASC_EEP_CMD_DONE) ==
  12523. 0) {
  12524. ASC_ASSERT(0);
  12525. }
  12526. return;
  12527. }
  12528. /*
  12529. * Write the EEPROM from 'cfg_buf'.
  12530. */
  12531. void __devinit
  12532. AdvSet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  12533. {
  12534. ushort *wbuf;
  12535. ushort addr, chksum;
  12536. ushort *charfields;
  12537. wbuf = (ushort *)cfg_buf;
  12538. charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
  12539. chksum = 0;
  12540. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  12541. AdvWaitEEPCmd(iop_base);
  12542. /*
  12543. * Write EEPROM from word 0 to word 20.
  12544. */
  12545. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  12546. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  12547. ushort word;
  12548. if (*charfields++) {
  12549. word = cpu_to_le16(*wbuf);
  12550. } else {
  12551. word = *wbuf;
  12552. }
  12553. chksum += *wbuf; /* Checksum is calculated from word values. */
  12554. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  12555. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  12556. ASC_EEP_CMD_WRITE | addr);
  12557. AdvWaitEEPCmd(iop_base);
  12558. DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
  12559. }
  12560. /*
  12561. * Write EEPROM checksum at word 21.
  12562. */
  12563. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  12564. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  12565. AdvWaitEEPCmd(iop_base);
  12566. wbuf++;
  12567. charfields++;
  12568. /*
  12569. * Write EEPROM OEM name at words 22 to 29.
  12570. */
  12571. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  12572. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  12573. ushort word;
  12574. if (*charfields++) {
  12575. word = cpu_to_le16(*wbuf);
  12576. } else {
  12577. word = *wbuf;
  12578. }
  12579. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  12580. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  12581. ASC_EEP_CMD_WRITE | addr);
  12582. AdvWaitEEPCmd(iop_base);
  12583. }
  12584. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  12585. AdvWaitEEPCmd(iop_base);
  12586. return;
  12587. }
  12588. /*
  12589. * Write the EEPROM from 'cfg_buf'.
  12590. */
  12591. void __devinit
  12592. AdvSet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
  12593. {
  12594. ushort *wbuf;
  12595. ushort *charfields;
  12596. ushort addr, chksum;
  12597. wbuf = (ushort *)cfg_buf;
  12598. charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
  12599. chksum = 0;
  12600. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  12601. AdvWaitEEPCmd(iop_base);
  12602. /*
  12603. * Write EEPROM from word 0 to word 20.
  12604. */
  12605. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  12606. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  12607. ushort word;
  12608. if (*charfields++) {
  12609. word = cpu_to_le16(*wbuf);
  12610. } else {
  12611. word = *wbuf;
  12612. }
  12613. chksum += *wbuf; /* Checksum is calculated from word values. */
  12614. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  12615. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  12616. ASC_EEP_CMD_WRITE | addr);
  12617. AdvWaitEEPCmd(iop_base);
  12618. DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
  12619. }
  12620. /*
  12621. * Write EEPROM checksum at word 21.
  12622. */
  12623. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  12624. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  12625. AdvWaitEEPCmd(iop_base);
  12626. wbuf++;
  12627. charfields++;
  12628. /*
  12629. * Write EEPROM OEM name at words 22 to 29.
  12630. */
  12631. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  12632. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  12633. ushort word;
  12634. if (*charfields++) {
  12635. word = cpu_to_le16(*wbuf);
  12636. } else {
  12637. word = *wbuf;
  12638. }
  12639. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  12640. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  12641. ASC_EEP_CMD_WRITE | addr);
  12642. AdvWaitEEPCmd(iop_base);
  12643. }
  12644. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  12645. AdvWaitEEPCmd(iop_base);
  12646. return;
  12647. }
  12648. /*
  12649. * Write the EEPROM from 'cfg_buf'.
  12650. */
  12651. void __devinit
  12652. AdvSet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
  12653. {
  12654. ushort *wbuf;
  12655. ushort *charfields;
  12656. ushort addr, chksum;
  12657. wbuf = (ushort *)cfg_buf;
  12658. charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
  12659. chksum = 0;
  12660. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  12661. AdvWaitEEPCmd(iop_base);
  12662. /*
  12663. * Write EEPROM from word 0 to word 20.
  12664. */
  12665. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  12666. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  12667. ushort word;
  12668. if (*charfields++) {
  12669. word = cpu_to_le16(*wbuf);
  12670. } else {
  12671. word = *wbuf;
  12672. }
  12673. chksum += *wbuf; /* Checksum is calculated from word values. */
  12674. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  12675. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  12676. ASC_EEP_CMD_WRITE | addr);
  12677. AdvWaitEEPCmd(iop_base);
  12678. DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
  12679. }
  12680. /*
  12681. * Write EEPROM checksum at word 21.
  12682. */
  12683. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  12684. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  12685. AdvWaitEEPCmd(iop_base);
  12686. wbuf++;
  12687. charfields++;
  12688. /*
  12689. * Write EEPROM OEM name at words 22 to 29.
  12690. */
  12691. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  12692. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  12693. ushort word;
  12694. if (*charfields++) {
  12695. word = cpu_to_le16(*wbuf);
  12696. } else {
  12697. word = *wbuf;
  12698. }
  12699. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  12700. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  12701. ASC_EEP_CMD_WRITE | addr);
  12702. AdvWaitEEPCmd(iop_base);
  12703. }
  12704. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  12705. AdvWaitEEPCmd(iop_base);
  12706. return;
  12707. }
  12708. /* a_advlib.c */
  12709. /*
  12710. * AdvExeScsiQueue() - Send a request to the RISC microcode program.
  12711. *
  12712. * Allocate a carrier structure, point the carrier to the ADV_SCSI_REQ_Q,
  12713. * add the carrier to the ICQ (Initiator Command Queue), and tickle the
  12714. * RISC to notify it a new command is ready to be executed.
  12715. *
  12716. * If 'done_status' is not set to QD_DO_RETRY, then 'error_retry' will be
  12717. * set to SCSI_MAX_RETRY.
  12718. *
  12719. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the microcode
  12720. * for DMA addresses or math operations are byte swapped to little-endian
  12721. * order.
  12722. *
  12723. * Return:
  12724. * ADV_SUCCESS(1) - The request was successfully queued.
  12725. * ADV_BUSY(0) - Resource unavailable; Retry again after pending
  12726. * request completes.
  12727. * ADV_ERROR(-1) - Invalid ADV_SCSI_REQ_Q request structure
  12728. * host IC error.
  12729. */
  12730. static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
  12731. {
  12732. ulong last_int_level;
  12733. AdvPortAddr iop_base;
  12734. ADV_DCNT req_size;
  12735. ADV_PADDR req_paddr;
  12736. ADV_CARR_T *new_carrp;
  12737. ASC_ASSERT(scsiq != NULL); /* 'scsiq' should never be NULL. */
  12738. /*
  12739. * The ADV_SCSI_REQ_Q 'target_id' field should never exceed ADV_MAX_TID.
  12740. */
  12741. if (scsiq->target_id > ADV_MAX_TID) {
  12742. scsiq->host_status = QHSTA_M_INVALID_DEVICE;
  12743. scsiq->done_status = QD_WITH_ERROR;
  12744. return ADV_ERROR;
  12745. }
  12746. iop_base = asc_dvc->iop_base;
  12747. last_int_level = DvcEnterCritical();
  12748. /*
  12749. * Allocate a carrier ensuring at least one carrier always
  12750. * remains on the freelist and initialize fields.
  12751. */
  12752. if ((new_carrp = asc_dvc->carr_freelist) == NULL) {
  12753. DvcLeaveCritical(last_int_level);
  12754. return ADV_BUSY;
  12755. }
  12756. asc_dvc->carr_freelist = (ADV_CARR_T *)
  12757. ADV_U32_TO_VADDR(le32_to_cpu(new_carrp->next_vpa));
  12758. asc_dvc->carr_pending_cnt++;
  12759. /*
  12760. * Set the carrier to be a stopper by setting 'next_vpa'
  12761. * to the stopper value. The current stopper will be changed
  12762. * below to point to the new stopper.
  12763. */
  12764. new_carrp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  12765. /*
  12766. * Clear the ADV_SCSI_REQ_Q done flag.
  12767. */
  12768. scsiq->a_flag &= ~ADV_SCSIQ_DONE;
  12769. req_size = sizeof(ADV_SCSI_REQ_Q);
  12770. req_paddr = DvcGetPhyAddr(asc_dvc, scsiq, (uchar *)scsiq,
  12771. (ADV_SDCNT *)&req_size, ADV_IS_SCSIQ_FLAG);
  12772. ASC_ASSERT(ADV_32BALIGN(req_paddr) == req_paddr);
  12773. ASC_ASSERT(req_size >= sizeof(ADV_SCSI_REQ_Q));
  12774. /* Wait for assertion before making little-endian */
  12775. req_paddr = cpu_to_le32(req_paddr);
  12776. /* Save virtual and physical address of ADV_SCSI_REQ_Q and carrier. */
  12777. scsiq->scsiq_ptr = cpu_to_le32(ADV_VADDR_TO_U32(scsiq));
  12778. scsiq->scsiq_rptr = req_paddr;
  12779. scsiq->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->icq_sp));
  12780. /*
  12781. * Every ADV_CARR_T.carr_pa is byte swapped to little-endian
  12782. * order during initialization.
  12783. */
  12784. scsiq->carr_pa = asc_dvc->icq_sp->carr_pa;
  12785. /*
  12786. * Use the current stopper to send the ADV_SCSI_REQ_Q command to
  12787. * the microcode. The newly allocated stopper will become the new
  12788. * stopper.
  12789. */
  12790. asc_dvc->icq_sp->areq_vpa = req_paddr;
  12791. /*
  12792. * Set the 'next_vpa' pointer for the old stopper to be the
  12793. * physical address of the new stopper. The RISC can only
  12794. * follow physical addresses.
  12795. */
  12796. asc_dvc->icq_sp->next_vpa = new_carrp->carr_pa;
  12797. /*
  12798. * Set the host adapter stopper pointer to point to the new carrier.
  12799. */
  12800. asc_dvc->icq_sp = new_carrp;
  12801. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  12802. asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  12803. /*
  12804. * Tickle the RISC to tell it to read its Command Queue Head pointer.
  12805. */
  12806. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_A);
  12807. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  12808. /*
  12809. * Clear the tickle value. In the ASC-3550 the RISC flag
  12810. * command 'clr_tickle_a' does not work unless the host
  12811. * value is cleared.
  12812. */
  12813. AdvWriteByteRegister(iop_base, IOPB_TICKLE,
  12814. ADV_TICKLE_NOP);
  12815. }
  12816. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  12817. /*
  12818. * Notify the RISC a carrier is ready by writing the physical
  12819. * address of the new carrier stopper to the COMMA register.
  12820. */
  12821. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  12822. le32_to_cpu(new_carrp->carr_pa));
  12823. }
  12824. DvcLeaveCritical(last_int_level);
  12825. return ADV_SUCCESS;
  12826. }
  12827. /*
  12828. * Reset SCSI Bus and purge all outstanding requests.
  12829. *
  12830. * Return Value:
  12831. * ADV_TRUE(1) - All requests are purged and SCSI Bus is reset.
  12832. * ADV_FALSE(0) - Microcode command failed.
  12833. * ADV_ERROR(-1) - Microcode command timed-out. Microcode or IC
  12834. * may be hung which requires driver recovery.
  12835. */
  12836. static int AdvResetSB(ADV_DVC_VAR *asc_dvc)
  12837. {
  12838. int status;
  12839. /*
  12840. * Send the SCSI Bus Reset idle start idle command which asserts
  12841. * the SCSI Bus Reset signal.
  12842. */
  12843. status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_START, 0L);
  12844. if (status != ADV_TRUE) {
  12845. return status;
  12846. }
  12847. /*
  12848. * Delay for the specified SCSI Bus Reset hold time.
  12849. *
  12850. * The hold time delay is done on the host because the RISC has no
  12851. * microsecond accurate timer.
  12852. */
  12853. DvcDelayMicroSecond(asc_dvc, (ushort)ASC_SCSI_RESET_HOLD_TIME_US);
  12854. /*
  12855. * Send the SCSI Bus Reset end idle command which de-asserts
  12856. * the SCSI Bus Reset signal and purges any pending requests.
  12857. */
  12858. status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_END, 0L);
  12859. if (status != ADV_TRUE) {
  12860. return status;
  12861. }
  12862. DvcSleepMilliSecond((ADV_DCNT)asc_dvc->scsi_reset_wait * 1000);
  12863. return status;
  12864. }
  12865. /*
  12866. * Reset chip and SCSI Bus.
  12867. *
  12868. * Return Value:
  12869. * ADV_TRUE(1) - Chip re-initialization and SCSI Bus Reset successful.
  12870. * ADV_FALSE(0) - Chip re-initialization and SCSI Bus Reset failure.
  12871. */
  12872. static int AdvResetChipAndSB(ADV_DVC_VAR *asc_dvc)
  12873. {
  12874. int status;
  12875. ushort wdtr_able, sdtr_able, tagqng_able;
  12876. ushort ppr_able = 0;
  12877. uchar tid, max_cmd[ADV_MAX_TID + 1];
  12878. AdvPortAddr iop_base;
  12879. ushort bios_sig;
  12880. iop_base = asc_dvc->iop_base;
  12881. /*
  12882. * Save current per TID negotiated values.
  12883. */
  12884. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  12885. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  12886. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  12887. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  12888. }
  12889. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  12890. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  12891. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  12892. max_cmd[tid]);
  12893. }
  12894. /*
  12895. * Force the AdvInitAsc3550/38C0800Driver() function to
  12896. * perform a SCSI Bus Reset by clearing the BIOS signature word.
  12897. * The initialization functions assumes a SCSI Bus Reset is not
  12898. * needed if the BIOS signature word is present.
  12899. */
  12900. AdvReadWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  12901. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, 0);
  12902. /*
  12903. * Stop chip and reset it.
  12904. */
  12905. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_STOP);
  12906. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, ADV_CTRL_REG_CMD_RESET);
  12907. DvcSleepMilliSecond(100);
  12908. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  12909. ADV_CTRL_REG_CMD_WR_IO_REG);
  12910. /*
  12911. * Reset Adv Library error code, if any, and try
  12912. * re-initializing the chip.
  12913. */
  12914. asc_dvc->err_code = 0;
  12915. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  12916. status = AdvInitAsc38C1600Driver(asc_dvc);
  12917. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  12918. status = AdvInitAsc38C0800Driver(asc_dvc);
  12919. } else {
  12920. status = AdvInitAsc3550Driver(asc_dvc);
  12921. }
  12922. /* Translate initialization return value to status value. */
  12923. if (status == 0) {
  12924. status = ADV_TRUE;
  12925. } else {
  12926. status = ADV_FALSE;
  12927. }
  12928. /*
  12929. * Restore the BIOS signature word.
  12930. */
  12931. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  12932. /*
  12933. * Restore per TID negotiated values.
  12934. */
  12935. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  12936. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  12937. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  12938. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  12939. }
  12940. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  12941. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  12942. AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  12943. max_cmd[tid]);
  12944. }
  12945. return status;
  12946. }
  12947. /*
  12948. * Adv Library Interrupt Service Routine
  12949. *
  12950. * This function is called by a driver's interrupt service routine.
  12951. * The function disables and re-enables interrupts.
  12952. *
  12953. * When a microcode idle command is completed, the ADV_DVC_VAR
  12954. * 'idle_cmd_done' field is set to ADV_TRUE.
  12955. *
  12956. * Note: AdvISR() can be called when interrupts are disabled or even
  12957. * when there is no hardware interrupt condition present. It will
  12958. * always check for completed idle commands and microcode requests.
  12959. * This is an important feature that shouldn't be changed because it
  12960. * allows commands to be completed from polling mode loops.
  12961. *
  12962. * Return:
  12963. * ADV_TRUE(1) - interrupt was pending
  12964. * ADV_FALSE(0) - no interrupt was pending
  12965. */
  12966. static int AdvISR(ADV_DVC_VAR *asc_dvc)
  12967. {
  12968. AdvPortAddr iop_base;
  12969. uchar int_stat;
  12970. ushort target_bit;
  12971. ADV_CARR_T *free_carrp;
  12972. ADV_VADDR irq_next_vpa;
  12973. int flags;
  12974. ADV_SCSI_REQ_Q *scsiq;
  12975. flags = DvcEnterCritical();
  12976. iop_base = asc_dvc->iop_base;
  12977. /* Reading the register clears the interrupt. */
  12978. int_stat = AdvReadByteRegister(iop_base, IOPB_INTR_STATUS_REG);
  12979. if ((int_stat & (ADV_INTR_STATUS_INTRA | ADV_INTR_STATUS_INTRB |
  12980. ADV_INTR_STATUS_INTRC)) == 0) {
  12981. DvcLeaveCritical(flags);
  12982. return ADV_FALSE;
  12983. }
  12984. /*
  12985. * Notify the driver of an asynchronous microcode condition by
  12986. * calling the adv_async_callback function. The function
  12987. * is passed the microcode ASC_MC_INTRB_CODE byte value.
  12988. */
  12989. if (int_stat & ADV_INTR_STATUS_INTRB) {
  12990. uchar intrb_code;
  12991. AdvReadByteLram(iop_base, ASC_MC_INTRB_CODE, intrb_code);
  12992. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  12993. asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  12994. if (intrb_code == ADV_ASYNC_CARRIER_READY_FAILURE &&
  12995. asc_dvc->carr_pending_cnt != 0) {
  12996. AdvWriteByteRegister(iop_base, IOPB_TICKLE,
  12997. ADV_TICKLE_A);
  12998. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  12999. AdvWriteByteRegister(iop_base,
  13000. IOPB_TICKLE,
  13001. ADV_TICKLE_NOP);
  13002. }
  13003. }
  13004. }
  13005. adv_async_callback(asc_dvc, intrb_code);
  13006. }
  13007. /*
  13008. * Check if the IRQ stopper carrier contains a completed request.
  13009. */
  13010. while (((irq_next_vpa =
  13011. le32_to_cpu(asc_dvc->irq_sp->next_vpa)) & ASC_RQ_DONE) != 0) {
  13012. /*
  13013. * Get a pointer to the newly completed ADV_SCSI_REQ_Q structure.
  13014. * The RISC will have set 'areq_vpa' to a virtual address.
  13015. *
  13016. * The firmware will have copied the ASC_SCSI_REQ_Q.scsiq_ptr
  13017. * field to the carrier ADV_CARR_T.areq_vpa field. The conversion
  13018. * below complements the conversion of ASC_SCSI_REQ_Q.scsiq_ptr'
  13019. * in AdvExeScsiQueue().
  13020. */
  13021. scsiq = (ADV_SCSI_REQ_Q *)
  13022. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->areq_vpa));
  13023. /*
  13024. * Request finished with good status and the queue was not
  13025. * DMAed to host memory by the firmware. Set all status fields
  13026. * to indicate good status.
  13027. */
  13028. if ((irq_next_vpa & ASC_RQ_GOOD) != 0) {
  13029. scsiq->done_status = QD_NO_ERROR;
  13030. scsiq->host_status = scsiq->scsi_status = 0;
  13031. scsiq->data_cnt = 0L;
  13032. }
  13033. /*
  13034. * Advance the stopper pointer to the next carrier
  13035. * ignoring the lower four bits. Free the previous
  13036. * stopper carrier.
  13037. */
  13038. free_carrp = asc_dvc->irq_sp;
  13039. asc_dvc->irq_sp = (ADV_CARR_T *)
  13040. ADV_U32_TO_VADDR(ASC_GET_CARRP(irq_next_vpa));
  13041. free_carrp->next_vpa =
  13042. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  13043. asc_dvc->carr_freelist = free_carrp;
  13044. asc_dvc->carr_pending_cnt--;
  13045. ASC_ASSERT(scsiq != NULL);
  13046. target_bit = ADV_TID_TO_TIDMASK(scsiq->target_id);
  13047. /*
  13048. * Clear request microcode control flag.
  13049. */
  13050. scsiq->cntl = 0;
  13051. /*
  13052. * Notify the driver of the completed request by passing
  13053. * the ADV_SCSI_REQ_Q pointer to its callback function.
  13054. */
  13055. scsiq->a_flag |= ADV_SCSIQ_DONE;
  13056. adv_isr_callback(asc_dvc, scsiq);
  13057. /*
  13058. * Note: After the driver callback function is called, 'scsiq'
  13059. * can no longer be referenced.
  13060. *
  13061. * Fall through and continue processing other completed
  13062. * requests...
  13063. */
  13064. /*
  13065. * Disable interrupts again in case the driver inadvertently
  13066. * enabled interrupts in its callback function.
  13067. *
  13068. * The DvcEnterCritical() return value is ignored, because
  13069. * the 'flags' saved when AdvISR() was first entered will be
  13070. * used to restore the interrupt flag on exit.
  13071. */
  13072. (void)DvcEnterCritical();
  13073. }
  13074. DvcLeaveCritical(flags);
  13075. return ADV_TRUE;
  13076. }
  13077. /*
  13078. * Send an idle command to the chip and wait for completion.
  13079. *
  13080. * Command completion is polled for once per microsecond.
  13081. *
  13082. * The function can be called from anywhere including an interrupt handler.
  13083. * But the function is not re-entrant, so it uses the DvcEnter/LeaveCritical()
  13084. * functions to prevent reentrancy.
  13085. *
  13086. * Return Values:
  13087. * ADV_TRUE - command completed successfully
  13088. * ADV_FALSE - command failed
  13089. * ADV_ERROR - command timed out
  13090. */
  13091. static int
  13092. AdvSendIdleCmd(ADV_DVC_VAR *asc_dvc,
  13093. ushort idle_cmd, ADV_DCNT idle_cmd_parameter)
  13094. {
  13095. ulong last_int_level;
  13096. int result;
  13097. ADV_DCNT i, j;
  13098. AdvPortAddr iop_base;
  13099. last_int_level = DvcEnterCritical();
  13100. iop_base = asc_dvc->iop_base;
  13101. /*
  13102. * Clear the idle command status which is set by the microcode
  13103. * to a non-zero value to indicate when the command is completed.
  13104. * The non-zero result is one of the IDLE_CMD_STATUS_* values
  13105. * defined in a_advlib.h.
  13106. */
  13107. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS, (ushort)0);
  13108. /*
  13109. * Write the idle command value after the idle command parameter
  13110. * has been written to avoid a race condition. If the order is not
  13111. * followed, the microcode may process the idle command before the
  13112. * parameters have been written to LRAM.
  13113. */
  13114. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IDLE_CMD_PARAMETER,
  13115. cpu_to_le32(idle_cmd_parameter));
  13116. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD, idle_cmd);
  13117. /*
  13118. * Tickle the RISC to tell it to process the idle command.
  13119. */
  13120. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_B);
  13121. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  13122. /*
  13123. * Clear the tickle value. In the ASC-3550 the RISC flag
  13124. * command 'clr_tickle_b' does not work unless the host
  13125. * value is cleared.
  13126. */
  13127. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
  13128. }
  13129. /* Wait for up to 100 millisecond for the idle command to timeout. */
  13130. for (i = 0; i < SCSI_WAIT_100_MSEC; i++) {
  13131. /* Poll once each microsecond for command completion. */
  13132. for (j = 0; j < SCSI_US_PER_MSEC; j++) {
  13133. AdvReadWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS,
  13134. result);
  13135. if (result != 0) {
  13136. DvcLeaveCritical(last_int_level);
  13137. return result;
  13138. }
  13139. DvcDelayMicroSecond(asc_dvc, (ushort)1);
  13140. }
  13141. }
  13142. ASC_ASSERT(0); /* The idle command should never timeout. */
  13143. DvcLeaveCritical(last_int_level);
  13144. return ADV_ERROR;
  13145. }
  13146. static int __devinit
  13147. advansys_wide_init_chip(asc_board_t *boardp, ADV_DVC_VAR *adv_dvc_varp)
  13148. {
  13149. int req_cnt = 0;
  13150. adv_req_t *reqp = NULL;
  13151. int sg_cnt = 0;
  13152. adv_sgblk_t *sgp;
  13153. int warn_code, err_code;
  13154. /*
  13155. * Allocate buffer carrier structures. The total size
  13156. * is about 4 KB, so allocate all at once.
  13157. */
  13158. boardp->carrp = kmalloc(ADV_CARRIER_BUFSIZE, GFP_KERNEL);
  13159. ASC_DBG1(1, "advansys_wide_init_chip: carrp 0x%p\n", boardp->carrp);
  13160. if (!boardp->carrp)
  13161. goto kmalloc_failed;
  13162. /*
  13163. * Allocate up to 'max_host_qng' request structures for the Wide
  13164. * board. The total size is about 16 KB, so allocate all at once.
  13165. * If the allocation fails decrement and try again.
  13166. */
  13167. for (req_cnt = adv_dvc_varp->max_host_qng; req_cnt > 0; req_cnt--) {
  13168. reqp = kmalloc(sizeof(adv_req_t) * req_cnt, GFP_KERNEL);
  13169. ASC_DBG3(1, "advansys_wide_init_chip: reqp 0x%p, req_cnt %d, "
  13170. "bytes %lu\n", reqp, req_cnt,
  13171. (ulong)sizeof(adv_req_t) * req_cnt);
  13172. if (reqp)
  13173. break;
  13174. }
  13175. if (!reqp)
  13176. goto kmalloc_failed;
  13177. boardp->orig_reqp = reqp;
  13178. /*
  13179. * Allocate up to ADV_TOT_SG_BLOCK request structures for
  13180. * the Wide board. Each structure is about 136 bytes.
  13181. */
  13182. boardp->adv_sgblkp = NULL;
  13183. for (sg_cnt = 0; sg_cnt < ADV_TOT_SG_BLOCK; sg_cnt++) {
  13184. sgp = kmalloc(sizeof(adv_sgblk_t), GFP_KERNEL);
  13185. if (!sgp)
  13186. break;
  13187. sgp->next_sgblkp = boardp->adv_sgblkp;
  13188. boardp->adv_sgblkp = sgp;
  13189. }
  13190. ASC_DBG3(1, "advansys_wide_init_chip: sg_cnt %d * %u = %u bytes\n",
  13191. sg_cnt, sizeof(adv_sgblk_t),
  13192. (unsigned)(sizeof(adv_sgblk_t) * sg_cnt));
  13193. if (!boardp->adv_sgblkp)
  13194. goto kmalloc_failed;
  13195. adv_dvc_varp->carrier_buf = boardp->carrp;
  13196. /*
  13197. * Point 'adv_reqp' to the request structures and
  13198. * link them together.
  13199. */
  13200. req_cnt--;
  13201. reqp[req_cnt].next_reqp = NULL;
  13202. for (; req_cnt > 0; req_cnt--) {
  13203. reqp[req_cnt - 1].next_reqp = &reqp[req_cnt];
  13204. }
  13205. boardp->adv_reqp = &reqp[0];
  13206. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  13207. ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc3550Driver()\n");
  13208. warn_code = AdvInitAsc3550Driver(adv_dvc_varp);
  13209. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  13210. ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc38C0800Driver()"
  13211. "\n");
  13212. warn_code = AdvInitAsc38C0800Driver(adv_dvc_varp);
  13213. } else {
  13214. ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc38C1600Driver()"
  13215. "\n");
  13216. warn_code = AdvInitAsc38C1600Driver(adv_dvc_varp);
  13217. }
  13218. err_code = adv_dvc_varp->err_code;
  13219. if (warn_code || err_code) {
  13220. ASC_PRINT3("advansys_wide_init_chip: board %d error: warn 0x%x,"
  13221. " error 0x%x\n", boardp->id, warn_code, err_code);
  13222. }
  13223. goto exit;
  13224. kmalloc_failed:
  13225. ASC_PRINT1("advansys_wide_init_chip: board %d error: kmalloc() "
  13226. "failed\n", boardp->id);
  13227. err_code = ADV_ERROR;
  13228. exit:
  13229. return err_code;
  13230. }
  13231. static void advansys_wide_free_mem(asc_board_t *boardp)
  13232. {
  13233. kfree(boardp->carrp);
  13234. boardp->carrp = NULL;
  13235. kfree(boardp->orig_reqp);
  13236. boardp->orig_reqp = boardp->adv_reqp = NULL;
  13237. while (boardp->adv_sgblkp) {
  13238. adv_sgblk_t *sgp = boardp->adv_sgblkp;
  13239. boardp->adv_sgblkp = sgp->next_sgblkp;
  13240. kfree(sgp);
  13241. }
  13242. }
  13243. static struct Scsi_Host *__devinit
  13244. advansys_board_found(int iop, struct device *dev, int bus_type)
  13245. {
  13246. struct Scsi_Host *shost;
  13247. struct pci_dev *pdev = bus_type == ASC_IS_PCI ? to_pci_dev(dev) : NULL;
  13248. asc_board_t *boardp;
  13249. ASC_DVC_VAR *asc_dvc_varp = NULL;
  13250. ADV_DVC_VAR *adv_dvc_varp = NULL;
  13251. int share_irq;
  13252. int warn_code, err_code;
  13253. int ret;
  13254. /*
  13255. * Register the adapter, get its configuration, and
  13256. * initialize it.
  13257. */
  13258. ASC_DBG(2, "advansys_board_found: scsi_host_alloc()\n");
  13259. shost = scsi_host_alloc(&advansys_template, sizeof(asc_board_t));
  13260. if (!shost)
  13261. return NULL;
  13262. /* Initialize private per board data */
  13263. boardp = ASC_BOARDP(shost);
  13264. memset(boardp, 0, sizeof(asc_board_t));
  13265. boardp->id = asc_board_count++;
  13266. spin_lock_init(&boardp->lock);
  13267. boardp->dev = dev;
  13268. /*
  13269. * Handle both narrow and wide boards.
  13270. *
  13271. * If a Wide board was detected, set the board structure
  13272. * wide board flag. Set-up the board structure based on
  13273. * the board type.
  13274. */
  13275. #ifdef CONFIG_PCI
  13276. if (bus_type == ASC_IS_PCI &&
  13277. (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW ||
  13278. pdev->device == PCI_DEVICE_ID_38C0800_REV1 ||
  13279. pdev->device == PCI_DEVICE_ID_38C1600_REV1)) {
  13280. boardp->flags |= ASC_IS_WIDE_BOARD;
  13281. }
  13282. #endif /* CONFIG_PCI */
  13283. if (ASC_NARROW_BOARD(boardp)) {
  13284. ASC_DBG(1, "advansys_board_found: narrow board\n");
  13285. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  13286. asc_dvc_varp->bus_type = bus_type;
  13287. asc_dvc_varp->drv_ptr = boardp;
  13288. asc_dvc_varp->cfg = &boardp->dvc_cfg.asc_dvc_cfg;
  13289. asc_dvc_varp->cfg->overrun_buf = &overrun_buf[0];
  13290. asc_dvc_varp->iop_base = iop;
  13291. } else {
  13292. #ifdef CONFIG_PCI
  13293. ASC_DBG(1, "advansys_board_found: wide board\n");
  13294. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  13295. adv_dvc_varp->drv_ptr = boardp;
  13296. adv_dvc_varp->cfg = &boardp->dvc_cfg.adv_dvc_cfg;
  13297. if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW) {
  13298. ASC_DBG(1, "advansys_board_found: ASC-3550\n");
  13299. adv_dvc_varp->chip_type = ADV_CHIP_ASC3550;
  13300. } else if (pdev->device == PCI_DEVICE_ID_38C0800_REV1) {
  13301. ASC_DBG(1, "advansys_board_found: ASC-38C0800\n");
  13302. adv_dvc_varp->chip_type = ADV_CHIP_ASC38C0800;
  13303. } else {
  13304. ASC_DBG(1, "advansys_board_found: ASC-38C1600\n");
  13305. adv_dvc_varp->chip_type = ADV_CHIP_ASC38C1600;
  13306. }
  13307. boardp->asc_n_io_port = pci_resource_len(pdev, 1);
  13308. boardp->ioremap_addr = ioremap(pci_resource_start(pdev, 1),
  13309. boardp->asc_n_io_port);
  13310. if (!boardp->ioremap_addr) {
  13311. ASC_PRINT3
  13312. ("advansys_board_found: board %d: ioremap(%x, %d) returned NULL\n",
  13313. boardp->id, pci_resource_start(pdev, 1),
  13314. boardp->asc_n_io_port);
  13315. goto err_shost;
  13316. }
  13317. adv_dvc_varp->iop_base = (AdvPortAddr)boardp->ioremap_addr
  13318. ASC_DBG1(1, "advansys_board_found: iop_base: 0x%lx\n",
  13319. adv_dvc_varp->iop_base);
  13320. /*
  13321. * Even though it isn't used to access wide boards, other
  13322. * than for the debug line below, save I/O Port address so
  13323. * that it can be reported.
  13324. */
  13325. boardp->ioport = iop;
  13326. ASC_DBG2(1, "advansys_board_found: iopb_chip_id_1 0x%x, "
  13327. "iopw_chip_id_0 0x%x\n", (ushort)inp(iop + 1),
  13328. (ushort)inpw(iop));
  13329. #endif /* CONFIG_PCI */
  13330. }
  13331. #ifdef CONFIG_PROC_FS
  13332. /*
  13333. * Allocate buffer for printing information from
  13334. * /proc/scsi/advansys/[0...].
  13335. */
  13336. boardp->prtbuf = kmalloc(ASC_PRTBUF_SIZE, GFP_KERNEL);
  13337. if (!boardp->prtbuf) {
  13338. ASC_PRINT2("advansys_board_found: board %d: kmalloc(%d) "
  13339. "returned NULL\n", boardp->id, ASC_PRTBUF_SIZE);
  13340. goto err_unmap;
  13341. }
  13342. #endif /* CONFIG_PROC_FS */
  13343. if (ASC_NARROW_BOARD(boardp)) {
  13344. /*
  13345. * Set the board bus type and PCI IRQ before
  13346. * calling AscInitGetConfig().
  13347. */
  13348. switch (asc_dvc_varp->bus_type) {
  13349. #ifdef CONFIG_ISA
  13350. case ASC_IS_ISA:
  13351. shost->unchecked_isa_dma = TRUE;
  13352. share_irq = 0;
  13353. break;
  13354. case ASC_IS_VL:
  13355. shost->unchecked_isa_dma = FALSE;
  13356. share_irq = 0;
  13357. break;
  13358. case ASC_IS_EISA:
  13359. shost->unchecked_isa_dma = FALSE;
  13360. share_irq = IRQF_SHARED;
  13361. break;
  13362. #endif /* CONFIG_ISA */
  13363. #ifdef CONFIG_PCI
  13364. case ASC_IS_PCI:
  13365. shost->irq = asc_dvc_varp->irq_no = pdev->irq;
  13366. shost->unchecked_isa_dma = FALSE;
  13367. share_irq = IRQF_SHARED;
  13368. break;
  13369. #endif /* CONFIG_PCI */
  13370. default:
  13371. ASC_PRINT2
  13372. ("advansys_board_found: board %d: unknown adapter type: %d\n",
  13373. boardp->id, asc_dvc_varp->bus_type);
  13374. shost->unchecked_isa_dma = TRUE;
  13375. share_irq = 0;
  13376. break;
  13377. }
  13378. /*
  13379. * NOTE: AscInitGetConfig() may change the board's
  13380. * bus_type value. The bus_type value should no
  13381. * longer be used. If the bus_type field must be
  13382. * referenced only use the bit-wise AND operator "&".
  13383. */
  13384. ASC_DBG(2, "advansys_board_found: AscInitGetConfig()\n");
  13385. err_code = AscInitGetConfig(boardp);
  13386. } else {
  13387. #ifdef CONFIG_PCI
  13388. /*
  13389. * For Wide boards set PCI information before calling
  13390. * AdvInitGetConfig().
  13391. */
  13392. shost->irq = adv_dvc_varp->irq_no = pdev->irq;
  13393. shost->unchecked_isa_dma = FALSE;
  13394. share_irq = IRQF_SHARED;
  13395. ASC_DBG(2, "advansys_board_found: AdvInitGetConfig()\n");
  13396. err_code = AdvInitGetConfig(pdev, boardp);
  13397. #endif /* CONFIG_PCI */
  13398. }
  13399. if (err_code != 0)
  13400. goto err_free_proc;
  13401. /*
  13402. * Save the EEPROM configuration so that it can be displayed
  13403. * from /proc/scsi/advansys/[0...].
  13404. */
  13405. if (ASC_NARROW_BOARD(boardp)) {
  13406. ASCEEP_CONFIG *ep;
  13407. /*
  13408. * Set the adapter's target id bit in the 'init_tidmask' field.
  13409. */
  13410. boardp->init_tidmask |=
  13411. ADV_TID_TO_TIDMASK(asc_dvc_varp->cfg->chip_scsi_id);
  13412. /*
  13413. * Save EEPROM settings for the board.
  13414. */
  13415. ep = &boardp->eep_config.asc_eep;
  13416. ep->init_sdtr = asc_dvc_varp->cfg->sdtr_enable;
  13417. ep->disc_enable = asc_dvc_varp->cfg->disc_enable;
  13418. ep->use_cmd_qng = asc_dvc_varp->cfg->cmd_qng_enabled;
  13419. ASC_EEP_SET_DMA_SPD(ep, asc_dvc_varp->cfg->isa_dma_speed);
  13420. ep->start_motor = asc_dvc_varp->start_motor;
  13421. ep->cntl = asc_dvc_varp->dvc_cntl;
  13422. ep->no_scam = asc_dvc_varp->no_scam;
  13423. ep->max_total_qng = asc_dvc_varp->max_total_qng;
  13424. ASC_EEP_SET_CHIP_ID(ep, asc_dvc_varp->cfg->chip_scsi_id);
  13425. /* 'max_tag_qng' is set to the same value for every device. */
  13426. ep->max_tag_qng = asc_dvc_varp->cfg->max_tag_qng[0];
  13427. ep->adapter_info[0] = asc_dvc_varp->cfg->adapter_info[0];
  13428. ep->adapter_info[1] = asc_dvc_varp->cfg->adapter_info[1];
  13429. ep->adapter_info[2] = asc_dvc_varp->cfg->adapter_info[2];
  13430. ep->adapter_info[3] = asc_dvc_varp->cfg->adapter_info[3];
  13431. ep->adapter_info[4] = asc_dvc_varp->cfg->adapter_info[4];
  13432. ep->adapter_info[5] = asc_dvc_varp->cfg->adapter_info[5];
  13433. /*
  13434. * Modify board configuration.
  13435. */
  13436. ASC_DBG(2, "advansys_board_found: AscInitSetConfig()\n");
  13437. err_code = AscInitSetConfig(pdev, boardp);
  13438. if (err_code)
  13439. goto err_free_proc;
  13440. /*
  13441. * Finish initializing the 'Scsi_Host' structure.
  13442. */
  13443. /* AscInitSetConfig() will set the IRQ for non-PCI boards. */
  13444. if ((asc_dvc_varp->bus_type & ASC_IS_PCI) == 0) {
  13445. shost->irq = asc_dvc_varp->irq_no;
  13446. }
  13447. } else {
  13448. ADVEEP_3550_CONFIG *ep_3550;
  13449. ADVEEP_38C0800_CONFIG *ep_38C0800;
  13450. ADVEEP_38C1600_CONFIG *ep_38C1600;
  13451. /*
  13452. * Save Wide EEP Configuration Information.
  13453. */
  13454. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  13455. ep_3550 = &boardp->eep_config.adv_3550_eep;
  13456. ep_3550->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
  13457. ep_3550->max_host_qng = adv_dvc_varp->max_host_qng;
  13458. ep_3550->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  13459. ep_3550->termination = adv_dvc_varp->cfg->termination;
  13460. ep_3550->disc_enable = adv_dvc_varp->cfg->disc_enable;
  13461. ep_3550->bios_ctrl = adv_dvc_varp->bios_ctrl;
  13462. ep_3550->wdtr_able = adv_dvc_varp->wdtr_able;
  13463. ep_3550->sdtr_able = adv_dvc_varp->sdtr_able;
  13464. ep_3550->ultra_able = adv_dvc_varp->ultra_able;
  13465. ep_3550->tagqng_able = adv_dvc_varp->tagqng_able;
  13466. ep_3550->start_motor = adv_dvc_varp->start_motor;
  13467. ep_3550->scsi_reset_delay =
  13468. adv_dvc_varp->scsi_reset_wait;
  13469. ep_3550->serial_number_word1 =
  13470. adv_dvc_varp->cfg->serial1;
  13471. ep_3550->serial_number_word2 =
  13472. adv_dvc_varp->cfg->serial2;
  13473. ep_3550->serial_number_word3 =
  13474. adv_dvc_varp->cfg->serial3;
  13475. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  13476. ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
  13477. ep_38C0800->adapter_scsi_id =
  13478. adv_dvc_varp->chip_scsi_id;
  13479. ep_38C0800->max_host_qng = adv_dvc_varp->max_host_qng;
  13480. ep_38C0800->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  13481. ep_38C0800->termination_lvd =
  13482. adv_dvc_varp->cfg->termination;
  13483. ep_38C0800->disc_enable =
  13484. adv_dvc_varp->cfg->disc_enable;
  13485. ep_38C0800->bios_ctrl = adv_dvc_varp->bios_ctrl;
  13486. ep_38C0800->wdtr_able = adv_dvc_varp->wdtr_able;
  13487. ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
  13488. ep_38C0800->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
  13489. ep_38C0800->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
  13490. ep_38C0800->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
  13491. ep_38C0800->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
  13492. ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
  13493. ep_38C0800->start_motor = adv_dvc_varp->start_motor;
  13494. ep_38C0800->scsi_reset_delay =
  13495. adv_dvc_varp->scsi_reset_wait;
  13496. ep_38C0800->serial_number_word1 =
  13497. adv_dvc_varp->cfg->serial1;
  13498. ep_38C0800->serial_number_word2 =
  13499. adv_dvc_varp->cfg->serial2;
  13500. ep_38C0800->serial_number_word3 =
  13501. adv_dvc_varp->cfg->serial3;
  13502. } else {
  13503. ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
  13504. ep_38C1600->adapter_scsi_id =
  13505. adv_dvc_varp->chip_scsi_id;
  13506. ep_38C1600->max_host_qng = adv_dvc_varp->max_host_qng;
  13507. ep_38C1600->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  13508. ep_38C1600->termination_lvd =
  13509. adv_dvc_varp->cfg->termination;
  13510. ep_38C1600->disc_enable =
  13511. adv_dvc_varp->cfg->disc_enable;
  13512. ep_38C1600->bios_ctrl = adv_dvc_varp->bios_ctrl;
  13513. ep_38C1600->wdtr_able = adv_dvc_varp->wdtr_able;
  13514. ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
  13515. ep_38C1600->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
  13516. ep_38C1600->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
  13517. ep_38C1600->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
  13518. ep_38C1600->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
  13519. ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
  13520. ep_38C1600->start_motor = adv_dvc_varp->start_motor;
  13521. ep_38C1600->scsi_reset_delay =
  13522. adv_dvc_varp->scsi_reset_wait;
  13523. ep_38C1600->serial_number_word1 =
  13524. adv_dvc_varp->cfg->serial1;
  13525. ep_38C1600->serial_number_word2 =
  13526. adv_dvc_varp->cfg->serial2;
  13527. ep_38C1600->serial_number_word3 =
  13528. adv_dvc_varp->cfg->serial3;
  13529. }
  13530. /*
  13531. * Set the adapter's target id bit in the 'init_tidmask' field.
  13532. */
  13533. boardp->init_tidmask |=
  13534. ADV_TID_TO_TIDMASK(adv_dvc_varp->chip_scsi_id);
  13535. }
  13536. /*
  13537. * Channels are numbered beginning with 0. For AdvanSys one host
  13538. * structure supports one channel. Multi-channel boards have a
  13539. * separate host structure for each channel.
  13540. */
  13541. shost->max_channel = 0;
  13542. if (ASC_NARROW_BOARD(boardp)) {
  13543. shost->max_id = ASC_MAX_TID + 1;
  13544. shost->max_lun = ASC_MAX_LUN + 1;
  13545. shost->max_cmd_len = ASC_MAX_CDB_LEN;
  13546. shost->io_port = asc_dvc_varp->iop_base;
  13547. boardp->asc_n_io_port = ASC_IOADR_GAP;
  13548. shost->this_id = asc_dvc_varp->cfg->chip_scsi_id;
  13549. /* Set maximum number of queues the adapter can handle. */
  13550. shost->can_queue = asc_dvc_varp->max_total_qng;
  13551. } else {
  13552. shost->max_id = ADV_MAX_TID + 1;
  13553. shost->max_lun = ADV_MAX_LUN + 1;
  13554. shost->max_cmd_len = ADV_MAX_CDB_LEN;
  13555. /*
  13556. * Save the I/O Port address and length even though
  13557. * I/O ports are not used to access Wide boards.
  13558. * Instead the Wide boards are accessed with
  13559. * PCI Memory Mapped I/O.
  13560. */
  13561. shost->io_port = iop;
  13562. shost->this_id = adv_dvc_varp->chip_scsi_id;
  13563. /* Set maximum number of queues the adapter can handle. */
  13564. shost->can_queue = adv_dvc_varp->max_host_qng;
  13565. }
  13566. /*
  13567. * Following v1.3.89, 'cmd_per_lun' is no longer needed
  13568. * and should be set to zero.
  13569. *
  13570. * But because of a bug introduced in v1.3.89 if the driver is
  13571. * compiled as a module and 'cmd_per_lun' is zero, the Mid-Level
  13572. * SCSI function 'allocate_device' will panic. To allow the driver
  13573. * to work as a module in these kernels set 'cmd_per_lun' to 1.
  13574. *
  13575. * Note: This is wrong. cmd_per_lun should be set to the depth
  13576. * you want on untagged devices always.
  13577. #ifdef MODULE
  13578. */
  13579. shost->cmd_per_lun = 1;
  13580. /* #else
  13581. shost->cmd_per_lun = 0;
  13582. #endif */
  13583. /*
  13584. * Set the maximum number of scatter-gather elements the
  13585. * adapter can handle.
  13586. */
  13587. if (ASC_NARROW_BOARD(boardp)) {
  13588. /*
  13589. * Allow two commands with 'sg_tablesize' scatter-gather
  13590. * elements to be executed simultaneously. This value is
  13591. * the theoretical hardware limit. It may be decreased
  13592. * below.
  13593. */
  13594. shost->sg_tablesize =
  13595. (((asc_dvc_varp->max_total_qng - 2) / 2) *
  13596. ASC_SG_LIST_PER_Q) + 1;
  13597. } else {
  13598. shost->sg_tablesize = ADV_MAX_SG_LIST;
  13599. }
  13600. /*
  13601. * The value of 'sg_tablesize' can not exceed the SCSI
  13602. * mid-level driver definition of SG_ALL. SG_ALL also
  13603. * must not be exceeded, because it is used to define the
  13604. * size of the scatter-gather table in 'struct asc_sg_head'.
  13605. */
  13606. if (shost->sg_tablesize > SG_ALL) {
  13607. shost->sg_tablesize = SG_ALL;
  13608. }
  13609. ASC_DBG1(1, "advansys_board_found: sg_tablesize: %d\n", shost->sg_tablesize);
  13610. /* BIOS start address. */
  13611. if (ASC_NARROW_BOARD(boardp)) {
  13612. shost->base = AscGetChipBiosAddress(asc_dvc_varp->iop_base,
  13613. asc_dvc_varp->bus_type);
  13614. } else {
  13615. /*
  13616. * Fill-in BIOS board variables. The Wide BIOS saves
  13617. * information in LRAM that is used by the driver.
  13618. */
  13619. AdvReadWordLram(adv_dvc_varp->iop_base,
  13620. BIOS_SIGNATURE, boardp->bios_signature);
  13621. AdvReadWordLram(adv_dvc_varp->iop_base,
  13622. BIOS_VERSION, boardp->bios_version);
  13623. AdvReadWordLram(adv_dvc_varp->iop_base,
  13624. BIOS_CODESEG, boardp->bios_codeseg);
  13625. AdvReadWordLram(adv_dvc_varp->iop_base,
  13626. BIOS_CODELEN, boardp->bios_codelen);
  13627. ASC_DBG2(1,
  13628. "advansys_board_found: bios_signature 0x%x, bios_version 0x%x\n",
  13629. boardp->bios_signature, boardp->bios_version);
  13630. ASC_DBG2(1,
  13631. "advansys_board_found: bios_codeseg 0x%x, bios_codelen 0x%x\n",
  13632. boardp->bios_codeseg, boardp->bios_codelen);
  13633. /*
  13634. * If the BIOS saved a valid signature, then fill in
  13635. * the BIOS code segment base address.
  13636. */
  13637. if (boardp->bios_signature == 0x55AA) {
  13638. /*
  13639. * Convert x86 realmode code segment to a linear
  13640. * address by shifting left 4.
  13641. */
  13642. shost->base = ((ulong)boardp->bios_codeseg << 4);
  13643. } else {
  13644. shost->base = 0;
  13645. }
  13646. }
  13647. /*
  13648. * Register Board Resources - I/O Port, DMA, IRQ
  13649. */
  13650. /* Register DMA Channel for Narrow boards. */
  13651. shost->dma_channel = NO_ISA_DMA; /* Default to no ISA DMA. */
  13652. #ifdef CONFIG_ISA
  13653. if (ASC_NARROW_BOARD(boardp)) {
  13654. /* Register DMA channel for ISA bus. */
  13655. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  13656. shost->dma_channel = asc_dvc_varp->cfg->isa_dma_channel;
  13657. ret = request_dma(shost->dma_channel, "advansys");
  13658. if (ret) {
  13659. ASC_PRINT3
  13660. ("advansys_board_found: board %d: request_dma() %d failed %d\n",
  13661. boardp->id, shost->dma_channel, ret);
  13662. goto err_free_proc;
  13663. }
  13664. AscEnableIsaDma(shost->dma_channel);
  13665. }
  13666. }
  13667. #endif /* CONFIG_ISA */
  13668. /* Register IRQ Number. */
  13669. ASC_DBG1(2, "advansys_board_found: request_irq() %d\n", shost->irq);
  13670. ret = request_irq(shost->irq, advansys_interrupt, share_irq,
  13671. "advansys", shost);
  13672. if (ret) {
  13673. if (ret == -EBUSY) {
  13674. ASC_PRINT2
  13675. ("advansys_board_found: board %d: request_irq(): IRQ 0x%x already in use.\n",
  13676. boardp->id, shost->irq);
  13677. } else if (ret == -EINVAL) {
  13678. ASC_PRINT2
  13679. ("advansys_board_found: board %d: request_irq(): IRQ 0x%x not valid.\n",
  13680. boardp->id, shost->irq);
  13681. } else {
  13682. ASC_PRINT3
  13683. ("advansys_board_found: board %d: request_irq(): IRQ 0x%x failed with %d\n",
  13684. boardp->id, shost->irq, ret);
  13685. }
  13686. goto err_free_dma;
  13687. }
  13688. /*
  13689. * Initialize board RISC chip and enable interrupts.
  13690. */
  13691. if (ASC_NARROW_BOARD(boardp)) {
  13692. ASC_DBG(2, "advansys_board_found: AscInitAsc1000Driver()\n");
  13693. warn_code = AscInitAsc1000Driver(asc_dvc_varp);
  13694. err_code = asc_dvc_varp->err_code;
  13695. if (warn_code || err_code) {
  13696. ASC_PRINT4
  13697. ("advansys_board_found: board %d error: init_state 0x%x, warn 0x%x, error 0x%x\n",
  13698. boardp->id,
  13699. asc_dvc_varp->init_state, warn_code, err_code);
  13700. }
  13701. } else {
  13702. err_code = advansys_wide_init_chip(boardp, adv_dvc_varp);
  13703. }
  13704. if (err_code != 0)
  13705. goto err_free_wide_mem;
  13706. ASC_DBG_PRT_SCSI_HOST(2, shost);
  13707. ret = scsi_add_host(shost, dev);
  13708. if (ret)
  13709. goto err_free_wide_mem;
  13710. scsi_scan_host(shost);
  13711. return shost;
  13712. err_free_wide_mem:
  13713. advansys_wide_free_mem(boardp);
  13714. free_irq(shost->irq, shost);
  13715. err_free_dma:
  13716. if (shost->dma_channel != NO_ISA_DMA)
  13717. free_dma(shost->dma_channel);
  13718. err_free_proc:
  13719. kfree(boardp->prtbuf);
  13720. err_unmap:
  13721. if (boardp->ioremap_addr)
  13722. iounmap(boardp->ioremap_addr);
  13723. err_shost:
  13724. scsi_host_put(shost);
  13725. return NULL;
  13726. }
  13727. /*
  13728. * advansys_release()
  13729. *
  13730. * Release resources allocated for a single AdvanSys adapter.
  13731. */
  13732. static int advansys_release(struct Scsi_Host *shost)
  13733. {
  13734. asc_board_t *boardp;
  13735. ASC_DBG(1, "advansys_release: begin\n");
  13736. scsi_remove_host(shost);
  13737. boardp = ASC_BOARDP(shost);
  13738. free_irq(shost->irq, shost);
  13739. if (shost->dma_channel != NO_ISA_DMA) {
  13740. ASC_DBG(1, "advansys_release: free_dma()\n");
  13741. free_dma(shost->dma_channel);
  13742. }
  13743. if (ASC_WIDE_BOARD(boardp)) {
  13744. iounmap(boardp->ioremap_addr);
  13745. advansys_wide_free_mem(boardp);
  13746. }
  13747. kfree(boardp->prtbuf);
  13748. scsi_host_put(shost);
  13749. ASC_DBG(1, "advansys_release: end\n");
  13750. return 0;
  13751. }
  13752. static PortAddr _asc_def_iop_base[ASC_IOADR_TABLE_MAX_IX] __devinitdata = {
  13753. 0x100, 0x0110, 0x120, 0x0130, 0x140, 0x0150, 0x0190,
  13754. 0x0210, 0x0230, 0x0250, 0x0330
  13755. };
  13756. static int __devinit advansys_isa_probe(struct device *dev, unsigned int id)
  13757. {
  13758. PortAddr iop_base = _asc_def_iop_base[id];
  13759. struct Scsi_Host *shost;
  13760. if (!request_region(iop_base, ASC_IOADR_GAP, "advansys")) {
  13761. ASC_DBG1(1, "advansys_isa_match: I/O port 0x%x busy\n",
  13762. iop_base);
  13763. return -ENODEV;
  13764. }
  13765. ASC_DBG1(1, "advansys_isa_match: probing I/O port 0x%x\n", iop_base);
  13766. if (!AscFindSignature(iop_base))
  13767. goto nodev;
  13768. if (!(AscGetChipVersion(iop_base, ASC_IS_ISA) & ASC_CHIP_VER_ISA_BIT))
  13769. goto nodev;
  13770. shost = advansys_board_found(iop_base, dev, ASC_IS_ISA);
  13771. if (!shost)
  13772. goto nodev;
  13773. dev_set_drvdata(dev, shost);
  13774. return 0;
  13775. nodev:
  13776. release_region(iop_base, ASC_IOADR_GAP);
  13777. return -ENODEV;
  13778. }
  13779. static int __devexit advansys_isa_remove(struct device *dev, unsigned int id)
  13780. {
  13781. int ioport = _asc_def_iop_base[id];
  13782. advansys_release(dev_get_drvdata(dev));
  13783. release_region(ioport, ASC_IOADR_GAP);
  13784. return 0;
  13785. }
  13786. static struct isa_driver advansys_isa_driver = {
  13787. .probe = advansys_isa_probe,
  13788. .remove = __devexit_p(advansys_isa_remove),
  13789. .driver = {
  13790. .owner = THIS_MODULE,
  13791. .name = "advansys",
  13792. },
  13793. };
  13794. static int __devinit advansys_vlb_probe(struct device *dev, unsigned int id)
  13795. {
  13796. PortAddr iop_base = _asc_def_iop_base[id];
  13797. struct Scsi_Host *shost;
  13798. if (!request_region(iop_base, ASC_IOADR_GAP, "advansys")) {
  13799. ASC_DBG1(1, "advansys_vlb_match: I/O port 0x%x busy\n",
  13800. iop_base);
  13801. return -ENODEV;
  13802. }
  13803. ASC_DBG1(1, "advansys_vlb_match: probing I/O port 0x%x\n", iop_base);
  13804. if (!AscFindSignature(iop_base))
  13805. goto nodev;
  13806. /*
  13807. * I don't think this condition can actually happen, but the old
  13808. * driver did it, and the chances of finding a VLB setup in 2007
  13809. * to do testing with is slight to none.
  13810. */
  13811. if (AscGetChipVersion(iop_base, ASC_IS_VL) > ASC_CHIP_MAX_VER_VL)
  13812. goto nodev;
  13813. shost = advansys_board_found(iop_base, dev, ASC_IS_VL);
  13814. if (!shost)
  13815. goto nodev;
  13816. dev_set_drvdata(dev, shost);
  13817. return 0;
  13818. nodev:
  13819. release_region(iop_base, ASC_IOADR_GAP);
  13820. return -ENODEV;
  13821. }
  13822. static struct isa_driver advansys_vlb_driver = {
  13823. .probe = advansys_vlb_probe,
  13824. .remove = __devexit_p(advansys_isa_remove),
  13825. .driver = {
  13826. .owner = THIS_MODULE,
  13827. .name = "advansys_vlb",
  13828. },
  13829. };
  13830. static struct eisa_device_id advansys_eisa_table[] __devinitdata = {
  13831. { "ABP7401" },
  13832. { "ABP7501" },
  13833. { "" }
  13834. };
  13835. MODULE_DEVICE_TABLE(eisa, advansys_eisa_table);
  13836. /*
  13837. * EISA is a little more tricky than PCI; each EISA device may have two
  13838. * channels, and this driver is written to make each channel its own Scsi_Host
  13839. */
  13840. struct eisa_scsi_data {
  13841. struct Scsi_Host *host[2];
  13842. };
  13843. static int __devinit advansys_eisa_probe(struct device *dev)
  13844. {
  13845. int i, ioport;
  13846. int err;
  13847. struct eisa_device *edev = to_eisa_device(dev);
  13848. struct eisa_scsi_data *data;
  13849. err = -ENOMEM;
  13850. data = kzalloc(sizeof(*data), GFP_KERNEL);
  13851. if (!data)
  13852. goto fail;
  13853. ioport = edev->base_addr + 0xc30;
  13854. err = -ENODEV;
  13855. for (i = 0; i < 2; i++, ioport += 0x20) {
  13856. if (!request_region(ioport, ASC_IOADR_GAP, "advansys")) {
  13857. printk(KERN_WARNING "Region %x-%x busy\n", ioport,
  13858. ioport + ASC_IOADR_GAP - 1);
  13859. continue;
  13860. }
  13861. if (!AscFindSignature(ioport)) {
  13862. release_region(ioport, ASC_IOADR_GAP);
  13863. continue;
  13864. }
  13865. /*
  13866. * I don't know why we need to do this for EISA chips, but
  13867. * not for any others. It looks to be equivalent to
  13868. * AscGetChipCfgMsw, but I may have overlooked something,
  13869. * so I'm not converting it until I get an EISA board to
  13870. * test with.
  13871. */
  13872. inw(ioport + 4);
  13873. data->host[i] = advansys_board_found(ioport, dev, ASC_IS_EISA);
  13874. if (data->host[i]) {
  13875. err = 0;
  13876. } else {
  13877. release_region(ioport, ASC_IOADR_GAP);
  13878. }
  13879. }
  13880. if (err) {
  13881. kfree(data);
  13882. } else {
  13883. dev_set_drvdata(dev, data);
  13884. }
  13885. fail:
  13886. return err;
  13887. }
  13888. static __devexit int advansys_eisa_remove(struct device *dev)
  13889. {
  13890. int i;
  13891. struct eisa_scsi_data *data = dev_get_drvdata(dev);
  13892. for (i = 0; i < 2; i++) {
  13893. int ioport;
  13894. struct Scsi_Host *shost = data->host[i];
  13895. if (!shost)
  13896. continue;
  13897. ioport = shost->io_port;
  13898. advansys_release(shost);
  13899. release_region(ioport, ASC_IOADR_GAP);
  13900. }
  13901. kfree(data);
  13902. return 0;
  13903. }
  13904. static struct eisa_driver advansys_eisa_driver = {
  13905. .id_table = advansys_eisa_table,
  13906. .driver = {
  13907. .name = "advansys",
  13908. .probe = advansys_eisa_probe,
  13909. .remove = __devexit_p(advansys_eisa_remove),
  13910. }
  13911. };
  13912. /* PCI Devices supported by this driver */
  13913. static struct pci_device_id advansys_pci_tbl[] __devinitdata = {
  13914. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_1200A,
  13915. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13916. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940,
  13917. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13918. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940U,
  13919. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13920. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940UW,
  13921. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13922. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C0800_REV1,
  13923. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13924. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C1600_REV1,
  13925. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13926. {}
  13927. };
  13928. MODULE_DEVICE_TABLE(pci, advansys_pci_tbl);
  13929. static void __devinit advansys_set_latency(struct pci_dev *pdev)
  13930. {
  13931. if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
  13932. (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
  13933. pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0);
  13934. } else {
  13935. u8 latency;
  13936. pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency);
  13937. if (latency < 0x20)
  13938. pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x20);
  13939. }
  13940. }
  13941. static int __devinit
  13942. advansys_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  13943. {
  13944. int err, ioport;
  13945. struct Scsi_Host *shost;
  13946. err = pci_enable_device(pdev);
  13947. if (err)
  13948. goto fail;
  13949. err = pci_request_regions(pdev, "advansys");
  13950. if (err)
  13951. goto disable_device;
  13952. pci_set_master(pdev);
  13953. advansys_set_latency(pdev);
  13954. if (pci_resource_len(pdev, 0) == 0)
  13955. goto nodev;
  13956. ioport = pci_resource_start(pdev, 0);
  13957. shost = advansys_board_found(ioport, &pdev->dev, ASC_IS_PCI);
  13958. if (!shost)
  13959. goto nodev;
  13960. pci_set_drvdata(pdev, shost);
  13961. return 0;
  13962. nodev:
  13963. err = -ENODEV;
  13964. pci_release_regions(pdev);
  13965. disable_device:
  13966. pci_disable_device(pdev);
  13967. fail:
  13968. return err;
  13969. }
  13970. static void __devexit advansys_pci_remove(struct pci_dev *pdev)
  13971. {
  13972. advansys_release(pci_get_drvdata(pdev));
  13973. pci_release_regions(pdev);
  13974. pci_disable_device(pdev);
  13975. }
  13976. static struct pci_driver advansys_pci_driver = {
  13977. .name = "advansys",
  13978. .id_table = advansys_pci_tbl,
  13979. .probe = advansys_pci_probe,
  13980. .remove = __devexit_p(advansys_pci_remove),
  13981. };
  13982. static int __init advansys_init(void)
  13983. {
  13984. int error;
  13985. error = isa_register_driver(&advansys_isa_driver,
  13986. ASC_IOADR_TABLE_MAX_IX);
  13987. if (error)
  13988. goto fail;
  13989. error = isa_register_driver(&advansys_vlb_driver,
  13990. ASC_IOADR_TABLE_MAX_IX);
  13991. if (error)
  13992. goto unregister_isa;
  13993. error = eisa_driver_register(&advansys_eisa_driver);
  13994. if (error)
  13995. goto unregister_vlb;
  13996. error = pci_register_driver(&advansys_pci_driver);
  13997. if (error)
  13998. goto unregister_eisa;
  13999. return 0;
  14000. unregister_eisa:
  14001. eisa_driver_unregister(&advansys_eisa_driver);
  14002. unregister_vlb:
  14003. isa_unregister_driver(&advansys_vlb_driver);
  14004. unregister_isa:
  14005. isa_unregister_driver(&advansys_isa_driver);
  14006. fail:
  14007. return error;
  14008. }
  14009. static void __exit advansys_exit(void)
  14010. {
  14011. pci_unregister_driver(&advansys_pci_driver);
  14012. eisa_driver_unregister(&advansys_eisa_driver);
  14013. isa_unregister_driver(&advansys_vlb_driver);
  14014. isa_unregister_driver(&advansys_isa_driver);
  14015. }
  14016. module_init(advansys_init);
  14017. module_exit(advansys_exit);
  14018. MODULE_LICENSE("GPL");