advansys.c 483 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284
  1. #define DRV_NAME "advansys"
  2. #define ASC_VERSION "3.4" /* AdvanSys Driver Version */
  3. /*
  4. * advansys.c - Linux Host Driver for AdvanSys SCSI Adapters
  5. *
  6. * Copyright (c) 1995-2000 Advanced System Products, Inc.
  7. * Copyright (c) 2000-2001 ConnectCom Solutions, Inc.
  8. * Copyright (c) 2007 Matthew Wilcox <matthew@wil.cx>
  9. * All Rights Reserved.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. */
  16. /*
  17. * As of March 8, 2000 Advanced System Products, Inc. (AdvanSys)
  18. * changed its name to ConnectCom Solutions, Inc.
  19. * On June 18, 2001 Initio Corp. acquired ConnectCom's SCSI assets
  20. */
  21. #include <linux/module.h>
  22. #include <linux/string.h>
  23. #include <linux/kernel.h>
  24. #include <linux/types.h>
  25. #include <linux/ioport.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/delay.h>
  28. #include <linux/slab.h>
  29. #include <linux/mm.h>
  30. #include <linux/proc_fs.h>
  31. #include <linux/init.h>
  32. #include <linux/blkdev.h>
  33. #include <linux/isa.h>
  34. #include <linux/eisa.h>
  35. #include <linux/pci.h>
  36. #include <linux/spinlock.h>
  37. #include <linux/dma-mapping.h>
  38. #include <asm/io.h>
  39. #include <asm/system.h>
  40. #include <asm/dma.h>
  41. #include <scsi/scsi_cmnd.h>
  42. #include <scsi/scsi_device.h>
  43. #include <scsi/scsi_tcq.h>
  44. #include <scsi/scsi.h>
  45. #include <scsi/scsi_host.h>
  46. /* FIXME:
  47. *
  48. * 1. Although all of the necessary command mapping places have the
  49. * appropriate dma_map.. APIs, the driver still processes its internal
  50. * queue using bus_to_virt() and virt_to_bus() which are illegal under
  51. * the API. The entire queue processing structure will need to be
  52. * altered to fix this.
  53. * 2. Need to add memory mapping workaround. Test the memory mapping.
  54. * If it doesn't work revert to I/O port access. Can a test be done
  55. * safely?
  56. * 3. Handle an interrupt not working. Keep an interrupt counter in
  57. * the interrupt handler. In the timeout function if the interrupt
  58. * has not occurred then print a message and run in polled mode.
  59. * 4. Need to add support for target mode commands, cf. CAM XPT.
  60. * 5. check DMA mapping functions for failure
  61. * 6. Use scsi_transport_spi
  62. * 7. advansys_info is not safe against multiple simultaneous callers
  63. * 8. 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 /proc statistics. */
  67. #define ADVANSYS_STATS
  68. /* Enable driver tracing. */
  69. #undef ADVANSYS_DEBUG
  70. /*
  71. * Portable Data Types
  72. *
  73. * Any instance where a 32-bit long or pointer type is assumed
  74. * for precision or HW defined structures, the following define
  75. * types must be used. In Linux the char, short, and int types
  76. * are all consistent at 8, 16, and 32 bits respectively. Pointers
  77. * and long types are 64 bits on Alpha and UltraSPARC.
  78. */
  79. #define ASC_PADDR __u32 /* Physical/Bus address data type. */
  80. #define ASC_VADDR __u32 /* Virtual address data type. */
  81. #define ASC_DCNT __u32 /* Unsigned Data count type. */
  82. #define ASC_SDCNT __s32 /* Signed Data count type. */
  83. /*
  84. * These macros are used to convert a virtual address to a
  85. * 32-bit value. This currently can be used on Linux Alpha
  86. * which uses 64-bit virtual address but a 32-bit bus address.
  87. * This is likely to break in the future, but doing this now
  88. * will give us time to change the HW and FW to handle 64-bit
  89. * addresses.
  90. */
  91. #define ASC_VADDR_TO_U32 virt_to_bus
  92. #define ASC_U32_TO_VADDR bus_to_virt
  93. typedef unsigned char uchar;
  94. #ifndef TRUE
  95. #define TRUE (1)
  96. #endif
  97. #ifndef FALSE
  98. #define FALSE (0)
  99. #endif
  100. #define ERR (-1)
  101. #define UW_ERR (uint)(0xFFFF)
  102. #define isodd_word(val) ((((uint)val) & (uint)0x0001) != 0)
  103. #define PCI_VENDOR_ID_ASP 0x10cd
  104. #define PCI_DEVICE_ID_ASP_1200A 0x1100
  105. #define PCI_DEVICE_ID_ASP_ABP940 0x1200
  106. #define PCI_DEVICE_ID_ASP_ABP940U 0x1300
  107. #define PCI_DEVICE_ID_ASP_ABP940UW 0x2300
  108. #define PCI_DEVICE_ID_38C0800_REV1 0x2500
  109. #define PCI_DEVICE_ID_38C1600_REV1 0x2700
  110. /*
  111. * Enable CC_VERY_LONG_SG_LIST to support up to 64K element SG lists.
  112. * The SRB structure will have to be changed and the ASC_SRB2SCSIQ()
  113. * macro re-defined to be able to obtain a ASC_SCSI_Q pointer from the
  114. * SRB structure.
  115. */
  116. #define CC_VERY_LONG_SG_LIST 0
  117. #define ASC_SRB2SCSIQ(srb_ptr) (srb_ptr)
  118. #define PortAddr unsigned short /* port address size */
  119. #define inp(port) inb(port)
  120. #define outp(port, byte) outb((byte), (port))
  121. #define inpw(port) inw(port)
  122. #define outpw(port, word) outw((word), (port))
  123. #define ASC_MAX_SG_QUEUE 7
  124. #define ASC_MAX_SG_LIST 255
  125. #define ASC_CS_TYPE unsigned short
  126. #define ASC_IS_ISA (0x0001)
  127. #define ASC_IS_ISAPNP (0x0081)
  128. #define ASC_IS_EISA (0x0002)
  129. #define ASC_IS_PCI (0x0004)
  130. #define ASC_IS_PCI_ULTRA (0x0104)
  131. #define ASC_IS_PCMCIA (0x0008)
  132. #define ASC_IS_MCA (0x0020)
  133. #define ASC_IS_VL (0x0040)
  134. #define ASC_IS_WIDESCSI_16 (0x0100)
  135. #define ASC_IS_WIDESCSI_32 (0x0200)
  136. #define ASC_IS_BIG_ENDIAN (0x8000)
  137. #define ASC_CHIP_MIN_VER_VL (0x01)
  138. #define ASC_CHIP_MAX_VER_VL (0x07)
  139. #define ASC_CHIP_MIN_VER_PCI (0x09)
  140. #define ASC_CHIP_MAX_VER_PCI (0x0F)
  141. #define ASC_CHIP_VER_PCI_BIT (0x08)
  142. #define ASC_CHIP_MIN_VER_ISA (0x11)
  143. #define ASC_CHIP_MIN_VER_ISA_PNP (0x21)
  144. #define ASC_CHIP_MAX_VER_ISA (0x27)
  145. #define ASC_CHIP_VER_ISA_BIT (0x30)
  146. #define ASC_CHIP_VER_ISAPNP_BIT (0x20)
  147. #define ASC_CHIP_VER_ASYN_BUG (0x21)
  148. #define ASC_CHIP_VER_PCI 0x08
  149. #define ASC_CHIP_VER_PCI_ULTRA_3150 (ASC_CHIP_VER_PCI | 0x02)
  150. #define ASC_CHIP_VER_PCI_ULTRA_3050 (ASC_CHIP_VER_PCI | 0x03)
  151. #define ASC_CHIP_MIN_VER_EISA (0x41)
  152. #define ASC_CHIP_MAX_VER_EISA (0x47)
  153. #define ASC_CHIP_VER_EISA_BIT (0x40)
  154. #define ASC_CHIP_LATEST_VER_EISA ((ASC_CHIP_MIN_VER_EISA - 1) + 3)
  155. #define ASC_MAX_VL_DMA_COUNT (0x07FFFFFFL)
  156. #define ASC_MAX_PCI_DMA_COUNT (0xFFFFFFFFL)
  157. #define ASC_MAX_ISA_DMA_COUNT (0x00FFFFFFL)
  158. #define ASC_SCSI_ID_BITS 3
  159. #define ASC_SCSI_TIX_TYPE uchar
  160. #define ASC_ALL_DEVICE_BIT_SET 0xFF
  161. #define ASC_SCSI_BIT_ID_TYPE uchar
  162. #define ASC_MAX_TID 7
  163. #define ASC_MAX_LUN 7
  164. #define ASC_SCSI_WIDTH_BIT_SET 0xFF
  165. #define ASC_MAX_SENSE_LEN 32
  166. #define ASC_MIN_SENSE_LEN 14
  167. #define ASC_SCSI_RESET_HOLD_TIME_US 60
  168. /*
  169. * Narrow boards only support 12-byte commands, while wide boards
  170. * extend to 16-byte commands.
  171. */
  172. #define ASC_MAX_CDB_LEN 12
  173. #define ADV_MAX_CDB_LEN 16
  174. #define MS_SDTR_LEN 0x03
  175. #define MS_WDTR_LEN 0x02
  176. #define ASC_SG_LIST_PER_Q 7
  177. #define QS_FREE 0x00
  178. #define QS_READY 0x01
  179. #define QS_DISC1 0x02
  180. #define QS_DISC2 0x04
  181. #define QS_BUSY 0x08
  182. #define QS_ABORTED 0x40
  183. #define QS_DONE 0x80
  184. #define QC_NO_CALLBACK 0x01
  185. #define QC_SG_SWAP_QUEUE 0x02
  186. #define QC_SG_HEAD 0x04
  187. #define QC_DATA_IN 0x08
  188. #define QC_DATA_OUT 0x10
  189. #define QC_URGENT 0x20
  190. #define QC_MSG_OUT 0x40
  191. #define QC_REQ_SENSE 0x80
  192. #define QCSG_SG_XFER_LIST 0x02
  193. #define QCSG_SG_XFER_MORE 0x04
  194. #define QCSG_SG_XFER_END 0x08
  195. #define QD_IN_PROGRESS 0x00
  196. #define QD_NO_ERROR 0x01
  197. #define QD_ABORTED_BY_HOST 0x02
  198. #define QD_WITH_ERROR 0x04
  199. #define QD_INVALID_REQUEST 0x80
  200. #define QD_INVALID_HOST_NUM 0x81
  201. #define QD_INVALID_DEVICE 0x82
  202. #define QD_ERR_INTERNAL 0xFF
  203. #define QHSTA_NO_ERROR 0x00
  204. #define QHSTA_M_SEL_TIMEOUT 0x11
  205. #define QHSTA_M_DATA_OVER_RUN 0x12
  206. #define QHSTA_M_DATA_UNDER_RUN 0x12
  207. #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
  208. #define QHSTA_M_BAD_BUS_PHASE_SEQ 0x14
  209. #define QHSTA_D_QDONE_SG_LIST_CORRUPTED 0x21
  210. #define QHSTA_D_ASC_DVC_ERROR_CODE_SET 0x22
  211. #define QHSTA_D_HOST_ABORT_FAILED 0x23
  212. #define QHSTA_D_EXE_SCSI_Q_FAILED 0x24
  213. #define QHSTA_D_EXE_SCSI_Q_BUSY_TIMEOUT 0x25
  214. #define QHSTA_D_ASPI_NO_BUF_POOL 0x26
  215. #define QHSTA_M_WTM_TIMEOUT 0x41
  216. #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
  217. #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
  218. #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
  219. #define QHSTA_M_TARGET_STATUS_BUSY 0x45
  220. #define QHSTA_M_BAD_TAG_CODE 0x46
  221. #define QHSTA_M_BAD_QUEUE_FULL_OR_BUSY 0x47
  222. #define QHSTA_M_HUNG_REQ_SCSI_BUS_RESET 0x48
  223. #define QHSTA_D_LRAM_CMP_ERROR 0x81
  224. #define QHSTA_M_MICRO_CODE_ERROR_HALT 0xA1
  225. #define ASC_FLAG_SCSIQ_REQ 0x01
  226. #define ASC_FLAG_BIOS_SCSIQ_REQ 0x02
  227. #define ASC_FLAG_BIOS_ASYNC_IO 0x04
  228. #define ASC_FLAG_SRB_LINEAR_ADDR 0x08
  229. #define ASC_FLAG_WIN16 0x10
  230. #define ASC_FLAG_WIN32 0x20
  231. #define ASC_FLAG_ISA_OVER_16MB 0x40
  232. #define ASC_FLAG_DOS_VM_CALLBACK 0x80
  233. #define ASC_TAG_FLAG_EXTRA_BYTES 0x10
  234. #define ASC_TAG_FLAG_DISABLE_DISCONNECT 0x04
  235. #define ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX 0x08
  236. #define ASC_TAG_FLAG_DISABLE_CHK_COND_INT_HOST 0x40
  237. #define ASC_SCSIQ_CPY_BEG 4
  238. #define ASC_SCSIQ_SGHD_CPY_BEG 2
  239. #define ASC_SCSIQ_B_FWD 0
  240. #define ASC_SCSIQ_B_BWD 1
  241. #define ASC_SCSIQ_B_STATUS 2
  242. #define ASC_SCSIQ_B_QNO 3
  243. #define ASC_SCSIQ_B_CNTL 4
  244. #define ASC_SCSIQ_B_SG_QUEUE_CNT 5
  245. #define ASC_SCSIQ_D_DATA_ADDR 8
  246. #define ASC_SCSIQ_D_DATA_CNT 12
  247. #define ASC_SCSIQ_B_SENSE_LEN 20
  248. #define ASC_SCSIQ_DONE_INFO_BEG 22
  249. #define ASC_SCSIQ_D_SRBPTR 22
  250. #define ASC_SCSIQ_B_TARGET_IX 26
  251. #define ASC_SCSIQ_B_CDB_LEN 28
  252. #define ASC_SCSIQ_B_TAG_CODE 29
  253. #define ASC_SCSIQ_W_VM_ID 30
  254. #define ASC_SCSIQ_DONE_STATUS 32
  255. #define ASC_SCSIQ_HOST_STATUS 33
  256. #define ASC_SCSIQ_SCSI_STATUS 34
  257. #define ASC_SCSIQ_CDB_BEG 36
  258. #define ASC_SCSIQ_DW_REMAIN_XFER_ADDR 56
  259. #define ASC_SCSIQ_DW_REMAIN_XFER_CNT 60
  260. #define ASC_SCSIQ_B_FIRST_SG_WK_QP 48
  261. #define ASC_SCSIQ_B_SG_WK_QP 49
  262. #define ASC_SCSIQ_B_SG_WK_IX 50
  263. #define ASC_SCSIQ_W_ALT_DC1 52
  264. #define ASC_SCSIQ_B_LIST_CNT 6
  265. #define ASC_SCSIQ_B_CUR_LIST_CNT 7
  266. #define ASC_SGQ_B_SG_CNTL 4
  267. #define ASC_SGQ_B_SG_HEAD_QP 5
  268. #define ASC_SGQ_B_SG_LIST_CNT 6
  269. #define ASC_SGQ_B_SG_CUR_LIST_CNT 7
  270. #define ASC_SGQ_LIST_BEG 8
  271. #define ASC_DEF_SCSI1_QNG 4
  272. #define ASC_MAX_SCSI1_QNG 4
  273. #define ASC_DEF_SCSI2_QNG 16
  274. #define ASC_MAX_SCSI2_QNG 32
  275. #define ASC_TAG_CODE_MASK 0x23
  276. #define ASC_STOP_REQ_RISC_STOP 0x01
  277. #define ASC_STOP_ACK_RISC_STOP 0x03
  278. #define ASC_STOP_CLEAN_UP_BUSY_Q 0x10
  279. #define ASC_STOP_CLEAN_UP_DISC_Q 0x20
  280. #define ASC_STOP_HOST_REQ_RISC_HALT 0x40
  281. #define ASC_TIDLUN_TO_IX(tid, lun) (ASC_SCSI_TIX_TYPE)((tid) + ((lun)<<ASC_SCSI_ID_BITS))
  282. #define ASC_TID_TO_TARGET_ID(tid) (ASC_SCSI_BIT_ID_TYPE)(0x01 << (tid))
  283. #define ASC_TIX_TO_TARGET_ID(tix) (0x01 << ((tix) & ASC_MAX_TID))
  284. #define ASC_TIX_TO_TID(tix) ((tix) & ASC_MAX_TID)
  285. #define ASC_TID_TO_TIX(tid) ((tid) & ASC_MAX_TID)
  286. #define ASC_TIX_TO_LUN(tix) (((tix) >> ASC_SCSI_ID_BITS) & ASC_MAX_LUN)
  287. #define ASC_QNO_TO_QADDR(q_no) ((ASC_QADR_BEG)+((int)(q_no) << 6))
  288. typedef struct asc_scsiq_1 {
  289. uchar status;
  290. uchar q_no;
  291. uchar cntl;
  292. uchar sg_queue_cnt;
  293. uchar target_id;
  294. uchar target_lun;
  295. ASC_PADDR data_addr;
  296. ASC_DCNT data_cnt;
  297. ASC_PADDR sense_addr;
  298. uchar sense_len;
  299. uchar extra_bytes;
  300. } ASC_SCSIQ_1;
  301. typedef struct asc_scsiq_2 {
  302. ASC_VADDR srb_ptr;
  303. uchar target_ix;
  304. uchar flag;
  305. uchar cdb_len;
  306. uchar tag_code;
  307. ushort vm_id;
  308. } ASC_SCSIQ_2;
  309. typedef struct asc_scsiq_3 {
  310. uchar done_stat;
  311. uchar host_stat;
  312. uchar scsi_stat;
  313. uchar scsi_msg;
  314. } ASC_SCSIQ_3;
  315. typedef struct asc_scsiq_4 {
  316. uchar cdb[ASC_MAX_CDB_LEN];
  317. uchar y_first_sg_list_qp;
  318. uchar y_working_sg_qp;
  319. uchar y_working_sg_ix;
  320. uchar y_res;
  321. ushort x_req_count;
  322. ushort x_reconnect_rtn;
  323. ASC_PADDR x_saved_data_addr;
  324. ASC_DCNT x_saved_data_cnt;
  325. } ASC_SCSIQ_4;
  326. typedef struct asc_q_done_info {
  327. ASC_SCSIQ_2 d2;
  328. ASC_SCSIQ_3 d3;
  329. uchar q_status;
  330. uchar q_no;
  331. uchar cntl;
  332. uchar sense_len;
  333. uchar extra_bytes;
  334. uchar res;
  335. ASC_DCNT remain_bytes;
  336. } ASC_QDONE_INFO;
  337. typedef struct asc_sg_list {
  338. ASC_PADDR addr;
  339. ASC_DCNT bytes;
  340. } ASC_SG_LIST;
  341. typedef struct asc_sg_head {
  342. ushort entry_cnt;
  343. ushort queue_cnt;
  344. ushort entry_to_copy;
  345. ushort res;
  346. ASC_SG_LIST sg_list[0];
  347. } ASC_SG_HEAD;
  348. typedef struct asc_scsi_q {
  349. ASC_SCSIQ_1 q1;
  350. ASC_SCSIQ_2 q2;
  351. uchar *cdbptr;
  352. ASC_SG_HEAD *sg_head;
  353. ushort remain_sg_entry_cnt;
  354. ushort next_sg_index;
  355. } ASC_SCSI_Q;
  356. typedef struct asc_scsi_req_q {
  357. ASC_SCSIQ_1 r1;
  358. ASC_SCSIQ_2 r2;
  359. uchar *cdbptr;
  360. ASC_SG_HEAD *sg_head;
  361. uchar *sense_ptr;
  362. ASC_SCSIQ_3 r3;
  363. uchar cdb[ASC_MAX_CDB_LEN];
  364. uchar sense[ASC_MIN_SENSE_LEN];
  365. } ASC_SCSI_REQ_Q;
  366. typedef struct asc_scsi_bios_req_q {
  367. ASC_SCSIQ_1 r1;
  368. ASC_SCSIQ_2 r2;
  369. uchar *cdbptr;
  370. ASC_SG_HEAD *sg_head;
  371. uchar *sense_ptr;
  372. ASC_SCSIQ_3 r3;
  373. uchar cdb[ASC_MAX_CDB_LEN];
  374. uchar sense[ASC_MIN_SENSE_LEN];
  375. } ASC_SCSI_BIOS_REQ_Q;
  376. typedef struct asc_risc_q {
  377. uchar fwd;
  378. uchar bwd;
  379. ASC_SCSIQ_1 i1;
  380. ASC_SCSIQ_2 i2;
  381. ASC_SCSIQ_3 i3;
  382. ASC_SCSIQ_4 i4;
  383. } ASC_RISC_Q;
  384. typedef struct asc_sg_list_q {
  385. uchar seq_no;
  386. uchar q_no;
  387. uchar cntl;
  388. uchar sg_head_qp;
  389. uchar sg_list_cnt;
  390. uchar sg_cur_list_cnt;
  391. } ASC_SG_LIST_Q;
  392. typedef struct asc_risc_sg_list_q {
  393. uchar fwd;
  394. uchar bwd;
  395. ASC_SG_LIST_Q sg;
  396. ASC_SG_LIST sg_list[7];
  397. } ASC_RISC_SG_LIST_Q;
  398. #define ASCQ_ERR_Q_STATUS 0x0D
  399. #define ASCQ_ERR_CUR_QNG 0x17
  400. #define ASCQ_ERR_SG_Q_LINKS 0x18
  401. #define ASCQ_ERR_ISR_RE_ENTRY 0x1A
  402. #define ASCQ_ERR_CRITICAL_RE_ENTRY 0x1B
  403. #define ASCQ_ERR_ISR_ON_CRITICAL 0x1C
  404. /*
  405. * Warning code values are set in ASC_DVC_VAR 'warn_code'.
  406. */
  407. #define ASC_WARN_NO_ERROR 0x0000
  408. #define ASC_WARN_IO_PORT_ROTATE 0x0001
  409. #define ASC_WARN_EEPROM_CHKSUM 0x0002
  410. #define ASC_WARN_IRQ_MODIFIED 0x0004
  411. #define ASC_WARN_AUTO_CONFIG 0x0008
  412. #define ASC_WARN_CMD_QNG_CONFLICT 0x0010
  413. #define ASC_WARN_EEPROM_RECOVER 0x0020
  414. #define ASC_WARN_CFG_MSW_RECOVER 0x0040
  415. /*
  416. * Error code values are set in {ASC/ADV}_DVC_VAR 'err_code'.
  417. */
  418. #define ASC_IERR_NO_CARRIER 0x0001 /* No more carrier memory */
  419. #define ASC_IERR_MCODE_CHKSUM 0x0002 /* micro code check sum error */
  420. #define ASC_IERR_SET_PC_ADDR 0x0004
  421. #define ASC_IERR_START_STOP_CHIP 0x0008 /* start/stop chip failed */
  422. #define ASC_IERR_ILLEGAL_CONNECTION 0x0010 /* Illegal cable connection */
  423. #define ASC_IERR_SINGLE_END_DEVICE 0x0020 /* SE device on DIFF bus */
  424. #define ASC_IERR_REVERSED_CABLE 0x0040 /* Narrow flat cable reversed */
  425. #define ASC_IERR_SET_SCSI_ID 0x0080 /* set SCSI ID failed */
  426. #define ASC_IERR_HVD_DEVICE 0x0100 /* HVD device on LVD port */
  427. #define ASC_IERR_BAD_SIGNATURE 0x0200 /* signature not found */
  428. #define ASC_IERR_NO_BUS_TYPE 0x0400
  429. #define ASC_IERR_BIST_PRE_TEST 0x0800 /* BIST pre-test error */
  430. #define ASC_IERR_BIST_RAM_TEST 0x1000 /* BIST RAM test error */
  431. #define ASC_IERR_BAD_CHIPTYPE 0x2000 /* Invalid chip_type setting */
  432. #define ASC_DEF_MAX_TOTAL_QNG (0xF0)
  433. #define ASC_MIN_TAG_Q_PER_DVC (0x04)
  434. #define ASC_MIN_FREE_Q (0x02)
  435. #define ASC_MIN_TOTAL_QNG ((ASC_MAX_SG_QUEUE)+(ASC_MIN_FREE_Q))
  436. #define ASC_MAX_TOTAL_QNG 240
  437. #define ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG 16
  438. #define ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG 8
  439. #define ASC_MAX_PCI_INRAM_TOTAL_QNG 20
  440. #define ASC_MAX_INRAM_TAG_QNG 16
  441. #define ASC_IOADR_GAP 0x10
  442. #define ASC_SYN_MAX_OFFSET 0x0F
  443. #define ASC_DEF_SDTR_OFFSET 0x0F
  444. #define ASC_SDTR_ULTRA_PCI_10MB_INDEX 0x02
  445. #define ASYN_SDTR_DATA_FIX_PCI_REV_AB 0x41
  446. /* The narrow chip only supports a limited selection of transfer rates.
  447. * These are encoded in the range 0..7 or 0..15 depending whether the chip
  448. * is Ultra-capable or not. These tables let us convert from one to the other.
  449. */
  450. static const unsigned char asc_syn_xfer_period[8] = {
  451. 25, 30, 35, 40, 50, 60, 70, 85
  452. };
  453. static const unsigned char asc_syn_ultra_xfer_period[16] = {
  454. 12, 19, 25, 32, 38, 44, 50, 57, 63, 69, 75, 82, 88, 94, 100, 107
  455. };
  456. typedef struct ext_msg {
  457. uchar msg_type;
  458. uchar msg_len;
  459. uchar msg_req;
  460. union {
  461. struct {
  462. uchar sdtr_xfer_period;
  463. uchar sdtr_req_ack_offset;
  464. } sdtr;
  465. struct {
  466. uchar wdtr_width;
  467. } wdtr;
  468. struct {
  469. uchar mdp_b3;
  470. uchar mdp_b2;
  471. uchar mdp_b1;
  472. uchar mdp_b0;
  473. } mdp;
  474. } u_ext_msg;
  475. uchar res;
  476. } EXT_MSG;
  477. #define xfer_period u_ext_msg.sdtr.sdtr_xfer_period
  478. #define req_ack_offset u_ext_msg.sdtr.sdtr_req_ack_offset
  479. #define wdtr_width u_ext_msg.wdtr.wdtr_width
  480. #define mdp_b3 u_ext_msg.mdp_b3
  481. #define mdp_b2 u_ext_msg.mdp_b2
  482. #define mdp_b1 u_ext_msg.mdp_b1
  483. #define mdp_b0 u_ext_msg.mdp_b0
  484. typedef struct asc_dvc_cfg {
  485. ASC_SCSI_BIT_ID_TYPE can_tagged_qng;
  486. ASC_SCSI_BIT_ID_TYPE cmd_qng_enabled;
  487. ASC_SCSI_BIT_ID_TYPE disc_enable;
  488. ASC_SCSI_BIT_ID_TYPE sdtr_enable;
  489. uchar chip_scsi_id;
  490. uchar isa_dma_speed;
  491. uchar isa_dma_channel;
  492. uchar chip_version;
  493. ushort mcode_date;
  494. ushort mcode_version;
  495. uchar max_tag_qng[ASC_MAX_TID + 1];
  496. uchar *overrun_buf;
  497. uchar sdtr_period_offset[ASC_MAX_TID + 1];
  498. uchar adapter_info[6];
  499. } ASC_DVC_CFG;
  500. #define ASC_DEF_DVC_CNTL 0xFFFF
  501. #define ASC_DEF_CHIP_SCSI_ID 7
  502. #define ASC_DEF_ISA_DMA_SPEED 4
  503. #define ASC_INIT_STATE_BEG_GET_CFG 0x0001
  504. #define ASC_INIT_STATE_END_GET_CFG 0x0002
  505. #define ASC_INIT_STATE_BEG_SET_CFG 0x0004
  506. #define ASC_INIT_STATE_END_SET_CFG 0x0008
  507. #define ASC_INIT_STATE_BEG_LOAD_MC 0x0010
  508. #define ASC_INIT_STATE_END_LOAD_MC 0x0020
  509. #define ASC_INIT_STATE_BEG_INQUIRY 0x0040
  510. #define ASC_INIT_STATE_END_INQUIRY 0x0080
  511. #define ASC_INIT_RESET_SCSI_DONE 0x0100
  512. #define ASC_INIT_STATE_WITHOUT_EEP 0x8000
  513. #define ASC_BUG_FIX_IF_NOT_DWB 0x0001
  514. #define ASC_BUG_FIX_ASYN_USE_SYN 0x0002
  515. #define ASC_MIN_TAGGED_CMD 7
  516. #define ASC_MAX_SCSI_RESET_WAIT 30
  517. struct asc_dvc_var; /* Forward Declaration. */
  518. typedef struct asc_dvc_var {
  519. PortAddr iop_base;
  520. ushort err_code;
  521. ushort dvc_cntl;
  522. ushort bug_fix_cntl;
  523. ushort bus_type;
  524. ASC_SCSI_BIT_ID_TYPE init_sdtr;
  525. ASC_SCSI_BIT_ID_TYPE sdtr_done;
  526. ASC_SCSI_BIT_ID_TYPE use_tagged_qng;
  527. ASC_SCSI_BIT_ID_TYPE unit_not_ready;
  528. ASC_SCSI_BIT_ID_TYPE queue_full_or_busy;
  529. ASC_SCSI_BIT_ID_TYPE start_motor;
  530. uchar scsi_reset_wait;
  531. uchar chip_no;
  532. char is_in_int;
  533. uchar max_total_qng;
  534. uchar cur_total_qng;
  535. uchar in_critical_cnt;
  536. uchar last_q_shortage;
  537. ushort init_state;
  538. uchar cur_dvc_qng[ASC_MAX_TID + 1];
  539. uchar max_dvc_qng[ASC_MAX_TID + 1];
  540. ASC_SCSI_Q *scsiq_busy_head[ASC_MAX_TID + 1];
  541. ASC_SCSI_Q *scsiq_busy_tail[ASC_MAX_TID + 1];
  542. const uchar *sdtr_period_tbl;
  543. ASC_DVC_CFG *cfg;
  544. ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer_always;
  545. char redo_scam;
  546. ushort res2;
  547. uchar dos_int13_table[ASC_MAX_TID + 1];
  548. ASC_DCNT max_dma_count;
  549. ASC_SCSI_BIT_ID_TYPE no_scam;
  550. ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer;
  551. uchar min_sdtr_index;
  552. uchar max_sdtr_index;
  553. struct asc_board *drv_ptr;
  554. ASC_DCNT uc_break;
  555. } ASC_DVC_VAR;
  556. typedef struct asc_dvc_inq_info {
  557. uchar type[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
  558. } ASC_DVC_INQ_INFO;
  559. typedef struct asc_cap_info {
  560. ASC_DCNT lba;
  561. ASC_DCNT blk_size;
  562. } ASC_CAP_INFO;
  563. typedef struct asc_cap_info_array {
  564. ASC_CAP_INFO cap_info[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
  565. } ASC_CAP_INFO_ARRAY;
  566. #define ASC_MCNTL_NO_SEL_TIMEOUT (ushort)0x0001
  567. #define ASC_MCNTL_NULL_TARGET (ushort)0x0002
  568. #define ASC_CNTL_INITIATOR (ushort)0x0001
  569. #define ASC_CNTL_BIOS_GT_1GB (ushort)0x0002
  570. #define ASC_CNTL_BIOS_GT_2_DISK (ushort)0x0004
  571. #define ASC_CNTL_BIOS_REMOVABLE (ushort)0x0008
  572. #define ASC_CNTL_NO_SCAM (ushort)0x0010
  573. #define ASC_CNTL_INT_MULTI_Q (ushort)0x0080
  574. #define ASC_CNTL_NO_LUN_SUPPORT (ushort)0x0040
  575. #define ASC_CNTL_NO_VERIFY_COPY (ushort)0x0100
  576. #define ASC_CNTL_RESET_SCSI (ushort)0x0200
  577. #define ASC_CNTL_INIT_INQUIRY (ushort)0x0400
  578. #define ASC_CNTL_INIT_VERBOSE (ushort)0x0800
  579. #define ASC_CNTL_SCSI_PARITY (ushort)0x1000
  580. #define ASC_CNTL_BURST_MODE (ushort)0x2000
  581. #define ASC_CNTL_SDTR_ENABLE_ULTRA (ushort)0x4000
  582. #define ASC_EEP_DVC_CFG_BEG_VL 2
  583. #define ASC_EEP_MAX_DVC_ADDR_VL 15
  584. #define ASC_EEP_DVC_CFG_BEG 32
  585. #define ASC_EEP_MAX_DVC_ADDR 45
  586. #define ASC_EEP_MAX_RETRY 20
  587. /*
  588. * These macros keep the chip SCSI id and ISA DMA speed
  589. * bitfields in board order. C bitfields aren't portable
  590. * between big and little-endian platforms so they are
  591. * not used.
  592. */
  593. #define ASC_EEP_GET_CHIP_ID(cfg) ((cfg)->id_speed & 0x0f)
  594. #define ASC_EEP_GET_DMA_SPD(cfg) (((cfg)->id_speed & 0xf0) >> 4)
  595. #define ASC_EEP_SET_CHIP_ID(cfg, sid) \
  596. ((cfg)->id_speed = ((cfg)->id_speed & 0xf0) | ((sid) & ASC_MAX_TID))
  597. #define ASC_EEP_SET_DMA_SPD(cfg, spd) \
  598. ((cfg)->id_speed = ((cfg)->id_speed & 0x0f) | ((spd) & 0x0f) << 4)
  599. typedef struct asceep_config {
  600. ushort cfg_lsw;
  601. ushort cfg_msw;
  602. uchar init_sdtr;
  603. uchar disc_enable;
  604. uchar use_cmd_qng;
  605. uchar start_motor;
  606. uchar max_total_qng;
  607. uchar max_tag_qng;
  608. uchar bios_scan;
  609. uchar power_up_wait;
  610. uchar no_scam;
  611. uchar id_speed; /* low order 4 bits is chip scsi id */
  612. /* high order 4 bits is isa dma speed */
  613. uchar dos_int13_table[ASC_MAX_TID + 1];
  614. uchar adapter_info[6];
  615. ushort cntl;
  616. ushort chksum;
  617. } ASCEEP_CONFIG;
  618. #define ASC_EEP_CMD_READ 0x80
  619. #define ASC_EEP_CMD_WRITE 0x40
  620. #define ASC_EEP_CMD_WRITE_ABLE 0x30
  621. #define ASC_EEP_CMD_WRITE_DISABLE 0x00
  622. #define ASC_OVERRUN_BSIZE 0x00000048UL
  623. #define ASCV_MSGOUT_BEG 0x0000
  624. #define ASCV_MSGOUT_SDTR_PERIOD (ASCV_MSGOUT_BEG+3)
  625. #define ASCV_MSGOUT_SDTR_OFFSET (ASCV_MSGOUT_BEG+4)
  626. #define ASCV_BREAK_SAVED_CODE (ushort)0x0006
  627. #define ASCV_MSGIN_BEG (ASCV_MSGOUT_BEG+8)
  628. #define ASCV_MSGIN_SDTR_PERIOD (ASCV_MSGIN_BEG+3)
  629. #define ASCV_MSGIN_SDTR_OFFSET (ASCV_MSGIN_BEG+4)
  630. #define ASCV_SDTR_DATA_BEG (ASCV_MSGIN_BEG+8)
  631. #define ASCV_SDTR_DONE_BEG (ASCV_SDTR_DATA_BEG+8)
  632. #define ASCV_MAX_DVC_QNG_BEG (ushort)0x0020
  633. #define ASCV_BREAK_ADDR (ushort)0x0028
  634. #define ASCV_BREAK_NOTIFY_COUNT (ushort)0x002A
  635. #define ASCV_BREAK_CONTROL (ushort)0x002C
  636. #define ASCV_BREAK_HIT_COUNT (ushort)0x002E
  637. #define ASCV_ASCDVC_ERR_CODE_W (ushort)0x0030
  638. #define ASCV_MCODE_CHKSUM_W (ushort)0x0032
  639. #define ASCV_MCODE_SIZE_W (ushort)0x0034
  640. #define ASCV_STOP_CODE_B (ushort)0x0036
  641. #define ASCV_DVC_ERR_CODE_B (ushort)0x0037
  642. #define ASCV_OVERRUN_PADDR_D (ushort)0x0038
  643. #define ASCV_OVERRUN_BSIZE_D (ushort)0x003C
  644. #define ASCV_HALTCODE_W (ushort)0x0040
  645. #define ASCV_CHKSUM_W (ushort)0x0042
  646. #define ASCV_MC_DATE_W (ushort)0x0044
  647. #define ASCV_MC_VER_W (ushort)0x0046
  648. #define ASCV_NEXTRDY_B (ushort)0x0048
  649. #define ASCV_DONENEXT_B (ushort)0x0049
  650. #define ASCV_USE_TAGGED_QNG_B (ushort)0x004A
  651. #define ASCV_SCSIBUSY_B (ushort)0x004B
  652. #define ASCV_Q_DONE_IN_PROGRESS_B (ushort)0x004C
  653. #define ASCV_CURCDB_B (ushort)0x004D
  654. #define ASCV_RCLUN_B (ushort)0x004E
  655. #define ASCV_BUSY_QHEAD_B (ushort)0x004F
  656. #define ASCV_DISC1_QHEAD_B (ushort)0x0050
  657. #define ASCV_DISC_ENABLE_B (ushort)0x0052
  658. #define ASCV_CAN_TAGGED_QNG_B (ushort)0x0053
  659. #define ASCV_HOSTSCSI_ID_B (ushort)0x0055
  660. #define ASCV_MCODE_CNTL_B (ushort)0x0056
  661. #define ASCV_NULL_TARGET_B (ushort)0x0057
  662. #define ASCV_FREE_Q_HEAD_W (ushort)0x0058
  663. #define ASCV_DONE_Q_TAIL_W (ushort)0x005A
  664. #define ASCV_FREE_Q_HEAD_B (ushort)(ASCV_FREE_Q_HEAD_W+1)
  665. #define ASCV_DONE_Q_TAIL_B (ushort)(ASCV_DONE_Q_TAIL_W+1)
  666. #define ASCV_HOST_FLAG_B (ushort)0x005D
  667. #define ASCV_TOTAL_READY_Q_B (ushort)0x0064
  668. #define ASCV_VER_SERIAL_B (ushort)0x0065
  669. #define ASCV_HALTCODE_SAVED_W (ushort)0x0066
  670. #define ASCV_WTM_FLAG_B (ushort)0x0068
  671. #define ASCV_RISC_FLAG_B (ushort)0x006A
  672. #define ASCV_REQ_SG_LIST_QP (ushort)0x006B
  673. #define ASC_HOST_FLAG_IN_ISR 0x01
  674. #define ASC_HOST_FLAG_ACK_INT 0x02
  675. #define ASC_RISC_FLAG_GEN_INT 0x01
  676. #define ASC_RISC_FLAG_REQ_SG_LIST 0x02
  677. #define IOP_CTRL (0x0F)
  678. #define IOP_STATUS (0x0E)
  679. #define IOP_INT_ACK IOP_STATUS
  680. #define IOP_REG_IFC (0x0D)
  681. #define IOP_SYN_OFFSET (0x0B)
  682. #define IOP_EXTRA_CONTROL (0x0D)
  683. #define IOP_REG_PC (0x0C)
  684. #define IOP_RAM_ADDR (0x0A)
  685. #define IOP_RAM_DATA (0x08)
  686. #define IOP_EEP_DATA (0x06)
  687. #define IOP_EEP_CMD (0x07)
  688. #define IOP_VERSION (0x03)
  689. #define IOP_CONFIG_HIGH (0x04)
  690. #define IOP_CONFIG_LOW (0x02)
  691. #define IOP_SIG_BYTE (0x01)
  692. #define IOP_SIG_WORD (0x00)
  693. #define IOP_REG_DC1 (0x0E)
  694. #define IOP_REG_DC0 (0x0C)
  695. #define IOP_REG_SB (0x0B)
  696. #define IOP_REG_DA1 (0x0A)
  697. #define IOP_REG_DA0 (0x08)
  698. #define IOP_REG_SC (0x09)
  699. #define IOP_DMA_SPEED (0x07)
  700. #define IOP_REG_FLAG (0x07)
  701. #define IOP_FIFO_H (0x06)
  702. #define IOP_FIFO_L (0x04)
  703. #define IOP_REG_ID (0x05)
  704. #define IOP_REG_QP (0x03)
  705. #define IOP_REG_IH (0x02)
  706. #define IOP_REG_IX (0x01)
  707. #define IOP_REG_AX (0x00)
  708. #define IFC_REG_LOCK (0x00)
  709. #define IFC_REG_UNLOCK (0x09)
  710. #define IFC_WR_EN_FILTER (0x10)
  711. #define IFC_RD_NO_EEPROM (0x10)
  712. #define IFC_SLEW_RATE (0x20)
  713. #define IFC_ACT_NEG (0x40)
  714. #define IFC_INP_FILTER (0x80)
  715. #define IFC_INIT_DEFAULT (IFC_ACT_NEG | IFC_REG_UNLOCK)
  716. #define SC_SEL (uchar)(0x80)
  717. #define SC_BSY (uchar)(0x40)
  718. #define SC_ACK (uchar)(0x20)
  719. #define SC_REQ (uchar)(0x10)
  720. #define SC_ATN (uchar)(0x08)
  721. #define SC_IO (uchar)(0x04)
  722. #define SC_CD (uchar)(0x02)
  723. #define SC_MSG (uchar)(0x01)
  724. #define SEC_SCSI_CTL (uchar)(0x80)
  725. #define SEC_ACTIVE_NEGATE (uchar)(0x40)
  726. #define SEC_SLEW_RATE (uchar)(0x20)
  727. #define SEC_ENABLE_FILTER (uchar)(0x10)
  728. #define ASC_HALT_EXTMSG_IN (ushort)0x8000
  729. #define ASC_HALT_CHK_CONDITION (ushort)0x8100
  730. #define ASC_HALT_SS_QUEUE_FULL (ushort)0x8200
  731. #define ASC_HALT_DISABLE_ASYN_USE_SYN_FIX (ushort)0x8300
  732. #define ASC_HALT_ENABLE_ASYN_USE_SYN_FIX (ushort)0x8400
  733. #define ASC_HALT_SDTR_REJECTED (ushort)0x4000
  734. #define ASC_HALT_HOST_COPY_SG_LIST_TO_RISC ( ushort )0x2000
  735. #define ASC_MAX_QNO 0xF8
  736. #define ASC_DATA_SEC_BEG (ushort)0x0080
  737. #define ASC_DATA_SEC_END (ushort)0x0080
  738. #define ASC_CODE_SEC_BEG (ushort)0x0080
  739. #define ASC_CODE_SEC_END (ushort)0x0080
  740. #define ASC_QADR_BEG (0x4000)
  741. #define ASC_QADR_USED (ushort)(ASC_MAX_QNO * 64)
  742. #define ASC_QADR_END (ushort)0x7FFF
  743. #define ASC_QLAST_ADR (ushort)0x7FC0
  744. #define ASC_QBLK_SIZE 0x40
  745. #define ASC_BIOS_DATA_QBEG 0xF8
  746. #define ASC_MIN_ACTIVE_QNO 0x01
  747. #define ASC_QLINK_END 0xFF
  748. #define ASC_EEPROM_WORDS 0x10
  749. #define ASC_MAX_MGS_LEN 0x10
  750. #define ASC_BIOS_ADDR_DEF 0xDC00
  751. #define ASC_BIOS_SIZE 0x3800
  752. #define ASC_BIOS_RAM_OFF 0x3800
  753. #define ASC_BIOS_RAM_SIZE 0x800
  754. #define ASC_BIOS_MIN_ADDR 0xC000
  755. #define ASC_BIOS_MAX_ADDR 0xEC00
  756. #define ASC_BIOS_BANK_SIZE 0x0400
  757. #define ASC_MCODE_START_ADDR 0x0080
  758. #define ASC_CFG0_HOST_INT_ON 0x0020
  759. #define ASC_CFG0_BIOS_ON 0x0040
  760. #define ASC_CFG0_VERA_BURST_ON 0x0080
  761. #define ASC_CFG0_SCSI_PARITY_ON 0x0800
  762. #define ASC_CFG1_SCSI_TARGET_ON 0x0080
  763. #define ASC_CFG1_LRAM_8BITS_ON 0x0800
  764. #define ASC_CFG_MSW_CLR_MASK 0x3080
  765. #define CSW_TEST1 (ASC_CS_TYPE)0x8000
  766. #define CSW_AUTO_CONFIG (ASC_CS_TYPE)0x4000
  767. #define CSW_RESERVED1 (ASC_CS_TYPE)0x2000
  768. #define CSW_IRQ_WRITTEN (ASC_CS_TYPE)0x1000
  769. #define CSW_33MHZ_SELECTED (ASC_CS_TYPE)0x0800
  770. #define CSW_TEST2 (ASC_CS_TYPE)0x0400
  771. #define CSW_TEST3 (ASC_CS_TYPE)0x0200
  772. #define CSW_RESERVED2 (ASC_CS_TYPE)0x0100
  773. #define CSW_DMA_DONE (ASC_CS_TYPE)0x0080
  774. #define CSW_FIFO_RDY (ASC_CS_TYPE)0x0040
  775. #define CSW_EEP_READ_DONE (ASC_CS_TYPE)0x0020
  776. #define CSW_HALTED (ASC_CS_TYPE)0x0010
  777. #define CSW_SCSI_RESET_ACTIVE (ASC_CS_TYPE)0x0008
  778. #define CSW_PARITY_ERR (ASC_CS_TYPE)0x0004
  779. #define CSW_SCSI_RESET_LATCH (ASC_CS_TYPE)0x0002
  780. #define CSW_INT_PENDING (ASC_CS_TYPE)0x0001
  781. #define CIW_CLR_SCSI_RESET_INT (ASC_CS_TYPE)0x1000
  782. #define CIW_INT_ACK (ASC_CS_TYPE)0x0100
  783. #define CIW_TEST1 (ASC_CS_TYPE)0x0200
  784. #define CIW_TEST2 (ASC_CS_TYPE)0x0400
  785. #define CIW_SEL_33MHZ (ASC_CS_TYPE)0x0800
  786. #define CIW_IRQ_ACT (ASC_CS_TYPE)0x1000
  787. #define CC_CHIP_RESET (uchar)0x80
  788. #define CC_SCSI_RESET (uchar)0x40
  789. #define CC_HALT (uchar)0x20
  790. #define CC_SINGLE_STEP (uchar)0x10
  791. #define CC_DMA_ABLE (uchar)0x08
  792. #define CC_TEST (uchar)0x04
  793. #define CC_BANK_ONE (uchar)0x02
  794. #define CC_DIAG (uchar)0x01
  795. #define ASC_1000_ID0W 0x04C1
  796. #define ASC_1000_ID0W_FIX 0x00C1
  797. #define ASC_1000_ID1B 0x25
  798. #define ASC_EISA_REV_IOP_MASK (0x0C83)
  799. #define ASC_EISA_CFG_IOP_MASK (0x0C86)
  800. #define ASC_GET_EISA_SLOT(iop) (PortAddr)((iop) & 0xF000)
  801. #define INS_HALTINT (ushort)0x6281
  802. #define INS_HALT (ushort)0x6280
  803. #define INS_SINT (ushort)0x6200
  804. #define INS_RFLAG_WTM (ushort)0x7380
  805. #define ASC_MC_SAVE_CODE_WSIZE 0x500
  806. #define ASC_MC_SAVE_DATA_WSIZE 0x40
  807. typedef struct asc_mc_saved {
  808. ushort data[ASC_MC_SAVE_DATA_WSIZE];
  809. ushort code[ASC_MC_SAVE_CODE_WSIZE];
  810. } ASC_MC_SAVED;
  811. #define AscGetQDoneInProgress(port) AscReadLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B)
  812. #define AscPutQDoneInProgress(port, val) AscWriteLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B, val)
  813. #define AscGetVarFreeQHead(port) AscReadLramWord((port), ASCV_FREE_Q_HEAD_W)
  814. #define AscGetVarDoneQTail(port) AscReadLramWord((port), ASCV_DONE_Q_TAIL_W)
  815. #define AscPutVarFreeQHead(port, val) AscWriteLramWord((port), ASCV_FREE_Q_HEAD_W, val)
  816. #define AscPutVarDoneQTail(port, val) AscWriteLramWord((port), ASCV_DONE_Q_TAIL_W, val)
  817. #define AscGetRiscVarFreeQHead(port) AscReadLramByte((port), ASCV_NEXTRDY_B)
  818. #define AscGetRiscVarDoneQTail(port) AscReadLramByte((port), ASCV_DONENEXT_B)
  819. #define AscPutRiscVarFreeQHead(port, val) AscWriteLramByte((port), ASCV_NEXTRDY_B, val)
  820. #define AscPutRiscVarDoneQTail(port, val) AscWriteLramByte((port), ASCV_DONENEXT_B, val)
  821. #define AscPutMCodeSDTRDoneAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id), (data))
  822. #define AscGetMCodeSDTRDoneAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id))
  823. #define AscPutMCodeInitSDTRAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id), data)
  824. #define AscGetMCodeInitSDTRAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id))
  825. #define AscGetChipSignatureByte(port) (uchar)inp((port)+IOP_SIG_BYTE)
  826. #define AscGetChipSignatureWord(port) (ushort)inpw((port)+IOP_SIG_WORD)
  827. #define AscGetChipVerNo(port) (uchar)inp((port)+IOP_VERSION)
  828. #define AscGetChipCfgLsw(port) (ushort)inpw((port)+IOP_CONFIG_LOW)
  829. #define AscGetChipCfgMsw(port) (ushort)inpw((port)+IOP_CONFIG_HIGH)
  830. #define AscSetChipCfgLsw(port, data) outpw((port)+IOP_CONFIG_LOW, data)
  831. #define AscSetChipCfgMsw(port, data) outpw((port)+IOP_CONFIG_HIGH, data)
  832. #define AscGetChipEEPCmd(port) (uchar)inp((port)+IOP_EEP_CMD)
  833. #define AscSetChipEEPCmd(port, data) outp((port)+IOP_EEP_CMD, data)
  834. #define AscGetChipEEPData(port) (ushort)inpw((port)+IOP_EEP_DATA)
  835. #define AscSetChipEEPData(port, data) outpw((port)+IOP_EEP_DATA, data)
  836. #define AscGetChipLramAddr(port) (ushort)inpw((PortAddr)((port)+IOP_RAM_ADDR))
  837. #define AscSetChipLramAddr(port, addr) outpw((PortAddr)((port)+IOP_RAM_ADDR), addr)
  838. #define AscGetChipLramData(port) (ushort)inpw((port)+IOP_RAM_DATA)
  839. #define AscSetChipLramData(port, data) outpw((port)+IOP_RAM_DATA, data)
  840. #define AscGetChipIFC(port) (uchar)inp((port)+IOP_REG_IFC)
  841. #define AscSetChipIFC(port, data) outp((port)+IOP_REG_IFC, data)
  842. #define AscGetChipStatus(port) (ASC_CS_TYPE)inpw((port)+IOP_STATUS)
  843. #define AscSetChipStatus(port, cs_val) outpw((port)+IOP_STATUS, cs_val)
  844. #define AscGetChipControl(port) (uchar)inp((port)+IOP_CTRL)
  845. #define AscSetChipControl(port, cc_val) outp((port)+IOP_CTRL, cc_val)
  846. #define AscGetChipSyn(port) (uchar)inp((port)+IOP_SYN_OFFSET)
  847. #define AscSetChipSyn(port, data) outp((port)+IOP_SYN_OFFSET, data)
  848. #define AscSetPCAddr(port, data) outpw((port)+IOP_REG_PC, data)
  849. #define AscGetPCAddr(port) (ushort)inpw((port)+IOP_REG_PC)
  850. #define AscIsIntPending(port) (AscGetChipStatus(port) & (CSW_INT_PENDING | CSW_SCSI_RESET_LATCH))
  851. #define AscGetChipScsiID(port) ((AscGetChipCfgLsw(port) >> 8) & ASC_MAX_TID)
  852. #define AscGetExtraControl(port) (uchar)inp((port)+IOP_EXTRA_CONTROL)
  853. #define AscSetExtraControl(port, data) outp((port)+IOP_EXTRA_CONTROL, data)
  854. #define AscReadChipAX(port) (ushort)inpw((port)+IOP_REG_AX)
  855. #define AscWriteChipAX(port, data) outpw((port)+IOP_REG_AX, data)
  856. #define AscReadChipIX(port) (uchar)inp((port)+IOP_REG_IX)
  857. #define AscWriteChipIX(port, data) outp((port)+IOP_REG_IX, data)
  858. #define AscReadChipIH(port) (ushort)inpw((port)+IOP_REG_IH)
  859. #define AscWriteChipIH(port, data) outpw((port)+IOP_REG_IH, data)
  860. #define AscReadChipQP(port) (uchar)inp((port)+IOP_REG_QP)
  861. #define AscWriteChipQP(port, data) outp((port)+IOP_REG_QP, data)
  862. #define AscReadChipFIFO_L(port) (ushort)inpw((port)+IOP_REG_FIFO_L)
  863. #define AscWriteChipFIFO_L(port, data) outpw((port)+IOP_REG_FIFO_L, data)
  864. #define AscReadChipFIFO_H(port) (ushort)inpw((port)+IOP_REG_FIFO_H)
  865. #define AscWriteChipFIFO_H(port, data) outpw((port)+IOP_REG_FIFO_H, data)
  866. #define AscReadChipDmaSpeed(port) (uchar)inp((port)+IOP_DMA_SPEED)
  867. #define AscWriteChipDmaSpeed(port, data) outp((port)+IOP_DMA_SPEED, data)
  868. #define AscReadChipDA0(port) (ushort)inpw((port)+IOP_REG_DA0)
  869. #define AscWriteChipDA0(port) outpw((port)+IOP_REG_DA0, data)
  870. #define AscReadChipDA1(port) (ushort)inpw((port)+IOP_REG_DA1)
  871. #define AscWriteChipDA1(port) outpw((port)+IOP_REG_DA1, data)
  872. #define AscReadChipDC0(port) (ushort)inpw((port)+IOP_REG_DC0)
  873. #define AscWriteChipDC0(port) outpw((port)+IOP_REG_DC0, data)
  874. #define AscReadChipDC1(port) (ushort)inpw((port)+IOP_REG_DC1)
  875. #define AscWriteChipDC1(port) outpw((port)+IOP_REG_DC1, data)
  876. #define AscReadChipDvcID(port) (uchar)inp((port)+IOP_REG_ID)
  877. #define AscWriteChipDvcID(port, data) outp((port)+IOP_REG_ID, data)
  878. /*
  879. * Portable Data Types
  880. *
  881. * Any instance where a 32-bit long or pointer type is assumed
  882. * for precision or HW defined structures, the following define
  883. * types must be used. In Linux the char, short, and int types
  884. * are all consistent at 8, 16, and 32 bits respectively. Pointers
  885. * and long types are 64 bits on Alpha and UltraSPARC.
  886. */
  887. #define ADV_PADDR __u32 /* Physical address data type. */
  888. #define ADV_VADDR __u32 /* Virtual address data type. */
  889. #define ADV_DCNT __u32 /* Unsigned Data count type. */
  890. #define ADV_SDCNT __s32 /* Signed Data count type. */
  891. /*
  892. * These macros are used to convert a virtual address to a
  893. * 32-bit value. This currently can be used on Linux Alpha
  894. * which uses 64-bit virtual address but a 32-bit bus address.
  895. * This is likely to break in the future, but doing this now
  896. * will give us time to change the HW and FW to handle 64-bit
  897. * addresses.
  898. */
  899. #define ADV_VADDR_TO_U32 virt_to_bus
  900. #define ADV_U32_TO_VADDR bus_to_virt
  901. #define AdvPortAddr void __iomem * /* Virtual memory address size */
  902. /*
  903. * Define Adv Library required memory access macros.
  904. */
  905. #define ADV_MEM_READB(addr) readb(addr)
  906. #define ADV_MEM_READW(addr) readw(addr)
  907. #define ADV_MEM_WRITEB(addr, byte) writeb(byte, addr)
  908. #define ADV_MEM_WRITEW(addr, word) writew(word, addr)
  909. #define ADV_MEM_WRITEDW(addr, dword) writel(dword, addr)
  910. #define ADV_CARRIER_COUNT (ASC_DEF_MAX_HOST_QNG + 15)
  911. /*
  912. * Define total number of simultaneous maximum element scatter-gather
  913. * request blocks per wide adapter. ASC_DEF_MAX_HOST_QNG (253) is the
  914. * maximum number of outstanding commands per wide host adapter. Each
  915. * command uses one or more ADV_SG_BLOCK each with 15 scatter-gather
  916. * elements. Allow each command to have at least one ADV_SG_BLOCK structure.
  917. * This allows about 15 commands to have the maximum 17 ADV_SG_BLOCK
  918. * structures or 255 scatter-gather elements.
  919. */
  920. #define ADV_TOT_SG_BLOCK ASC_DEF_MAX_HOST_QNG
  921. /*
  922. * Define maximum number of scatter-gather elements per request.
  923. */
  924. #define ADV_MAX_SG_LIST 255
  925. #define NO_OF_SG_PER_BLOCK 15
  926. #define ADV_EEP_DVC_CFG_BEGIN (0x00)
  927. #define ADV_EEP_DVC_CFG_END (0x15)
  928. #define ADV_EEP_DVC_CTL_BEGIN (0x16) /* location of OEM name */
  929. #define ADV_EEP_MAX_WORD_ADDR (0x1E)
  930. #define ADV_EEP_DELAY_MS 100
  931. #define ADV_EEPROM_BIG_ENDIAN 0x8000 /* EEPROM Bit 15 */
  932. #define ADV_EEPROM_BIOS_ENABLE 0x4000 /* EEPROM Bit 14 */
  933. /*
  934. * For the ASC3550 Bit 13 is Termination Polarity control bit.
  935. * For later ICs Bit 13 controls whether the CIS (Card Information
  936. * Service Section) is loaded from EEPROM.
  937. */
  938. #define ADV_EEPROM_TERM_POL 0x2000 /* EEPROM Bit 13 */
  939. #define ADV_EEPROM_CIS_LD 0x2000 /* EEPROM Bit 13 */
  940. /*
  941. * ASC38C1600 Bit 11
  942. *
  943. * If EEPROM Bit 11 is 0 for Function 0, then Function 0 will specify
  944. * INT A in the PCI Configuration Space Int Pin field. If it is 1, then
  945. * Function 0 will specify INT B.
  946. *
  947. * If EEPROM Bit 11 is 0 for Function 1, then Function 1 will specify
  948. * INT B in the PCI Configuration Space Int Pin field. If it is 1, then
  949. * Function 1 will specify INT A.
  950. */
  951. #define ADV_EEPROM_INTAB 0x0800 /* EEPROM Bit 11 */
  952. typedef struct adveep_3550_config {
  953. /* Word Offset, Description */
  954. ushort cfg_lsw; /* 00 power up initialization */
  955. /* bit 13 set - Term Polarity Control */
  956. /* bit 14 set - BIOS Enable */
  957. /* bit 15 set - Big Endian Mode */
  958. ushort cfg_msw; /* 01 unused */
  959. ushort disc_enable; /* 02 disconnect enable */
  960. ushort wdtr_able; /* 03 Wide DTR able */
  961. ushort sdtr_able; /* 04 Synchronous DTR able */
  962. ushort start_motor; /* 05 send start up motor */
  963. ushort tagqng_able; /* 06 tag queuing able */
  964. ushort bios_scan; /* 07 BIOS device control */
  965. ushort scam_tolerant; /* 08 no scam */
  966. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  967. uchar bios_boot_delay; /* power up wait */
  968. uchar scsi_reset_delay; /* 10 reset delay */
  969. uchar bios_id_lun; /* first boot device scsi id & lun */
  970. /* high nibble is lun */
  971. /* low nibble is scsi id */
  972. uchar termination; /* 11 0 - automatic */
  973. /* 1 - low off / high off */
  974. /* 2 - low off / high on */
  975. /* 3 - low on / high on */
  976. /* There is no low on / high off */
  977. uchar reserved1; /* reserved byte (not used) */
  978. ushort bios_ctrl; /* 12 BIOS control bits */
  979. /* bit 0 BIOS don't act as initiator. */
  980. /* bit 1 BIOS > 1 GB support */
  981. /* bit 2 BIOS > 2 Disk Support */
  982. /* bit 3 BIOS don't support removables */
  983. /* bit 4 BIOS support bootable CD */
  984. /* bit 5 BIOS scan enabled */
  985. /* bit 6 BIOS support multiple LUNs */
  986. /* bit 7 BIOS display of message */
  987. /* bit 8 SCAM disabled */
  988. /* bit 9 Reset SCSI bus during init. */
  989. /* bit 10 */
  990. /* bit 11 No verbose initialization. */
  991. /* bit 12 SCSI parity enabled */
  992. /* bit 13 */
  993. /* bit 14 */
  994. /* bit 15 */
  995. ushort ultra_able; /* 13 ULTRA speed able */
  996. ushort reserved2; /* 14 reserved */
  997. uchar max_host_qng; /* 15 maximum host queuing */
  998. uchar max_dvc_qng; /* maximum per device queuing */
  999. ushort dvc_cntl; /* 16 control bit for driver */
  1000. ushort bug_fix; /* 17 control bit for bug fix */
  1001. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1002. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1003. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1004. ushort check_sum; /* 21 EEP check sum */
  1005. uchar oem_name[16]; /* 22 OEM name */
  1006. ushort dvc_err_code; /* 30 last device driver error code */
  1007. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1008. ushort adv_err_addr; /* 32 last uc error address */
  1009. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1010. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1011. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1012. ushort num_of_err; /* 36 number of error */
  1013. } ADVEEP_3550_CONFIG;
  1014. typedef struct adveep_38C0800_config {
  1015. /* Word Offset, Description */
  1016. ushort cfg_lsw; /* 00 power up initialization */
  1017. /* bit 13 set - Load CIS */
  1018. /* bit 14 set - BIOS Enable */
  1019. /* bit 15 set - Big Endian Mode */
  1020. ushort cfg_msw; /* 01 unused */
  1021. ushort disc_enable; /* 02 disconnect enable */
  1022. ushort wdtr_able; /* 03 Wide DTR able */
  1023. ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
  1024. ushort start_motor; /* 05 send start up motor */
  1025. ushort tagqng_able; /* 06 tag queuing able */
  1026. ushort bios_scan; /* 07 BIOS device control */
  1027. ushort scam_tolerant; /* 08 no scam */
  1028. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1029. uchar bios_boot_delay; /* power up wait */
  1030. uchar scsi_reset_delay; /* 10 reset delay */
  1031. uchar bios_id_lun; /* first boot device scsi id & lun */
  1032. /* high nibble is lun */
  1033. /* low nibble is scsi id */
  1034. uchar termination_se; /* 11 0 - automatic */
  1035. /* 1 - low off / high off */
  1036. /* 2 - low off / high on */
  1037. /* 3 - low on / high on */
  1038. /* There is no low on / high off */
  1039. uchar termination_lvd; /* 11 0 - automatic */
  1040. /* 1 - low off / high off */
  1041. /* 2 - low off / high on */
  1042. /* 3 - low on / high on */
  1043. /* There is no low on / high off */
  1044. ushort bios_ctrl; /* 12 BIOS control bits */
  1045. /* bit 0 BIOS don't act as initiator. */
  1046. /* bit 1 BIOS > 1 GB support */
  1047. /* bit 2 BIOS > 2 Disk Support */
  1048. /* bit 3 BIOS don't support removables */
  1049. /* bit 4 BIOS support bootable CD */
  1050. /* bit 5 BIOS scan enabled */
  1051. /* bit 6 BIOS support multiple LUNs */
  1052. /* bit 7 BIOS display of message */
  1053. /* bit 8 SCAM disabled */
  1054. /* bit 9 Reset SCSI bus during init. */
  1055. /* bit 10 */
  1056. /* bit 11 No verbose initialization. */
  1057. /* bit 12 SCSI parity enabled */
  1058. /* bit 13 */
  1059. /* bit 14 */
  1060. /* bit 15 */
  1061. ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
  1062. ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
  1063. uchar max_host_qng; /* 15 maximum host queueing */
  1064. uchar max_dvc_qng; /* maximum per device queuing */
  1065. ushort dvc_cntl; /* 16 control bit for driver */
  1066. ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
  1067. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1068. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1069. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1070. ushort check_sum; /* 21 EEP check sum */
  1071. uchar oem_name[16]; /* 22 OEM name */
  1072. ushort dvc_err_code; /* 30 last device driver error code */
  1073. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1074. ushort adv_err_addr; /* 32 last uc error address */
  1075. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1076. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1077. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1078. ushort reserved36; /* 36 reserved */
  1079. ushort reserved37; /* 37 reserved */
  1080. ushort reserved38; /* 38 reserved */
  1081. ushort reserved39; /* 39 reserved */
  1082. ushort reserved40; /* 40 reserved */
  1083. ushort reserved41; /* 41 reserved */
  1084. ushort reserved42; /* 42 reserved */
  1085. ushort reserved43; /* 43 reserved */
  1086. ushort reserved44; /* 44 reserved */
  1087. ushort reserved45; /* 45 reserved */
  1088. ushort reserved46; /* 46 reserved */
  1089. ushort reserved47; /* 47 reserved */
  1090. ushort reserved48; /* 48 reserved */
  1091. ushort reserved49; /* 49 reserved */
  1092. ushort reserved50; /* 50 reserved */
  1093. ushort reserved51; /* 51 reserved */
  1094. ushort reserved52; /* 52 reserved */
  1095. ushort reserved53; /* 53 reserved */
  1096. ushort reserved54; /* 54 reserved */
  1097. ushort reserved55; /* 55 reserved */
  1098. ushort cisptr_lsw; /* 56 CIS PTR LSW */
  1099. ushort cisprt_msw; /* 57 CIS PTR MSW */
  1100. ushort subsysvid; /* 58 SubSystem Vendor ID */
  1101. ushort subsysid; /* 59 SubSystem ID */
  1102. ushort reserved60; /* 60 reserved */
  1103. ushort reserved61; /* 61 reserved */
  1104. ushort reserved62; /* 62 reserved */
  1105. ushort reserved63; /* 63 reserved */
  1106. } ADVEEP_38C0800_CONFIG;
  1107. typedef struct adveep_38C1600_config {
  1108. /* Word Offset, Description */
  1109. ushort cfg_lsw; /* 00 power up initialization */
  1110. /* bit 11 set - Func. 0 INTB, Func. 1 INTA */
  1111. /* clear - Func. 0 INTA, Func. 1 INTB */
  1112. /* bit 13 set - Load CIS */
  1113. /* bit 14 set - BIOS Enable */
  1114. /* bit 15 set - Big Endian Mode */
  1115. ushort cfg_msw; /* 01 unused */
  1116. ushort disc_enable; /* 02 disconnect enable */
  1117. ushort wdtr_able; /* 03 Wide DTR able */
  1118. ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
  1119. ushort start_motor; /* 05 send start up motor */
  1120. ushort tagqng_able; /* 06 tag queuing able */
  1121. ushort bios_scan; /* 07 BIOS device control */
  1122. ushort scam_tolerant; /* 08 no scam */
  1123. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1124. uchar bios_boot_delay; /* power up wait */
  1125. uchar scsi_reset_delay; /* 10 reset delay */
  1126. uchar bios_id_lun; /* first boot device scsi id & lun */
  1127. /* high nibble is lun */
  1128. /* low nibble is scsi id */
  1129. uchar termination_se; /* 11 0 - automatic */
  1130. /* 1 - low off / high off */
  1131. /* 2 - low off / high on */
  1132. /* 3 - low on / high on */
  1133. /* There is no low on / high off */
  1134. uchar termination_lvd; /* 11 0 - automatic */
  1135. /* 1 - low off / high off */
  1136. /* 2 - low off / high on */
  1137. /* 3 - low on / high on */
  1138. /* There is no low on / high off */
  1139. ushort bios_ctrl; /* 12 BIOS control bits */
  1140. /* bit 0 BIOS don't act as initiator. */
  1141. /* bit 1 BIOS > 1 GB support */
  1142. /* bit 2 BIOS > 2 Disk Support */
  1143. /* bit 3 BIOS don't support removables */
  1144. /* bit 4 BIOS support bootable CD */
  1145. /* bit 5 BIOS scan enabled */
  1146. /* bit 6 BIOS support multiple LUNs */
  1147. /* bit 7 BIOS display of message */
  1148. /* bit 8 SCAM disabled */
  1149. /* bit 9 Reset SCSI bus during init. */
  1150. /* bit 10 Basic Integrity Checking disabled */
  1151. /* bit 11 No verbose initialization. */
  1152. /* bit 12 SCSI parity enabled */
  1153. /* bit 13 AIPP (Asyn. Info. Ph. Prot.) dis. */
  1154. /* bit 14 */
  1155. /* bit 15 */
  1156. ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
  1157. ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
  1158. uchar max_host_qng; /* 15 maximum host queueing */
  1159. uchar max_dvc_qng; /* maximum per device queuing */
  1160. ushort dvc_cntl; /* 16 control bit for driver */
  1161. ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
  1162. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1163. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1164. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1165. ushort check_sum; /* 21 EEP check sum */
  1166. uchar oem_name[16]; /* 22 OEM name */
  1167. ushort dvc_err_code; /* 30 last device driver error code */
  1168. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1169. ushort adv_err_addr; /* 32 last uc error address */
  1170. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1171. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1172. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1173. ushort reserved36; /* 36 reserved */
  1174. ushort reserved37; /* 37 reserved */
  1175. ushort reserved38; /* 38 reserved */
  1176. ushort reserved39; /* 39 reserved */
  1177. ushort reserved40; /* 40 reserved */
  1178. ushort reserved41; /* 41 reserved */
  1179. ushort reserved42; /* 42 reserved */
  1180. ushort reserved43; /* 43 reserved */
  1181. ushort reserved44; /* 44 reserved */
  1182. ushort reserved45; /* 45 reserved */
  1183. ushort reserved46; /* 46 reserved */
  1184. ushort reserved47; /* 47 reserved */
  1185. ushort reserved48; /* 48 reserved */
  1186. ushort reserved49; /* 49 reserved */
  1187. ushort reserved50; /* 50 reserved */
  1188. ushort reserved51; /* 51 reserved */
  1189. ushort reserved52; /* 52 reserved */
  1190. ushort reserved53; /* 53 reserved */
  1191. ushort reserved54; /* 54 reserved */
  1192. ushort reserved55; /* 55 reserved */
  1193. ushort cisptr_lsw; /* 56 CIS PTR LSW */
  1194. ushort cisprt_msw; /* 57 CIS PTR MSW */
  1195. ushort subsysvid; /* 58 SubSystem Vendor ID */
  1196. ushort subsysid; /* 59 SubSystem ID */
  1197. ushort reserved60; /* 60 reserved */
  1198. ushort reserved61; /* 61 reserved */
  1199. ushort reserved62; /* 62 reserved */
  1200. ushort reserved63; /* 63 reserved */
  1201. } ADVEEP_38C1600_CONFIG;
  1202. /*
  1203. * EEPROM Commands
  1204. */
  1205. #define ASC_EEP_CMD_DONE 0x0200
  1206. /* bios_ctrl */
  1207. #define BIOS_CTRL_BIOS 0x0001
  1208. #define BIOS_CTRL_EXTENDED_XLAT 0x0002
  1209. #define BIOS_CTRL_GT_2_DISK 0x0004
  1210. #define BIOS_CTRL_BIOS_REMOVABLE 0x0008
  1211. #define BIOS_CTRL_BOOTABLE_CD 0x0010
  1212. #define BIOS_CTRL_MULTIPLE_LUN 0x0040
  1213. #define BIOS_CTRL_DISPLAY_MSG 0x0080
  1214. #define BIOS_CTRL_NO_SCAM 0x0100
  1215. #define BIOS_CTRL_RESET_SCSI_BUS 0x0200
  1216. #define BIOS_CTRL_INIT_VERBOSE 0x0800
  1217. #define BIOS_CTRL_SCSI_PARITY 0x1000
  1218. #define BIOS_CTRL_AIPP_DIS 0x2000
  1219. #define ADV_3550_MEMSIZE 0x2000 /* 8 KB Internal Memory */
  1220. #define ADV_38C0800_MEMSIZE 0x4000 /* 16 KB Internal Memory */
  1221. /*
  1222. * XXX - Since ASC38C1600 Rev.3 has a local RAM failure issue, there is
  1223. * a special 16K Adv Library and Microcode version. After the issue is
  1224. * resolved, should restore 32K support.
  1225. *
  1226. * #define ADV_38C1600_MEMSIZE 0x8000L * 32 KB Internal Memory *
  1227. */
  1228. #define ADV_38C1600_MEMSIZE 0x4000 /* 16 KB Internal Memory */
  1229. /*
  1230. * Byte I/O register address from base of 'iop_base'.
  1231. */
  1232. #define IOPB_INTR_STATUS_REG 0x00
  1233. #define IOPB_CHIP_ID_1 0x01
  1234. #define IOPB_INTR_ENABLES 0x02
  1235. #define IOPB_CHIP_TYPE_REV 0x03
  1236. #define IOPB_RES_ADDR_4 0x04
  1237. #define IOPB_RES_ADDR_5 0x05
  1238. #define IOPB_RAM_DATA 0x06
  1239. #define IOPB_RES_ADDR_7 0x07
  1240. #define IOPB_FLAG_REG 0x08
  1241. #define IOPB_RES_ADDR_9 0x09
  1242. #define IOPB_RISC_CSR 0x0A
  1243. #define IOPB_RES_ADDR_B 0x0B
  1244. #define IOPB_RES_ADDR_C 0x0C
  1245. #define IOPB_RES_ADDR_D 0x0D
  1246. #define IOPB_SOFT_OVER_WR 0x0E
  1247. #define IOPB_RES_ADDR_F 0x0F
  1248. #define IOPB_MEM_CFG 0x10
  1249. #define IOPB_RES_ADDR_11 0x11
  1250. #define IOPB_GPIO_DATA 0x12
  1251. #define IOPB_RES_ADDR_13 0x13
  1252. #define IOPB_FLASH_PAGE 0x14
  1253. #define IOPB_RES_ADDR_15 0x15
  1254. #define IOPB_GPIO_CNTL 0x16
  1255. #define IOPB_RES_ADDR_17 0x17
  1256. #define IOPB_FLASH_DATA 0x18
  1257. #define IOPB_RES_ADDR_19 0x19
  1258. #define IOPB_RES_ADDR_1A 0x1A
  1259. #define IOPB_RES_ADDR_1B 0x1B
  1260. #define IOPB_RES_ADDR_1C 0x1C
  1261. #define IOPB_RES_ADDR_1D 0x1D
  1262. #define IOPB_RES_ADDR_1E 0x1E
  1263. #define IOPB_RES_ADDR_1F 0x1F
  1264. #define IOPB_DMA_CFG0 0x20
  1265. #define IOPB_DMA_CFG1 0x21
  1266. #define IOPB_TICKLE 0x22
  1267. #define IOPB_DMA_REG_WR 0x23
  1268. #define IOPB_SDMA_STATUS 0x24
  1269. #define IOPB_SCSI_BYTE_CNT 0x25
  1270. #define IOPB_HOST_BYTE_CNT 0x26
  1271. #define IOPB_BYTE_LEFT_TO_XFER 0x27
  1272. #define IOPB_BYTE_TO_XFER_0 0x28
  1273. #define IOPB_BYTE_TO_XFER_1 0x29
  1274. #define IOPB_BYTE_TO_XFER_2 0x2A
  1275. #define IOPB_BYTE_TO_XFER_3 0x2B
  1276. #define IOPB_ACC_GRP 0x2C
  1277. #define IOPB_RES_ADDR_2D 0x2D
  1278. #define IOPB_DEV_ID 0x2E
  1279. #define IOPB_RES_ADDR_2F 0x2F
  1280. #define IOPB_SCSI_DATA 0x30
  1281. #define IOPB_RES_ADDR_31 0x31
  1282. #define IOPB_RES_ADDR_32 0x32
  1283. #define IOPB_SCSI_DATA_HSHK 0x33
  1284. #define IOPB_SCSI_CTRL 0x34
  1285. #define IOPB_RES_ADDR_35 0x35
  1286. #define IOPB_RES_ADDR_36 0x36
  1287. #define IOPB_RES_ADDR_37 0x37
  1288. #define IOPB_RAM_BIST 0x38
  1289. #define IOPB_PLL_TEST 0x39
  1290. #define IOPB_PCI_INT_CFG 0x3A
  1291. #define IOPB_RES_ADDR_3B 0x3B
  1292. #define IOPB_RFIFO_CNT 0x3C
  1293. #define IOPB_RES_ADDR_3D 0x3D
  1294. #define IOPB_RES_ADDR_3E 0x3E
  1295. #define IOPB_RES_ADDR_3F 0x3F
  1296. /*
  1297. * Word I/O register address from base of 'iop_base'.
  1298. */
  1299. #define IOPW_CHIP_ID_0 0x00 /* CID0 */
  1300. #define IOPW_CTRL_REG 0x02 /* CC */
  1301. #define IOPW_RAM_ADDR 0x04 /* LA */
  1302. #define IOPW_RAM_DATA 0x06 /* LD */
  1303. #define IOPW_RES_ADDR_08 0x08
  1304. #define IOPW_RISC_CSR 0x0A /* CSR */
  1305. #define IOPW_SCSI_CFG0 0x0C /* CFG0 */
  1306. #define IOPW_SCSI_CFG1 0x0E /* CFG1 */
  1307. #define IOPW_RES_ADDR_10 0x10
  1308. #define IOPW_SEL_MASK 0x12 /* SM */
  1309. #define IOPW_RES_ADDR_14 0x14
  1310. #define IOPW_FLASH_ADDR 0x16 /* FA */
  1311. #define IOPW_RES_ADDR_18 0x18
  1312. #define IOPW_EE_CMD 0x1A /* EC */
  1313. #define IOPW_EE_DATA 0x1C /* ED */
  1314. #define IOPW_SFIFO_CNT 0x1E /* SFC */
  1315. #define IOPW_RES_ADDR_20 0x20
  1316. #define IOPW_Q_BASE 0x22 /* QB */
  1317. #define IOPW_QP 0x24 /* QP */
  1318. #define IOPW_IX 0x26 /* IX */
  1319. #define IOPW_SP 0x28 /* SP */
  1320. #define IOPW_PC 0x2A /* PC */
  1321. #define IOPW_RES_ADDR_2C 0x2C
  1322. #define IOPW_RES_ADDR_2E 0x2E
  1323. #define IOPW_SCSI_DATA 0x30 /* SD */
  1324. #define IOPW_SCSI_DATA_HSHK 0x32 /* SDH */
  1325. #define IOPW_SCSI_CTRL 0x34 /* SC */
  1326. #define IOPW_HSHK_CFG 0x36 /* HCFG */
  1327. #define IOPW_SXFR_STATUS 0x36 /* SXS */
  1328. #define IOPW_SXFR_CNTL 0x38 /* SXL */
  1329. #define IOPW_SXFR_CNTH 0x3A /* SXH */
  1330. #define IOPW_RES_ADDR_3C 0x3C
  1331. #define IOPW_RFIFO_DATA 0x3E /* RFD */
  1332. /*
  1333. * Doubleword I/O register address from base of 'iop_base'.
  1334. */
  1335. #define IOPDW_RES_ADDR_0 0x00
  1336. #define IOPDW_RAM_DATA 0x04
  1337. #define IOPDW_RES_ADDR_8 0x08
  1338. #define IOPDW_RES_ADDR_C 0x0C
  1339. #define IOPDW_RES_ADDR_10 0x10
  1340. #define IOPDW_COMMA 0x14
  1341. #define IOPDW_COMMB 0x18
  1342. #define IOPDW_RES_ADDR_1C 0x1C
  1343. #define IOPDW_SDMA_ADDR0 0x20
  1344. #define IOPDW_SDMA_ADDR1 0x24
  1345. #define IOPDW_SDMA_COUNT 0x28
  1346. #define IOPDW_SDMA_ERROR 0x2C
  1347. #define IOPDW_RDMA_ADDR0 0x30
  1348. #define IOPDW_RDMA_ADDR1 0x34
  1349. #define IOPDW_RDMA_COUNT 0x38
  1350. #define IOPDW_RDMA_ERROR 0x3C
  1351. #define ADV_CHIP_ID_BYTE 0x25
  1352. #define ADV_CHIP_ID_WORD 0x04C1
  1353. #define ADV_INTR_ENABLE_HOST_INTR 0x01
  1354. #define ADV_INTR_ENABLE_SEL_INTR 0x02
  1355. #define ADV_INTR_ENABLE_DPR_INTR 0x04
  1356. #define ADV_INTR_ENABLE_RTA_INTR 0x08
  1357. #define ADV_INTR_ENABLE_RMA_INTR 0x10
  1358. #define ADV_INTR_ENABLE_RST_INTR 0x20
  1359. #define ADV_INTR_ENABLE_DPE_INTR 0x40
  1360. #define ADV_INTR_ENABLE_GLOBAL_INTR 0x80
  1361. #define ADV_INTR_STATUS_INTRA 0x01
  1362. #define ADV_INTR_STATUS_INTRB 0x02
  1363. #define ADV_INTR_STATUS_INTRC 0x04
  1364. #define ADV_RISC_CSR_STOP (0x0000)
  1365. #define ADV_RISC_TEST_COND (0x2000)
  1366. #define ADV_RISC_CSR_RUN (0x4000)
  1367. #define ADV_RISC_CSR_SINGLE_STEP (0x8000)
  1368. #define ADV_CTRL_REG_HOST_INTR 0x0100
  1369. #define ADV_CTRL_REG_SEL_INTR 0x0200
  1370. #define ADV_CTRL_REG_DPR_INTR 0x0400
  1371. #define ADV_CTRL_REG_RTA_INTR 0x0800
  1372. #define ADV_CTRL_REG_RMA_INTR 0x1000
  1373. #define ADV_CTRL_REG_RES_BIT14 0x2000
  1374. #define ADV_CTRL_REG_DPE_INTR 0x4000
  1375. #define ADV_CTRL_REG_POWER_DONE 0x8000
  1376. #define ADV_CTRL_REG_ANY_INTR 0xFF00
  1377. #define ADV_CTRL_REG_CMD_RESET 0x00C6
  1378. #define ADV_CTRL_REG_CMD_WR_IO_REG 0x00C5
  1379. #define ADV_CTRL_REG_CMD_RD_IO_REG 0x00C4
  1380. #define ADV_CTRL_REG_CMD_WR_PCI_CFG_SPACE 0x00C3
  1381. #define ADV_CTRL_REG_CMD_RD_PCI_CFG_SPACE 0x00C2
  1382. #define ADV_TICKLE_NOP 0x00
  1383. #define ADV_TICKLE_A 0x01
  1384. #define ADV_TICKLE_B 0x02
  1385. #define ADV_TICKLE_C 0x03
  1386. #define AdvIsIntPending(port) \
  1387. (AdvReadWordRegister(port, IOPW_CTRL_REG) & ADV_CTRL_REG_HOST_INTR)
  1388. /*
  1389. * SCSI_CFG0 Register bit definitions
  1390. */
  1391. #define TIMER_MODEAB 0xC000 /* Watchdog, Second, and Select. Timer Ctrl. */
  1392. #define PARITY_EN 0x2000 /* Enable SCSI Parity Error detection */
  1393. #define EVEN_PARITY 0x1000 /* Select Even Parity */
  1394. #define WD_LONG 0x0800 /* Watchdog Interval, 1: 57 min, 0: 13 sec */
  1395. #define QUEUE_128 0x0400 /* Queue Size, 1: 128 byte, 0: 64 byte */
  1396. #define PRIM_MODE 0x0100 /* Primitive SCSI mode */
  1397. #define SCAM_EN 0x0080 /* Enable SCAM selection */
  1398. #define SEL_TMO_LONG 0x0040 /* Sel/Resel Timeout, 1: 400 ms, 0: 1.6 ms */
  1399. #define CFRM_ID 0x0020 /* SCAM id sel. confirm., 1: fast, 0: 6.4 ms */
  1400. #define OUR_ID_EN 0x0010 /* Enable OUR_ID bits */
  1401. #define OUR_ID 0x000F /* SCSI ID */
  1402. /*
  1403. * SCSI_CFG1 Register bit definitions
  1404. */
  1405. #define BIG_ENDIAN 0x8000 /* Enable Big Endian Mode MIO:15, EEP:15 */
  1406. #define TERM_POL 0x2000 /* Terminator Polarity Ctrl. MIO:13, EEP:13 */
  1407. #define SLEW_RATE 0x1000 /* SCSI output buffer slew rate */
  1408. #define FILTER_SEL 0x0C00 /* Filter Period Selection */
  1409. #define FLTR_DISABLE 0x0000 /* Input Filtering Disabled */
  1410. #define FLTR_11_TO_20NS 0x0800 /* Input Filtering 11ns to 20ns */
  1411. #define FLTR_21_TO_39NS 0x0C00 /* Input Filtering 21ns to 39ns */
  1412. #define ACTIVE_DBL 0x0200 /* Disable Active Negation */
  1413. #define DIFF_MODE 0x0100 /* SCSI differential Mode (Read-Only) */
  1414. #define DIFF_SENSE 0x0080 /* 1: No SE cables, 0: SE cable (Read-Only) */
  1415. #define TERM_CTL_SEL 0x0040 /* Enable TERM_CTL_H and TERM_CTL_L */
  1416. #define TERM_CTL 0x0030 /* External SCSI Termination Bits */
  1417. #define TERM_CTL_H 0x0020 /* Enable External SCSI Upper Termination */
  1418. #define TERM_CTL_L 0x0010 /* Enable External SCSI Lower Termination */
  1419. #define CABLE_DETECT 0x000F /* External SCSI Cable Connection Status */
  1420. /*
  1421. * Addendum for ASC-38C0800 Chip
  1422. *
  1423. * The ASC-38C1600 Chip uses the same definitions except that the
  1424. * bus mode override bits [12:10] have been moved to byte register
  1425. * offset 0xE (IOPB_SOFT_OVER_WR) bits [12:10]. The [12:10] bits in
  1426. * SCSI_CFG1 are read-only and always available. Bit 14 (DIS_TERM_DRV)
  1427. * is not needed. The [12:10] bits in IOPB_SOFT_OVER_WR are write-only.
  1428. * Also each ASC-38C1600 function or channel uses only cable bits [5:4]
  1429. * and [1:0]. Bits [14], [7:6], [3:2] are unused.
  1430. */
  1431. #define DIS_TERM_DRV 0x4000 /* 1: Read c_det[3:0], 0: cannot read */
  1432. #define HVD_LVD_SE 0x1C00 /* Device Detect Bits */
  1433. #define HVD 0x1000 /* HVD Device Detect */
  1434. #define LVD 0x0800 /* LVD Device Detect */
  1435. #define SE 0x0400 /* SE Device Detect */
  1436. #define TERM_LVD 0x00C0 /* LVD Termination Bits */
  1437. #define TERM_LVD_HI 0x0080 /* Enable LVD Upper Termination */
  1438. #define TERM_LVD_LO 0x0040 /* Enable LVD Lower Termination */
  1439. #define TERM_SE 0x0030 /* SE Termination Bits */
  1440. #define TERM_SE_HI 0x0020 /* Enable SE Upper Termination */
  1441. #define TERM_SE_LO 0x0010 /* Enable SE Lower Termination */
  1442. #define C_DET_LVD 0x000C /* LVD Cable Detect Bits */
  1443. #define C_DET3 0x0008 /* Cable Detect for LVD External Wide */
  1444. #define C_DET2 0x0004 /* Cable Detect for LVD Internal Wide */
  1445. #define C_DET_SE 0x0003 /* SE Cable Detect Bits */
  1446. #define C_DET1 0x0002 /* Cable Detect for SE Internal Wide */
  1447. #define C_DET0 0x0001 /* Cable Detect for SE Internal Narrow */
  1448. #define CABLE_ILLEGAL_A 0x7
  1449. /* x 0 0 0 | on on | Illegal (all 3 connectors are used) */
  1450. #define CABLE_ILLEGAL_B 0xB
  1451. /* 0 x 0 0 | on on | Illegal (all 3 connectors are used) */
  1452. /*
  1453. * MEM_CFG Register bit definitions
  1454. */
  1455. #define BIOS_EN 0x40 /* BIOS Enable MIO:14,EEP:14 */
  1456. #define FAST_EE_CLK 0x20 /* Diagnostic Bit */
  1457. #define RAM_SZ 0x1C /* Specify size of RAM to RISC */
  1458. #define RAM_SZ_2KB 0x00 /* 2 KB */
  1459. #define RAM_SZ_4KB 0x04 /* 4 KB */
  1460. #define RAM_SZ_8KB 0x08 /* 8 KB */
  1461. #define RAM_SZ_16KB 0x0C /* 16 KB */
  1462. #define RAM_SZ_32KB 0x10 /* 32 KB */
  1463. #define RAM_SZ_64KB 0x14 /* 64 KB */
  1464. /*
  1465. * DMA_CFG0 Register bit definitions
  1466. *
  1467. * This register is only accessible to the host.
  1468. */
  1469. #define BC_THRESH_ENB 0x80 /* PCI DMA Start Conditions */
  1470. #define FIFO_THRESH 0x70 /* PCI DMA FIFO Threshold */
  1471. #define FIFO_THRESH_16B 0x00 /* 16 bytes */
  1472. #define FIFO_THRESH_32B 0x20 /* 32 bytes */
  1473. #define FIFO_THRESH_48B 0x30 /* 48 bytes */
  1474. #define FIFO_THRESH_64B 0x40 /* 64 bytes */
  1475. #define FIFO_THRESH_80B 0x50 /* 80 bytes (default) */
  1476. #define FIFO_THRESH_96B 0x60 /* 96 bytes */
  1477. #define FIFO_THRESH_112B 0x70 /* 112 bytes */
  1478. #define START_CTL 0x0C /* DMA start conditions */
  1479. #define START_CTL_TH 0x00 /* Wait threshold level (default) */
  1480. #define START_CTL_ID 0x04 /* Wait SDMA/SBUS idle */
  1481. #define START_CTL_THID 0x08 /* Wait threshold and SDMA/SBUS idle */
  1482. #define START_CTL_EMFU 0x0C /* Wait SDMA FIFO empty/full */
  1483. #define READ_CMD 0x03 /* Memory Read Method */
  1484. #define READ_CMD_MR 0x00 /* Memory Read */
  1485. #define READ_CMD_MRL 0x02 /* Memory Read Long */
  1486. #define READ_CMD_MRM 0x03 /* Memory Read Multiple (default) */
  1487. /*
  1488. * ASC-38C0800 RAM BIST Register bit definitions
  1489. */
  1490. #define RAM_TEST_MODE 0x80
  1491. #define PRE_TEST_MODE 0x40
  1492. #define NORMAL_MODE 0x00
  1493. #define RAM_TEST_DONE 0x10
  1494. #define RAM_TEST_STATUS 0x0F
  1495. #define RAM_TEST_HOST_ERROR 0x08
  1496. #define RAM_TEST_INTRAM_ERROR 0x04
  1497. #define RAM_TEST_RISC_ERROR 0x02
  1498. #define RAM_TEST_SCSI_ERROR 0x01
  1499. #define RAM_TEST_SUCCESS 0x00
  1500. #define PRE_TEST_VALUE 0x05
  1501. #define NORMAL_VALUE 0x00
  1502. /*
  1503. * ASC38C1600 Definitions
  1504. *
  1505. * IOPB_PCI_INT_CFG Bit Field Definitions
  1506. */
  1507. #define INTAB_LD 0x80 /* Value loaded from EEPROM Bit 11. */
  1508. /*
  1509. * Bit 1 can be set to change the interrupt for the Function to operate in
  1510. * Totem Pole mode. By default Bit 1 is 0 and the interrupt operates in
  1511. * Open Drain mode. Both functions of the ASC38C1600 must be set to the same
  1512. * mode, otherwise the operating mode is undefined.
  1513. */
  1514. #define TOTEMPOLE 0x02
  1515. /*
  1516. * Bit 0 can be used to change the Int Pin for the Function. The value is
  1517. * 0 by default for both Functions with Function 0 using INT A and Function
  1518. * B using INT B. For Function 0 if set, INT B is used. For Function 1 if set,
  1519. * INT A is used.
  1520. *
  1521. * EEPROM Word 0 Bit 11 for each Function may change the initial Int Pin
  1522. * value specified in the PCI Configuration Space.
  1523. */
  1524. #define INTAB 0x01
  1525. /*
  1526. * Adv Library Status Definitions
  1527. */
  1528. #define ADV_TRUE 1
  1529. #define ADV_FALSE 0
  1530. #define ADV_SUCCESS 1
  1531. #define ADV_BUSY 0
  1532. #define ADV_ERROR (-1)
  1533. /*
  1534. * ADV_DVC_VAR 'warn_code' values
  1535. */
  1536. #define ASC_WARN_BUSRESET_ERROR 0x0001 /* SCSI Bus Reset error */
  1537. #define ASC_WARN_EEPROM_CHKSUM 0x0002 /* EEP check sum error */
  1538. #define ASC_WARN_EEPROM_TERMINATION 0x0004 /* EEP termination bad field */
  1539. #define ASC_WARN_ERROR 0xFFFF /* ADV_ERROR return */
  1540. #define ADV_MAX_TID 15 /* max. target identifier */
  1541. #define ADV_MAX_LUN 7 /* max. logical unit number */
  1542. /*
  1543. * Fixed locations of microcode operating variables.
  1544. */
  1545. #define ASC_MC_CODE_BEGIN_ADDR 0x0028 /* microcode start address */
  1546. #define ASC_MC_CODE_END_ADDR 0x002A /* microcode end address */
  1547. #define ASC_MC_CODE_CHK_SUM 0x002C /* microcode code checksum */
  1548. #define ASC_MC_VERSION_DATE 0x0038 /* microcode version */
  1549. #define ASC_MC_VERSION_NUM 0x003A /* microcode number */
  1550. #define ASC_MC_BIOSMEM 0x0040 /* BIOS RISC Memory Start */
  1551. #define ASC_MC_BIOSLEN 0x0050 /* BIOS RISC Memory Length */
  1552. #define ASC_MC_BIOS_SIGNATURE 0x0058 /* BIOS Signature 0x55AA */
  1553. #define ASC_MC_BIOS_VERSION 0x005A /* BIOS Version (2 bytes) */
  1554. #define ASC_MC_SDTR_SPEED1 0x0090 /* SDTR Speed for TID 0-3 */
  1555. #define ASC_MC_SDTR_SPEED2 0x0092 /* SDTR Speed for TID 4-7 */
  1556. #define ASC_MC_SDTR_SPEED3 0x0094 /* SDTR Speed for TID 8-11 */
  1557. #define ASC_MC_SDTR_SPEED4 0x0096 /* SDTR Speed for TID 12-15 */
  1558. #define ASC_MC_CHIP_TYPE 0x009A
  1559. #define ASC_MC_INTRB_CODE 0x009B
  1560. #define ASC_MC_WDTR_ABLE 0x009C
  1561. #define ASC_MC_SDTR_ABLE 0x009E
  1562. #define ASC_MC_TAGQNG_ABLE 0x00A0
  1563. #define ASC_MC_DISC_ENABLE 0x00A2
  1564. #define ASC_MC_IDLE_CMD_STATUS 0x00A4
  1565. #define ASC_MC_IDLE_CMD 0x00A6
  1566. #define ASC_MC_IDLE_CMD_PARAMETER 0x00A8
  1567. #define ASC_MC_DEFAULT_SCSI_CFG0 0x00AC
  1568. #define ASC_MC_DEFAULT_SCSI_CFG1 0x00AE
  1569. #define ASC_MC_DEFAULT_MEM_CFG 0x00B0
  1570. #define ASC_MC_DEFAULT_SEL_MASK 0x00B2
  1571. #define ASC_MC_SDTR_DONE 0x00B6
  1572. #define ASC_MC_NUMBER_OF_QUEUED_CMD 0x00C0
  1573. #define ASC_MC_NUMBER_OF_MAX_CMD 0x00D0
  1574. #define ASC_MC_DEVICE_HSHK_CFG_TABLE 0x0100
  1575. #define ASC_MC_CONTROL_FLAG 0x0122 /* Microcode control flag. */
  1576. #define ASC_MC_WDTR_DONE 0x0124
  1577. #define ASC_MC_CAM_MODE_MASK 0x015E /* CAM mode TID bitmask. */
  1578. #define ASC_MC_ICQ 0x0160
  1579. #define ASC_MC_IRQ 0x0164
  1580. #define ASC_MC_PPR_ABLE 0x017A
  1581. /*
  1582. * BIOS LRAM variable absolute offsets.
  1583. */
  1584. #define BIOS_CODESEG 0x54
  1585. #define BIOS_CODELEN 0x56
  1586. #define BIOS_SIGNATURE 0x58
  1587. #define BIOS_VERSION 0x5A
  1588. /*
  1589. * Microcode Control Flags
  1590. *
  1591. * Flags set by the Adv Library in RISC variable 'control_flag' (0x122)
  1592. * and handled by the microcode.
  1593. */
  1594. #define CONTROL_FLAG_IGNORE_PERR 0x0001 /* Ignore DMA Parity Errors */
  1595. #define CONTROL_FLAG_ENABLE_AIPP 0x0002 /* Enabled AIPP checking. */
  1596. /*
  1597. * ASC_MC_DEVICE_HSHK_CFG_TABLE microcode table or HSHK_CFG register format
  1598. */
  1599. #define HSHK_CFG_WIDE_XFR 0x8000
  1600. #define HSHK_CFG_RATE 0x0F00
  1601. #define HSHK_CFG_OFFSET 0x001F
  1602. #define ASC_DEF_MAX_HOST_QNG 0xFD /* Max. number of host commands (253) */
  1603. #define ASC_DEF_MIN_HOST_QNG 0x10 /* Min. number of host commands (16) */
  1604. #define ASC_DEF_MAX_DVC_QNG 0x3F /* Max. number commands per device (63) */
  1605. #define ASC_DEF_MIN_DVC_QNG 0x04 /* Min. number commands per device (4) */
  1606. #define ASC_QC_DATA_CHECK 0x01 /* Require ASC_QC_DATA_OUT set or clear. */
  1607. #define ASC_QC_DATA_OUT 0x02 /* Data out DMA transfer. */
  1608. #define ASC_QC_START_MOTOR 0x04 /* Send auto-start motor before request. */
  1609. #define ASC_QC_NO_OVERRUN 0x08 /* Don't report overrun. */
  1610. #define ASC_QC_FREEZE_TIDQ 0x10 /* Freeze TID queue after request. XXX TBD */
  1611. #define ASC_QSC_NO_DISC 0x01 /* Don't allow disconnect for request. */
  1612. #define ASC_QSC_NO_TAGMSG 0x02 /* Don't allow tag queuing for request. */
  1613. #define ASC_QSC_NO_SYNC 0x04 /* Don't use Synch. transfer on request. */
  1614. #define ASC_QSC_NO_WIDE 0x08 /* Don't use Wide transfer on request. */
  1615. #define ASC_QSC_REDO_DTR 0x10 /* Renegotiate WDTR/SDTR before request. */
  1616. /*
  1617. * Note: If a Tag Message is to be sent and neither ASC_QSC_HEAD_TAG or
  1618. * ASC_QSC_ORDERED_TAG is set, then a Simple Tag Message (0x20) is used.
  1619. */
  1620. #define ASC_QSC_HEAD_TAG 0x40 /* Use Head Tag Message (0x21). */
  1621. #define ASC_QSC_ORDERED_TAG 0x80 /* Use Ordered Tag Message (0x22). */
  1622. /*
  1623. * All fields here are accessed by the board microcode and need to be
  1624. * little-endian.
  1625. */
  1626. typedef struct adv_carr_t {
  1627. ADV_VADDR carr_va; /* Carrier Virtual Address */
  1628. ADV_PADDR carr_pa; /* Carrier Physical Address */
  1629. ADV_VADDR areq_vpa; /* ASC_SCSI_REQ_Q Virtual or Physical Address */
  1630. /*
  1631. * next_vpa [31:4] Carrier Virtual or Physical Next Pointer
  1632. *
  1633. * next_vpa [3:1] Reserved Bits
  1634. * next_vpa [0] Done Flag set in Response Queue.
  1635. */
  1636. ADV_VADDR next_vpa;
  1637. } ADV_CARR_T;
  1638. /*
  1639. * Mask used to eliminate low 4 bits of carrier 'next_vpa' field.
  1640. */
  1641. #define ASC_NEXT_VPA_MASK 0xFFFFFFF0
  1642. #define ASC_RQ_DONE 0x00000001
  1643. #define ASC_RQ_GOOD 0x00000002
  1644. #define ASC_CQ_STOPPER 0x00000000
  1645. #define ASC_GET_CARRP(carrp) ((carrp) & ASC_NEXT_VPA_MASK)
  1646. #define ADV_CARRIER_NUM_PAGE_CROSSING \
  1647. (((ADV_CARRIER_COUNT * sizeof(ADV_CARR_T)) + (PAGE_SIZE - 1))/PAGE_SIZE)
  1648. #define ADV_CARRIER_BUFSIZE \
  1649. ((ADV_CARRIER_COUNT + ADV_CARRIER_NUM_PAGE_CROSSING) * sizeof(ADV_CARR_T))
  1650. /*
  1651. * ASC_SCSI_REQ_Q 'a_flag' definitions
  1652. *
  1653. * The Adv Library should limit use to the lower nibble (4 bits) of
  1654. * a_flag. Drivers are free to use the upper nibble (4 bits) of a_flag.
  1655. */
  1656. #define ADV_POLL_REQUEST 0x01 /* poll for request completion */
  1657. #define ADV_SCSIQ_DONE 0x02 /* request done */
  1658. #define ADV_DONT_RETRY 0x08 /* don't do retry */
  1659. #define ADV_CHIP_ASC3550 0x01 /* Ultra-Wide IC */
  1660. #define ADV_CHIP_ASC38C0800 0x02 /* Ultra2-Wide/LVD IC */
  1661. #define ADV_CHIP_ASC38C1600 0x03 /* Ultra3-Wide/LVD2 IC */
  1662. /*
  1663. * Adapter temporary configuration structure
  1664. *
  1665. * This structure can be discarded after initialization. Don't add
  1666. * fields here needed after initialization.
  1667. *
  1668. * Field naming convention:
  1669. *
  1670. * *_enable indicates the field enables or disables a feature. The
  1671. * value of the field is never reset.
  1672. */
  1673. typedef struct adv_dvc_cfg {
  1674. ushort disc_enable; /* enable disconnection */
  1675. uchar chip_version; /* chip version */
  1676. uchar termination; /* Term. Ctrl. bits 6-5 of SCSI_CFG1 register */
  1677. ushort control_flag; /* Microcode Control Flag */
  1678. ushort mcode_date; /* Microcode date */
  1679. ushort mcode_version; /* Microcode version */
  1680. ushort serial1; /* EEPROM serial number word 1 */
  1681. ushort serial2; /* EEPROM serial number word 2 */
  1682. ushort serial3; /* EEPROM serial number word 3 */
  1683. } ADV_DVC_CFG;
  1684. struct adv_dvc_var;
  1685. struct adv_scsi_req_q;
  1686. typedef struct asc_sg_block {
  1687. uchar reserved1;
  1688. uchar reserved2;
  1689. uchar reserved3;
  1690. uchar sg_cnt; /* Valid entries in block. */
  1691. ADV_PADDR sg_ptr; /* Pointer to next sg block. */
  1692. struct {
  1693. ADV_PADDR sg_addr; /* SG element address. */
  1694. ADV_DCNT sg_count; /* SG element count. */
  1695. } sg_list[NO_OF_SG_PER_BLOCK];
  1696. } ADV_SG_BLOCK;
  1697. /*
  1698. * ADV_SCSI_REQ_Q - microcode request structure
  1699. *
  1700. * All fields in this structure up to byte 60 are used by the microcode.
  1701. * The microcode makes assumptions about the size and ordering of fields
  1702. * in this structure. Do not change the structure definition here without
  1703. * coordinating the change with the microcode.
  1704. *
  1705. * All fields accessed by microcode must be maintained in little_endian
  1706. * order.
  1707. */
  1708. typedef struct adv_scsi_req_q {
  1709. uchar cntl; /* Ucode flags and state (ASC_MC_QC_*). */
  1710. uchar target_cmd;
  1711. uchar target_id; /* Device target identifier. */
  1712. uchar target_lun; /* Device target logical unit number. */
  1713. ADV_PADDR data_addr; /* Data buffer physical address. */
  1714. ADV_DCNT data_cnt; /* Data count. Ucode sets to residual. */
  1715. ADV_PADDR sense_addr;
  1716. ADV_PADDR carr_pa;
  1717. uchar mflag;
  1718. uchar sense_len;
  1719. uchar cdb_len; /* SCSI CDB length. Must <= 16 bytes. */
  1720. uchar scsi_cntl;
  1721. uchar done_status; /* Completion status. */
  1722. uchar scsi_status; /* SCSI status byte. */
  1723. uchar host_status; /* Ucode host status. */
  1724. uchar sg_working_ix;
  1725. uchar cdb[12]; /* SCSI CDB bytes 0-11. */
  1726. ADV_PADDR sg_real_addr; /* SG list physical address. */
  1727. ADV_PADDR scsiq_rptr;
  1728. uchar cdb16[4]; /* SCSI CDB bytes 12-15. */
  1729. ADV_VADDR scsiq_ptr;
  1730. ADV_VADDR carr_va;
  1731. /*
  1732. * End of microcode structure - 60 bytes. The rest of the structure
  1733. * is used by the Adv Library and ignored by the microcode.
  1734. */
  1735. ADV_VADDR srb_ptr;
  1736. ADV_SG_BLOCK *sg_list_ptr; /* SG list virtual address. */
  1737. char *vdata_addr; /* Data buffer virtual address. */
  1738. uchar a_flag;
  1739. uchar pad[2]; /* Pad out to a word boundary. */
  1740. } ADV_SCSI_REQ_Q;
  1741. /*
  1742. * The following two structures are used to process Wide Board requests.
  1743. *
  1744. * The ADV_SCSI_REQ_Q structure in adv_req_t is passed to the Adv Library
  1745. * and microcode with the ADV_SCSI_REQ_Q field 'srb_ptr' pointing to the
  1746. * adv_req_t. The adv_req_t structure 'cmndp' field in turn points to the
  1747. * Mid-Level SCSI request structure.
  1748. *
  1749. * Zero or more ADV_SG_BLOCK are used with each ADV_SCSI_REQ_Q. Each
  1750. * ADV_SG_BLOCK structure holds 15 scatter-gather elements. Under Linux
  1751. * up to 255 scatter-gather elements may be used per request or
  1752. * ADV_SCSI_REQ_Q.
  1753. *
  1754. * Both structures must be 32 byte aligned.
  1755. */
  1756. typedef struct adv_sgblk {
  1757. ADV_SG_BLOCK sg_block; /* Sgblock structure. */
  1758. uchar align[32]; /* Sgblock structure padding. */
  1759. struct adv_sgblk *next_sgblkp; /* Next scatter-gather structure. */
  1760. } adv_sgblk_t;
  1761. typedef struct adv_req {
  1762. ADV_SCSI_REQ_Q scsi_req_q; /* Adv Library request structure. */
  1763. uchar align[32]; /* Request structure padding. */
  1764. struct scsi_cmnd *cmndp; /* Mid-Level SCSI command pointer. */
  1765. adv_sgblk_t *sgblkp; /* Adv Library scatter-gather pointer. */
  1766. struct adv_req *next_reqp; /* Next Request Structure. */
  1767. } adv_req_t;
  1768. /*
  1769. * Adapter operation variable structure.
  1770. *
  1771. * One structure is required per host adapter.
  1772. *
  1773. * Field naming convention:
  1774. *
  1775. * *_able indicates both whether a feature should be enabled or disabled
  1776. * and whether a device isi capable of the feature. At initialization
  1777. * this field may be set, but later if a device is found to be incapable
  1778. * of the feature, the field is cleared.
  1779. */
  1780. typedef struct adv_dvc_var {
  1781. AdvPortAddr iop_base; /* I/O port address */
  1782. ushort err_code; /* fatal error code */
  1783. ushort bios_ctrl; /* BIOS control word, EEPROM word 12 */
  1784. ushort wdtr_able; /* try WDTR for a device */
  1785. ushort sdtr_able; /* try SDTR for a device */
  1786. ushort ultra_able; /* try SDTR Ultra speed for a device */
  1787. ushort sdtr_speed1; /* EEPROM SDTR Speed for TID 0-3 */
  1788. ushort sdtr_speed2; /* EEPROM SDTR Speed for TID 4-7 */
  1789. ushort sdtr_speed3; /* EEPROM SDTR Speed for TID 8-11 */
  1790. ushort sdtr_speed4; /* EEPROM SDTR Speed for TID 12-15 */
  1791. ushort tagqng_able; /* try tagged queuing with a device */
  1792. ushort ppr_able; /* PPR message capable per TID bitmask. */
  1793. uchar max_dvc_qng; /* maximum number of tagged commands per device */
  1794. ushort start_motor; /* start motor command allowed */
  1795. uchar scsi_reset_wait; /* delay in seconds after scsi bus reset */
  1796. uchar chip_no; /* should be assigned by caller */
  1797. uchar max_host_qng; /* maximum number of Q'ed command allowed */
  1798. ushort no_scam; /* scam_tolerant of EEPROM */
  1799. struct asc_board *drv_ptr; /* driver pointer to private structure */
  1800. uchar chip_scsi_id; /* chip SCSI target ID */
  1801. uchar chip_type;
  1802. uchar bist_err_code;
  1803. ADV_CARR_T *carrier_buf;
  1804. ADV_CARR_T *carr_freelist; /* Carrier free list. */
  1805. ADV_CARR_T *icq_sp; /* Initiator command queue stopper pointer. */
  1806. ADV_CARR_T *irq_sp; /* Initiator response queue stopper pointer. */
  1807. ushort carr_pending_cnt; /* Count of pending carriers. */
  1808. struct adv_req *orig_reqp; /* adv_req_t memory block. */
  1809. /*
  1810. * Note: The following fields will not be used after initialization. The
  1811. * driver may discard the buffer after initialization is done.
  1812. */
  1813. ADV_DVC_CFG *cfg; /* temporary configuration structure */
  1814. } ADV_DVC_VAR;
  1815. /*
  1816. * Microcode idle loop commands
  1817. */
  1818. #define IDLE_CMD_COMPLETED 0
  1819. #define IDLE_CMD_STOP_CHIP 0x0001
  1820. #define IDLE_CMD_STOP_CHIP_SEND_INT 0x0002
  1821. #define IDLE_CMD_SEND_INT 0x0004
  1822. #define IDLE_CMD_ABORT 0x0008
  1823. #define IDLE_CMD_DEVICE_RESET 0x0010
  1824. #define IDLE_CMD_SCSI_RESET_START 0x0020 /* Assert SCSI Bus Reset */
  1825. #define IDLE_CMD_SCSI_RESET_END 0x0040 /* Deassert SCSI Bus Reset */
  1826. #define IDLE_CMD_SCSIREQ 0x0080
  1827. #define IDLE_CMD_STATUS_SUCCESS 0x0001
  1828. #define IDLE_CMD_STATUS_FAILURE 0x0002
  1829. /*
  1830. * AdvSendIdleCmd() flag definitions.
  1831. */
  1832. #define ADV_NOWAIT 0x01
  1833. /*
  1834. * Wait loop time out values.
  1835. */
  1836. #define SCSI_WAIT_100_MSEC 100UL /* 100 milliseconds */
  1837. #define SCSI_US_PER_MSEC 1000 /* microseconds per millisecond */
  1838. #define SCSI_MAX_RETRY 10 /* retry count */
  1839. #define ADV_ASYNC_RDMA_FAILURE 0x01 /* Fatal RDMA failure. */
  1840. #define ADV_ASYNC_SCSI_BUS_RESET_DET 0x02 /* Detected SCSI Bus Reset. */
  1841. #define ADV_ASYNC_CARRIER_READY_FAILURE 0x03 /* Carrier Ready failure. */
  1842. #define ADV_RDMA_IN_CARR_AND_Q_INVALID 0x04 /* RDMAed-in data invalid. */
  1843. #define ADV_HOST_SCSI_BUS_RESET 0x80 /* Host Initiated SCSI Bus Reset. */
  1844. /* Read byte from a register. */
  1845. #define AdvReadByteRegister(iop_base, reg_off) \
  1846. (ADV_MEM_READB((iop_base) + (reg_off)))
  1847. /* Write byte to a register. */
  1848. #define AdvWriteByteRegister(iop_base, reg_off, byte) \
  1849. (ADV_MEM_WRITEB((iop_base) + (reg_off), (byte)))
  1850. /* Read word (2 bytes) from a register. */
  1851. #define AdvReadWordRegister(iop_base, reg_off) \
  1852. (ADV_MEM_READW((iop_base) + (reg_off)))
  1853. /* Write word (2 bytes) to a register. */
  1854. #define AdvWriteWordRegister(iop_base, reg_off, word) \
  1855. (ADV_MEM_WRITEW((iop_base) + (reg_off), (word)))
  1856. /* Write dword (4 bytes) to a register. */
  1857. #define AdvWriteDWordRegister(iop_base, reg_off, dword) \
  1858. (ADV_MEM_WRITEDW((iop_base) + (reg_off), (dword)))
  1859. /* Read byte from LRAM. */
  1860. #define AdvReadByteLram(iop_base, addr, byte) \
  1861. do { \
  1862. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
  1863. (byte) = ADV_MEM_READB((iop_base) + IOPB_RAM_DATA); \
  1864. } while (0)
  1865. /* Write byte to LRAM. */
  1866. #define AdvWriteByteLram(iop_base, addr, byte) \
  1867. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  1868. ADV_MEM_WRITEB((iop_base) + IOPB_RAM_DATA, (byte)))
  1869. /* Read word (2 bytes) from LRAM. */
  1870. #define AdvReadWordLram(iop_base, addr, word) \
  1871. do { \
  1872. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
  1873. (word) = (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA)); \
  1874. } while (0)
  1875. /* Write word (2 bytes) to LRAM. */
  1876. #define AdvWriteWordLram(iop_base, addr, word) \
  1877. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  1878. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
  1879. /* Write little-endian double word (4 bytes) to LRAM */
  1880. /* Because of unspecified C language ordering don't use auto-increment. */
  1881. #define AdvWriteDWordLramNoSwap(iop_base, addr, dword) \
  1882. ((ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  1883. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
  1884. cpu_to_le16((ushort) ((dword) & 0xFFFF)))), \
  1885. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr) + 2), \
  1886. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
  1887. cpu_to_le16((ushort) ((dword >> 16) & 0xFFFF)))))
  1888. /* Read word (2 bytes) from LRAM assuming that the address is already set. */
  1889. #define AdvReadWordAutoIncLram(iop_base) \
  1890. (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA))
  1891. /* Write word (2 bytes) to LRAM assuming that the address is already set. */
  1892. #define AdvWriteWordAutoIncLram(iop_base, word) \
  1893. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
  1894. /*
  1895. * Define macro to check for Condor signature.
  1896. *
  1897. * Evaluate to ADV_TRUE if a Condor chip is found the specified port
  1898. * address 'iop_base'. Otherwise evalue to ADV_FALSE.
  1899. */
  1900. #define AdvFindSignature(iop_base) \
  1901. (((AdvReadByteRegister((iop_base), IOPB_CHIP_ID_1) == \
  1902. ADV_CHIP_ID_BYTE) && \
  1903. (AdvReadWordRegister((iop_base), IOPW_CHIP_ID_0) == \
  1904. ADV_CHIP_ID_WORD)) ? ADV_TRUE : ADV_FALSE)
  1905. /*
  1906. * Define macro to Return the version number of the chip at 'iop_base'.
  1907. *
  1908. * The second parameter 'bus_type' is currently unused.
  1909. */
  1910. #define AdvGetChipVersion(iop_base, bus_type) \
  1911. AdvReadByteRegister((iop_base), IOPB_CHIP_TYPE_REV)
  1912. /*
  1913. * Abort an SRB in the chip's RISC Memory. The 'srb_ptr' argument must
  1914. * match the ASC_SCSI_REQ_Q 'srb_ptr' field.
  1915. *
  1916. * If the request has not yet been sent to the device it will simply be
  1917. * aborted from RISC memory. If the request is disconnected it will be
  1918. * aborted on reselection by sending an Abort Message to the target ID.
  1919. *
  1920. * Return value:
  1921. * ADV_TRUE(1) - Queue was successfully aborted.
  1922. * ADV_FALSE(0) - Queue was not found on the active queue list.
  1923. */
  1924. #define AdvAbortQueue(asc_dvc, scsiq) \
  1925. AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_ABORT, \
  1926. (ADV_DCNT) (scsiq))
  1927. /*
  1928. * Send a Bus Device Reset Message to the specified target ID.
  1929. *
  1930. * All outstanding commands will be purged if sending the
  1931. * Bus Device Reset Message is successful.
  1932. *
  1933. * Return Value:
  1934. * ADV_TRUE(1) - All requests on the target are purged.
  1935. * ADV_FALSE(0) - Couldn't issue Bus Device Reset Message; Requests
  1936. * are not purged.
  1937. */
  1938. #define AdvResetDevice(asc_dvc, target_id) \
  1939. AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_DEVICE_RESET, \
  1940. (ADV_DCNT) (target_id))
  1941. /*
  1942. * SCSI Wide Type definition.
  1943. */
  1944. #define ADV_SCSI_BIT_ID_TYPE ushort
  1945. /*
  1946. * AdvInitScsiTarget() 'cntl_flag' options.
  1947. */
  1948. #define ADV_SCAN_LUN 0x01
  1949. #define ADV_CAPINFO_NOLUN 0x02
  1950. /*
  1951. * Convert target id to target id bit mask.
  1952. */
  1953. #define ADV_TID_TO_TIDMASK(tid) (0x01 << ((tid) & ADV_MAX_TID))
  1954. /*
  1955. * ASC_SCSI_REQ_Q 'done_status' and 'host_status' return values.
  1956. */
  1957. #define QD_NO_STATUS 0x00 /* Request not completed yet. */
  1958. #define QD_NO_ERROR 0x01
  1959. #define QD_ABORTED_BY_HOST 0x02
  1960. #define QD_WITH_ERROR 0x04
  1961. #define QHSTA_NO_ERROR 0x00
  1962. #define QHSTA_M_SEL_TIMEOUT 0x11
  1963. #define QHSTA_M_DATA_OVER_RUN 0x12
  1964. #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
  1965. #define QHSTA_M_QUEUE_ABORTED 0x15
  1966. #define QHSTA_M_SXFR_SDMA_ERR 0x16 /* SXFR_STATUS SCSI DMA Error */
  1967. #define QHSTA_M_SXFR_SXFR_PERR 0x17 /* SXFR_STATUS SCSI Bus Parity Error */
  1968. #define QHSTA_M_RDMA_PERR 0x18 /* RISC PCI DMA parity error */
  1969. #define QHSTA_M_SXFR_OFF_UFLW 0x19 /* SXFR_STATUS Offset Underflow */
  1970. #define QHSTA_M_SXFR_OFF_OFLW 0x20 /* SXFR_STATUS Offset Overflow */
  1971. #define QHSTA_M_SXFR_WD_TMO 0x21 /* SXFR_STATUS Watchdog Timeout */
  1972. #define QHSTA_M_SXFR_DESELECTED 0x22 /* SXFR_STATUS Deselected */
  1973. /* Note: QHSTA_M_SXFR_XFR_OFLW is identical to QHSTA_M_DATA_OVER_RUN. */
  1974. #define QHSTA_M_SXFR_XFR_OFLW 0x12 /* SXFR_STATUS Transfer Overflow */
  1975. #define QHSTA_M_SXFR_XFR_PH_ERR 0x24 /* SXFR_STATUS Transfer Phase Error */
  1976. #define QHSTA_M_SXFR_UNKNOWN_ERROR 0x25 /* SXFR_STATUS Unknown Error */
  1977. #define QHSTA_M_SCSI_BUS_RESET 0x30 /* Request aborted from SBR */
  1978. #define QHSTA_M_SCSI_BUS_RESET_UNSOL 0x31 /* Request aborted from unsol. SBR */
  1979. #define QHSTA_M_BUS_DEVICE_RESET 0x32 /* Request aborted from BDR */
  1980. #define QHSTA_M_DIRECTION_ERR 0x35 /* Data Phase mismatch */
  1981. #define QHSTA_M_DIRECTION_ERR_HUNG 0x36 /* Data Phase mismatch and bus hang */
  1982. #define QHSTA_M_WTM_TIMEOUT 0x41
  1983. #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
  1984. #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
  1985. #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
  1986. #define QHSTA_M_INVALID_DEVICE 0x45 /* Bad target ID */
  1987. #define QHSTA_M_FROZEN_TIDQ 0x46 /* TID Queue frozen. */
  1988. #define QHSTA_M_SGBACKUP_ERROR 0x47 /* Scatter-Gather backup error */
  1989. /* Return the address that is aligned at the next doubleword >= to 'addr'. */
  1990. #define ADV_8BALIGN(addr) (((ulong) (addr) + 0x7) & ~0x7)
  1991. #define ADV_16BALIGN(addr) (((ulong) (addr) + 0xF) & ~0xF)
  1992. #define ADV_32BALIGN(addr) (((ulong) (addr) + 0x1F) & ~0x1F)
  1993. /*
  1994. * Total contiguous memory needed for driver SG blocks.
  1995. *
  1996. * ADV_MAX_SG_LIST must be defined by a driver. It is the maximum
  1997. * number of scatter-gather elements the driver supports in a
  1998. * single request.
  1999. */
  2000. #define ADV_SG_LIST_MAX_BYTE_SIZE \
  2001. (sizeof(ADV_SG_BLOCK) * \
  2002. ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK))
  2003. /* struct asc_board flags */
  2004. #define ASC_IS_WIDE_BOARD 0x04 /* AdvanSys Wide Board */
  2005. #define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0)
  2006. #define NO_ISA_DMA 0xff /* No ISA DMA Channel Used */
  2007. #define ASC_INFO_SIZE 128 /* advansys_info() line size */
  2008. #ifdef CONFIG_PROC_FS
  2009. /* /proc/scsi/advansys/[0...] related definitions */
  2010. #define ASC_PRTBUF_SIZE 2048
  2011. #define ASC_PRTLINE_SIZE 160
  2012. #define ASC_PRT_NEXT() \
  2013. if (cp) { \
  2014. totlen += len; \
  2015. leftlen -= len; \
  2016. if (leftlen == 0) { \
  2017. return totlen; \
  2018. } \
  2019. cp += len; \
  2020. }
  2021. #endif /* CONFIG_PROC_FS */
  2022. /* Asc Library return codes */
  2023. #define ASC_TRUE 1
  2024. #define ASC_FALSE 0
  2025. #define ASC_NOERROR 1
  2026. #define ASC_BUSY 0
  2027. #define ASC_ERROR (-1)
  2028. /* struct scsi_cmnd function return codes */
  2029. #define STATUS_BYTE(byte) (byte)
  2030. #define MSG_BYTE(byte) ((byte) << 8)
  2031. #define HOST_BYTE(byte) ((byte) << 16)
  2032. #define DRIVER_BYTE(byte) ((byte) << 24)
  2033. #define ASC_STATS(shost, counter) ASC_STATS_ADD(shost, counter, 1)
  2034. #ifndef ADVANSYS_STATS
  2035. #define ASC_STATS_ADD(shost, counter, count)
  2036. #else /* ADVANSYS_STATS */
  2037. #define ASC_STATS_ADD(shost, counter, count) \
  2038. (((struct asc_board *) shost_priv(shost))->asc_stats.counter += (count))
  2039. #endif /* ADVANSYS_STATS */
  2040. /* If the result wraps when calculating tenths, return 0. */
  2041. #define ASC_TENTHS(num, den) \
  2042. (((10 * ((num)/(den))) > (((num) * 10)/(den))) ? \
  2043. 0 : ((((num) * 10)/(den)) - (10 * ((num)/(den)))))
  2044. /*
  2045. * Display a message to the console.
  2046. */
  2047. #define ASC_PRINT(s) \
  2048. { \
  2049. printk("advansys: "); \
  2050. printk(s); \
  2051. }
  2052. #define ASC_PRINT1(s, a1) \
  2053. { \
  2054. printk("advansys: "); \
  2055. printk((s), (a1)); \
  2056. }
  2057. #define ASC_PRINT2(s, a1, a2) \
  2058. { \
  2059. printk("advansys: "); \
  2060. printk((s), (a1), (a2)); \
  2061. }
  2062. #define ASC_PRINT3(s, a1, a2, a3) \
  2063. { \
  2064. printk("advansys: "); \
  2065. printk((s), (a1), (a2), (a3)); \
  2066. }
  2067. #define ASC_PRINT4(s, a1, a2, a3, a4) \
  2068. { \
  2069. printk("advansys: "); \
  2070. printk((s), (a1), (a2), (a3), (a4)); \
  2071. }
  2072. #ifndef ADVANSYS_DEBUG
  2073. #define ASC_DBG(lvl, s...)
  2074. #define ASC_DBG_PRT_SCSI_HOST(lvl, s)
  2075. #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp)
  2076. #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
  2077. #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone)
  2078. #define ADV_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
  2079. #define ASC_DBG_PRT_HEX(lvl, name, start, length)
  2080. #define ASC_DBG_PRT_CDB(lvl, cdb, len)
  2081. #define ASC_DBG_PRT_SENSE(lvl, sense, len)
  2082. #define ASC_DBG_PRT_INQUIRY(lvl, inq, len)
  2083. #else /* ADVANSYS_DEBUG */
  2084. /*
  2085. * Debugging Message Levels:
  2086. * 0: Errors Only
  2087. * 1: High-Level Tracing
  2088. * 2-N: Verbose Tracing
  2089. */
  2090. #define ASC_DBG(lvl, format, arg...) { \
  2091. if (asc_dbglvl >= (lvl)) \
  2092. printk(KERN_DEBUG "%s: %s: " format, DRV_NAME, \
  2093. __FUNCTION__ , ## arg); \
  2094. }
  2095. #define ASC_DBG_PRT_SCSI_HOST(lvl, s) \
  2096. { \
  2097. if (asc_dbglvl >= (lvl)) { \
  2098. asc_prt_scsi_host(s); \
  2099. } \
  2100. }
  2101. #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp) \
  2102. { \
  2103. if (asc_dbglvl >= (lvl)) { \
  2104. asc_prt_asc_scsi_q(scsiqp); \
  2105. } \
  2106. }
  2107. #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone) \
  2108. { \
  2109. if (asc_dbglvl >= (lvl)) { \
  2110. asc_prt_asc_qdone_info(qdone); \
  2111. } \
  2112. }
  2113. #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp) \
  2114. { \
  2115. if (asc_dbglvl >= (lvl)) { \
  2116. asc_prt_adv_scsi_req_q(scsiqp); \
  2117. } \
  2118. }
  2119. #define ASC_DBG_PRT_HEX(lvl, name, start, length) \
  2120. { \
  2121. if (asc_dbglvl >= (lvl)) { \
  2122. asc_prt_hex((name), (start), (length)); \
  2123. } \
  2124. }
  2125. #define ASC_DBG_PRT_CDB(lvl, cdb, len) \
  2126. ASC_DBG_PRT_HEX((lvl), "CDB", (uchar *) (cdb), (len));
  2127. #define ASC_DBG_PRT_SENSE(lvl, sense, len) \
  2128. ASC_DBG_PRT_HEX((lvl), "SENSE", (uchar *) (sense), (len));
  2129. #define ASC_DBG_PRT_INQUIRY(lvl, inq, len) \
  2130. ASC_DBG_PRT_HEX((lvl), "INQUIRY", (uchar *) (inq), (len));
  2131. #endif /* ADVANSYS_DEBUG */
  2132. #ifdef ADVANSYS_STATS
  2133. /* Per board statistics structure */
  2134. struct asc_stats {
  2135. /* Driver Entrypoint Statistics */
  2136. ADV_DCNT queuecommand; /* # calls to advansys_queuecommand() */
  2137. ADV_DCNT reset; /* # calls to advansys_eh_bus_reset() */
  2138. ADV_DCNT biosparam; /* # calls to advansys_biosparam() */
  2139. ADV_DCNT interrupt; /* # advansys_interrupt() calls */
  2140. ADV_DCNT callback; /* # calls to asc/adv_isr_callback() */
  2141. ADV_DCNT done; /* # calls to request's scsi_done function */
  2142. ADV_DCNT build_error; /* # asc/adv_build_req() ASC_ERROR returns. */
  2143. ADV_DCNT adv_build_noreq; /* # adv_build_req() adv_req_t alloc. fail. */
  2144. ADV_DCNT adv_build_nosg; /* # adv_build_req() adv_sgblk_t alloc. fail. */
  2145. /* AscExeScsiQueue()/AdvExeScsiQueue() Statistics */
  2146. ADV_DCNT exe_noerror; /* # ASC_NOERROR returns. */
  2147. ADV_DCNT exe_busy; /* # ASC_BUSY returns. */
  2148. ADV_DCNT exe_error; /* # ASC_ERROR returns. */
  2149. ADV_DCNT exe_unknown; /* # unknown returns. */
  2150. /* Data Transfer Statistics */
  2151. ADV_DCNT xfer_cnt; /* # I/O requests received */
  2152. ADV_DCNT xfer_elem; /* # scatter-gather elements */
  2153. ADV_DCNT xfer_sect; /* # 512-byte blocks */
  2154. };
  2155. #endif /* ADVANSYS_STATS */
  2156. /*
  2157. * Structure allocated for each board.
  2158. *
  2159. * This structure is allocated by scsi_host_alloc() at the end
  2160. * of the 'Scsi_Host' structure starting at the 'hostdata'
  2161. * field. It is guaranteed to be allocated from DMA-able memory.
  2162. */
  2163. struct asc_board {
  2164. struct device *dev;
  2165. uint flags; /* Board flags */
  2166. unsigned int irq;
  2167. union {
  2168. ASC_DVC_VAR asc_dvc_var; /* Narrow board */
  2169. ADV_DVC_VAR adv_dvc_var; /* Wide board */
  2170. } dvc_var;
  2171. union {
  2172. ASC_DVC_CFG asc_dvc_cfg; /* Narrow board */
  2173. ADV_DVC_CFG adv_dvc_cfg; /* Wide board */
  2174. } dvc_cfg;
  2175. ushort asc_n_io_port; /* Number I/O ports. */
  2176. ADV_SCSI_BIT_ID_TYPE init_tidmask; /* Target init./valid mask */
  2177. ushort reqcnt[ADV_MAX_TID + 1]; /* Starvation request count */
  2178. ADV_SCSI_BIT_ID_TYPE queue_full; /* Queue full mask */
  2179. ushort queue_full_cnt[ADV_MAX_TID + 1]; /* Queue full count */
  2180. union {
  2181. ASCEEP_CONFIG asc_eep; /* Narrow EEPROM config. */
  2182. ADVEEP_3550_CONFIG adv_3550_eep; /* 3550 EEPROM config. */
  2183. ADVEEP_38C0800_CONFIG adv_38C0800_eep; /* 38C0800 EEPROM config. */
  2184. ADVEEP_38C1600_CONFIG adv_38C1600_eep; /* 38C1600 EEPROM config. */
  2185. } eep_config;
  2186. ulong last_reset; /* Saved last reset time */
  2187. /* /proc/scsi/advansys/[0...] */
  2188. char *prtbuf; /* /proc print buffer */
  2189. #ifdef ADVANSYS_STATS
  2190. struct asc_stats asc_stats; /* Board statistics */
  2191. #endif /* ADVANSYS_STATS */
  2192. /*
  2193. * The following fields are used only for Narrow Boards.
  2194. */
  2195. uchar sdtr_data[ASC_MAX_TID + 1]; /* SDTR information */
  2196. /*
  2197. * The following fields are used only for Wide Boards.
  2198. */
  2199. void __iomem *ioremap_addr; /* I/O Memory remap address. */
  2200. ushort ioport; /* I/O Port address. */
  2201. adv_req_t *adv_reqp; /* Request structures. */
  2202. adv_sgblk_t *adv_sgblkp; /* Scatter-gather structures. */
  2203. ushort bios_signature; /* BIOS Signature. */
  2204. ushort bios_version; /* BIOS Version. */
  2205. ushort bios_codeseg; /* BIOS Code Segment. */
  2206. ushort bios_codelen; /* BIOS Code Segment Length. */
  2207. };
  2208. #define adv_dvc_to_board(adv_dvc) container_of(adv_dvc, struct asc_board, \
  2209. dvc_var.adv_dvc_var)
  2210. #define adv_dvc_to_pdev(adv_dvc) to_pci_dev(adv_dvc_to_board(adv_dvc)->dev)
  2211. /* Overrun buffer used by all narrow boards. */
  2212. static uchar overrun_buf[ASC_OVERRUN_BSIZE] = { 0 };
  2213. #ifdef ADVANSYS_DEBUG
  2214. static int asc_dbglvl = 3;
  2215. /*
  2216. * asc_prt_asc_dvc_var()
  2217. */
  2218. static void asc_prt_asc_dvc_var(ASC_DVC_VAR *h)
  2219. {
  2220. printk("ASC_DVC_VAR at addr 0x%lx\n", (ulong)h);
  2221. printk(" iop_base 0x%x, err_code 0x%x, dvc_cntl 0x%x, bug_fix_cntl "
  2222. "%d,\n", h->iop_base, h->err_code, h->dvc_cntl, h->bug_fix_cntl);
  2223. printk(" bus_type %d, init_sdtr 0x%x,\n", h->bus_type,
  2224. (unsigned)h->init_sdtr);
  2225. printk(" sdtr_done 0x%x, use_tagged_qng 0x%x, unit_not_ready 0x%x, "
  2226. "chip_no 0x%x,\n", (unsigned)h->sdtr_done,
  2227. (unsigned)h->use_tagged_qng, (unsigned)h->unit_not_ready,
  2228. (unsigned)h->chip_no);
  2229. printk(" queue_full_or_busy 0x%x, start_motor 0x%x, scsi_reset_wait "
  2230. "%u,\n", (unsigned)h->queue_full_or_busy,
  2231. (unsigned)h->start_motor, (unsigned)h->scsi_reset_wait);
  2232. printk(" is_in_int %u, max_total_qng %u, cur_total_qng %u, "
  2233. "in_critical_cnt %u,\n", (unsigned)h->is_in_int,
  2234. (unsigned)h->max_total_qng, (unsigned)h->cur_total_qng,
  2235. (unsigned)h->in_critical_cnt);
  2236. printk(" last_q_shortage %u, init_state 0x%x, no_scam 0x%x, "
  2237. "pci_fix_asyn_xfer 0x%x,\n", (unsigned)h->last_q_shortage,
  2238. (unsigned)h->init_state, (unsigned)h->no_scam,
  2239. (unsigned)h->pci_fix_asyn_xfer);
  2240. printk(" cfg 0x%lx\n", (ulong)h->cfg);
  2241. }
  2242. /*
  2243. * asc_prt_asc_dvc_cfg()
  2244. */
  2245. static void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *h)
  2246. {
  2247. printk("ASC_DVC_CFG at addr 0x%lx\n", (ulong)h);
  2248. printk(" can_tagged_qng 0x%x, cmd_qng_enabled 0x%x,\n",
  2249. h->can_tagged_qng, h->cmd_qng_enabled);
  2250. printk(" disc_enable 0x%x, sdtr_enable 0x%x,\n",
  2251. h->disc_enable, h->sdtr_enable);
  2252. printk(" chip_scsi_id %d, isa_dma_speed %d, isa_dma_channel %d, "
  2253. "chip_version %d,\n", h->chip_scsi_id, h->isa_dma_speed,
  2254. h->isa_dma_channel, h->chip_version);
  2255. printk(" mcode_date 0x%x, mcode_version %d, overrun_buf 0x%p\n",
  2256. h->mcode_date, h->mcode_version, h->overrun_buf);
  2257. }
  2258. /*
  2259. * asc_prt_adv_dvc_var()
  2260. *
  2261. * Display an ADV_DVC_VAR structure.
  2262. */
  2263. static void asc_prt_adv_dvc_var(ADV_DVC_VAR *h)
  2264. {
  2265. printk(" ADV_DVC_VAR at addr 0x%lx\n", (ulong)h);
  2266. printk(" iop_base 0x%lx, err_code 0x%x, ultra_able 0x%x\n",
  2267. (ulong)h->iop_base, h->err_code, (unsigned)h->ultra_able);
  2268. printk(" sdtr_able 0x%x, wdtr_able 0x%x\n",
  2269. (unsigned)h->sdtr_able, (unsigned)h->wdtr_able);
  2270. printk(" start_motor 0x%x, scsi_reset_wait 0x%x\n",
  2271. (unsigned)h->start_motor, (unsigned)h->scsi_reset_wait);
  2272. printk(" max_host_qng %u, max_dvc_qng %u, carr_freelist 0x%lxn\n",
  2273. (unsigned)h->max_host_qng, (unsigned)h->max_dvc_qng,
  2274. (ulong)h->carr_freelist);
  2275. printk(" icq_sp 0x%lx, irq_sp 0x%lx\n",
  2276. (ulong)h->icq_sp, (ulong)h->irq_sp);
  2277. printk(" no_scam 0x%x, tagqng_able 0x%x\n",
  2278. (unsigned)h->no_scam, (unsigned)h->tagqng_able);
  2279. printk(" chip_scsi_id 0x%x, cfg 0x%lx\n",
  2280. (unsigned)h->chip_scsi_id, (ulong)h->cfg);
  2281. }
  2282. /*
  2283. * asc_prt_adv_dvc_cfg()
  2284. *
  2285. * Display an ADV_DVC_CFG structure.
  2286. */
  2287. static void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *h)
  2288. {
  2289. printk(" ADV_DVC_CFG at addr 0x%lx\n", (ulong)h);
  2290. printk(" disc_enable 0x%x, termination 0x%x\n",
  2291. h->disc_enable, h->termination);
  2292. printk(" chip_version 0x%x, mcode_date 0x%x\n",
  2293. h->chip_version, h->mcode_date);
  2294. printk(" mcode_version 0x%x, control_flag 0x%x\n",
  2295. h->mcode_version, h->control_flag);
  2296. }
  2297. /*
  2298. * asc_prt_scsi_host()
  2299. */
  2300. static void asc_prt_scsi_host(struct Scsi_Host *s)
  2301. {
  2302. struct asc_board *boardp = shost_priv(s);
  2303. printk("Scsi_Host at addr 0x%p, device %s\n", s, boardp->dev->bus_id);
  2304. printk(" host_busy %u, host_no %d, last_reset %d,\n",
  2305. s->host_busy, s->host_no, (unsigned)s->last_reset);
  2306. printk(" base 0x%lx, io_port 0x%lx, irq %d,\n",
  2307. (ulong)s->base, (ulong)s->io_port, boardp->irq);
  2308. printk(" dma_channel %d, this_id %d, can_queue %d,\n",
  2309. s->dma_channel, s->this_id, s->can_queue);
  2310. printk(" cmd_per_lun %d, sg_tablesize %d, unchecked_isa_dma %d\n",
  2311. s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma);
  2312. if (ASC_NARROW_BOARD(boardp)) {
  2313. asc_prt_asc_dvc_var(&boardp->dvc_var.asc_dvc_var);
  2314. asc_prt_asc_dvc_cfg(&boardp->dvc_cfg.asc_dvc_cfg);
  2315. } else {
  2316. asc_prt_adv_dvc_var(&boardp->dvc_var.adv_dvc_var);
  2317. asc_prt_adv_dvc_cfg(&boardp->dvc_cfg.adv_dvc_cfg);
  2318. }
  2319. }
  2320. /*
  2321. * asc_prt_hex()
  2322. *
  2323. * Print hexadecimal output in 4 byte groupings 32 bytes
  2324. * or 8 double-words per line.
  2325. */
  2326. static void asc_prt_hex(char *f, uchar *s, int l)
  2327. {
  2328. int i;
  2329. int j;
  2330. int k;
  2331. int m;
  2332. printk("%s: (%d bytes)\n", f, l);
  2333. for (i = 0; i < l; i += 32) {
  2334. /* Display a maximum of 8 double-words per line. */
  2335. if ((k = (l - i) / 4) >= 8) {
  2336. k = 8;
  2337. m = 0;
  2338. } else {
  2339. m = (l - i) % 4;
  2340. }
  2341. for (j = 0; j < k; j++) {
  2342. printk(" %2.2X%2.2X%2.2X%2.2X",
  2343. (unsigned)s[i + (j * 4)],
  2344. (unsigned)s[i + (j * 4) + 1],
  2345. (unsigned)s[i + (j * 4) + 2],
  2346. (unsigned)s[i + (j * 4) + 3]);
  2347. }
  2348. switch (m) {
  2349. case 0:
  2350. default:
  2351. break;
  2352. case 1:
  2353. printk(" %2.2X", (unsigned)s[i + (j * 4)]);
  2354. break;
  2355. case 2:
  2356. printk(" %2.2X%2.2X",
  2357. (unsigned)s[i + (j * 4)],
  2358. (unsigned)s[i + (j * 4) + 1]);
  2359. break;
  2360. case 3:
  2361. printk(" %2.2X%2.2X%2.2X",
  2362. (unsigned)s[i + (j * 4) + 1],
  2363. (unsigned)s[i + (j * 4) + 2],
  2364. (unsigned)s[i + (j * 4) + 3]);
  2365. break;
  2366. }
  2367. printk("\n");
  2368. }
  2369. }
  2370. /*
  2371. * asc_prt_asc_scsi_q()
  2372. */
  2373. static void asc_prt_asc_scsi_q(ASC_SCSI_Q *q)
  2374. {
  2375. ASC_SG_HEAD *sgp;
  2376. int i;
  2377. printk("ASC_SCSI_Q at addr 0x%lx\n", (ulong)q);
  2378. printk
  2379. (" target_ix 0x%x, target_lun %u, srb_ptr 0x%lx, tag_code 0x%x,\n",
  2380. q->q2.target_ix, q->q1.target_lun, (ulong)q->q2.srb_ptr,
  2381. q->q2.tag_code);
  2382. printk
  2383. (" data_addr 0x%lx, data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  2384. (ulong)le32_to_cpu(q->q1.data_addr),
  2385. (ulong)le32_to_cpu(q->q1.data_cnt),
  2386. (ulong)le32_to_cpu(q->q1.sense_addr), q->q1.sense_len);
  2387. printk(" cdbptr 0x%lx, cdb_len %u, sg_head 0x%lx, sg_queue_cnt %u\n",
  2388. (ulong)q->cdbptr, q->q2.cdb_len,
  2389. (ulong)q->sg_head, q->q1.sg_queue_cnt);
  2390. if (q->sg_head) {
  2391. sgp = q->sg_head;
  2392. printk("ASC_SG_HEAD at addr 0x%lx\n", (ulong)sgp);
  2393. printk(" entry_cnt %u, queue_cnt %u\n", sgp->entry_cnt,
  2394. sgp->queue_cnt);
  2395. for (i = 0; i < sgp->entry_cnt; i++) {
  2396. printk(" [%u]: addr 0x%lx, bytes %lu\n",
  2397. i, (ulong)le32_to_cpu(sgp->sg_list[i].addr),
  2398. (ulong)le32_to_cpu(sgp->sg_list[i].bytes));
  2399. }
  2400. }
  2401. }
  2402. /*
  2403. * asc_prt_asc_qdone_info()
  2404. */
  2405. static void asc_prt_asc_qdone_info(ASC_QDONE_INFO *q)
  2406. {
  2407. printk("ASC_QDONE_INFO at addr 0x%lx\n", (ulong)q);
  2408. printk(" srb_ptr 0x%lx, target_ix %u, cdb_len %u, tag_code %u,\n",
  2409. (ulong)q->d2.srb_ptr, q->d2.target_ix, q->d2.cdb_len,
  2410. q->d2.tag_code);
  2411. printk
  2412. (" done_stat 0x%x, host_stat 0x%x, scsi_stat 0x%x, scsi_msg 0x%x\n",
  2413. q->d3.done_stat, q->d3.host_stat, q->d3.scsi_stat, q->d3.scsi_msg);
  2414. }
  2415. /*
  2416. * asc_prt_adv_sgblock()
  2417. *
  2418. * Display an ADV_SG_BLOCK structure.
  2419. */
  2420. static void asc_prt_adv_sgblock(int sgblockno, ADV_SG_BLOCK *b)
  2421. {
  2422. int i;
  2423. printk(" ASC_SG_BLOCK at addr 0x%lx (sgblockno %d)\n",
  2424. (ulong)b, sgblockno);
  2425. printk(" sg_cnt %u, sg_ptr 0x%lx\n",
  2426. b->sg_cnt, (ulong)le32_to_cpu(b->sg_ptr));
  2427. BUG_ON(b->sg_cnt > NO_OF_SG_PER_BLOCK);
  2428. if (b->sg_ptr != 0)
  2429. BUG_ON(b->sg_cnt != NO_OF_SG_PER_BLOCK);
  2430. for (i = 0; i < b->sg_cnt; i++) {
  2431. printk(" [%u]: sg_addr 0x%lx, sg_count 0x%lx\n",
  2432. i, (ulong)b->sg_list[i].sg_addr,
  2433. (ulong)b->sg_list[i].sg_count);
  2434. }
  2435. }
  2436. /*
  2437. * asc_prt_adv_scsi_req_q()
  2438. *
  2439. * Display an ADV_SCSI_REQ_Q structure.
  2440. */
  2441. static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
  2442. {
  2443. int sg_blk_cnt;
  2444. struct asc_sg_block *sg_ptr;
  2445. printk("ADV_SCSI_REQ_Q at addr 0x%lx\n", (ulong)q);
  2446. printk(" target_id %u, target_lun %u, srb_ptr 0x%lx, a_flag 0x%x\n",
  2447. q->target_id, q->target_lun, (ulong)q->srb_ptr, q->a_flag);
  2448. printk(" cntl 0x%x, data_addr 0x%lx, vdata_addr 0x%lx\n",
  2449. q->cntl, (ulong)le32_to_cpu(q->data_addr), (ulong)q->vdata_addr);
  2450. printk(" data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  2451. (ulong)le32_to_cpu(q->data_cnt),
  2452. (ulong)le32_to_cpu(q->sense_addr), q->sense_len);
  2453. printk
  2454. (" cdb_len %u, done_status 0x%x, host_status 0x%x, scsi_status 0x%x\n",
  2455. q->cdb_len, q->done_status, q->host_status, q->scsi_status);
  2456. printk(" sg_working_ix 0x%x, target_cmd %u\n",
  2457. q->sg_working_ix, q->target_cmd);
  2458. printk(" scsiq_rptr 0x%lx, sg_real_addr 0x%lx, sg_list_ptr 0x%lx\n",
  2459. (ulong)le32_to_cpu(q->scsiq_rptr),
  2460. (ulong)le32_to_cpu(q->sg_real_addr), (ulong)q->sg_list_ptr);
  2461. /* Display the request's ADV_SG_BLOCK structures. */
  2462. if (q->sg_list_ptr != NULL) {
  2463. sg_blk_cnt = 0;
  2464. while (1) {
  2465. /*
  2466. * 'sg_ptr' is a physical address. Convert it to a virtual
  2467. * address by indexing 'sg_blk_cnt' into the virtual address
  2468. * array 'sg_list_ptr'.
  2469. *
  2470. * XXX - Assumes all SG physical blocks are virtually contiguous.
  2471. */
  2472. sg_ptr =
  2473. &(((ADV_SG_BLOCK *)(q->sg_list_ptr))[sg_blk_cnt]);
  2474. asc_prt_adv_sgblock(sg_blk_cnt, sg_ptr);
  2475. if (sg_ptr->sg_ptr == 0) {
  2476. break;
  2477. }
  2478. sg_blk_cnt++;
  2479. }
  2480. }
  2481. }
  2482. #endif /* ADVANSYS_DEBUG */
  2483. /*
  2484. * advansys_info()
  2485. *
  2486. * Return suitable for printing on the console with the argument
  2487. * adapter's configuration information.
  2488. *
  2489. * Note: The information line should not exceed ASC_INFO_SIZE bytes,
  2490. * otherwise the static 'info' array will be overrun.
  2491. */
  2492. static const char *advansys_info(struct Scsi_Host *shost)
  2493. {
  2494. static char info[ASC_INFO_SIZE];
  2495. struct asc_board *boardp = shost_priv(shost);
  2496. ASC_DVC_VAR *asc_dvc_varp;
  2497. ADV_DVC_VAR *adv_dvc_varp;
  2498. char *busname;
  2499. char *widename = NULL;
  2500. if (ASC_NARROW_BOARD(boardp)) {
  2501. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  2502. ASC_DBG(1, "begin\n");
  2503. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  2504. if ((asc_dvc_varp->bus_type & ASC_IS_ISAPNP) ==
  2505. ASC_IS_ISAPNP) {
  2506. busname = "ISA PnP";
  2507. } else {
  2508. busname = "ISA";
  2509. }
  2510. sprintf(info,
  2511. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X, DMA 0x%X",
  2512. ASC_VERSION, busname,
  2513. (ulong)shost->io_port,
  2514. (ulong)shost->io_port + ASC_IOADR_GAP - 1,
  2515. boardp->irq, shost->dma_channel);
  2516. } else {
  2517. if (asc_dvc_varp->bus_type & ASC_IS_VL) {
  2518. busname = "VL";
  2519. } else if (asc_dvc_varp->bus_type & ASC_IS_EISA) {
  2520. busname = "EISA";
  2521. } else if (asc_dvc_varp->bus_type & ASC_IS_PCI) {
  2522. if ((asc_dvc_varp->bus_type & ASC_IS_PCI_ULTRA)
  2523. == ASC_IS_PCI_ULTRA) {
  2524. busname = "PCI Ultra";
  2525. } else {
  2526. busname = "PCI";
  2527. }
  2528. } else {
  2529. busname = "?";
  2530. shost_printk(KERN_ERR, shost, "unknown bus "
  2531. "type %d\n", asc_dvc_varp->bus_type);
  2532. }
  2533. sprintf(info,
  2534. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X",
  2535. ASC_VERSION, busname, (ulong)shost->io_port,
  2536. (ulong)shost->io_port + ASC_IOADR_GAP - 1,
  2537. boardp->irq);
  2538. }
  2539. } else {
  2540. /*
  2541. * Wide Adapter Information
  2542. *
  2543. * Memory-mapped I/O is used instead of I/O space to access
  2544. * the adapter, but display the I/O Port range. The Memory
  2545. * I/O address is displayed through the driver /proc file.
  2546. */
  2547. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  2548. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  2549. widename = "Ultra-Wide";
  2550. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  2551. widename = "Ultra2-Wide";
  2552. } else {
  2553. widename = "Ultra3-Wide";
  2554. }
  2555. sprintf(info,
  2556. "AdvanSys SCSI %s: PCI %s: PCIMEM 0x%lX-0x%lX, IRQ 0x%X",
  2557. ASC_VERSION, widename, (ulong)adv_dvc_varp->iop_base,
  2558. (ulong)adv_dvc_varp->iop_base + boardp->asc_n_io_port - 1, boardp->irq);
  2559. }
  2560. BUG_ON(strlen(info) >= ASC_INFO_SIZE);
  2561. ASC_DBG(1, "end\n");
  2562. return info;
  2563. }
  2564. #ifdef CONFIG_PROC_FS
  2565. /*
  2566. * asc_prt_line()
  2567. *
  2568. * If 'cp' is NULL print to the console, otherwise print to a buffer.
  2569. *
  2570. * Return 0 if printing to the console, otherwise return the number of
  2571. * bytes written to the buffer.
  2572. *
  2573. * Note: If any single line is greater than ASC_PRTLINE_SIZE bytes the stack
  2574. * will be corrupted. 's[]' is defined to be ASC_PRTLINE_SIZE bytes.
  2575. */
  2576. static int asc_prt_line(char *buf, int buflen, char *fmt, ...)
  2577. {
  2578. va_list args;
  2579. int ret;
  2580. char s[ASC_PRTLINE_SIZE];
  2581. va_start(args, fmt);
  2582. ret = vsprintf(s, fmt, args);
  2583. BUG_ON(ret >= ASC_PRTLINE_SIZE);
  2584. if (buf == NULL) {
  2585. (void)printk(s);
  2586. ret = 0;
  2587. } else {
  2588. ret = min(buflen, ret);
  2589. memcpy(buf, s, ret);
  2590. }
  2591. va_end(args);
  2592. return ret;
  2593. }
  2594. /*
  2595. * asc_prt_board_devices()
  2596. *
  2597. * Print driver information for devices attached to the board.
  2598. *
  2599. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  2600. * cf. asc_prt_line().
  2601. *
  2602. * Return the number of characters copied into 'cp'. No more than
  2603. * 'cplen' characters will be copied to 'cp'.
  2604. */
  2605. static int asc_prt_board_devices(struct Scsi_Host *shost, char *cp, int cplen)
  2606. {
  2607. struct asc_board *boardp = shost_priv(shost);
  2608. int leftlen;
  2609. int totlen;
  2610. int len;
  2611. int chip_scsi_id;
  2612. int i;
  2613. leftlen = cplen;
  2614. totlen = len = 0;
  2615. len = asc_prt_line(cp, leftlen,
  2616. "\nDevice Information for AdvanSys SCSI Host %d:\n",
  2617. shost->host_no);
  2618. ASC_PRT_NEXT();
  2619. if (ASC_NARROW_BOARD(boardp)) {
  2620. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  2621. } else {
  2622. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  2623. }
  2624. len = asc_prt_line(cp, leftlen, "Target IDs Detected:");
  2625. ASC_PRT_NEXT();
  2626. for (i = 0; i <= ADV_MAX_TID; i++) {
  2627. if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) {
  2628. len = asc_prt_line(cp, leftlen, " %X,", i);
  2629. ASC_PRT_NEXT();
  2630. }
  2631. }
  2632. len = asc_prt_line(cp, leftlen, " (%X=Host Adapter)\n", chip_scsi_id);
  2633. ASC_PRT_NEXT();
  2634. return totlen;
  2635. }
  2636. /*
  2637. * Display Wide Board BIOS Information.
  2638. */
  2639. static int asc_prt_adv_bios(struct Scsi_Host *shost, char *cp, int cplen)
  2640. {
  2641. struct asc_board *boardp = shost_priv(shost);
  2642. int leftlen;
  2643. int totlen;
  2644. int len;
  2645. ushort major, minor, letter;
  2646. leftlen = cplen;
  2647. totlen = len = 0;
  2648. len = asc_prt_line(cp, leftlen, "\nROM BIOS Version: ");
  2649. ASC_PRT_NEXT();
  2650. /*
  2651. * If the BIOS saved a valid signature, then fill in
  2652. * the BIOS code segment base address.
  2653. */
  2654. if (boardp->bios_signature != 0x55AA) {
  2655. len = asc_prt_line(cp, leftlen, "Disabled or Pre-3.1\n");
  2656. ASC_PRT_NEXT();
  2657. len = asc_prt_line(cp, leftlen,
  2658. "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n");
  2659. ASC_PRT_NEXT();
  2660. len = asc_prt_line(cp, leftlen,
  2661. "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
  2662. ASC_PRT_NEXT();
  2663. } else {
  2664. major = (boardp->bios_version >> 12) & 0xF;
  2665. minor = (boardp->bios_version >> 8) & 0xF;
  2666. letter = (boardp->bios_version & 0xFF);
  2667. len = asc_prt_line(cp, leftlen, "%d.%d%c\n",
  2668. major, minor,
  2669. letter >= 26 ? '?' : letter + 'A');
  2670. ASC_PRT_NEXT();
  2671. /*
  2672. * Current available ROM BIOS release is 3.1I for UW
  2673. * and 3.2I for U2W. This code doesn't differentiate
  2674. * UW and U2W boards.
  2675. */
  2676. if (major < 3 || (major <= 3 && minor < 1) ||
  2677. (major <= 3 && minor <= 1 && letter < ('I' - 'A'))) {
  2678. len = asc_prt_line(cp, leftlen,
  2679. "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n");
  2680. ASC_PRT_NEXT();
  2681. len = asc_prt_line(cp, leftlen,
  2682. "ftp://ftp.connectcom.net/pub\n");
  2683. ASC_PRT_NEXT();
  2684. }
  2685. }
  2686. return totlen;
  2687. }
  2688. /*
  2689. * Add serial number to information bar if signature AAh
  2690. * is found in at bit 15-9 (7 bits) of word 1.
  2691. *
  2692. * Serial Number consists fo 12 alpha-numeric digits.
  2693. *
  2694. * 1 - Product type (A,B,C,D..) Word0: 15-13 (3 bits)
  2695. * 2 - MFG Location (A,B,C,D..) Word0: 12-10 (3 bits)
  2696. * 3-4 - Product ID (0-99) Word0: 9-0 (10 bits)
  2697. * 5 - Product revision (A-J) Word0: " "
  2698. *
  2699. * Signature Word1: 15-9 (7 bits)
  2700. * 6 - Year (0-9) Word1: 8-6 (3 bits) & Word2: 15 (1 bit)
  2701. * 7-8 - Week of the year (1-52) Word1: 5-0 (6 bits)
  2702. *
  2703. * 9-12 - Serial Number (A001-Z999) Word2: 14-0 (15 bits)
  2704. *
  2705. * Note 1: Only production cards will have a serial number.
  2706. *
  2707. * Note 2: Signature is most significant 7 bits (0xFE).
  2708. *
  2709. * Returns ASC_TRUE if serial number found, otherwise returns ASC_FALSE.
  2710. */
  2711. static int asc_get_eeprom_string(ushort *serialnum, uchar *cp)
  2712. {
  2713. ushort w, num;
  2714. if ((serialnum[1] & 0xFE00) != ((ushort)0xAA << 8)) {
  2715. return ASC_FALSE;
  2716. } else {
  2717. /*
  2718. * First word - 6 digits.
  2719. */
  2720. w = serialnum[0];
  2721. /* Product type - 1st digit. */
  2722. if ((*cp = 'A' + ((w & 0xE000) >> 13)) == 'H') {
  2723. /* Product type is P=Prototype */
  2724. *cp += 0x8;
  2725. }
  2726. cp++;
  2727. /* Manufacturing location - 2nd digit. */
  2728. *cp++ = 'A' + ((w & 0x1C00) >> 10);
  2729. /* Product ID - 3rd, 4th digits. */
  2730. num = w & 0x3FF;
  2731. *cp++ = '0' + (num / 100);
  2732. num %= 100;
  2733. *cp++ = '0' + (num / 10);
  2734. /* Product revision - 5th digit. */
  2735. *cp++ = 'A' + (num % 10);
  2736. /*
  2737. * Second word
  2738. */
  2739. w = serialnum[1];
  2740. /*
  2741. * Year - 6th digit.
  2742. *
  2743. * If bit 15 of third word is set, then the
  2744. * last digit of the year is greater than 7.
  2745. */
  2746. if (serialnum[2] & 0x8000) {
  2747. *cp++ = '8' + ((w & 0x1C0) >> 6);
  2748. } else {
  2749. *cp++ = '0' + ((w & 0x1C0) >> 6);
  2750. }
  2751. /* Week of year - 7th, 8th digits. */
  2752. num = w & 0x003F;
  2753. *cp++ = '0' + num / 10;
  2754. num %= 10;
  2755. *cp++ = '0' + num;
  2756. /*
  2757. * Third word
  2758. */
  2759. w = serialnum[2] & 0x7FFF;
  2760. /* Serial number - 9th digit. */
  2761. *cp++ = 'A' + (w / 1000);
  2762. /* 10th, 11th, 12th digits. */
  2763. num = w % 1000;
  2764. *cp++ = '0' + num / 100;
  2765. num %= 100;
  2766. *cp++ = '0' + num / 10;
  2767. num %= 10;
  2768. *cp++ = '0' + num;
  2769. *cp = '\0'; /* Null Terminate the string. */
  2770. return ASC_TRUE;
  2771. }
  2772. }
  2773. /*
  2774. * asc_prt_asc_board_eeprom()
  2775. *
  2776. * Print board EEPROM configuration.
  2777. *
  2778. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  2779. * cf. asc_prt_line().
  2780. *
  2781. * Return the number of characters copied into 'cp'. No more than
  2782. * 'cplen' characters will be copied to 'cp'.
  2783. */
  2784. static int asc_prt_asc_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
  2785. {
  2786. struct asc_board *boardp = shost_priv(shost);
  2787. ASC_DVC_VAR *asc_dvc_varp;
  2788. int leftlen;
  2789. int totlen;
  2790. int len;
  2791. ASCEEP_CONFIG *ep;
  2792. int i;
  2793. #ifdef CONFIG_ISA
  2794. int isa_dma_speed[] = { 10, 8, 7, 6, 5, 4, 3, 2 };
  2795. #endif /* CONFIG_ISA */
  2796. uchar serialstr[13];
  2797. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  2798. ep = &boardp->eep_config.asc_eep;
  2799. leftlen = cplen;
  2800. totlen = len = 0;
  2801. len = asc_prt_line(cp, leftlen,
  2802. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
  2803. shost->host_no);
  2804. ASC_PRT_NEXT();
  2805. if (asc_get_eeprom_string((ushort *)&ep->adapter_info[0], serialstr)
  2806. == ASC_TRUE) {
  2807. len =
  2808. asc_prt_line(cp, leftlen, " Serial Number: %s\n",
  2809. serialstr);
  2810. ASC_PRT_NEXT();
  2811. } else {
  2812. if (ep->adapter_info[5] == 0xBB) {
  2813. len = asc_prt_line(cp, leftlen,
  2814. " Default Settings Used for EEPROM-less Adapter.\n");
  2815. ASC_PRT_NEXT();
  2816. } else {
  2817. len = asc_prt_line(cp, leftlen,
  2818. " Serial Number Signature Not Present.\n");
  2819. ASC_PRT_NEXT();
  2820. }
  2821. }
  2822. len = asc_prt_line(cp, leftlen,
  2823. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  2824. ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng,
  2825. ep->max_tag_qng);
  2826. ASC_PRT_NEXT();
  2827. len = asc_prt_line(cp, leftlen,
  2828. " cntl 0x%x, no_scam 0x%x\n", ep->cntl, ep->no_scam);
  2829. ASC_PRT_NEXT();
  2830. len = asc_prt_line(cp, leftlen, " Target ID: ");
  2831. ASC_PRT_NEXT();
  2832. for (i = 0; i <= ASC_MAX_TID; i++) {
  2833. len = asc_prt_line(cp, leftlen, " %d", i);
  2834. ASC_PRT_NEXT();
  2835. }
  2836. len = asc_prt_line(cp, leftlen, "\n");
  2837. ASC_PRT_NEXT();
  2838. len = asc_prt_line(cp, leftlen, " Disconnects: ");
  2839. ASC_PRT_NEXT();
  2840. for (i = 0; i <= ASC_MAX_TID; i++) {
  2841. len = asc_prt_line(cp, leftlen, " %c",
  2842. (ep->
  2843. disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  2844. 'N');
  2845. ASC_PRT_NEXT();
  2846. }
  2847. len = asc_prt_line(cp, leftlen, "\n");
  2848. ASC_PRT_NEXT();
  2849. len = asc_prt_line(cp, leftlen, " Command Queuing: ");
  2850. ASC_PRT_NEXT();
  2851. for (i = 0; i <= ASC_MAX_TID; i++) {
  2852. len = asc_prt_line(cp, leftlen, " %c",
  2853. (ep->
  2854. use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  2855. 'N');
  2856. ASC_PRT_NEXT();
  2857. }
  2858. len = asc_prt_line(cp, leftlen, "\n");
  2859. ASC_PRT_NEXT();
  2860. len = asc_prt_line(cp, leftlen, " Start Motor: ");
  2861. ASC_PRT_NEXT();
  2862. for (i = 0; i <= ASC_MAX_TID; i++) {
  2863. len = asc_prt_line(cp, leftlen, " %c",
  2864. (ep->
  2865. start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  2866. 'N');
  2867. ASC_PRT_NEXT();
  2868. }
  2869. len = asc_prt_line(cp, leftlen, "\n");
  2870. ASC_PRT_NEXT();
  2871. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  2872. ASC_PRT_NEXT();
  2873. for (i = 0; i <= ASC_MAX_TID; i++) {
  2874. len = asc_prt_line(cp, leftlen, " %c",
  2875. (ep->
  2876. init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  2877. 'N');
  2878. ASC_PRT_NEXT();
  2879. }
  2880. len = asc_prt_line(cp, leftlen, "\n");
  2881. ASC_PRT_NEXT();
  2882. #ifdef CONFIG_ISA
  2883. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  2884. len = asc_prt_line(cp, leftlen,
  2885. " Host ISA DMA speed: %d MB/S\n",
  2886. isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]);
  2887. ASC_PRT_NEXT();
  2888. }
  2889. #endif /* CONFIG_ISA */
  2890. return totlen;
  2891. }
  2892. /*
  2893. * asc_prt_adv_board_eeprom()
  2894. *
  2895. * Print board EEPROM configuration.
  2896. *
  2897. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  2898. * cf. asc_prt_line().
  2899. *
  2900. * Return the number of characters copied into 'cp'. No more than
  2901. * 'cplen' characters will be copied to 'cp'.
  2902. */
  2903. static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
  2904. {
  2905. struct asc_board *boardp = shost_priv(shost);
  2906. ADV_DVC_VAR *adv_dvc_varp;
  2907. int leftlen;
  2908. int totlen;
  2909. int len;
  2910. int i;
  2911. char *termstr;
  2912. uchar serialstr[13];
  2913. ADVEEP_3550_CONFIG *ep_3550 = NULL;
  2914. ADVEEP_38C0800_CONFIG *ep_38C0800 = NULL;
  2915. ADVEEP_38C1600_CONFIG *ep_38C1600 = NULL;
  2916. ushort word;
  2917. ushort *wordp;
  2918. ushort sdtr_speed = 0;
  2919. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  2920. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  2921. ep_3550 = &boardp->eep_config.adv_3550_eep;
  2922. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  2923. ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
  2924. } else {
  2925. ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
  2926. }
  2927. leftlen = cplen;
  2928. totlen = len = 0;
  2929. len = asc_prt_line(cp, leftlen,
  2930. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
  2931. shost->host_no);
  2932. ASC_PRT_NEXT();
  2933. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  2934. wordp = &ep_3550->serial_number_word1;
  2935. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  2936. wordp = &ep_38C0800->serial_number_word1;
  2937. } else {
  2938. wordp = &ep_38C1600->serial_number_word1;
  2939. }
  2940. if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) {
  2941. len =
  2942. asc_prt_line(cp, leftlen, " Serial Number: %s\n",
  2943. serialstr);
  2944. ASC_PRT_NEXT();
  2945. } else {
  2946. len = asc_prt_line(cp, leftlen,
  2947. " Serial Number Signature Not Present.\n");
  2948. ASC_PRT_NEXT();
  2949. }
  2950. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  2951. len = asc_prt_line(cp, leftlen,
  2952. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  2953. ep_3550->adapter_scsi_id,
  2954. ep_3550->max_host_qng, ep_3550->max_dvc_qng);
  2955. ASC_PRT_NEXT();
  2956. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  2957. len = asc_prt_line(cp, leftlen,
  2958. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  2959. ep_38C0800->adapter_scsi_id,
  2960. ep_38C0800->max_host_qng,
  2961. ep_38C0800->max_dvc_qng);
  2962. ASC_PRT_NEXT();
  2963. } else {
  2964. len = asc_prt_line(cp, leftlen,
  2965. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  2966. ep_38C1600->adapter_scsi_id,
  2967. ep_38C1600->max_host_qng,
  2968. ep_38C1600->max_dvc_qng);
  2969. ASC_PRT_NEXT();
  2970. }
  2971. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  2972. word = ep_3550->termination;
  2973. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  2974. word = ep_38C0800->termination_lvd;
  2975. } else {
  2976. word = ep_38C1600->termination_lvd;
  2977. }
  2978. switch (word) {
  2979. case 1:
  2980. termstr = "Low Off/High Off";
  2981. break;
  2982. case 2:
  2983. termstr = "Low Off/High On";
  2984. break;
  2985. case 3:
  2986. termstr = "Low On/High On";
  2987. break;
  2988. default:
  2989. case 0:
  2990. termstr = "Automatic";
  2991. break;
  2992. }
  2993. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  2994. len = asc_prt_line(cp, leftlen,
  2995. " termination: %u (%s), bios_ctrl: 0x%x\n",
  2996. ep_3550->termination, termstr,
  2997. ep_3550->bios_ctrl);
  2998. ASC_PRT_NEXT();
  2999. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3000. len = asc_prt_line(cp, leftlen,
  3001. " termination: %u (%s), bios_ctrl: 0x%x\n",
  3002. ep_38C0800->termination_lvd, termstr,
  3003. ep_38C0800->bios_ctrl);
  3004. ASC_PRT_NEXT();
  3005. } else {
  3006. len = asc_prt_line(cp, leftlen,
  3007. " termination: %u (%s), bios_ctrl: 0x%x\n",
  3008. ep_38C1600->termination_lvd, termstr,
  3009. ep_38C1600->bios_ctrl);
  3010. ASC_PRT_NEXT();
  3011. }
  3012. len = asc_prt_line(cp, leftlen, " Target ID: ");
  3013. ASC_PRT_NEXT();
  3014. for (i = 0; i <= ADV_MAX_TID; i++) {
  3015. len = asc_prt_line(cp, leftlen, " %X", i);
  3016. ASC_PRT_NEXT();
  3017. }
  3018. len = asc_prt_line(cp, leftlen, "\n");
  3019. ASC_PRT_NEXT();
  3020. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3021. word = ep_3550->disc_enable;
  3022. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3023. word = ep_38C0800->disc_enable;
  3024. } else {
  3025. word = ep_38C1600->disc_enable;
  3026. }
  3027. len = asc_prt_line(cp, leftlen, " Disconnects: ");
  3028. ASC_PRT_NEXT();
  3029. for (i = 0; i <= ADV_MAX_TID; i++) {
  3030. len = asc_prt_line(cp, leftlen, " %c",
  3031. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3032. ASC_PRT_NEXT();
  3033. }
  3034. len = asc_prt_line(cp, leftlen, "\n");
  3035. ASC_PRT_NEXT();
  3036. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3037. word = ep_3550->tagqng_able;
  3038. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3039. word = ep_38C0800->tagqng_able;
  3040. } else {
  3041. word = ep_38C1600->tagqng_able;
  3042. }
  3043. len = asc_prt_line(cp, leftlen, " Command Queuing: ");
  3044. ASC_PRT_NEXT();
  3045. for (i = 0; i <= ADV_MAX_TID; i++) {
  3046. len = asc_prt_line(cp, leftlen, " %c",
  3047. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3048. ASC_PRT_NEXT();
  3049. }
  3050. len = asc_prt_line(cp, leftlen, "\n");
  3051. ASC_PRT_NEXT();
  3052. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3053. word = ep_3550->start_motor;
  3054. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3055. word = ep_38C0800->start_motor;
  3056. } else {
  3057. word = ep_38C1600->start_motor;
  3058. }
  3059. len = asc_prt_line(cp, leftlen, " Start Motor: ");
  3060. ASC_PRT_NEXT();
  3061. for (i = 0; i <= ADV_MAX_TID; i++) {
  3062. len = asc_prt_line(cp, leftlen, " %c",
  3063. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3064. ASC_PRT_NEXT();
  3065. }
  3066. len = asc_prt_line(cp, leftlen, "\n");
  3067. ASC_PRT_NEXT();
  3068. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3069. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  3070. ASC_PRT_NEXT();
  3071. for (i = 0; i <= ADV_MAX_TID; i++) {
  3072. len = asc_prt_line(cp, leftlen, " %c",
  3073. (ep_3550->
  3074. sdtr_able & ADV_TID_TO_TIDMASK(i)) ?
  3075. 'Y' : 'N');
  3076. ASC_PRT_NEXT();
  3077. }
  3078. len = asc_prt_line(cp, leftlen, "\n");
  3079. ASC_PRT_NEXT();
  3080. }
  3081. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3082. len = asc_prt_line(cp, leftlen, " Ultra Transfer: ");
  3083. ASC_PRT_NEXT();
  3084. for (i = 0; i <= ADV_MAX_TID; i++) {
  3085. len = asc_prt_line(cp, leftlen, " %c",
  3086. (ep_3550->
  3087. ultra_able & ADV_TID_TO_TIDMASK(i))
  3088. ? 'Y' : 'N');
  3089. ASC_PRT_NEXT();
  3090. }
  3091. len = asc_prt_line(cp, leftlen, "\n");
  3092. ASC_PRT_NEXT();
  3093. }
  3094. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3095. word = ep_3550->wdtr_able;
  3096. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3097. word = ep_38C0800->wdtr_able;
  3098. } else {
  3099. word = ep_38C1600->wdtr_able;
  3100. }
  3101. len = asc_prt_line(cp, leftlen, " Wide Transfer: ");
  3102. ASC_PRT_NEXT();
  3103. for (i = 0; i <= ADV_MAX_TID; i++) {
  3104. len = asc_prt_line(cp, leftlen, " %c",
  3105. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3106. ASC_PRT_NEXT();
  3107. }
  3108. len = asc_prt_line(cp, leftlen, "\n");
  3109. ASC_PRT_NEXT();
  3110. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 ||
  3111. adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) {
  3112. len = asc_prt_line(cp, leftlen,
  3113. " Synchronous Transfer Speed (Mhz):\n ");
  3114. ASC_PRT_NEXT();
  3115. for (i = 0; i <= ADV_MAX_TID; i++) {
  3116. char *speed_str;
  3117. if (i == 0) {
  3118. sdtr_speed = adv_dvc_varp->sdtr_speed1;
  3119. } else if (i == 4) {
  3120. sdtr_speed = adv_dvc_varp->sdtr_speed2;
  3121. } else if (i == 8) {
  3122. sdtr_speed = adv_dvc_varp->sdtr_speed3;
  3123. } else if (i == 12) {
  3124. sdtr_speed = adv_dvc_varp->sdtr_speed4;
  3125. }
  3126. switch (sdtr_speed & ADV_MAX_TID) {
  3127. case 0:
  3128. speed_str = "Off";
  3129. break;
  3130. case 1:
  3131. speed_str = " 5";
  3132. break;
  3133. case 2:
  3134. speed_str = " 10";
  3135. break;
  3136. case 3:
  3137. speed_str = " 20";
  3138. break;
  3139. case 4:
  3140. speed_str = " 40";
  3141. break;
  3142. case 5:
  3143. speed_str = " 80";
  3144. break;
  3145. default:
  3146. speed_str = "Unk";
  3147. break;
  3148. }
  3149. len = asc_prt_line(cp, leftlen, "%X:%s ", i, speed_str);
  3150. ASC_PRT_NEXT();
  3151. if (i == 7) {
  3152. len = asc_prt_line(cp, leftlen, "\n ");
  3153. ASC_PRT_NEXT();
  3154. }
  3155. sdtr_speed >>= 4;
  3156. }
  3157. len = asc_prt_line(cp, leftlen, "\n");
  3158. ASC_PRT_NEXT();
  3159. }
  3160. return totlen;
  3161. }
  3162. /*
  3163. * asc_prt_driver_conf()
  3164. *
  3165. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3166. * cf. asc_prt_line().
  3167. *
  3168. * Return the number of characters copied into 'cp'. No more than
  3169. * 'cplen' characters will be copied to 'cp'.
  3170. */
  3171. static int asc_prt_driver_conf(struct Scsi_Host *shost, char *cp, int cplen)
  3172. {
  3173. struct asc_board *boardp = shost_priv(shost);
  3174. int leftlen;
  3175. int totlen;
  3176. int len;
  3177. int chip_scsi_id;
  3178. leftlen = cplen;
  3179. totlen = len = 0;
  3180. len = asc_prt_line(cp, leftlen,
  3181. "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n",
  3182. shost->host_no);
  3183. ASC_PRT_NEXT();
  3184. len = asc_prt_line(cp, leftlen,
  3185. " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n",
  3186. shost->host_busy, shost->last_reset, shost->max_id,
  3187. shost->max_lun, shost->max_channel);
  3188. ASC_PRT_NEXT();
  3189. len = asc_prt_line(cp, leftlen,
  3190. " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n",
  3191. shost->unique_id, shost->can_queue, shost->this_id,
  3192. shost->sg_tablesize, shost->cmd_per_lun);
  3193. ASC_PRT_NEXT();
  3194. len = asc_prt_line(cp, leftlen,
  3195. " unchecked_isa_dma %d, use_clustering %d\n",
  3196. shost->unchecked_isa_dma, shost->use_clustering);
  3197. ASC_PRT_NEXT();
  3198. len = asc_prt_line(cp, leftlen,
  3199. " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n",
  3200. boardp->flags, boardp->last_reset, jiffies,
  3201. boardp->asc_n_io_port);
  3202. ASC_PRT_NEXT();
  3203. len = asc_prt_line(cp, leftlen, " io_port 0x%x\n", shost->io_port);
  3204. ASC_PRT_NEXT();
  3205. if (ASC_NARROW_BOARD(boardp)) {
  3206. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  3207. } else {
  3208. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  3209. }
  3210. return totlen;
  3211. }
  3212. /*
  3213. * asc_prt_asc_board_info()
  3214. *
  3215. * Print dynamic board configuration information.
  3216. *
  3217. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3218. * cf. asc_prt_line().
  3219. *
  3220. * Return the number of characters copied into 'cp'. No more than
  3221. * 'cplen' characters will be copied to 'cp'.
  3222. */
  3223. static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen)
  3224. {
  3225. struct asc_board *boardp = shost_priv(shost);
  3226. int chip_scsi_id;
  3227. int leftlen;
  3228. int totlen;
  3229. int len;
  3230. ASC_DVC_VAR *v;
  3231. ASC_DVC_CFG *c;
  3232. int i;
  3233. int renegotiate = 0;
  3234. v = &boardp->dvc_var.asc_dvc_var;
  3235. c = &boardp->dvc_cfg.asc_dvc_cfg;
  3236. chip_scsi_id = c->chip_scsi_id;
  3237. leftlen = cplen;
  3238. totlen = len = 0;
  3239. len = asc_prt_line(cp, leftlen,
  3240. "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  3241. shost->host_no);
  3242. ASC_PRT_NEXT();
  3243. len = asc_prt_line(cp, leftlen, " chip_version %u, mcode_date 0x%x, "
  3244. "mcode_version 0x%x, err_code %u\n",
  3245. c->chip_version, c->mcode_date, c->mcode_version,
  3246. v->err_code);
  3247. ASC_PRT_NEXT();
  3248. /* Current number of commands waiting for the host. */
  3249. len = asc_prt_line(cp, leftlen,
  3250. " Total Command Pending: %d\n", v->cur_total_qng);
  3251. ASC_PRT_NEXT();
  3252. len = asc_prt_line(cp, leftlen, " Command Queuing:");
  3253. ASC_PRT_NEXT();
  3254. for (i = 0; i <= ASC_MAX_TID; i++) {
  3255. if ((chip_scsi_id == i) ||
  3256. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3257. continue;
  3258. }
  3259. len = asc_prt_line(cp, leftlen, " %X:%c",
  3260. i,
  3261. (v->
  3262. use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ?
  3263. 'Y' : 'N');
  3264. ASC_PRT_NEXT();
  3265. }
  3266. len = asc_prt_line(cp, leftlen, "\n");
  3267. ASC_PRT_NEXT();
  3268. /* Current number of commands waiting for a device. */
  3269. len = asc_prt_line(cp, leftlen, " Command Queue Pending:");
  3270. ASC_PRT_NEXT();
  3271. for (i = 0; i <= ASC_MAX_TID; i++) {
  3272. if ((chip_scsi_id == i) ||
  3273. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3274. continue;
  3275. }
  3276. len = asc_prt_line(cp, leftlen, " %X:%u", i, v->cur_dvc_qng[i]);
  3277. ASC_PRT_NEXT();
  3278. }
  3279. len = asc_prt_line(cp, leftlen, "\n");
  3280. ASC_PRT_NEXT();
  3281. /* Current limit on number of commands that can be sent to a device. */
  3282. len = asc_prt_line(cp, leftlen, " Command Queue Limit:");
  3283. ASC_PRT_NEXT();
  3284. for (i = 0; i <= ASC_MAX_TID; i++) {
  3285. if ((chip_scsi_id == i) ||
  3286. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3287. continue;
  3288. }
  3289. len = asc_prt_line(cp, leftlen, " %X:%u", i, v->max_dvc_qng[i]);
  3290. ASC_PRT_NEXT();
  3291. }
  3292. len = asc_prt_line(cp, leftlen, "\n");
  3293. ASC_PRT_NEXT();
  3294. /* Indicate whether the device has returned queue full status. */
  3295. len = asc_prt_line(cp, leftlen, " Command Queue Full:");
  3296. ASC_PRT_NEXT();
  3297. for (i = 0; i <= ASC_MAX_TID; i++) {
  3298. if ((chip_scsi_id == i) ||
  3299. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3300. continue;
  3301. }
  3302. if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) {
  3303. len = asc_prt_line(cp, leftlen, " %X:Y-%d",
  3304. i, boardp->queue_full_cnt[i]);
  3305. } else {
  3306. len = asc_prt_line(cp, leftlen, " %X:N", i);
  3307. }
  3308. ASC_PRT_NEXT();
  3309. }
  3310. len = asc_prt_line(cp, leftlen, "\n");
  3311. ASC_PRT_NEXT();
  3312. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  3313. ASC_PRT_NEXT();
  3314. for (i = 0; i <= ASC_MAX_TID; i++) {
  3315. if ((chip_scsi_id == i) ||
  3316. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3317. continue;
  3318. }
  3319. len = asc_prt_line(cp, leftlen, " %X:%c",
  3320. i,
  3321. (v->
  3322. sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3323. 'N');
  3324. ASC_PRT_NEXT();
  3325. }
  3326. len = asc_prt_line(cp, leftlen, "\n");
  3327. ASC_PRT_NEXT();
  3328. for (i = 0; i <= ASC_MAX_TID; i++) {
  3329. uchar syn_period_ix;
  3330. if ((chip_scsi_id == i) ||
  3331. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  3332. ((v->init_sdtr & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3333. continue;
  3334. }
  3335. len = asc_prt_line(cp, leftlen, " %X:", i);
  3336. ASC_PRT_NEXT();
  3337. if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0) {
  3338. len = asc_prt_line(cp, leftlen, " Asynchronous");
  3339. ASC_PRT_NEXT();
  3340. } else {
  3341. syn_period_ix =
  3342. (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index -
  3343. 1);
  3344. len = asc_prt_line(cp, leftlen,
  3345. " Transfer Period Factor: %d (%d.%d Mhz),",
  3346. v->sdtr_period_tbl[syn_period_ix],
  3347. 250 /
  3348. v->sdtr_period_tbl[syn_period_ix],
  3349. ASC_TENTHS(250,
  3350. v->
  3351. sdtr_period_tbl
  3352. [syn_period_ix]));
  3353. ASC_PRT_NEXT();
  3354. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  3355. boardp->
  3356. sdtr_data[i] & ASC_SYN_MAX_OFFSET);
  3357. ASC_PRT_NEXT();
  3358. }
  3359. if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  3360. len = asc_prt_line(cp, leftlen, "*\n");
  3361. renegotiate = 1;
  3362. } else {
  3363. len = asc_prt_line(cp, leftlen, "\n");
  3364. }
  3365. ASC_PRT_NEXT();
  3366. }
  3367. if (renegotiate) {
  3368. len = asc_prt_line(cp, leftlen,
  3369. " * = Re-negotiation pending before next command.\n");
  3370. ASC_PRT_NEXT();
  3371. }
  3372. return totlen;
  3373. }
  3374. /*
  3375. * asc_prt_adv_board_info()
  3376. *
  3377. * Print dynamic board configuration information.
  3378. *
  3379. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3380. * cf. asc_prt_line().
  3381. *
  3382. * Return the number of characters copied into 'cp'. No more than
  3383. * 'cplen' characters will be copied to 'cp'.
  3384. */
  3385. static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
  3386. {
  3387. struct asc_board *boardp = shost_priv(shost);
  3388. int leftlen;
  3389. int totlen;
  3390. int len;
  3391. int i;
  3392. ADV_DVC_VAR *v;
  3393. ADV_DVC_CFG *c;
  3394. AdvPortAddr iop_base;
  3395. ushort chip_scsi_id;
  3396. ushort lramword;
  3397. uchar lrambyte;
  3398. ushort tagqng_able;
  3399. ushort sdtr_able, wdtr_able;
  3400. ushort wdtr_done, sdtr_done;
  3401. ushort period = 0;
  3402. int renegotiate = 0;
  3403. v = &boardp->dvc_var.adv_dvc_var;
  3404. c = &boardp->dvc_cfg.adv_dvc_cfg;
  3405. iop_base = v->iop_base;
  3406. chip_scsi_id = v->chip_scsi_id;
  3407. leftlen = cplen;
  3408. totlen = len = 0;
  3409. len = asc_prt_line(cp, leftlen,
  3410. "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  3411. shost->host_no);
  3412. ASC_PRT_NEXT();
  3413. len = asc_prt_line(cp, leftlen,
  3414. " iop_base 0x%lx, cable_detect: %X, err_code %u\n",
  3415. v->iop_base,
  3416. AdvReadWordRegister(iop_base,
  3417. IOPW_SCSI_CFG1) & CABLE_DETECT,
  3418. v->err_code);
  3419. ASC_PRT_NEXT();
  3420. len = asc_prt_line(cp, leftlen, " chip_version %u, mcode_date 0x%x, "
  3421. "mcode_version 0x%x\n", c->chip_version,
  3422. c->mcode_date, c->mcode_version);
  3423. ASC_PRT_NEXT();
  3424. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  3425. len = asc_prt_line(cp, leftlen, " Queuing Enabled:");
  3426. ASC_PRT_NEXT();
  3427. for (i = 0; i <= ADV_MAX_TID; i++) {
  3428. if ((chip_scsi_id == i) ||
  3429. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3430. continue;
  3431. }
  3432. len = asc_prt_line(cp, leftlen, " %X:%c",
  3433. i,
  3434. (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3435. 'N');
  3436. ASC_PRT_NEXT();
  3437. }
  3438. len = asc_prt_line(cp, leftlen, "\n");
  3439. ASC_PRT_NEXT();
  3440. len = asc_prt_line(cp, leftlen, " Queue Limit:");
  3441. ASC_PRT_NEXT();
  3442. for (i = 0; i <= ADV_MAX_TID; i++) {
  3443. if ((chip_scsi_id == i) ||
  3444. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3445. continue;
  3446. }
  3447. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i,
  3448. lrambyte);
  3449. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  3450. ASC_PRT_NEXT();
  3451. }
  3452. len = asc_prt_line(cp, leftlen, "\n");
  3453. ASC_PRT_NEXT();
  3454. len = asc_prt_line(cp, leftlen, " Command Pending:");
  3455. ASC_PRT_NEXT();
  3456. for (i = 0; i <= ADV_MAX_TID; i++) {
  3457. if ((chip_scsi_id == i) ||
  3458. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3459. continue;
  3460. }
  3461. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i,
  3462. lrambyte);
  3463. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  3464. ASC_PRT_NEXT();
  3465. }
  3466. len = asc_prt_line(cp, leftlen, "\n");
  3467. ASC_PRT_NEXT();
  3468. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  3469. len = asc_prt_line(cp, leftlen, " Wide Enabled:");
  3470. ASC_PRT_NEXT();
  3471. for (i = 0; i <= ADV_MAX_TID; i++) {
  3472. if ((chip_scsi_id == i) ||
  3473. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3474. continue;
  3475. }
  3476. len = asc_prt_line(cp, leftlen, " %X:%c",
  3477. i,
  3478. (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3479. 'N');
  3480. ASC_PRT_NEXT();
  3481. }
  3482. len = asc_prt_line(cp, leftlen, "\n");
  3483. ASC_PRT_NEXT();
  3484. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done);
  3485. len = asc_prt_line(cp, leftlen, " Transfer Bit Width:");
  3486. ASC_PRT_NEXT();
  3487. for (i = 0; i <= ADV_MAX_TID; i++) {
  3488. if ((chip_scsi_id == i) ||
  3489. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3490. continue;
  3491. }
  3492. AdvReadWordLram(iop_base,
  3493. ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  3494. lramword);
  3495. len = asc_prt_line(cp, leftlen, " %X:%d",
  3496. i, (lramword & 0x8000) ? 16 : 8);
  3497. ASC_PRT_NEXT();
  3498. if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) &&
  3499. (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  3500. len = asc_prt_line(cp, leftlen, "*");
  3501. ASC_PRT_NEXT();
  3502. renegotiate = 1;
  3503. }
  3504. }
  3505. len = asc_prt_line(cp, leftlen, "\n");
  3506. ASC_PRT_NEXT();
  3507. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  3508. len = asc_prt_line(cp, leftlen, " Synchronous Enabled:");
  3509. ASC_PRT_NEXT();
  3510. for (i = 0; i <= ADV_MAX_TID; i++) {
  3511. if ((chip_scsi_id == i) ||
  3512. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3513. continue;
  3514. }
  3515. len = asc_prt_line(cp, leftlen, " %X:%c",
  3516. i,
  3517. (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3518. 'N');
  3519. ASC_PRT_NEXT();
  3520. }
  3521. len = asc_prt_line(cp, leftlen, "\n");
  3522. ASC_PRT_NEXT();
  3523. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done);
  3524. for (i = 0; i <= ADV_MAX_TID; i++) {
  3525. AdvReadWordLram(iop_base,
  3526. ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  3527. lramword);
  3528. lramword &= ~0x8000;
  3529. if ((chip_scsi_id == i) ||
  3530. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  3531. ((sdtr_able & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3532. continue;
  3533. }
  3534. len = asc_prt_line(cp, leftlen, " %X:", i);
  3535. ASC_PRT_NEXT();
  3536. if ((lramword & 0x1F) == 0) { /* Check for REQ/ACK Offset 0. */
  3537. len = asc_prt_line(cp, leftlen, " Asynchronous");
  3538. ASC_PRT_NEXT();
  3539. } else {
  3540. len =
  3541. asc_prt_line(cp, leftlen,
  3542. " Transfer Period Factor: ");
  3543. ASC_PRT_NEXT();
  3544. if ((lramword & 0x1F00) == 0x1100) { /* 80 Mhz */
  3545. len =
  3546. asc_prt_line(cp, leftlen, "9 (80.0 Mhz),");
  3547. ASC_PRT_NEXT();
  3548. } else if ((lramword & 0x1F00) == 0x1000) { /* 40 Mhz */
  3549. len =
  3550. asc_prt_line(cp, leftlen, "10 (40.0 Mhz),");
  3551. ASC_PRT_NEXT();
  3552. } else { /* 20 Mhz or below. */
  3553. period = (((lramword >> 8) * 25) + 50) / 4;
  3554. if (period == 0) { /* Should never happen. */
  3555. len =
  3556. asc_prt_line(cp, leftlen,
  3557. "%d (? Mhz), ");
  3558. ASC_PRT_NEXT();
  3559. } else {
  3560. len = asc_prt_line(cp, leftlen,
  3561. "%d (%d.%d Mhz),",
  3562. period, 250 / period,
  3563. ASC_TENTHS(250,
  3564. period));
  3565. ASC_PRT_NEXT();
  3566. }
  3567. }
  3568. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  3569. lramword & 0x1F);
  3570. ASC_PRT_NEXT();
  3571. }
  3572. if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  3573. len = asc_prt_line(cp, leftlen, "*\n");
  3574. renegotiate = 1;
  3575. } else {
  3576. len = asc_prt_line(cp, leftlen, "\n");
  3577. }
  3578. ASC_PRT_NEXT();
  3579. }
  3580. if (renegotiate) {
  3581. len = asc_prt_line(cp, leftlen,
  3582. " * = Re-negotiation pending before next command.\n");
  3583. ASC_PRT_NEXT();
  3584. }
  3585. return totlen;
  3586. }
  3587. /*
  3588. * asc_proc_copy()
  3589. *
  3590. * Copy proc information to a read buffer taking into account the current
  3591. * read offset in the file and the remaining space in the read buffer.
  3592. */
  3593. static int
  3594. asc_proc_copy(off_t advoffset, off_t offset, char *curbuf, int leftlen,
  3595. char *cp, int cplen)
  3596. {
  3597. int cnt = 0;
  3598. ASC_DBG(2, "offset %d, advoffset %d, cplen %d\n",
  3599. (unsigned)offset, (unsigned)advoffset, cplen);
  3600. if (offset <= advoffset) {
  3601. /* Read offset below current offset, copy everything. */
  3602. cnt = min(cplen, leftlen);
  3603. ASC_DBG(2, "curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  3604. (ulong)curbuf, (ulong)cp, cnt);
  3605. memcpy(curbuf, cp, cnt);
  3606. } else if (offset < advoffset + cplen) {
  3607. /* Read offset within current range, partial copy. */
  3608. cnt = (advoffset + cplen) - offset;
  3609. cp = (cp + cplen) - cnt;
  3610. cnt = min(cnt, leftlen);
  3611. ASC_DBG(2, "curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  3612. (ulong)curbuf, (ulong)cp, cnt);
  3613. memcpy(curbuf, cp, cnt);
  3614. }
  3615. return cnt;
  3616. }
  3617. #ifdef ADVANSYS_STATS
  3618. /*
  3619. * asc_prt_board_stats()
  3620. *
  3621. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3622. * cf. asc_prt_line().
  3623. *
  3624. * Return the number of characters copied into 'cp'. No more than
  3625. * 'cplen' characters will be copied to 'cp'.
  3626. */
  3627. static int asc_prt_board_stats(struct Scsi_Host *shost, char *cp, int cplen)
  3628. {
  3629. struct asc_board *boardp = shost_priv(shost);
  3630. struct asc_stats *s = &boardp->asc_stats;
  3631. int leftlen = cplen;
  3632. int len, totlen = 0;
  3633. len = asc_prt_line(cp, leftlen,
  3634. "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n",
  3635. shost->host_no);
  3636. ASC_PRT_NEXT();
  3637. len = asc_prt_line(cp, leftlen,
  3638. " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n",
  3639. s->queuecommand, s->reset, s->biosparam,
  3640. s->interrupt);
  3641. ASC_PRT_NEXT();
  3642. len = asc_prt_line(cp, leftlen,
  3643. " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n",
  3644. s->callback, s->done, s->build_error,
  3645. s->adv_build_noreq, s->adv_build_nosg);
  3646. ASC_PRT_NEXT();
  3647. len = asc_prt_line(cp, leftlen,
  3648. " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n",
  3649. s->exe_noerror, s->exe_busy, s->exe_error,
  3650. s->exe_unknown);
  3651. ASC_PRT_NEXT();
  3652. /*
  3653. * Display data transfer statistics.
  3654. */
  3655. if (s->xfer_cnt > 0) {
  3656. len = asc_prt_line(cp, leftlen, " xfer_cnt %lu, xfer_elem %lu, ",
  3657. s->xfer_cnt, s->xfer_elem);
  3658. ASC_PRT_NEXT();
  3659. len = asc_prt_line(cp, leftlen, "xfer_bytes %lu.%01lu kb\n",
  3660. s->xfer_sect / 2, ASC_TENTHS(s->xfer_sect, 2));
  3661. ASC_PRT_NEXT();
  3662. /* Scatter gather transfer statistics */
  3663. len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ",
  3664. s->xfer_elem / s->xfer_cnt,
  3665. ASC_TENTHS(s->xfer_elem, s->xfer_cnt));
  3666. ASC_PRT_NEXT();
  3667. len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ",
  3668. (s->xfer_sect / 2) / s->xfer_elem,
  3669. ASC_TENTHS((s->xfer_sect / 2), s->xfer_elem));
  3670. ASC_PRT_NEXT();
  3671. len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n",
  3672. (s->xfer_sect / 2) / s->xfer_cnt,
  3673. ASC_TENTHS((s->xfer_sect / 2), s->xfer_cnt));
  3674. ASC_PRT_NEXT();
  3675. }
  3676. return totlen;
  3677. }
  3678. #endif /* ADVANSYS_STATS */
  3679. /*
  3680. * advansys_proc_info() - /proc/scsi/advansys/{0,1,2,3,...}
  3681. *
  3682. * *buffer: I/O buffer
  3683. * **start: if inout == FALSE pointer into buffer where user read should start
  3684. * offset: current offset into a /proc/scsi/advansys/[0...] file
  3685. * length: length of buffer
  3686. * hostno: Scsi_Host host_no
  3687. * inout: TRUE - user is writing; FALSE - user is reading
  3688. *
  3689. * Return the number of bytes read from or written to a
  3690. * /proc/scsi/advansys/[0...] file.
  3691. *
  3692. * Note: This function uses the per board buffer 'prtbuf' which is
  3693. * allocated when the board is initialized in advansys_detect(). The
  3694. * buffer is ASC_PRTBUF_SIZE bytes. The function asc_proc_copy() is
  3695. * used to write to the buffer. The way asc_proc_copy() is written
  3696. * if 'prtbuf' is too small it will not be overwritten. Instead the
  3697. * user just won't get all the available statistics.
  3698. */
  3699. static int
  3700. advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
  3701. off_t offset, int length, int inout)
  3702. {
  3703. struct asc_board *boardp = shost_priv(shost);
  3704. char *cp;
  3705. int cplen;
  3706. int cnt;
  3707. int totcnt;
  3708. int leftlen;
  3709. char *curbuf;
  3710. off_t advoffset;
  3711. ASC_DBG(1, "begin\n");
  3712. /*
  3713. * User write not supported.
  3714. */
  3715. if (inout == TRUE)
  3716. return -ENOSYS;
  3717. /*
  3718. * User read of /proc/scsi/advansys/[0...] file.
  3719. */
  3720. /* Copy read data starting at the beginning of the buffer. */
  3721. *start = buffer;
  3722. curbuf = buffer;
  3723. advoffset = 0;
  3724. totcnt = 0;
  3725. leftlen = length;
  3726. /*
  3727. * Get board configuration information.
  3728. *
  3729. * advansys_info() returns the board string from its own static buffer.
  3730. */
  3731. cp = (char *)advansys_info(shost);
  3732. strcat(cp, "\n");
  3733. cplen = strlen(cp);
  3734. /* Copy board information. */
  3735. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3736. totcnt += cnt;
  3737. leftlen -= cnt;
  3738. if (leftlen == 0) {
  3739. ASC_DBG(1, "totcnt %d\n", totcnt);
  3740. return totcnt;
  3741. }
  3742. advoffset += cplen;
  3743. curbuf += cnt;
  3744. /*
  3745. * Display Wide Board BIOS Information.
  3746. */
  3747. if (!ASC_NARROW_BOARD(boardp)) {
  3748. cp = boardp->prtbuf;
  3749. cplen = asc_prt_adv_bios(shost, cp, ASC_PRTBUF_SIZE);
  3750. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3751. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
  3752. cplen);
  3753. totcnt += cnt;
  3754. leftlen -= cnt;
  3755. if (leftlen == 0) {
  3756. ASC_DBG(1, "totcnt %d\n", totcnt);
  3757. return totcnt;
  3758. }
  3759. advoffset += cplen;
  3760. curbuf += cnt;
  3761. }
  3762. /*
  3763. * Display driver information for each device attached to the board.
  3764. */
  3765. cp = boardp->prtbuf;
  3766. cplen = asc_prt_board_devices(shost, cp, ASC_PRTBUF_SIZE);
  3767. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3768. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3769. totcnt += cnt;
  3770. leftlen -= cnt;
  3771. if (leftlen == 0) {
  3772. ASC_DBG(1, "totcnt %d\n", totcnt);
  3773. return totcnt;
  3774. }
  3775. advoffset += cplen;
  3776. curbuf += cnt;
  3777. /*
  3778. * Display EEPROM configuration for the board.
  3779. */
  3780. cp = boardp->prtbuf;
  3781. if (ASC_NARROW_BOARD(boardp)) {
  3782. cplen = asc_prt_asc_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
  3783. } else {
  3784. cplen = asc_prt_adv_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
  3785. }
  3786. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3787. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3788. totcnt += cnt;
  3789. leftlen -= cnt;
  3790. if (leftlen == 0) {
  3791. ASC_DBG(1, "totcnt %d\n", totcnt);
  3792. return totcnt;
  3793. }
  3794. advoffset += cplen;
  3795. curbuf += cnt;
  3796. /*
  3797. * Display driver configuration and information for the board.
  3798. */
  3799. cp = boardp->prtbuf;
  3800. cplen = asc_prt_driver_conf(shost, cp, ASC_PRTBUF_SIZE);
  3801. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3802. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3803. totcnt += cnt;
  3804. leftlen -= cnt;
  3805. if (leftlen == 0) {
  3806. ASC_DBG(1, "totcnt %d\n", totcnt);
  3807. return totcnt;
  3808. }
  3809. advoffset += cplen;
  3810. curbuf += cnt;
  3811. #ifdef ADVANSYS_STATS
  3812. /*
  3813. * Display driver statistics for the board.
  3814. */
  3815. cp = boardp->prtbuf;
  3816. cplen = asc_prt_board_stats(shost, cp, ASC_PRTBUF_SIZE);
  3817. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3818. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3819. totcnt += cnt;
  3820. leftlen -= cnt;
  3821. if (leftlen == 0) {
  3822. ASC_DBG(1, "totcnt %d\n", totcnt);
  3823. return totcnt;
  3824. }
  3825. advoffset += cplen;
  3826. curbuf += cnt;
  3827. #endif /* ADVANSYS_STATS */
  3828. /*
  3829. * Display Asc Library dynamic configuration information
  3830. * for the board.
  3831. */
  3832. cp = boardp->prtbuf;
  3833. if (ASC_NARROW_BOARD(boardp)) {
  3834. cplen = asc_prt_asc_board_info(shost, cp, ASC_PRTBUF_SIZE);
  3835. } else {
  3836. cplen = asc_prt_adv_board_info(shost, cp, ASC_PRTBUF_SIZE);
  3837. }
  3838. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3839. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3840. totcnt += cnt;
  3841. leftlen -= cnt;
  3842. if (leftlen == 0) {
  3843. ASC_DBG(1, "totcnt %d\n", totcnt);
  3844. return totcnt;
  3845. }
  3846. advoffset += cplen;
  3847. curbuf += cnt;
  3848. ASC_DBG(1, "totcnt %d\n", totcnt);
  3849. return totcnt;
  3850. }
  3851. #endif /* CONFIG_PROC_FS */
  3852. static void asc_scsi_done(struct scsi_cmnd *scp)
  3853. {
  3854. scsi_dma_unmap(scp);
  3855. ASC_STATS(scp->device->host, done);
  3856. scp->scsi_done(scp);
  3857. }
  3858. static void AscSetBank(PortAddr iop_base, uchar bank)
  3859. {
  3860. uchar val;
  3861. val = AscGetChipControl(iop_base) &
  3862. (~
  3863. (CC_SINGLE_STEP | CC_TEST | CC_DIAG | CC_SCSI_RESET |
  3864. CC_CHIP_RESET));
  3865. if (bank == 1) {
  3866. val |= CC_BANK_ONE;
  3867. } else if (bank == 2) {
  3868. val |= CC_DIAG | CC_BANK_ONE;
  3869. } else {
  3870. val &= ~CC_BANK_ONE;
  3871. }
  3872. AscSetChipControl(iop_base, val);
  3873. }
  3874. static void AscSetChipIH(PortAddr iop_base, ushort ins_code)
  3875. {
  3876. AscSetBank(iop_base, 1);
  3877. AscWriteChipIH(iop_base, ins_code);
  3878. AscSetBank(iop_base, 0);
  3879. }
  3880. static int AscStartChip(PortAddr iop_base)
  3881. {
  3882. AscSetChipControl(iop_base, 0);
  3883. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  3884. return (0);
  3885. }
  3886. return (1);
  3887. }
  3888. static int AscStopChip(PortAddr iop_base)
  3889. {
  3890. uchar cc_val;
  3891. cc_val =
  3892. AscGetChipControl(iop_base) &
  3893. (~(CC_SINGLE_STEP | CC_TEST | CC_DIAG));
  3894. AscSetChipControl(iop_base, (uchar)(cc_val | CC_HALT));
  3895. AscSetChipIH(iop_base, INS_HALT);
  3896. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  3897. if ((AscGetChipStatus(iop_base) & CSW_HALTED) == 0) {
  3898. return (0);
  3899. }
  3900. return (1);
  3901. }
  3902. static int AscIsChipHalted(PortAddr iop_base)
  3903. {
  3904. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  3905. if ((AscGetChipControl(iop_base) & CC_HALT) != 0) {
  3906. return (1);
  3907. }
  3908. }
  3909. return (0);
  3910. }
  3911. static int AscResetChipAndScsiBus(ASC_DVC_VAR *asc_dvc)
  3912. {
  3913. PortAddr iop_base;
  3914. int i = 10;
  3915. iop_base = asc_dvc->iop_base;
  3916. while ((AscGetChipStatus(iop_base) & CSW_SCSI_RESET_ACTIVE)
  3917. && (i-- > 0)) {
  3918. mdelay(100);
  3919. }
  3920. AscStopChip(iop_base);
  3921. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_SCSI_RESET | CC_HALT);
  3922. udelay(60);
  3923. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  3924. AscSetChipIH(iop_base, INS_HALT);
  3925. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_HALT);
  3926. AscSetChipControl(iop_base, CC_HALT);
  3927. mdelay(200);
  3928. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  3929. AscSetChipStatus(iop_base, 0);
  3930. return (AscIsChipHalted(iop_base));
  3931. }
  3932. static int AscFindSignature(PortAddr iop_base)
  3933. {
  3934. ushort sig_word;
  3935. ASC_DBG(1, "AscGetChipSignatureByte(0x%x) 0x%x\n",
  3936. iop_base, AscGetChipSignatureByte(iop_base));
  3937. if (AscGetChipSignatureByte(iop_base) == (uchar)ASC_1000_ID1B) {
  3938. ASC_DBG(1, "AscGetChipSignatureWord(0x%x) 0x%x\n",
  3939. iop_base, AscGetChipSignatureWord(iop_base));
  3940. sig_word = AscGetChipSignatureWord(iop_base);
  3941. if ((sig_word == (ushort)ASC_1000_ID0W) ||
  3942. (sig_word == (ushort)ASC_1000_ID0W_FIX)) {
  3943. return (1);
  3944. }
  3945. }
  3946. return (0);
  3947. }
  3948. static void AscEnableInterrupt(PortAddr iop_base)
  3949. {
  3950. ushort cfg;
  3951. cfg = AscGetChipCfgLsw(iop_base);
  3952. AscSetChipCfgLsw(iop_base, cfg | ASC_CFG0_HOST_INT_ON);
  3953. }
  3954. static void AscDisableInterrupt(PortAddr iop_base)
  3955. {
  3956. ushort cfg;
  3957. cfg = AscGetChipCfgLsw(iop_base);
  3958. AscSetChipCfgLsw(iop_base, cfg & (~ASC_CFG0_HOST_INT_ON));
  3959. }
  3960. static uchar AscReadLramByte(PortAddr iop_base, ushort addr)
  3961. {
  3962. unsigned char byte_data;
  3963. unsigned short word_data;
  3964. if (isodd_word(addr)) {
  3965. AscSetChipLramAddr(iop_base, addr - 1);
  3966. word_data = AscGetChipLramData(iop_base);
  3967. byte_data = (word_data >> 8) & 0xFF;
  3968. } else {
  3969. AscSetChipLramAddr(iop_base, addr);
  3970. word_data = AscGetChipLramData(iop_base);
  3971. byte_data = word_data & 0xFF;
  3972. }
  3973. return byte_data;
  3974. }
  3975. static ushort AscReadLramWord(PortAddr iop_base, ushort addr)
  3976. {
  3977. ushort word_data;
  3978. AscSetChipLramAddr(iop_base, addr);
  3979. word_data = AscGetChipLramData(iop_base);
  3980. return (word_data);
  3981. }
  3982. #if CC_VERY_LONG_SG_LIST
  3983. static ASC_DCNT AscReadLramDWord(PortAddr iop_base, ushort addr)
  3984. {
  3985. ushort val_low, val_high;
  3986. ASC_DCNT dword_data;
  3987. AscSetChipLramAddr(iop_base, addr);
  3988. val_low = AscGetChipLramData(iop_base);
  3989. val_high = AscGetChipLramData(iop_base);
  3990. dword_data = ((ASC_DCNT) val_high << 16) | (ASC_DCNT) val_low;
  3991. return (dword_data);
  3992. }
  3993. #endif /* CC_VERY_LONG_SG_LIST */
  3994. static void
  3995. AscMemWordSetLram(PortAddr iop_base, ushort s_addr, ushort set_wval, int words)
  3996. {
  3997. int i;
  3998. AscSetChipLramAddr(iop_base, s_addr);
  3999. for (i = 0; i < words; i++) {
  4000. AscSetChipLramData(iop_base, set_wval);
  4001. }
  4002. }
  4003. static void AscWriteLramWord(PortAddr iop_base, ushort addr, ushort word_val)
  4004. {
  4005. AscSetChipLramAddr(iop_base, addr);
  4006. AscSetChipLramData(iop_base, word_val);
  4007. }
  4008. static void AscWriteLramByte(PortAddr iop_base, ushort addr, uchar byte_val)
  4009. {
  4010. ushort word_data;
  4011. if (isodd_word(addr)) {
  4012. addr--;
  4013. word_data = AscReadLramWord(iop_base, addr);
  4014. word_data &= 0x00FF;
  4015. word_data |= (((ushort)byte_val << 8) & 0xFF00);
  4016. } else {
  4017. word_data = AscReadLramWord(iop_base, addr);
  4018. word_data &= 0xFF00;
  4019. word_data |= ((ushort)byte_val & 0x00FF);
  4020. }
  4021. AscWriteLramWord(iop_base, addr, word_data);
  4022. }
  4023. /*
  4024. * Copy 2 bytes to LRAM.
  4025. *
  4026. * The source data is assumed to be in little-endian order in memory
  4027. * and is maintained in little-endian order when written to LRAM.
  4028. */
  4029. static void
  4030. AscMemWordCopyPtrToLram(PortAddr iop_base,
  4031. ushort s_addr, uchar *s_buffer, int words)
  4032. {
  4033. int i;
  4034. AscSetChipLramAddr(iop_base, s_addr);
  4035. for (i = 0; i < 2 * words; i += 2) {
  4036. /*
  4037. * On a little-endian system the second argument below
  4038. * produces a little-endian ushort which is written to
  4039. * LRAM in little-endian order. On a big-endian system
  4040. * the second argument produces a big-endian ushort which
  4041. * is "transparently" byte-swapped by outpw() and written
  4042. * in little-endian order to LRAM.
  4043. */
  4044. outpw(iop_base + IOP_RAM_DATA,
  4045. ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]);
  4046. }
  4047. }
  4048. /*
  4049. * Copy 4 bytes to LRAM.
  4050. *
  4051. * The source data is assumed to be in little-endian order in memory
  4052. * and is maintained in little-endian order when writen to LRAM.
  4053. */
  4054. static void
  4055. AscMemDWordCopyPtrToLram(PortAddr iop_base,
  4056. ushort s_addr, uchar *s_buffer, int dwords)
  4057. {
  4058. int i;
  4059. AscSetChipLramAddr(iop_base, s_addr);
  4060. for (i = 0; i < 4 * dwords; i += 4) {
  4061. outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]); /* LSW */
  4062. outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 3] << 8) | s_buffer[i + 2]); /* MSW */
  4063. }
  4064. }
  4065. /*
  4066. * Copy 2 bytes from LRAM.
  4067. *
  4068. * The source data is assumed to be in little-endian order in LRAM
  4069. * and is maintained in little-endian order when written to memory.
  4070. */
  4071. static void
  4072. AscMemWordCopyPtrFromLram(PortAddr iop_base,
  4073. ushort s_addr, uchar *d_buffer, int words)
  4074. {
  4075. int i;
  4076. ushort word;
  4077. AscSetChipLramAddr(iop_base, s_addr);
  4078. for (i = 0; i < 2 * words; i += 2) {
  4079. word = inpw(iop_base + IOP_RAM_DATA);
  4080. d_buffer[i] = word & 0xff;
  4081. d_buffer[i + 1] = (word >> 8) & 0xff;
  4082. }
  4083. }
  4084. static ASC_DCNT AscMemSumLramWord(PortAddr iop_base, ushort s_addr, int words)
  4085. {
  4086. ASC_DCNT sum;
  4087. int i;
  4088. sum = 0L;
  4089. for (i = 0; i < words; i++, s_addr += 2) {
  4090. sum += AscReadLramWord(iop_base, s_addr);
  4091. }
  4092. return (sum);
  4093. }
  4094. static ushort AscInitLram(ASC_DVC_VAR *asc_dvc)
  4095. {
  4096. uchar i;
  4097. ushort s_addr;
  4098. PortAddr iop_base;
  4099. ushort warn_code;
  4100. iop_base = asc_dvc->iop_base;
  4101. warn_code = 0;
  4102. AscMemWordSetLram(iop_base, ASC_QADR_BEG, 0,
  4103. (ushort)(((int)(asc_dvc->max_total_qng + 2 + 1) *
  4104. 64) >> 1));
  4105. i = ASC_MIN_ACTIVE_QNO;
  4106. s_addr = ASC_QADR_BEG + ASC_QBLK_SIZE;
  4107. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  4108. (uchar)(i + 1));
  4109. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  4110. (uchar)(asc_dvc->max_total_qng));
  4111. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  4112. (uchar)i);
  4113. i++;
  4114. s_addr += ASC_QBLK_SIZE;
  4115. for (; i < asc_dvc->max_total_qng; i++, s_addr += ASC_QBLK_SIZE) {
  4116. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  4117. (uchar)(i + 1));
  4118. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  4119. (uchar)(i - 1));
  4120. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  4121. (uchar)i);
  4122. }
  4123. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  4124. (uchar)ASC_QLINK_END);
  4125. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  4126. (uchar)(asc_dvc->max_total_qng - 1));
  4127. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  4128. (uchar)asc_dvc->max_total_qng);
  4129. i++;
  4130. s_addr += ASC_QBLK_SIZE;
  4131. for (; i <= (uchar)(asc_dvc->max_total_qng + 3);
  4132. i++, s_addr += ASC_QBLK_SIZE) {
  4133. AscWriteLramByte(iop_base,
  4134. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_FWD), i);
  4135. AscWriteLramByte(iop_base,
  4136. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_BWD), i);
  4137. AscWriteLramByte(iop_base,
  4138. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_QNO), i);
  4139. }
  4140. return warn_code;
  4141. }
  4142. static ASC_DCNT
  4143. AscLoadMicroCode(PortAddr iop_base,
  4144. ushort s_addr, uchar *mcode_buf, ushort mcode_size)
  4145. {
  4146. ASC_DCNT chksum;
  4147. ushort mcode_word_size;
  4148. ushort mcode_chksum;
  4149. /* Write the microcode buffer starting at LRAM address 0. */
  4150. mcode_word_size = (ushort)(mcode_size >> 1);
  4151. AscMemWordSetLram(iop_base, s_addr, 0, mcode_word_size);
  4152. AscMemWordCopyPtrToLram(iop_base, s_addr, mcode_buf, mcode_word_size);
  4153. chksum = AscMemSumLramWord(iop_base, s_addr, mcode_word_size);
  4154. ASC_DBG(1, "chksum 0x%lx\n", (ulong)chksum);
  4155. mcode_chksum = (ushort)AscMemSumLramWord(iop_base,
  4156. (ushort)ASC_CODE_SEC_BEG,
  4157. (ushort)((mcode_size -
  4158. s_addr - (ushort)
  4159. ASC_CODE_SEC_BEG) /
  4160. 2));
  4161. ASC_DBG(1, "mcode_chksum 0x%lx\n", (ulong)mcode_chksum);
  4162. AscWriteLramWord(iop_base, ASCV_MCODE_CHKSUM_W, mcode_chksum);
  4163. AscWriteLramWord(iop_base, ASCV_MCODE_SIZE_W, mcode_size);
  4164. return chksum;
  4165. }
  4166. /* Microcode buffer is kept after initialization for error recovery. */
  4167. static uchar _asc_mcode_buf[] = {
  4168. 0x01, 0x03, 0x01, 0x19, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4169. 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
  4170. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4171. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4172. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4173. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x12, 0x0D, 0x05,
  4174. 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4175. 0xFF, 0x80, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4176. 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0xFF,
  4177. 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
  4178. 0x00, 0x00, 0xE4, 0x88, 0x00, 0x00, 0x00, 0x00, 0x80, 0x73, 0x48, 0x04,
  4179. 0x36, 0x00, 0x00, 0xA2, 0xC2, 0x00, 0x80, 0x73, 0x03, 0x23, 0x36, 0x40,
  4180. 0xB6, 0x00, 0x36, 0x00, 0x05, 0xD6, 0x0C, 0xD2, 0x12, 0xDA, 0x00, 0xA2,
  4181. 0xC2, 0x00, 0x92, 0x80, 0x1E, 0x98, 0x50, 0x00, 0xF5, 0x00, 0x48, 0x98,
  4182. 0xDF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x4F, 0x00, 0xF5, 0x00,
  4183. 0x48, 0x98, 0xEF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x80, 0x62,
  4184. 0x92, 0x80, 0x00, 0x46, 0x15, 0xEE, 0x13, 0xEA, 0x02, 0x01, 0x09, 0xD8,
  4185. 0xCD, 0x04, 0x4D, 0x00, 0x00, 0xA3, 0xD6, 0x00, 0xA6, 0x97, 0x7F, 0x23,
  4186. 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84, 0xD2, 0xC1, 0x80, 0x73, 0xCD, 0x04,
  4187. 0x4D, 0x00, 0x00, 0xA3, 0xDA, 0x01, 0xA6, 0x97, 0xC6, 0x81, 0xC2, 0x88,
  4188. 0x80, 0x73, 0x80, 0x77, 0x00, 0x01, 0x01, 0xA1, 0xFE, 0x00, 0x4F, 0x00,
  4189. 0x84, 0x97, 0x07, 0xA6, 0x08, 0x01, 0x00, 0x33, 0x03, 0x00, 0xC2, 0x88,
  4190. 0x03, 0x03, 0x01, 0xDE, 0xC2, 0x88, 0xCE, 0x00, 0x69, 0x60, 0xCE, 0x00,
  4191. 0x02, 0x03, 0x4A, 0x60, 0x00, 0xA2, 0x78, 0x01, 0x80, 0x63, 0x07, 0xA6,
  4192. 0x24, 0x01, 0x78, 0x81, 0x03, 0x03, 0x80, 0x63, 0xE2, 0x00, 0x07, 0xA6,
  4193. 0x34, 0x01, 0x00, 0x33, 0x04, 0x00, 0xC2, 0x88, 0x03, 0x07, 0x02, 0x01,
  4194. 0x04, 0xCA, 0x0D, 0x23, 0x68, 0x98, 0x4D, 0x04, 0x04, 0x85, 0x05, 0xD8,
  4195. 0x0D, 0x23, 0x68, 0x98, 0xCD, 0x04, 0x15, 0x23, 0xF8, 0x88, 0xFB, 0x23,
  4196. 0x02, 0x61, 0x82, 0x01, 0x80, 0x63, 0x02, 0x03, 0x06, 0xA3, 0x62, 0x01,
  4197. 0x00, 0x33, 0x0A, 0x00, 0xC2, 0x88, 0x4E, 0x00, 0x07, 0xA3, 0x6E, 0x01,
  4198. 0x00, 0x33, 0x0B, 0x00, 0xC2, 0x88, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33,
  4199. 0x1A, 0x00, 0xC2, 0x88, 0x50, 0x04, 0x88, 0x81, 0x06, 0xAB, 0x82, 0x01,
  4200. 0x88, 0x81, 0x4E, 0x00, 0x07, 0xA3, 0x92, 0x01, 0x50, 0x00, 0x00, 0xA3,
  4201. 0x3C, 0x01, 0x00, 0x05, 0x7C, 0x81, 0x46, 0x97, 0x02, 0x01, 0x05, 0xC6,
  4202. 0x04, 0x23, 0xA0, 0x01, 0x15, 0x23, 0xA1, 0x01, 0xBE, 0x81, 0xFD, 0x23,
  4203. 0x02, 0x61, 0x82, 0x01, 0x0A, 0xDA, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA0,
  4204. 0xB4, 0x01, 0x80, 0x63, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33, 0x1B, 0x00,
  4205. 0xC2, 0x88, 0x06, 0x23, 0x68, 0x98, 0xCD, 0x04, 0xE6, 0x84, 0x06, 0x01,
  4206. 0x00, 0xA2, 0xD4, 0x01, 0x57, 0x60, 0x00, 0xA0, 0xDA, 0x01, 0xE6, 0x84,
  4207. 0x80, 0x23, 0xA0, 0x01, 0xE6, 0x84, 0x80, 0x73, 0x4B, 0x00, 0x06, 0x61,
  4208. 0x00, 0xA2, 0x00, 0x02, 0x04, 0x01, 0x0C, 0xDE, 0x02, 0x01, 0x03, 0xCC,
  4209. 0x4F, 0x00, 0x84, 0x97, 0xFC, 0x81, 0x08, 0x23, 0x02, 0x41, 0x82, 0x01,
  4210. 0x4F, 0x00, 0x62, 0x97, 0x48, 0x04, 0x84, 0x80, 0xF0, 0x97, 0x00, 0x46,
  4211. 0x56, 0x00, 0x03, 0xC0, 0x01, 0x23, 0xE8, 0x00, 0x81, 0x73, 0x06, 0x29,
  4212. 0x03, 0x42, 0x06, 0xE2, 0x03, 0xEE, 0x6B, 0xEB, 0x11, 0x23, 0xF8, 0x88,
  4213. 0x04, 0x98, 0xF0, 0x80, 0x80, 0x73, 0x80, 0x77, 0x07, 0xA4, 0x2A, 0x02,
  4214. 0x7C, 0x95, 0x06, 0xA6, 0x34, 0x02, 0x03, 0xA6, 0x4C, 0x04, 0x46, 0x82,
  4215. 0x04, 0x01, 0x03, 0xD8, 0xB4, 0x98, 0x6A, 0x96, 0x46, 0x82, 0xFE, 0x95,
  4216. 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0xB6, 0x2D, 0x02, 0xA6, 0x6C, 0x02,
  4217. 0x07, 0xA6, 0x5A, 0x02, 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x62, 0x02,
  4218. 0xC2, 0x88, 0x7C, 0x95, 0x48, 0x82, 0x60, 0x96, 0x48, 0x82, 0x04, 0x23,
  4219. 0xA0, 0x01, 0x14, 0x23, 0xA1, 0x01, 0x3C, 0x84, 0x04, 0x01, 0x0C, 0xDC,
  4220. 0xE0, 0x23, 0x25, 0x61, 0xEF, 0x00, 0x14, 0x01, 0x4F, 0x04, 0xA8, 0x01,
  4221. 0x6F, 0x00, 0xA5, 0x01, 0x03, 0x23, 0xA4, 0x01, 0x06, 0x23, 0x9C, 0x01,
  4222. 0x24, 0x2B, 0x1C, 0x01, 0x02, 0xA6, 0xAA, 0x02, 0x07, 0xA6, 0x5A, 0x02,
  4223. 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x20, 0x04, 0x01, 0xA6, 0xB4, 0x02,
  4224. 0x00, 0xA6, 0xB4, 0x02, 0x00, 0x33, 0x12, 0x00, 0xC2, 0x88, 0x00, 0x0E,
  4225. 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0x8C, 0x02, 0x4D, 0x04, 0x04, 0x01,
  4226. 0x0B, 0xDC, 0xE7, 0x23, 0x04, 0x61, 0x84, 0x01, 0x10, 0x31, 0x12, 0x35,
  4227. 0x14, 0x01, 0xEC, 0x00, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0xEA, 0x82,
  4228. 0x18, 0x23, 0x04, 0x61, 0x18, 0xA0, 0xE2, 0x02, 0x04, 0x01, 0xA2, 0xC8,
  4229. 0x00, 0x33, 0x1F, 0x00, 0xC2, 0x88, 0x08, 0x31, 0x0A, 0x35, 0x0C, 0x39,
  4230. 0x0E, 0x3D, 0x7E, 0x98, 0xB6, 0x2D, 0x01, 0xA6, 0x14, 0x03, 0x00, 0xA6,
  4231. 0x14, 0x03, 0x07, 0xA6, 0x0C, 0x03, 0x06, 0xA6, 0x10, 0x03, 0x03, 0xA6,
  4232. 0x20, 0x04, 0x02, 0xA6, 0x6C, 0x02, 0x00, 0x33, 0x33, 0x00, 0xC2, 0x88,
  4233. 0x7C, 0x95, 0xEE, 0x82, 0x60, 0x96, 0xEE, 0x82, 0x82, 0x98, 0x80, 0x42,
  4234. 0x7E, 0x98, 0x64, 0xE4, 0x04, 0x01, 0x2D, 0xC8, 0x31, 0x05, 0x07, 0x01,
  4235. 0x00, 0xA2, 0x54, 0x03, 0x00, 0x43, 0x87, 0x01, 0x05, 0x05, 0x86, 0x98,
  4236. 0x7E, 0x98, 0x00, 0xA6, 0x16, 0x03, 0x07, 0xA6, 0x4C, 0x03, 0x03, 0xA6,
  4237. 0x3C, 0x04, 0x06, 0xA6, 0x50, 0x03, 0x01, 0xA6, 0x16, 0x03, 0x00, 0x33,
  4238. 0x25, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x32, 0x83, 0x60, 0x96, 0x32, 0x83,
  4239. 0x04, 0x01, 0x10, 0xCE, 0x07, 0xC8, 0x05, 0x05, 0xEB, 0x04, 0x00, 0x33,
  4240. 0x00, 0x20, 0xC0, 0x20, 0x81, 0x62, 0x72, 0x83, 0x00, 0x01, 0x05, 0x05,
  4241. 0xFF, 0xA2, 0x7A, 0x03, 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x2E, 0x83,
  4242. 0x05, 0x05, 0x15, 0x01, 0x00, 0xA2, 0x9A, 0x03, 0xEC, 0x00, 0x6E, 0x00,
  4243. 0x95, 0x01, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0x01, 0xA6, 0x96, 0x03,
  4244. 0x00, 0xA6, 0x96, 0x03, 0x10, 0x84, 0x80, 0x42, 0x7E, 0x98, 0x01, 0xA6,
  4245. 0xA4, 0x03, 0x00, 0xA6, 0xBC, 0x03, 0x10, 0x84, 0xA8, 0x98, 0x80, 0x42,
  4246. 0x01, 0xA6, 0xA4, 0x03, 0x07, 0xA6, 0xB2, 0x03, 0xD4, 0x83, 0x7C, 0x95,
  4247. 0xA8, 0x83, 0x00, 0x33, 0x2F, 0x00, 0xC2, 0x88, 0xA8, 0x98, 0x80, 0x42,
  4248. 0x00, 0xA6, 0xBC, 0x03, 0x07, 0xA6, 0xCA, 0x03, 0xD4, 0x83, 0x7C, 0x95,
  4249. 0xC0, 0x83, 0x00, 0x33, 0x26, 0x00, 0xC2, 0x88, 0x38, 0x2B, 0x80, 0x32,
  4250. 0x80, 0x36, 0x04, 0x23, 0xA0, 0x01, 0x12, 0x23, 0xA1, 0x01, 0x10, 0x84,
  4251. 0x07, 0xF0, 0x06, 0xA4, 0xF4, 0x03, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23,
  4252. 0x83, 0x03, 0x80, 0x63, 0x03, 0xA6, 0x0E, 0x04, 0x07, 0xA6, 0x06, 0x04,
  4253. 0x06, 0xA6, 0x0A, 0x04, 0x00, 0x33, 0x17, 0x00, 0xC2, 0x88, 0x7C, 0x95,
  4254. 0xF4, 0x83, 0x60, 0x96, 0xF4, 0x83, 0x20, 0x84, 0x07, 0xF0, 0x06, 0xA4,
  4255. 0x20, 0x04, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23, 0x83, 0x03, 0x80, 0x63,
  4256. 0xB6, 0x2D, 0x03, 0xA6, 0x3C, 0x04, 0x07, 0xA6, 0x34, 0x04, 0x06, 0xA6,
  4257. 0x38, 0x04, 0x00, 0x33, 0x30, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x20, 0x84,
  4258. 0x60, 0x96, 0x20, 0x84, 0x1D, 0x01, 0x06, 0xCC, 0x00, 0x33, 0x00, 0x84,
  4259. 0xC0, 0x20, 0x00, 0x23, 0xEA, 0x00, 0x81, 0x62, 0xA2, 0x0D, 0x80, 0x63,
  4260. 0x07, 0xA6, 0x5A, 0x04, 0x00, 0x33, 0x18, 0x00, 0xC2, 0x88, 0x03, 0x03,
  4261. 0x80, 0x63, 0xA3, 0x01, 0x07, 0xA4, 0x64, 0x04, 0x23, 0x01, 0x00, 0xA2,
  4262. 0x86, 0x04, 0x0A, 0xA0, 0x76, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1D, 0x00,
  4263. 0xC2, 0x88, 0x0B, 0xA0, 0x82, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1E, 0x00,
  4264. 0xC2, 0x88, 0x42, 0x23, 0xF8, 0x88, 0x00, 0x23, 0x22, 0xA3, 0xE6, 0x04,
  4265. 0x08, 0x23, 0x22, 0xA3, 0xA2, 0x04, 0x28, 0x23, 0x22, 0xA3, 0xAE, 0x04,
  4266. 0x02, 0x23, 0x22, 0xA3, 0xC4, 0x04, 0x42, 0x23, 0xF8, 0x88, 0x4A, 0x00,
  4267. 0x06, 0x61, 0x00, 0xA0, 0xAE, 0x04, 0x45, 0x23, 0xF8, 0x88, 0x04, 0x98,
  4268. 0x00, 0xA2, 0xC0, 0x04, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x82, 0xC0, 0x20,
  4269. 0x81, 0x62, 0xE8, 0x81, 0x47, 0x23, 0xF8, 0x88, 0x04, 0x01, 0x0B, 0xDE,
  4270. 0x04, 0x98, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x81, 0xC0, 0x20, 0x81, 0x62,
  4271. 0x14, 0x01, 0x00, 0xA0, 0x00, 0x02, 0x43, 0x23, 0xF8, 0x88, 0x04, 0x23,
  4272. 0xA0, 0x01, 0x44, 0x23, 0xA1, 0x01, 0x80, 0x73, 0x4D, 0x00, 0x03, 0xA3,
  4273. 0xF4, 0x04, 0x00, 0x33, 0x27, 0x00, 0xC2, 0x88, 0x04, 0x01, 0x04, 0xDC,
  4274. 0x02, 0x23, 0xA2, 0x01, 0x04, 0x23, 0xA0, 0x01, 0x04, 0x98, 0x26, 0x95,
  4275. 0x4B, 0x00, 0xF6, 0x00, 0x4F, 0x04, 0x4F, 0x00, 0x00, 0xA3, 0x22, 0x05,
  4276. 0x00, 0x05, 0x76, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x1C, 0x05, 0x0A, 0x85,
  4277. 0x46, 0x97, 0xCD, 0x04, 0x24, 0x85, 0x48, 0x04, 0x84, 0x80, 0x02, 0x01,
  4278. 0x03, 0xDA, 0x80, 0x23, 0x82, 0x01, 0x34, 0x85, 0x02, 0x23, 0xA0, 0x01,
  4279. 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x40, 0x05, 0x1D, 0x01, 0x04, 0xD6,
  4280. 0xFF, 0x23, 0x86, 0x41, 0x4B, 0x60, 0xCB, 0x00, 0xFF, 0x23, 0x80, 0x01,
  4281. 0x49, 0x00, 0x81, 0x01, 0x04, 0x01, 0x02, 0xC8, 0x30, 0x01, 0x80, 0x01,
  4282. 0xF7, 0x04, 0x03, 0x01, 0x49, 0x04, 0x80, 0x01, 0xC9, 0x00, 0x00, 0x05,
  4283. 0x00, 0x01, 0xFF, 0xA0, 0x60, 0x05, 0x77, 0x04, 0x01, 0x23, 0xEA, 0x00,
  4284. 0x5D, 0x00, 0xFE, 0xC7, 0x00, 0x62, 0x00, 0x23, 0xEA, 0x00, 0x00, 0x63,
  4285. 0x07, 0xA4, 0xF8, 0x05, 0x03, 0x03, 0x02, 0xA0, 0x8E, 0x05, 0xF4, 0x85,
  4286. 0x00, 0x33, 0x2D, 0x00, 0xC2, 0x88, 0x04, 0xA0, 0xB8, 0x05, 0x80, 0x63,
  4287. 0x00, 0x23, 0xDF, 0x00, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0xA4, 0x05,
  4288. 0x1D, 0x01, 0x06, 0xD6, 0x02, 0x23, 0x02, 0x41, 0x82, 0x01, 0x50, 0x00,
  4289. 0x62, 0x97, 0x04, 0x85, 0x04, 0x23, 0x02, 0x41, 0x82, 0x01, 0x04, 0x85,
  4290. 0x08, 0xA0, 0xBE, 0x05, 0xF4, 0x85, 0x03, 0xA0, 0xC4, 0x05, 0xF4, 0x85,
  4291. 0x01, 0xA0, 0xCE, 0x05, 0x88, 0x00, 0x80, 0x63, 0xCC, 0x86, 0x07, 0xA0,
  4292. 0xEE, 0x05, 0x5F, 0x00, 0x00, 0x2B, 0xDF, 0x08, 0x00, 0xA2, 0xE6, 0x05,
  4293. 0x80, 0x67, 0x80, 0x63, 0x01, 0xA2, 0x7A, 0x06, 0x7C, 0x85, 0x06, 0x23,
  4294. 0x68, 0x98, 0x48, 0x23, 0xF8, 0x88, 0x07, 0x23, 0x80, 0x00, 0x06, 0x87,
  4295. 0x80, 0x63, 0x7C, 0x85, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63, 0x4A, 0x00,
  4296. 0x06, 0x61, 0x00, 0xA2, 0x36, 0x06, 0x1D, 0x01, 0x16, 0xD4, 0xC0, 0x23,
  4297. 0x07, 0x41, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x1C, 0x06, 0x00, 0x33,
  4298. 0x37, 0x00, 0xC2, 0x88, 0x1D, 0x01, 0x01, 0xD6, 0x20, 0x23, 0x63, 0x60,
  4299. 0x83, 0x03, 0x80, 0x63, 0x02, 0x23, 0xDF, 0x00, 0x07, 0xA6, 0x7C, 0x05,
  4300. 0xEF, 0x04, 0x6F, 0x00, 0x00, 0x63, 0x4B, 0x00, 0x06, 0x41, 0xCB, 0x00,
  4301. 0x52, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x4E, 0x06, 0x1D, 0x01, 0x03, 0xCA,
  4302. 0xC0, 0x23, 0x07, 0x41, 0x00, 0x63, 0x1D, 0x01, 0x04, 0xCC, 0x00, 0x33,
  4303. 0x00, 0x83, 0xC0, 0x20, 0x81, 0x62, 0x80, 0x23, 0x07, 0x41, 0x00, 0x63,
  4304. 0x80, 0x67, 0x08, 0x23, 0x83, 0x03, 0x80, 0x63, 0x00, 0x63, 0x01, 0x23,
  4305. 0xDF, 0x00, 0x06, 0xA6, 0x84, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67,
  4306. 0x80, 0x63, 0x00, 0x33, 0x00, 0x40, 0xC0, 0x20, 0x81, 0x62, 0x00, 0x63,
  4307. 0x00, 0x00, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x94, 0x06,
  4308. 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x00, 0x01, 0xA0, 0x14, 0x07, 0x00, 0x2B,
  4309. 0x40, 0x0E, 0x80, 0x63, 0x01, 0x00, 0x06, 0xA6, 0xAA, 0x06, 0x07, 0xA6,
  4310. 0x7C, 0x05, 0x40, 0x0E, 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0xA2, 0x06,
  4311. 0x06, 0xA6, 0xBC, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67, 0x40, 0x0E,
  4312. 0x80, 0x63, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63,
  4313. 0x07, 0xA6, 0xD6, 0x06, 0x00, 0x33, 0x2A, 0x00, 0xC2, 0x88, 0x03, 0x03,
  4314. 0x80, 0x63, 0x89, 0x00, 0x0A, 0x2B, 0x07, 0xA6, 0xE8, 0x06, 0x00, 0x33,
  4315. 0x29, 0x00, 0xC2, 0x88, 0x00, 0x43, 0x00, 0xA2, 0xF4, 0x06, 0xC0, 0x0E,
  4316. 0x80, 0x63, 0xDE, 0x86, 0xC0, 0x0E, 0x00, 0x33, 0x00, 0x80, 0xC0, 0x20,
  4317. 0x81, 0x62, 0x04, 0x01, 0x02, 0xDA, 0x80, 0x63, 0x7C, 0x85, 0x80, 0x7B,
  4318. 0x80, 0x63, 0x06, 0xA6, 0x8C, 0x06, 0x00, 0x33, 0x2C, 0x00, 0xC2, 0x88,
  4319. 0x0C, 0xA2, 0x2E, 0x07, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6,
  4320. 0x2C, 0x07, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x33, 0x3D, 0x00, 0xC2, 0x88,
  4321. 0x00, 0x00, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0x0C, 0xA0, 0x44, 0x07,
  4322. 0x07, 0xA6, 0x7C, 0x05, 0xBF, 0x23, 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84,
  4323. 0x00, 0x63, 0xF0, 0x04, 0x01, 0x01, 0xF1, 0x00, 0x00, 0x01, 0xF2, 0x00,
  4324. 0x01, 0x05, 0x80, 0x01, 0x72, 0x04, 0x71, 0x00, 0x81, 0x01, 0x70, 0x04,
  4325. 0x80, 0x05, 0x81, 0x05, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04,
  4326. 0x01, 0x01, 0xF1, 0x00, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04, 0x71, 0x00,
  4327. 0x81, 0x01, 0x72, 0x00, 0x80, 0x01, 0x71, 0x04, 0x70, 0x00, 0x80, 0x01,
  4328. 0x70, 0x04, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x00, 0x01,
  4329. 0xF1, 0x00, 0x70, 0x00, 0x80, 0x01, 0x70, 0x04, 0x71, 0x00, 0x80, 0x01,
  4330. 0x72, 0x00, 0x81, 0x01, 0x71, 0x04, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04,
  4331. 0x00, 0x63, 0x00, 0x23, 0xB3, 0x01, 0x83, 0x05, 0xA3, 0x01, 0xA2, 0x01,
  4332. 0xA1, 0x01, 0x01, 0x23, 0xA0, 0x01, 0x00, 0x01, 0xC8, 0x00, 0x03, 0xA1,
  4333. 0xC4, 0x07, 0x00, 0x33, 0x07, 0x00, 0xC2, 0x88, 0x80, 0x05, 0x81, 0x05,
  4334. 0x04, 0x01, 0x11, 0xC8, 0x48, 0x00, 0xB0, 0x01, 0xB1, 0x01, 0x08, 0x23,
  4335. 0xB2, 0x01, 0x05, 0x01, 0x48, 0x04, 0x00, 0x43, 0x00, 0xA2, 0xE4, 0x07,
  4336. 0x00, 0x05, 0xDA, 0x87, 0x00, 0x01, 0xC8, 0x00, 0xFF, 0x23, 0x80, 0x01,
  4337. 0x05, 0x05, 0x00, 0x63, 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04,
  4338. 0x00, 0x02, 0x80, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04, 0x00, 0x63,
  4339. 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04, 0x00, 0x02, 0x00, 0xA0,
  4340. 0x14, 0x08, 0x16, 0x88, 0x00, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04,
  4341. 0x00, 0x63, 0xF3, 0x04, 0x00, 0x23, 0xF4, 0x00, 0x74, 0x00, 0x80, 0x43,
  4342. 0xF4, 0x00, 0xCF, 0x40, 0x00, 0xA2, 0x44, 0x08, 0x74, 0x04, 0x02, 0x01,
  4343. 0xF7, 0xC9, 0xF6, 0xD9, 0x00, 0x01, 0x01, 0xA1, 0x24, 0x08, 0x04, 0x98,
  4344. 0x26, 0x95, 0x24, 0x88, 0x73, 0x04, 0x00, 0x63, 0xF3, 0x04, 0x75, 0x04,
  4345. 0x5A, 0x88, 0x02, 0x01, 0x04, 0xD8, 0x46, 0x97, 0x04, 0x98, 0x26, 0x95,
  4346. 0x4A, 0x88, 0x75, 0x00, 0x00, 0xA3, 0x64, 0x08, 0x00, 0x05, 0x4E, 0x88,
  4347. 0x73, 0x04, 0x00, 0x63, 0x80, 0x7B, 0x80, 0x63, 0x06, 0xA6, 0x76, 0x08,
  4348. 0x00, 0x33, 0x3E, 0x00, 0xC2, 0x88, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63,
  4349. 0x00, 0x63, 0x38, 0x2B, 0x9C, 0x88, 0x38, 0x2B, 0x92, 0x88, 0x32, 0x09,
  4350. 0x31, 0x05, 0x92, 0x98, 0x05, 0x05, 0xB2, 0x09, 0x00, 0x63, 0x00, 0x32,
  4351. 0x00, 0x36, 0x00, 0x3A, 0x00, 0x3E, 0x00, 0x63, 0x80, 0x32, 0x80, 0x36,
  4352. 0x80, 0x3A, 0x80, 0x3E, 0xB4, 0x3D, 0x00, 0x63, 0x38, 0x2B, 0x40, 0x32,
  4353. 0x40, 0x36, 0x40, 0x3A, 0x40, 0x3E, 0x00, 0x63, 0x5A, 0x20, 0xC9, 0x40,
  4354. 0x00, 0xA0, 0xB4, 0x08, 0x5D, 0x00, 0xFE, 0xC3, 0x00, 0x63, 0x80, 0x73,
  4355. 0xE6, 0x20, 0x02, 0x23, 0xE8, 0x00, 0x82, 0x73, 0xFF, 0xFD, 0x80, 0x73,
  4356. 0x13, 0x23, 0xF8, 0x88, 0x66, 0x20, 0xC0, 0x20, 0x04, 0x23, 0xA0, 0x01,
  4357. 0xA1, 0x23, 0xA1, 0x01, 0x81, 0x62, 0xE2, 0x88, 0x80, 0x73, 0x80, 0x77,
  4358. 0x68, 0x00, 0x00, 0xA2, 0x80, 0x00, 0x03, 0xC2, 0xF1, 0xC7, 0x41, 0x23,
  4359. 0xF8, 0x88, 0x11, 0x23, 0xA1, 0x01, 0x04, 0x23, 0xA0, 0x01, 0xE6, 0x84,
  4360. };
  4361. static unsigned short _asc_mcode_size = sizeof(_asc_mcode_buf);
  4362. static ADV_DCNT _asc_mcode_chksum = 0x012C453FUL;
  4363. /* Microcode buffer is kept after initialization for error recovery. */
  4364. static unsigned char _adv_asc3550_buf[] = {
  4365. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0x16, 0x18, 0xe4, 0x00, 0xfc,
  4366. 0x01, 0x00, 0x48, 0xe4, 0xbe, 0x18, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00,
  4367. 0x00, 0xfa, 0xff, 0xff, 0x28, 0x0e, 0x9e, 0xe7, 0xff, 0x00, 0x82, 0xe7,
  4368. 0x00, 0xea, 0x00, 0xf6, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0, 0x01, 0xf6,
  4369. 0x01, 0xfa, 0x08, 0x00, 0x03, 0x00, 0x04, 0x00, 0x18, 0xf4, 0x10, 0x00,
  4370. 0x00, 0xec, 0x85, 0xf0, 0xbc, 0x00, 0xd5, 0xf0, 0x8e, 0x0c, 0x38, 0x54,
  4371. 0x00, 0xe6, 0x1e, 0xf0, 0x86, 0xf0, 0xb4, 0x00, 0x98, 0x57, 0xd0, 0x01,
  4372. 0x0c, 0x1c, 0x3e, 0x1c, 0x0c, 0x00, 0xbb, 0x00, 0xaa, 0x18, 0x02, 0x80,
  4373. 0x32, 0xf0, 0x01, 0xfc, 0x88, 0x0c, 0xc6, 0x12, 0x02, 0x13, 0x18, 0x40,
  4374. 0x00, 0x57, 0x01, 0xea, 0x3c, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
  4375. 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
  4376. 0x3e, 0x01, 0xda, 0x0f, 0x22, 0x10, 0x08, 0x12, 0x02, 0x4a, 0xb9, 0x54,
  4377. 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4, 0x20, 0x00, 0x32, 0x00,
  4378. 0x3e, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
  4379. 0x70, 0x01, 0x72, 0x01, 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x62, 0x0a,
  4380. 0x92, 0x0c, 0x2c, 0x10, 0x2e, 0x10, 0x06, 0x13, 0x4c, 0x1c, 0xbb, 0x55,
  4381. 0x3c, 0x56, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0xb1, 0xf0,
  4382. 0x03, 0xf7, 0x06, 0xf7, 0x03, 0xfc, 0x0f, 0x00, 0x40, 0x00, 0xbe, 0x00,
  4383. 0x00, 0x01, 0xb0, 0x08, 0x30, 0x13, 0x64, 0x15, 0x32, 0x1c, 0x38, 0x1c,
  4384. 0x4e, 0x1c, 0x10, 0x44, 0x02, 0x48, 0x00, 0x4c, 0x04, 0xea, 0x5d, 0xf0,
  4385. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00,
  4386. 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01, 0x4e, 0x0b, 0x1e, 0x0e, 0x0c, 0x10,
  4387. 0x0a, 0x12, 0x04, 0x13, 0x40, 0x13, 0x30, 0x1c, 0x00, 0x4e, 0xbd, 0x56,
  4388. 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xa7, 0xf0,
  4389. 0xb8, 0xf0, 0x0e, 0xf7, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00,
  4390. 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00,
  4391. 0xde, 0x03, 0x56, 0x0a, 0x14, 0x0e, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10,
  4392. 0x36, 0x10, 0x0a, 0x13, 0x12, 0x13, 0x52, 0x13, 0x10, 0x15, 0x14, 0x15,
  4393. 0xac, 0x16, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44,
  4394. 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x83, 0x55,
  4395. 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0, 0x0c, 0xf0,
  4396. 0x5c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8, 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa,
  4397. 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00, 0x0a, 0x00, 0x0d, 0x00, 0x1c, 0x00,
  4398. 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01,
  4399. 0x26, 0x01, 0x79, 0x01, 0x7a, 0x01, 0xc0, 0x01, 0xc2, 0x01, 0x7c, 0x02,
  4400. 0x5a, 0x03, 0xea, 0x04, 0xe8, 0x07, 0x68, 0x08, 0x69, 0x08, 0xba, 0x08,
  4401. 0xe9, 0x09, 0x06, 0x0b, 0x3a, 0x0e, 0x00, 0x10, 0x1a, 0x10, 0xed, 0x10,
  4402. 0xf1, 0x10, 0x06, 0x12, 0x0c, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x82, 0x13,
  4403. 0x42, 0x14, 0xd6, 0x14, 0x8a, 0x15, 0xc6, 0x17, 0xd2, 0x17, 0x6b, 0x18,
  4404. 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40, 0x0e, 0x47, 0x48, 0x47,
  4405. 0x41, 0x48, 0x89, 0x48, 0x80, 0x4c, 0x00, 0x54, 0x44, 0x55, 0xe5, 0x55,
  4406. 0x14, 0x56, 0x77, 0x57, 0xbf, 0x57, 0x40, 0x5c, 0x06, 0x80, 0x08, 0x90,
  4407. 0x03, 0xa1, 0xfe, 0x9c, 0xf0, 0x29, 0x02, 0xfe, 0xb8, 0x0c, 0xff, 0x10,
  4408. 0x00, 0x00, 0xd0, 0xfe, 0xcc, 0x18, 0x00, 0xcf, 0xfe, 0x80, 0x01, 0xff,
  4409. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  4410. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x48, 0x00, 0x4f, 0xff, 0x04, 0x00,
  4411. 0x00, 0x10, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  4412. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x0f,
  4413. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  4414. 0xfe, 0x04, 0xf7, 0xcf, 0x2a, 0x67, 0x0b, 0x01, 0xfe, 0xce, 0x0e, 0xfe,
  4415. 0x04, 0xf7, 0xcf, 0x67, 0x0b, 0x3c, 0x2a, 0xfe, 0x3d, 0xf0, 0xfe, 0x02,
  4416. 0x02, 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x91, 0xf0, 0xfe, 0xf0, 0x01, 0xfe,
  4417. 0x90, 0xf0, 0xfe, 0xf0, 0x01, 0xfe, 0x8f, 0xf0, 0x9c, 0x05, 0x51, 0x3b,
  4418. 0x02, 0xfe, 0xd4, 0x0c, 0x01, 0xfe, 0x44, 0x0d, 0xfe, 0xdd, 0x12, 0xfe,
  4419. 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x05, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
  4420. 0x47, 0x18, 0xfe, 0xa6, 0x00, 0xb5, 0xfe, 0x48, 0xf0, 0xfe, 0x86, 0x02,
  4421. 0xfe, 0x49, 0xf0, 0xfe, 0xa0, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xbe, 0x02,
  4422. 0xfe, 0x46, 0xf0, 0xfe, 0x50, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x56, 0x02,
  4423. 0xfe, 0x43, 0xf0, 0xfe, 0x44, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x48, 0x02,
  4424. 0xfe, 0x45, 0xf0, 0xfe, 0x4c, 0x02, 0x17, 0x0b, 0xa0, 0x17, 0x06, 0x18,
  4425. 0x96, 0x02, 0x29, 0xfe, 0x00, 0x1c, 0xde, 0xfe, 0x02, 0x1c, 0xdd, 0xfe,
  4426. 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x20, 0x17, 0xfe, 0xe7, 0x10,
  4427. 0xfe, 0x06, 0xfc, 0xc7, 0x0a, 0x6b, 0x01, 0x9e, 0x02, 0x29, 0x14, 0x4d,
  4428. 0x37, 0x97, 0x01, 0xfe, 0x64, 0x0f, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xbd,
  4429. 0x10, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
  4430. 0x58, 0x1c, 0x17, 0x06, 0x18, 0x96, 0x2a, 0x25, 0x29, 0xfe, 0x3d, 0xf0,
  4431. 0xfe, 0x02, 0x02, 0x21, 0xfe, 0x94, 0x02, 0xfe, 0x5a, 0x1c, 0xea, 0xfe,
  4432. 0x14, 0x1c, 0x14, 0xfe, 0x30, 0x00, 0x37, 0x97, 0x01, 0xfe, 0x54, 0x0f,
  4433. 0x17, 0x06, 0x18, 0x96, 0x02, 0xd0, 0x1e, 0x20, 0x07, 0x10, 0x34, 0xfe,
  4434. 0x69, 0x10, 0x17, 0x06, 0x18, 0x96, 0xfe, 0x04, 0xec, 0x20, 0x46, 0x3d,
  4435. 0x12, 0x20, 0xfe, 0x05, 0xf6, 0xc7, 0x01, 0xfe, 0x52, 0x16, 0x09, 0x4a,
  4436. 0x4c, 0x35, 0x11, 0x2d, 0x3c, 0x8a, 0x01, 0xe6, 0x02, 0x29, 0x0a, 0x40,
  4437. 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x01, 0x6f, 0xfe, 0x18, 0x10, 0xfe, 0x41,
  4438. 0x58, 0x0a, 0x99, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x64, 0xfe, 0x0c, 0x03,
  4439. 0x01, 0xe6, 0x02, 0x29, 0x2a, 0x46, 0xfe, 0x02, 0xe8, 0x27, 0xf8, 0xfe,
  4440. 0x9e, 0x43, 0xf7, 0xfe, 0x27, 0xf0, 0xfe, 0xdc, 0x01, 0xfe, 0x07, 0x4b,
  4441. 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x40, 0x1c, 0x25, 0xd2, 0xfe, 0x26, 0xf0,
  4442. 0xfe, 0x56, 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x44, 0x03, 0xfe, 0x11, 0xf0,
  4443. 0x9c, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 0xf0, 0xfe, 0x64, 0x03, 0xeb, 0x0f,
  4444. 0xfe, 0x11, 0x00, 0x02, 0x5a, 0x2a, 0xfe, 0x48, 0x1c, 0xeb, 0x09, 0x04,
  4445. 0x1d, 0xfe, 0x18, 0x13, 0x23, 0x1e, 0x98, 0xac, 0x12, 0x98, 0x0a, 0x40,
  4446. 0x01, 0x0e, 0xac, 0x75, 0x01, 0xfe, 0xbc, 0x15, 0x11, 0xca, 0x25, 0xd2,
  4447. 0xfe, 0x01, 0xf0, 0xd2, 0xfe, 0x82, 0xf0, 0xfe, 0x92, 0x03, 0xec, 0x11,
  4448. 0xfe, 0xe4, 0x00, 0x65, 0xfe, 0xa4, 0x03, 0x25, 0x32, 0x1f, 0xfe, 0xb4,
  4449. 0x03, 0x01, 0x43, 0xfe, 0x06, 0xf0, 0xfe, 0xc4, 0x03, 0x8d, 0x81, 0xfe,
  4450. 0x0a, 0xf0, 0xfe, 0x7a, 0x06, 0x02, 0x22, 0x05, 0x6b, 0x28, 0x16, 0xfe,
  4451. 0xf6, 0x04, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02, 0xd1,
  4452. 0xeb, 0x2a, 0x67, 0x1a, 0xfe, 0x67, 0x1b, 0xf8, 0xf7, 0xfe, 0x48, 0x1c,
  4453. 0x70, 0x01, 0x6e, 0x87, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x16, 0xd3,
  4454. 0x0a, 0xca, 0x01, 0x0e, 0x74, 0x60, 0x59, 0x76, 0x27, 0x05, 0x6b, 0x28,
  4455. 0xfe, 0x10, 0x12, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02,
  4456. 0xd1, 0xbc, 0x7d, 0xbd, 0x7f, 0x25, 0x22, 0x65, 0xfe, 0x3c, 0x04, 0x1f,
  4457. 0xfe, 0x38, 0x04, 0x68, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
  4458. 0x12, 0x2b, 0xff, 0x02, 0x00, 0x10, 0x01, 0x08, 0x1f, 0xfe, 0xe0, 0x04,
  4459. 0x2b, 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd5, 0xfe, 0x4c, 0x44, 0xfe,
  4460. 0x4c, 0x12, 0x60, 0xfe, 0x44, 0x48, 0x13, 0x2c, 0xfe, 0x4c, 0x54, 0x64,
  4461. 0xd3, 0x46, 0x76, 0x27, 0xfa, 0xef, 0xfe, 0x62, 0x13, 0x09, 0x04, 0x1d,
  4462. 0xfe, 0x2a, 0x13, 0x2f, 0x07, 0x7e, 0xa5, 0xfe, 0x20, 0x10, 0x13, 0x2c,
  4463. 0xfe, 0x4c, 0x54, 0x64, 0xd3, 0xfa, 0xef, 0x86, 0x09, 0x04, 0x1d, 0xfe,
  4464. 0x08, 0x13, 0x2f, 0x07, 0x7e, 0x6e, 0x09, 0x04, 0x1d, 0xfe, 0x1c, 0x12,
  4465. 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe,
  4466. 0x70, 0x0c, 0x02, 0x22, 0x2b, 0x11, 0xfe, 0xe6, 0x00, 0xfe, 0x1c, 0x90,
  4467. 0xf9, 0x03, 0x14, 0x92, 0x01, 0x33, 0x02, 0x29, 0xfe, 0x42, 0x5b, 0x67,
  4468. 0x1a, 0xfe, 0x46, 0x59, 0xf8, 0xf7, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4,
  4469. 0x4f, 0x09, 0x04, 0x0b, 0xfe, 0x78, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x1a,
  4470. 0xfe, 0x70, 0x12, 0x49, 0x04, 0x06, 0xfe, 0x60, 0x13, 0x05, 0xfe, 0xa2,
  4471. 0x00, 0x28, 0x16, 0xfe, 0x80, 0x05, 0xfe, 0x31, 0xe4, 0x6a, 0x49, 0x04,
  4472. 0x0b, 0xfe, 0x4a, 0x13, 0x05, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x42, 0x12,
  4473. 0x5e, 0x01, 0x08, 0x25, 0x32, 0xf1, 0x01, 0x08, 0x26, 0xfe, 0x98, 0x05,
  4474. 0x11, 0xfe, 0xe3, 0x00, 0x23, 0x49, 0xfe, 0x4a, 0xf0, 0xfe, 0x6a, 0x05,
  4475. 0xfe, 0x49, 0xf0, 0xfe, 0x64, 0x05, 0x83, 0x24, 0xfe, 0x21, 0x00, 0xa1,
  4476. 0x24, 0xfe, 0x22, 0x00, 0xa0, 0x24, 0x4c, 0xfe, 0x09, 0x48, 0x01, 0x08,
  4477. 0x26, 0xfe, 0x98, 0x05, 0xfe, 0xe2, 0x08, 0x49, 0x04, 0xc5, 0x3b, 0x01,
  4478. 0x86, 0x24, 0x06, 0x12, 0xcc, 0x37, 0xfe, 0x27, 0x01, 0x09, 0x04, 0x1d,
  4479. 0xfe, 0x22, 0x12, 0x47, 0x01, 0xa7, 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b,
  4480. 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe, 0x70, 0x0c, 0x02, 0x22, 0x05, 0xfe,
  4481. 0x9c, 0x00, 0x28, 0xfe, 0x3e, 0x12, 0x05, 0x50, 0x28, 0xfe, 0x36, 0x13,
  4482. 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x08, 0x06, 0x0a, 0x06, 0x49, 0x04, 0x19,
  4483. 0xfe, 0x02, 0x12, 0x5f, 0x01, 0xfe, 0xaa, 0x14, 0x1f, 0xfe, 0xfe, 0x05,
  4484. 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x50, 0xb4, 0x0c,
  4485. 0x50, 0x05, 0xc6, 0x28, 0xfe, 0x62, 0x12, 0x05, 0x3f, 0x28, 0xfe, 0x5a,
  4486. 0x13, 0x01, 0xfe, 0x14, 0x18, 0x01, 0xfe, 0x66, 0x18, 0xfe, 0x43, 0x48,
  4487. 0xb7, 0x19, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d,
  4488. 0x85, 0xb7, 0x69, 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x72, 0x06, 0x49, 0x04,
  4489. 0x1b, 0xdf, 0x89, 0x0a, 0x4d, 0x01, 0xfe, 0xd8, 0x14, 0x1f, 0xfe, 0x68,
  4490. 0x06, 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x3f, 0xb4,
  4491. 0x0c, 0x3f, 0x17, 0x06, 0x01, 0xa7, 0xec, 0x72, 0x70, 0x01, 0x6e, 0x87,
  4492. 0x11, 0xfe, 0xe2, 0x00, 0x01, 0x08, 0x25, 0x32, 0xfe, 0x0a, 0xf0, 0xfe,
  4493. 0xa6, 0x06, 0x8c, 0xfe, 0x5c, 0x07, 0xfe, 0x06, 0xf0, 0xfe, 0x64, 0x07,
  4494. 0x8d, 0x81, 0x02, 0x22, 0x09, 0x04, 0x0b, 0xfe, 0x2e, 0x12, 0x15, 0x1a,
  4495. 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00,
  4496. 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08, 0x15, 0x00, 0x02, 0xfe, 0x32,
  4497. 0x08, 0x61, 0x04, 0x1b, 0xfe, 0x38, 0x12, 0x09, 0x04, 0x1b, 0x6e, 0x15,
  4498. 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01,
  4499. 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x06, 0x01, 0x08, 0x15, 0x00, 0x02,
  4500. 0xd9, 0x66, 0x4c, 0xfe, 0x3a, 0x55, 0x5f, 0xfe, 0x9a, 0x81, 0x4b, 0x1d,
  4501. 0xba, 0xfe, 0x32, 0x07, 0x0a, 0x1d, 0xfe, 0x09, 0x6f, 0xaf, 0xfe, 0xca,
  4502. 0x45, 0xfe, 0x32, 0x12, 0x62, 0x2c, 0x85, 0x66, 0x7b, 0x01, 0x08, 0x25,
  4503. 0x32, 0xfe, 0x0a, 0xf0, 0xfe, 0x32, 0x07, 0x8d, 0x81, 0x8c, 0xfe, 0x5c,
  4504. 0x07, 0x02, 0x22, 0x01, 0x43, 0x02, 0xfe, 0x8a, 0x06, 0x15, 0x19, 0x02,
  4505. 0xfe, 0x8a, 0x06, 0xfe, 0x9c, 0xf7, 0xd4, 0xfe, 0x2c, 0x90, 0xfe, 0xae,
  4506. 0x90, 0x77, 0xfe, 0xca, 0x07, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x4a, 0x6a,
  4507. 0x35, 0x1e, 0x20, 0x07, 0x10, 0xfe, 0x0e, 0x12, 0x74, 0xfe, 0x80, 0x80,
  4508. 0x37, 0x20, 0x63, 0x27, 0xfe, 0x06, 0x10, 0xfe, 0x83, 0xe7, 0xc4, 0xa1,
  4509. 0xfe, 0x03, 0x40, 0x09, 0x4a, 0x4f, 0x35, 0x01, 0xa8, 0xad, 0xfe, 0x1f,
  4510. 0x40, 0x12, 0x58, 0x01, 0xa5, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
  4511. 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x83, 0xfb, 0xfe, 0x8a, 0x90, 0x0c, 0x52,
  4512. 0x18, 0x53, 0xfe, 0x0c, 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe,
  4513. 0xc2, 0x50, 0x0c, 0x39, 0x18, 0x3a, 0xfe, 0x4a, 0x10, 0x09, 0x04, 0x6a,
  4514. 0xfe, 0x2a, 0x12, 0xfe, 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x54, 0x18,
  4515. 0x55, 0x09, 0x04, 0x4f, 0x85, 0x01, 0xa8, 0xfe, 0x1f, 0x80, 0x12, 0x58,
  4516. 0xfe, 0x44, 0x90, 0xfe, 0xc6, 0x90, 0x0c, 0x56, 0x18, 0x57, 0xfb, 0xfe,
  4517. 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90,
  4518. 0x0c, 0x39, 0x18, 0x3a, 0x0c, 0x38, 0x18, 0x4e, 0x09, 0x4a, 0x19, 0x35,
  4519. 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x48, 0x08, 0xfe, 0x9e, 0xf0,
  4520. 0xfe, 0x5c, 0x08, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0xfe, 0x80,
  4521. 0x08, 0xb9, 0xfe, 0x9e, 0x08, 0x8c, 0xfe, 0x74, 0x08, 0xfe, 0x06, 0xf0,
  4522. 0xfe, 0x7a, 0x08, 0x8d, 0x81, 0x02, 0x22, 0x01, 0x43, 0xfe, 0xc9, 0x10,
  4523. 0x15, 0x19, 0xfe, 0xc9, 0x10, 0x61, 0x04, 0x06, 0xfe, 0x10, 0x12, 0x61,
  4524. 0x04, 0x0b, 0x45, 0x09, 0x04, 0x0b, 0xfe, 0x68, 0x12, 0xfe, 0x2e, 0x1c,
  4525. 0x02, 0xfe, 0x24, 0x0a, 0x61, 0x04, 0x06, 0x45, 0x61, 0x04, 0x0b, 0xfe,
  4526. 0x52, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0x1e, 0x09, 0xfe,
  4527. 0xac, 0xf0, 0xfe, 0xbe, 0x08, 0xfe, 0x8a, 0x10, 0xaa, 0xfe, 0xf3, 0x10,
  4528. 0xfe, 0xad, 0xf0, 0xfe, 0xca, 0x08, 0x02, 0xfe, 0x24, 0x0a, 0xab, 0xfe,
  4529. 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0x9d, 0xe9, 0x1c, 0xfe, 0x00, 0xfe, 0xfe,
  4530. 0x1c, 0x12, 0xb5, 0xfe, 0xd2, 0xf0, 0x9d, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
  4531. 0x16, 0x9d, 0x05, 0xcb, 0x1c, 0x06, 0x16, 0x9d, 0xb8, 0x6d, 0xb9, 0x6d,
  4532. 0xaa, 0xab, 0xfe, 0xb1, 0x10, 0x70, 0x5e, 0x2b, 0x14, 0x92, 0x01, 0x33,
  4533. 0x0f, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x5a, 0x0f, 0x7c, 0x02, 0x5a,
  4534. 0xfe, 0x74, 0x18, 0x1c, 0xfe, 0x00, 0xf8, 0x16, 0x6d, 0x67, 0x1b, 0x01,
  4535. 0xfe, 0x44, 0x0d, 0x3b, 0x01, 0xe6, 0x1e, 0x27, 0x74, 0x67, 0x1a, 0x02,
  4536. 0x6d, 0x09, 0x04, 0x0b, 0x21, 0xfe, 0x06, 0x0a, 0x09, 0x04, 0x6a, 0xfe,
  4537. 0x82, 0x12, 0x09, 0x04, 0x19, 0xfe, 0x66, 0x13, 0x1e, 0x58, 0xac, 0xfc,
  4538. 0xfe, 0x83, 0x80, 0xfe, 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91,
  4539. 0xfe, 0x86, 0x91, 0x63, 0x27, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x77,
  4540. 0xd7, 0x05, 0x54, 0x31, 0x55, 0x0c, 0x7b, 0x18, 0x7c, 0xbe, 0x54, 0xbf,
  4541. 0x55, 0x01, 0xa8, 0xad, 0x63, 0x27, 0x12, 0x58, 0xc0, 0x38, 0xc1, 0x4e,
  4542. 0x79, 0x56, 0x68, 0x57, 0xf4, 0xf5, 0xfe, 0x04, 0xfa, 0x38, 0xfe, 0x05,
  4543. 0xfa, 0x4e, 0x01, 0xa5, 0xa2, 0x23, 0x0c, 0x7b, 0x0c, 0x7c, 0x79, 0x56,
  4544. 0x68, 0x57, 0xfe, 0x12, 0x10, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x79, 0x39,
  4545. 0x68, 0x3a, 0x09, 0x04, 0xfe, 0xf7, 0x00, 0x35, 0x05, 0x52, 0x31, 0x53,
  4546. 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59,
  4547. 0x02, 0x6d, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x09, 0x04, 0xfe, 0xf7, 0x00,
  4548. 0x35, 0xfe, 0x3a, 0x55, 0xfe, 0x19, 0x81, 0x5f, 0xfe, 0x10, 0x90, 0xfe,
  4549. 0x92, 0x90, 0xfe, 0xd7, 0x10, 0x2f, 0x07, 0x9b, 0x16, 0xfe, 0xc6, 0x08,
  4550. 0x11, 0x9b, 0x09, 0x04, 0x0b, 0xfe, 0x14, 0x13, 0x05, 0x39, 0x31, 0x3a,
  4551. 0x77, 0xfe, 0xc6, 0x08, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x6d,
  4552. 0x23, 0x47, 0xfe, 0x19, 0x80, 0xde, 0x09, 0x04, 0x0b, 0xfe, 0x1a, 0x12,
  4553. 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xe9, 0xb5, 0xfe, 0xd1, 0xf0, 0xd9,
  4554. 0x14, 0x7a, 0x01, 0x33, 0x0f, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe,
  4555. 0x6c, 0x19, 0xbe, 0x39, 0xfe, 0xed, 0x19, 0xbf, 0x3a, 0xfe, 0x0c, 0x51,
  4556. 0xfe, 0x8e, 0x51, 0xe9, 0x1c, 0xfe, 0x00, 0xff, 0x34, 0xfe, 0x74, 0x10,
  4557. 0xb5, 0xfe, 0xd2, 0xf0, 0xfe, 0xb2, 0x0a, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
  4558. 0x84, 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0x08, 0x13, 0x0f, 0xfe, 0x16, 0x00,
  4559. 0x02, 0x5a, 0xfe, 0xd1, 0xf0, 0xfe, 0xc4, 0x0a, 0x14, 0x7a, 0x01, 0x33,
  4560. 0x0f, 0xfe, 0x17, 0x00, 0xfe, 0x42, 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xca,
  4561. 0x0a, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xd6, 0x0a, 0x0f, 0xfe,
  4562. 0x22, 0x00, 0x02, 0x5a, 0xfe, 0xcb, 0xf0, 0xfe, 0xe2, 0x0a, 0x0f, 0xfe,
  4563. 0x24, 0x00, 0x02, 0x5a, 0xfe, 0xd0, 0xf0, 0xfe, 0xec, 0x0a, 0x0f, 0x93,
  4564. 0xdc, 0xfe, 0xcf, 0xf0, 0xfe, 0xf6, 0x0a, 0x0f, 0x4c, 0xfe, 0x10, 0x10,
  4565. 0xfe, 0xcc, 0xf0, 0xd9, 0x61, 0x04, 0x19, 0x3b, 0x0f, 0xfe, 0x12, 0x00,
  4566. 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x0c, 0x0b, 0xfe, 0x9e, 0xf0,
  4567. 0xfe, 0x20, 0x0b, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0x22, 0xb9,
  4568. 0x22, 0x2a, 0xec, 0x65, 0xfe, 0x2c, 0x0b, 0x25, 0x32, 0x8c, 0xfe, 0x48,
  4569. 0x0b, 0x8d, 0x81, 0xb8, 0xd4, 0xb9, 0xd4, 0x02, 0x22, 0x01, 0x43, 0xfe,
  4570. 0xdb, 0x10, 0x11, 0xfe, 0xe8, 0x00, 0xaa, 0xab, 0x70, 0xbc, 0x7d, 0xbd,
  4571. 0x7f, 0xfe, 0x89, 0xf0, 0x22, 0x30, 0x2e, 0xd8, 0xbc, 0x7d, 0xbd, 0x7f,
  4572. 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd6, 0xb1, 0x45, 0x0f, 0xfe, 0x42,
  4573. 0x00, 0x02, 0x5a, 0x78, 0x06, 0xfe, 0x81, 0x49, 0x16, 0xfe, 0x38, 0x0c,
  4574. 0x09, 0x04, 0x0b, 0xfe, 0x44, 0x13, 0x0f, 0x00, 0x4b, 0x0b, 0xfe, 0x54,
  4575. 0x12, 0x4b, 0xfe, 0x28, 0x00, 0x21, 0xfe, 0xa6, 0x0c, 0x0a, 0x40, 0x01,
  4576. 0x0e, 0x07, 0x00, 0x5d, 0x3e, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01,
  4577. 0xe7, 0x01, 0xe8, 0x0a, 0x99, 0x01, 0xfe, 0x32, 0x0e, 0x59, 0x11, 0x2d,
  4578. 0x01, 0x6f, 0x02, 0x29, 0x0f, 0xfe, 0x44, 0x00, 0x4b, 0x0b, 0xdf, 0x3e,
  4579. 0x0b, 0xfe, 0xb4, 0x10, 0x01, 0x86, 0x3e, 0x0b, 0xfe, 0xaa, 0x10, 0x01,
  4580. 0x86, 0xfe, 0x19, 0x82, 0xfe, 0x34, 0x46, 0xa3, 0x3e, 0x0b, 0x0f, 0xfe,
  4581. 0x43, 0x00, 0xfe, 0x96, 0x10, 0x09, 0x4a, 0x0b, 0x35, 0x01, 0xe7, 0x01,
  4582. 0xe8, 0x59, 0x11, 0x2d, 0x01, 0x6f, 0x67, 0x0b, 0x59, 0x3c, 0x8a, 0x02,
  4583. 0xfe, 0x2a, 0x03, 0x09, 0x04, 0x0b, 0x84, 0x3e, 0x0b, 0x0f, 0x00, 0xfe,
  4584. 0x5c, 0x10, 0x61, 0x04, 0x1b, 0xfe, 0x58, 0x12, 0x09, 0x04, 0x1b, 0xfe,
  4585. 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x5c, 0x0c, 0xfe,
  4586. 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x62, 0x0c, 0x09, 0x4a, 0x1b, 0x35,
  4587. 0xfe, 0xa9, 0x10, 0x0f, 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0b, 0x5f,
  4588. 0x5c, 0x0f, 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x0f, 0xfe, 0x47, 0x00,
  4589. 0xa1, 0x0f, 0xfe, 0x41, 0x00, 0xa0, 0x0f, 0xfe, 0x24, 0x00, 0x87, 0xaa,
  4590. 0xab, 0x70, 0x05, 0x6b, 0x28, 0x21, 0xd1, 0x5f, 0xfe, 0x04, 0xe6, 0x1b,
  4591. 0xfe, 0x9d, 0x41, 0xfe, 0x1c, 0x42, 0x59, 0x01, 0xda, 0x02, 0x29, 0xea,
  4592. 0x14, 0x0b, 0x37, 0x95, 0xa9, 0x14, 0xfe, 0x31, 0x00, 0x37, 0x97, 0x01,
  4593. 0xfe, 0x54, 0x0f, 0x02, 0xd0, 0x3c, 0xfe, 0x06, 0xec, 0xc9, 0xee, 0x3e,
  4594. 0x1d, 0xfe, 0xce, 0x45, 0x34, 0x3c, 0xfe, 0x06, 0xea, 0xc9, 0xfe, 0x47,
  4595. 0x4b, 0x89, 0xfe, 0x75, 0x57, 0x05, 0x51, 0xfe, 0x98, 0x56, 0xfe, 0x38,
  4596. 0x12, 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x44, 0x48, 0x46, 0x09, 0x04, 0x1d,
  4597. 0xfe, 0x1a, 0x13, 0x0a, 0x40, 0x01, 0x0e, 0x47, 0xfe, 0x41, 0x58, 0x0a,
  4598. 0x99, 0x01, 0x0e, 0xfe, 0x49, 0x54, 0x8e, 0xfe, 0x2a, 0x0d, 0x02, 0xfe,
  4599. 0x2a, 0x03, 0x0a, 0x51, 0xfe, 0xee, 0x14, 0xee, 0x3e, 0x1d, 0xfe, 0xce,
  4600. 0x45, 0x34, 0x3c, 0xfe, 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x29, 0x1e,
  4601. 0x20, 0x07, 0x10, 0xfe, 0x9e, 0x12, 0x23, 0x12, 0x4d, 0x12, 0x94, 0x12,
  4602. 0xce, 0x1e, 0x2d, 0x47, 0x37, 0x2d, 0xb1, 0xe0, 0xfe, 0xbc, 0xf0, 0xfe,
  4603. 0xec, 0x0d, 0x13, 0x06, 0x12, 0x4d, 0x01, 0xfe, 0xe2, 0x15, 0x05, 0xfe,
  4604. 0x38, 0x01, 0x31, 0xfe, 0x3a, 0x01, 0x77, 0xfe, 0xf0, 0x0d, 0xfe, 0x02,
  4605. 0xec, 0xce, 0x62, 0x00, 0x5d, 0xfe, 0x04, 0xec, 0x20, 0x46, 0xfe, 0x05,
  4606. 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x52, 0x16, 0xfb, 0xfe, 0x48, 0xf4,
  4607. 0x0d, 0xfe, 0x18, 0x13, 0xaf, 0xfe, 0x02, 0xea, 0xce, 0x62, 0x7a, 0xfe,
  4608. 0xc5, 0x13, 0x14, 0x1b, 0x37, 0x95, 0xa9, 0x5c, 0x05, 0xfe, 0x38, 0x01,
  4609. 0x1c, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x05, 0xfe, 0x3a, 0x01,
  4610. 0x0c, 0xfe, 0x62, 0x01, 0x3d, 0x12, 0x20, 0x24, 0x06, 0x12, 0x2d, 0x11,
  4611. 0x2d, 0x8a, 0x13, 0x06, 0x03, 0x23, 0x03, 0x1e, 0x4d, 0xfe, 0xf7, 0x12,
  4612. 0x1e, 0x94, 0xac, 0x12, 0x94, 0x07, 0x7a, 0xfe, 0x71, 0x13, 0xfe, 0x24,
  4613. 0x1c, 0x14, 0x1a, 0x37, 0x95, 0xa9, 0xfe, 0xd9, 0x10, 0xb6, 0xfe, 0x03,
  4614. 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xb6, 0xfe, 0x03, 0xdc,
  4615. 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x23,
  4616. 0xfe, 0x00, 0xcc, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x75, 0x03, 0x09, 0x04,
  4617. 0x4c, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
  4618. 0xfe, 0x1e, 0x80, 0xe1, 0xfe, 0x1d, 0x80, 0xa4, 0xfe, 0x0c, 0x90, 0xfe,
  4619. 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xa3, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
  4620. 0x0b, 0xfe, 0x3c, 0x50, 0xa0, 0x01, 0xfe, 0x82, 0x16, 0x2f, 0x07, 0x2d,
  4621. 0xe0, 0x01, 0xfe, 0xbc, 0x15, 0x09, 0x04, 0x1d, 0x45, 0x01, 0xe7, 0x01,
  4622. 0xe8, 0x11, 0xfe, 0xe9, 0x00, 0x09, 0x04, 0x4c, 0xfe, 0x2c, 0x13, 0x01,
  4623. 0xfe, 0x14, 0x16, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
  4624. 0x0c, 0xfe, 0x64, 0x01, 0x18, 0xfe, 0x66, 0x01, 0x09, 0x04, 0x4f, 0xfe,
  4625. 0x12, 0x12, 0xfe, 0x03, 0x80, 0x74, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
  4626. 0x40, 0x12, 0x20, 0x63, 0x27, 0x11, 0xc8, 0x59, 0x1e, 0x20, 0xed, 0x76,
  4627. 0x20, 0x03, 0xfe, 0x08, 0x1c, 0x05, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
  4628. 0x05, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x05, 0xfe, 0xb0, 0x00, 0xfe,
  4629. 0x08, 0x58, 0x05, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
  4630. 0x24, 0x69, 0x12, 0xc9, 0x23, 0x0c, 0x50, 0x0c, 0x3f, 0x13, 0x40, 0x48,
  4631. 0x5f, 0x17, 0x1d, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x21, 0xfe, 0x08,
  4632. 0x0f, 0x3e, 0x10, 0x13, 0x42, 0x48, 0x17, 0x4c, 0xfe, 0x90, 0x4d, 0xfe,
  4633. 0x91, 0x54, 0x21, 0xfe, 0x1e, 0x0f, 0x24, 0x10, 0x12, 0x20, 0x78, 0x2c,
  4634. 0x46, 0x1e, 0x20, 0xed, 0x76, 0x20, 0x11, 0xc8, 0xf6, 0xfe, 0xd6, 0xf0,
  4635. 0xfe, 0x32, 0x0f, 0xea, 0x70, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
  4636. 0x18, 0x1c, 0x03, 0x3c, 0xfe, 0x0c, 0x14, 0xee, 0xfe, 0x07, 0xe6, 0x1d,
  4637. 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x03, 0x01, 0x86, 0x78, 0x2c, 0x46,
  4638. 0xfa, 0xef, 0xfe, 0x42, 0x13, 0x2f, 0x07, 0x2d, 0xfe, 0x34, 0x13, 0x0a,
  4639. 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x36, 0x12, 0xf0, 0xfe, 0x45, 0x48, 0x01,
  4640. 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13, 0x3d, 0x75, 0x07, 0x10,
  4641. 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x6f, 0xfe, 0x0e,
  4642. 0x10, 0x07, 0x7e, 0x45, 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x6c, 0x0f, 0x03,
  4643. 0xfe, 0x44, 0x58, 0x74, 0xfe, 0x01, 0xec, 0x97, 0xfe, 0x9e, 0x40, 0xfe,
  4644. 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1b, 0x76, 0x27, 0x01, 0xda, 0xfe,
  4645. 0xdd, 0x10, 0x2a, 0xbc, 0x7d, 0xbd, 0x7f, 0x30, 0x2e, 0xd5, 0x07, 0x1b,
  4646. 0xfe, 0x48, 0x12, 0x07, 0x0b, 0xfe, 0x56, 0x12, 0x07, 0x1a, 0xfe, 0x30,
  4647. 0x12, 0x07, 0xc2, 0x16, 0xfe, 0x3e, 0x11, 0x07, 0xfe, 0x23, 0x00, 0x16,
  4648. 0xfe, 0x4a, 0x11, 0x07, 0x06, 0x16, 0xfe, 0xa8, 0x11, 0x07, 0x19, 0xfe,
  4649. 0x12, 0x12, 0x07, 0x00, 0x16, 0x22, 0x14, 0xc2, 0x01, 0x33, 0x9f, 0x2b,
  4650. 0x01, 0x08, 0x8c, 0x43, 0x03, 0x2b, 0xfe, 0x62, 0x08, 0x0a, 0xca, 0x01,
  4651. 0xfe, 0x32, 0x0e, 0x11, 0x7e, 0x02, 0x29, 0x2b, 0x2f, 0x07, 0x9b, 0xfe,
  4652. 0xd9, 0x13, 0x79, 0x39, 0x68, 0x3a, 0x77, 0xfe, 0xfc, 0x10, 0x09, 0x04,
  4653. 0x6a, 0xfe, 0x72, 0x12, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x8e, 0xfe,
  4654. 0xc6, 0x10, 0x1e, 0x58, 0xfe, 0x26, 0x13, 0x05, 0x7b, 0x31, 0x7c, 0x77,
  4655. 0xfe, 0x82, 0x0c, 0x0c, 0x54, 0x18, 0x55, 0x23, 0x0c, 0x7b, 0x0c, 0x7c,
  4656. 0x01, 0xa8, 0x24, 0x69, 0x73, 0x12, 0x58, 0x01, 0xa5, 0xc0, 0x38, 0xc1,
  4657. 0x4e, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x38, 0xfe,
  4658. 0x05, 0xfa, 0x4e, 0xfe, 0x91, 0x10, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x40,
  4659. 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x56, 0x18, 0x57, 0x83, 0xc0, 0x38, 0xc1,
  4660. 0x4e, 0xf4, 0xf5, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x00, 0x56, 0xfe, 0xa1,
  4661. 0x56, 0x0c, 0x52, 0x18, 0x53, 0x09, 0x04, 0x6a, 0xfe, 0x1e, 0x12, 0x1e,
  4662. 0x58, 0xfe, 0x1f, 0x40, 0x05, 0x54, 0x31, 0x55, 0xfe, 0x2c, 0x50, 0xfe,
  4663. 0xae, 0x50, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x44, 0x50, 0xfe, 0xc6, 0x50,
  4664. 0x05, 0x52, 0x31, 0x53, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x05, 0x39,
  4665. 0x31, 0x3a, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x5c, 0x24, 0x06,
  4666. 0x12, 0xcd, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x1f, 0x44, 0x30, 0x2e, 0xd5,
  4667. 0x07, 0x06, 0x21, 0x44, 0x2f, 0x07, 0x9b, 0x21, 0x5b, 0x01, 0x6e, 0x1c,
  4668. 0x3d, 0x16, 0x44, 0x09, 0x04, 0x0b, 0xe2, 0x79, 0x39, 0x68, 0x3a, 0xfe,
  4669. 0x0a, 0x55, 0x34, 0xfe, 0x8b, 0x55, 0xbe, 0x39, 0xbf, 0x3a, 0xfe, 0x0c,
  4670. 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x5b, 0xfe, 0x19, 0x81, 0xaf, 0xfe, 0x19,
  4671. 0x41, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e,
  4672. 0xd8, 0x4b, 0x1a, 0xfe, 0xa6, 0x12, 0x4b, 0x0b, 0x3b, 0x02, 0x44, 0x01,
  4673. 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e, 0xd6, 0x07, 0x1a, 0x21, 0x44,
  4674. 0x01, 0x08, 0x1f, 0xa2, 0x30, 0x2e, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49,
  4675. 0x60, 0x05, 0xfe, 0x9c, 0x00, 0x28, 0x84, 0x49, 0x04, 0x19, 0x34, 0x9f,
  4676. 0xfe, 0xbb, 0x45, 0x4b, 0x00, 0x45, 0x3e, 0x06, 0x78, 0x3d, 0xfe, 0xda,
  4677. 0x14, 0x01, 0x6e, 0x87, 0xfe, 0x4b, 0x45, 0xe2, 0x2f, 0x07, 0x9a, 0xe1,
  4678. 0x05, 0xc6, 0x28, 0x84, 0x05, 0x3f, 0x28, 0x34, 0x5e, 0x02, 0x5b, 0xfe,
  4679. 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17, 0x05, 0x50, 0xb4, 0x0c,
  4680. 0x50, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe, 0xaa, 0x14, 0x02,
  4681. 0x5c, 0x01, 0x08, 0x25, 0x32, 0x1f, 0x44, 0x30, 0x2e, 0xd6, 0x07, 0x06,
  4682. 0x21, 0x44, 0x01, 0xfe, 0x8e, 0x13, 0xfe, 0x42, 0x58, 0xfe, 0x82, 0x14,
  4683. 0xfe, 0xa4, 0x14, 0x87, 0xfe, 0x4a, 0xf4, 0x0b, 0x16, 0x44, 0xfe, 0x4a,
  4684. 0xf4, 0x06, 0xfe, 0x0c, 0x12, 0x2f, 0x07, 0x9a, 0x85, 0x02, 0x5b, 0x05,
  4685. 0x3f, 0xb4, 0x0c, 0x3f, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe,
  4686. 0xd8, 0x14, 0x02, 0x5c, 0x13, 0x06, 0x65, 0xfe, 0xca, 0x12, 0x26, 0xfe,
  4687. 0xe0, 0x12, 0x72, 0xf1, 0x01, 0x08, 0x23, 0x72, 0x03, 0x8f, 0xfe, 0xdc,
  4688. 0x12, 0x25, 0xfe, 0xdc, 0x12, 0x1f, 0xfe, 0xca, 0x12, 0x5e, 0x2b, 0x01,
  4689. 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
  4690. 0x1c, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13,
  4691. 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d, 0xfe, 0x30, 0x56,
  4692. 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
  4693. 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0xfe, 0x0b, 0x58,
  4694. 0x03, 0x0a, 0x50, 0x01, 0x82, 0x0a, 0x3f, 0x01, 0x82, 0x03, 0xfc, 0x1c,
  4695. 0x10, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x19, 0x48, 0xfe, 0x00,
  4696. 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c, 0x63, 0x27,
  4697. 0x0c, 0x52, 0x18, 0x53, 0xbe, 0x56, 0xbf, 0x57, 0x03, 0xfe, 0x62, 0x08,
  4698. 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x74, 0x03, 0x01,
  4699. 0xfe, 0x14, 0x18, 0xfe, 0x42, 0x48, 0x5f, 0x60, 0x89, 0x01, 0x08, 0x1f,
  4700. 0xfe, 0xa2, 0x14, 0x30, 0x2e, 0xd8, 0x01, 0x08, 0x1f, 0xfe, 0xa2, 0x14,
  4701. 0x30, 0x2e, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x05, 0xc6, 0x28, 0xfe,
  4702. 0xcc, 0x12, 0x49, 0x04, 0x1b, 0xfe, 0xc4, 0x13, 0x23, 0x62, 0x1b, 0xe2,
  4703. 0x4b, 0xc3, 0x64, 0xfe, 0xe8, 0x13, 0x3b, 0x13, 0x06, 0x17, 0xc3, 0x78,
  4704. 0xdb, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xa1, 0xff, 0x02, 0x83,
  4705. 0x55, 0x62, 0x1a, 0xa4, 0xbb, 0xfe, 0x30, 0x00, 0x8e, 0xe4, 0x17, 0x2c,
  4706. 0x13, 0x06, 0xfe, 0x56, 0x10, 0x62, 0x0b, 0xe1, 0xbb, 0xfe, 0x64, 0x00,
  4707. 0x8e, 0xe4, 0x0a, 0xfe, 0x64, 0x00, 0x17, 0x93, 0x13, 0x06, 0xfe, 0x28,
  4708. 0x10, 0x62, 0x06, 0xfe, 0x60, 0x13, 0xbb, 0xfe, 0xc8, 0x00, 0x8e, 0xe4,
  4709. 0x0a, 0xfe, 0xc8, 0x00, 0x17, 0x4d, 0x13, 0x06, 0x83, 0xbb, 0xfe, 0x90,
  4710. 0x01, 0xba, 0xfe, 0x4e, 0x14, 0x89, 0xfe, 0x12, 0x10, 0xfe, 0x43, 0xf4,
  4711. 0x94, 0xfe, 0x56, 0xf0, 0xfe, 0x60, 0x14, 0xfe, 0x04, 0xf4, 0x6c, 0xfe,
  4712. 0x43, 0xf4, 0x93, 0xfe, 0xf3, 0x10, 0xf9, 0x01, 0xfe, 0x22, 0x13, 0x1c,
  4713. 0x3d, 0xfe, 0x10, 0x13, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x69, 0xba,
  4714. 0xfe, 0x9c, 0x14, 0xb7, 0x69, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe,
  4715. 0x4d, 0xe4, 0x19, 0xba, 0xfe, 0x9c, 0x14, 0xb7, 0x19, 0x83, 0x60, 0x23,
  4716. 0xfe, 0x4d, 0xf4, 0x00, 0xdf, 0x89, 0x13, 0x06, 0xfe, 0xb4, 0x56, 0xfe,
  4717. 0xc3, 0x58, 0x03, 0x60, 0x13, 0x0b, 0x03, 0x15, 0x06, 0x01, 0x08, 0x26,
  4718. 0xe5, 0x15, 0x0b, 0x01, 0x08, 0x26, 0xe5, 0x15, 0x1a, 0x01, 0x08, 0x26,
  4719. 0xe5, 0x72, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x03, 0x15, 0x06, 0x01, 0x08,
  4720. 0x26, 0xa6, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xa6, 0x15, 0x06, 0x01, 0x08,
  4721. 0x26, 0xa6, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x26, 0xa6, 0x72, 0xfe, 0x89,
  4722. 0x4a, 0x01, 0x08, 0x03, 0x60, 0x03, 0x1e, 0xcc, 0x07, 0x06, 0xfe, 0x44,
  4723. 0x13, 0xad, 0x12, 0xcc, 0xfe, 0x49, 0xf4, 0x00, 0x3b, 0x72, 0x9f, 0x5e,
  4724. 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xf1, 0x01, 0x08, 0x2f, 0x07, 0xfe,
  4725. 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1f, 0xfe, 0x5a, 0x15, 0x23, 0x12, 0xcd,
  4726. 0x01, 0x43, 0x1e, 0xcd, 0x07, 0x06, 0x45, 0x09, 0x4a, 0x06, 0x35, 0x03,
  4727. 0x0a, 0x42, 0x01, 0x0e, 0xed, 0x88, 0x07, 0x10, 0xa4, 0x0a, 0x80, 0x01,
  4728. 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a, 0x80, 0x01, 0x0e, 0x88,
  4729. 0xfe, 0x80, 0xe7, 0x10, 0x07, 0x10, 0x84, 0xfe, 0x45, 0x58, 0x01, 0xe3,
  4730. 0x88, 0x03, 0x0a, 0x42, 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03,
  4731. 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x80, 0x80, 0xf2, 0xfe, 0x49, 0xe4, 0x10,
  4732. 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x0a, 0x51, 0x01, 0x82, 0x03, 0x17,
  4733. 0x10, 0x71, 0x66, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde,
  4734. 0xfe, 0x24, 0x1c, 0xfe, 0x1d, 0xf7, 0x1d, 0x90, 0xfe, 0xf6, 0x15, 0x01,
  4735. 0xfe, 0xfc, 0x16, 0xe0, 0x91, 0x1d, 0x66, 0xfe, 0x2c, 0x01, 0xfe, 0x2f,
  4736. 0x19, 0x03, 0xae, 0x21, 0xfe, 0xe6, 0x15, 0xfe, 0xda, 0x10, 0x17, 0x10,
  4737. 0x71, 0x05, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x19, 0xfe, 0x18, 0x58,
  4738. 0x05, 0xfe, 0x66, 0x01, 0xfe, 0x19, 0x58, 0x91, 0x19, 0xfe, 0x3c, 0x90,
  4739. 0xfe, 0x30, 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x66, 0xfe, 0x38, 0x00, 0xfe,
  4740. 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x19, 0x90, 0xfe, 0x40, 0x16, 0xfe, 0xb6,
  4741. 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x18, 0x16, 0xfe, 0x9c, 0x10, 0x17,
  4742. 0x10, 0x71, 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe,
  4743. 0x1d, 0xf7, 0x38, 0x90, 0xfe, 0x62, 0x16, 0xfe, 0x94, 0x14, 0xfe, 0x10,
  4744. 0x13, 0x91, 0x38, 0x66, 0x1b, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00,
  4745. 0x03, 0xae, 0x21, 0xfe, 0x56, 0x16, 0xfe, 0x6c, 0x10, 0x17, 0x10, 0x71,
  4746. 0xfe, 0x30, 0xbc, 0xfe, 0xb2, 0xbc, 0x91, 0xc5, 0x66, 0x1b, 0xfe, 0x0f,
  4747. 0x79, 0xfe, 0x1c, 0xf7, 0xc5, 0x90, 0xfe, 0x9a, 0x16, 0xfe, 0x5c, 0x14,
  4748. 0x34, 0x03, 0xae, 0x21, 0xfe, 0x86, 0x16, 0xfe, 0x42, 0x10, 0xfe, 0x02,
  4749. 0xf6, 0x10, 0x71, 0xfe, 0x18, 0xfe, 0x54, 0xfe, 0x19, 0xfe, 0x55, 0xfc,
  4750. 0xfe, 0x1d, 0xf7, 0x4f, 0x90, 0xfe, 0xc0, 0x16, 0xfe, 0x36, 0x14, 0xfe,
  4751. 0x1c, 0x13, 0x91, 0x4f, 0x47, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe,
  4752. 0x80, 0xe7, 0x10, 0xfe, 0x81, 0xe7, 0x10, 0x11, 0xfe, 0xdd, 0x00, 0x63,
  4753. 0x27, 0x03, 0x63, 0x27, 0xfe, 0x12, 0x45, 0x21, 0xfe, 0xb0, 0x16, 0x14,
  4754. 0x06, 0x37, 0x95, 0xa9, 0x02, 0x29, 0xfe, 0x39, 0xf0, 0xfe, 0x04, 0x17,
  4755. 0x23, 0x03, 0xfe, 0x7e, 0x18, 0x1c, 0x1a, 0x5d, 0x13, 0x0d, 0x03, 0x71,
  4756. 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x78, 0x2c,
  4757. 0x46, 0x2f, 0x07, 0x2d, 0xfe, 0x3c, 0x13, 0xfe, 0x82, 0x14, 0xfe, 0x42,
  4758. 0x13, 0x3c, 0x8a, 0x0a, 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x3e, 0x12, 0xf0,
  4759. 0xfe, 0x45, 0x48, 0x01, 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13,
  4760. 0x3d, 0x75, 0x07, 0x10, 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x01, 0x6f,
  4761. 0xfe, 0x16, 0x10, 0x07, 0x7e, 0x85, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12,
  4762. 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x24, 0x17, 0x17, 0x0b, 0x03, 0xfe, 0x9c,
  4763. 0xe7, 0x0b, 0x0f, 0xfe, 0x15, 0x00, 0x59, 0x76, 0x27, 0x01, 0xda, 0x17,
  4764. 0x06, 0x03, 0x3c, 0x8a, 0x09, 0x4a, 0x1d, 0x35, 0x11, 0x2d, 0x01, 0x6f,
  4765. 0x17, 0x06, 0x03, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x79, 0xc7, 0x68,
  4766. 0xc8, 0xfe, 0x48, 0x55, 0x34, 0xfe, 0xc9, 0x55, 0x03, 0x1e, 0x98, 0x73,
  4767. 0x12, 0x98, 0x03, 0x0a, 0x99, 0x01, 0x0e, 0xf0, 0x0a, 0x40, 0x01, 0x0e,
  4768. 0xfe, 0x49, 0x44, 0x16, 0xfe, 0xf0, 0x17, 0x73, 0x75, 0x03, 0x0a, 0x42,
  4769. 0x01, 0x0e, 0x07, 0x10, 0x45, 0x0a, 0x51, 0x01, 0x9e, 0x0a, 0x40, 0x01,
  4770. 0x0e, 0x73, 0x75, 0x03, 0xfe, 0x4e, 0xe4, 0x1a, 0x64, 0xfe, 0x24, 0x18,
  4771. 0x05, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0x5b, 0xfe, 0x4e, 0xe4, 0xc2,
  4772. 0x64, 0xfe, 0x36, 0x18, 0x05, 0xfe, 0x92, 0x00, 0xfe, 0x02, 0xe6, 0x1b,
  4773. 0xdc, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x64, 0xfe, 0x48, 0x18, 0x05,
  4774. 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x19, 0xfe, 0x08, 0x10, 0x05, 0xfe,
  4775. 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x2c, 0xfe, 0x4e, 0x45, 0xfe, 0x0c, 0x12,
  4776. 0xaf, 0xff, 0x04, 0x68, 0x54, 0xde, 0x1c, 0x69, 0x03, 0x07, 0x7a, 0xfe,
  4777. 0x5a, 0xf0, 0xfe, 0x74, 0x18, 0x24, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10,
  4778. 0x07, 0x1b, 0xfe, 0x5a, 0xf0, 0xfe, 0x82, 0x18, 0x24, 0xc3, 0xfe, 0x26,
  4779. 0x10, 0x07, 0x1a, 0x5d, 0x24, 0x2c, 0xdc, 0x07, 0x0b, 0x5d, 0x24, 0x93,
  4780. 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x5d, 0x24, 0x4d, 0x9f, 0xad, 0x03, 0x14,
  4781. 0xfe, 0x09, 0x00, 0x01, 0x33, 0xfe, 0x04, 0xfe, 0x7d, 0x05, 0x7f, 0xf9,
  4782. 0x03, 0x25, 0xfe, 0xca, 0x18, 0xfe, 0x14, 0xf0, 0x08, 0x65, 0xfe, 0xc6,
  4783. 0x18, 0x03, 0xff, 0x1a, 0x00, 0x00,
  4784. };
  4785. static unsigned short _adv_asc3550_size = sizeof(_adv_asc3550_buf); /* 0x13AD */
  4786. static ADV_DCNT _adv_asc3550_chksum = 0x04D52DDDUL; /* Expanded little-endian checksum. */
  4787. /* Microcode buffer is kept after initialization for error recovery. */
  4788. static unsigned char _adv_asc38C0800_buf[] = {
  4789. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0xfc, 0x00, 0x16, 0x18, 0xe4,
  4790. 0x01, 0x00, 0x48, 0xe4, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0xce, 0x19,
  4791. 0x00, 0xfa, 0xff, 0xff, 0x1c, 0x0f, 0x00, 0xf6, 0x9e, 0xe7, 0xff, 0x00,
  4792. 0x82, 0xe7, 0x00, 0xea, 0x01, 0xfa, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0,
  4793. 0x01, 0xf6, 0x03, 0x00, 0x04, 0x00, 0x10, 0x00, 0x1e, 0xf0, 0x85, 0xf0,
  4794. 0x18, 0xf4, 0x08, 0x00, 0xbc, 0x00, 0x38, 0x54, 0x00, 0xec, 0xd5, 0xf0,
  4795. 0x82, 0x0d, 0x00, 0xe6, 0x86, 0xf0, 0xb1, 0xf0, 0x98, 0x57, 0x01, 0xfc,
  4796. 0xb4, 0x00, 0xd4, 0x01, 0x0c, 0x1c, 0x3e, 0x1c, 0x3c, 0x00, 0xbb, 0x00,
  4797. 0x00, 0x10, 0xba, 0x19, 0x02, 0x80, 0x32, 0xf0, 0x7c, 0x0d, 0x02, 0x13,
  4798. 0xba, 0x13, 0x18, 0x40, 0x00, 0x57, 0x01, 0xea, 0x02, 0xfc, 0x03, 0xfc,
  4799. 0x3e, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x74, 0x01, 0x76, 0x01, 0xb9, 0x54,
  4800. 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
  4801. 0x3e, 0x01, 0x7a, 0x01, 0xca, 0x08, 0xce, 0x10, 0x16, 0x11, 0x04, 0x12,
  4802. 0x08, 0x12, 0x02, 0x4a, 0xbb, 0x55, 0x3c, 0x56, 0x03, 0x58, 0x1b, 0x80,
  4803. 0x30, 0xe4, 0x4b, 0xe4, 0x5d, 0xf0, 0x02, 0xfa, 0x20, 0x00, 0x32, 0x00,
  4804. 0x40, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
  4805. 0x70, 0x01, 0x72, 0x01, 0x78, 0x01, 0x7c, 0x01, 0x62, 0x0a, 0x86, 0x0d,
  4806. 0x06, 0x13, 0x4c, 0x1c, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0,
  4807. 0x03, 0xf7, 0x0c, 0x00, 0x0f, 0x00, 0x47, 0x00, 0xbe, 0x00, 0x00, 0x01,
  4808. 0x20, 0x11, 0x5c, 0x16, 0x32, 0x1c, 0x38, 0x1c, 0x4e, 0x1c, 0x10, 0x44,
  4809. 0x00, 0x4c, 0x04, 0xea, 0x5c, 0xf0, 0xa7, 0xf0, 0x04, 0xf6, 0x03, 0xfa,
  4810. 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0xcc, 0x00, 0x20, 0x01,
  4811. 0x4e, 0x01, 0x4a, 0x0b, 0x42, 0x0c, 0x12, 0x0f, 0x0c, 0x10, 0x22, 0x11,
  4812. 0x0a, 0x12, 0x04, 0x13, 0x30, 0x1c, 0x02, 0x48, 0x00, 0x4e, 0x42, 0x54,
  4813. 0x44, 0x55, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0,
  4814. 0x59, 0xf0, 0xb8, 0xf0, 0x4b, 0xf4, 0x06, 0xf7, 0x0e, 0xf7, 0x04, 0xfc,
  4815. 0x05, 0xfc, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00, 0xa4, 0x00,
  4816. 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00, 0xe2, 0x03,
  4817. 0x08, 0x0f, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10, 0x0a, 0x13, 0x0c, 0x13,
  4818. 0x12, 0x13, 0x24, 0x14, 0x34, 0x14, 0x04, 0x16, 0x08, 0x16, 0xa4, 0x17,
  4819. 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44,
  4820. 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x3a, 0x55, 0x83, 0x55,
  4821. 0xe5, 0x55, 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0,
  4822. 0x0c, 0xf0, 0x04, 0xf8, 0x05, 0xf8, 0x07, 0x00, 0x0a, 0x00, 0x1c, 0x00,
  4823. 0x1e, 0x00, 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00,
  4824. 0x22, 0x01, 0x26, 0x01, 0x79, 0x01, 0x7e, 0x01, 0xc4, 0x01, 0xc6, 0x01,
  4825. 0x80, 0x02, 0x5e, 0x03, 0xee, 0x04, 0x9a, 0x06, 0xf8, 0x07, 0x62, 0x08,
  4826. 0x68, 0x08, 0x69, 0x08, 0xd6, 0x08, 0xe9, 0x09, 0xfa, 0x0b, 0x2e, 0x0f,
  4827. 0x12, 0x10, 0x1a, 0x10, 0xed, 0x10, 0xf1, 0x10, 0x2a, 0x11, 0x06, 0x12,
  4828. 0x0c, 0x12, 0x3e, 0x12, 0x10, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x46, 0x14,
  4829. 0x76, 0x14, 0x82, 0x14, 0x36, 0x15, 0xca, 0x15, 0x6b, 0x18, 0xbe, 0x18,
  4830. 0xca, 0x18, 0xe6, 0x19, 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40,
  4831. 0x0e, 0x47, 0xfe, 0x9c, 0xf0, 0x2b, 0x02, 0xfe, 0xac, 0x0d, 0xff, 0x10,
  4832. 0x00, 0x00, 0xd7, 0xfe, 0xe8, 0x19, 0x00, 0xd6, 0xfe, 0x84, 0x01, 0xff,
  4833. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  4834. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x5b, 0xff, 0x04, 0x00,
  4835. 0x00, 0x11, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  4836. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x11,
  4837. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  4838. 0xfe, 0x04, 0xf7, 0xd6, 0x2c, 0x99, 0x0a, 0x01, 0xfe, 0xc2, 0x0f, 0xfe,
  4839. 0x04, 0xf7, 0xd6, 0x99, 0x0a, 0x42, 0x2c, 0xfe, 0x3d, 0xf0, 0xfe, 0x06,
  4840. 0x02, 0xfe, 0x20, 0xf0, 0xa7, 0xfe, 0x91, 0xf0, 0xfe, 0xf4, 0x01, 0xfe,
  4841. 0x90, 0xf0, 0xfe, 0xf4, 0x01, 0xfe, 0x8f, 0xf0, 0xa7, 0x03, 0x5d, 0x4d,
  4842. 0x02, 0xfe, 0xc8, 0x0d, 0x01, 0xfe, 0x38, 0x0e, 0xfe, 0xdd, 0x12, 0xfe,
  4843. 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
  4844. 0x41, 0x14, 0xfe, 0xa6, 0x00, 0xc2, 0xfe, 0x48, 0xf0, 0xfe, 0x8a, 0x02,
  4845. 0xfe, 0x49, 0xf0, 0xfe, 0xa4, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc2, 0x02,
  4846. 0xfe, 0x46, 0xf0, 0xfe, 0x54, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x5a, 0x02,
  4847. 0xfe, 0x43, 0xf0, 0xfe, 0x48, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x4c, 0x02,
  4848. 0xfe, 0x45, 0xf0, 0xfe, 0x50, 0x02, 0x18, 0x0a, 0xaa, 0x18, 0x06, 0x14,
  4849. 0xa1, 0x02, 0x2b, 0xfe, 0x00, 0x1c, 0xe7, 0xfe, 0x02, 0x1c, 0xe6, 0xfe,
  4850. 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x18, 0x18, 0xfe, 0xe7, 0x10,
  4851. 0xfe, 0x06, 0xfc, 0xce, 0x09, 0x70, 0x01, 0xa8, 0x02, 0x2b, 0x15, 0x59,
  4852. 0x39, 0xa2, 0x01, 0xfe, 0x58, 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xbd,
  4853. 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
  4854. 0x58, 0x1c, 0x18, 0x06, 0x14, 0xa1, 0x2c, 0x1c, 0x2b, 0xfe, 0x3d, 0xf0,
  4855. 0xfe, 0x06, 0x02, 0x23, 0xfe, 0x98, 0x02, 0xfe, 0x5a, 0x1c, 0xf8, 0xfe,
  4856. 0x14, 0x1c, 0x15, 0xfe, 0x30, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10,
  4857. 0x18, 0x06, 0x14, 0xa1, 0x02, 0xd7, 0x22, 0x20, 0x07, 0x11, 0x35, 0xfe,
  4858. 0x69, 0x10, 0x18, 0x06, 0x14, 0xa1, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0x43,
  4859. 0x13, 0x20, 0xfe, 0x05, 0xf6, 0xce, 0x01, 0xfe, 0x4a, 0x17, 0x08, 0x54,
  4860. 0x58, 0x37, 0x12, 0x2f, 0x42, 0x92, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b,
  4861. 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66, 0x01, 0x73, 0xfe, 0x18, 0x10,
  4862. 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x6b, 0xfe,
  4863. 0x10, 0x03, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b, 0x2c, 0x4f, 0xfe, 0x02,
  4864. 0xe8, 0x2a, 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe,
  4865. 0x27, 0xf0, 0xfe, 0xe0, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xa7,
  4866. 0xfe, 0x40, 0x1c, 0x1c, 0xd9, 0xfe, 0x26, 0xf0, 0xfe, 0x5a, 0x03, 0xfe,
  4867. 0xa0, 0xf0, 0xfe, 0x48, 0x03, 0xfe, 0x11, 0xf0, 0xa7, 0xfe, 0xef, 0x10,
  4868. 0xfe, 0x9f, 0xf0, 0xfe, 0x68, 0x03, 0xf9, 0x10, 0xfe, 0x11, 0x00, 0x02,
  4869. 0x65, 0x2c, 0xfe, 0x48, 0x1c, 0xf9, 0x08, 0x05, 0x1b, 0xfe, 0x18, 0x13,
  4870. 0x21, 0x22, 0xa3, 0xb7, 0x13, 0xa3, 0x09, 0x46, 0x01, 0x0e, 0xb7, 0x78,
  4871. 0x01, 0xfe, 0xb4, 0x16, 0x12, 0xd1, 0x1c, 0xd9, 0xfe, 0x01, 0xf0, 0xd9,
  4872. 0xfe, 0x82, 0xf0, 0xfe, 0x96, 0x03, 0xfa, 0x12, 0xfe, 0xe4, 0x00, 0x27,
  4873. 0xfe, 0xa8, 0x03, 0x1c, 0x34, 0x1d, 0xfe, 0xb8, 0x03, 0x01, 0x4b, 0xfe,
  4874. 0x06, 0xf0, 0xfe, 0xc8, 0x03, 0x95, 0x86, 0xfe, 0x0a, 0xf0, 0xfe, 0x8a,
  4875. 0x06, 0x02, 0x24, 0x03, 0x70, 0x28, 0x17, 0xfe, 0xfa, 0x04, 0x15, 0x6d,
  4876. 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02, 0xd8, 0xf9, 0x2c, 0x99, 0x19,
  4877. 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c,
  4878. 0x74, 0x01, 0xaf, 0x8c, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x17, 0xda,
  4879. 0x09, 0xd1, 0x01, 0x0e, 0x8d, 0x51, 0x64, 0x79, 0x2a, 0x03, 0x70, 0x28,
  4880. 0xfe, 0x10, 0x12, 0x15, 0x6d, 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02,
  4881. 0xd8, 0xc7, 0x81, 0xc8, 0x83, 0x1c, 0x24, 0x27, 0xfe, 0x40, 0x04, 0x1d,
  4882. 0xfe, 0x3c, 0x04, 0x3b, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
  4883. 0x12, 0x2d, 0xff, 0x02, 0x00, 0x10, 0x01, 0x0b, 0x1d, 0xfe, 0xe4, 0x04,
  4884. 0x2d, 0x01, 0x0b, 0x1d, 0x24, 0x33, 0x31, 0xde, 0xfe, 0x4c, 0x44, 0xfe,
  4885. 0x4c, 0x12, 0x51, 0xfe, 0x44, 0x48, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b,
  4886. 0xda, 0x4f, 0x79, 0x2a, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x62,
  4887. 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x2a, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x52,
  4888. 0x13, 0xfe, 0x20, 0x10, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b, 0xda, 0xfe,
  4889. 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x40, 0x13, 0x08, 0x05, 0x1b, 0xfe,
  4890. 0x08, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x30, 0x13, 0x08, 0x05, 0x1b, 0xfe,
  4891. 0x1c, 0x12, 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00,
  4892. 0x01, 0x36, 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x2d, 0x12, 0xfe, 0xe6,
  4893. 0x00, 0xfe, 0x1c, 0x90, 0xfe, 0x40, 0x5c, 0x04, 0x15, 0x9d, 0x01, 0x36,
  4894. 0x02, 0x2b, 0xfe, 0x42, 0x5b, 0x99, 0x19, 0xfe, 0x46, 0x59, 0xfe, 0xbf,
  4895. 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4, 0x5b, 0x08,
  4896. 0x05, 0x0a, 0xfe, 0x84, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x19, 0xfe, 0x7c,
  4897. 0x12, 0x53, 0x05, 0x06, 0xfe, 0x6c, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x28,
  4898. 0x17, 0xfe, 0x90, 0x05, 0xfe, 0x31, 0xe4, 0x5a, 0x53, 0x05, 0x0a, 0xfe,
  4899. 0x56, 0x13, 0x03, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x4e, 0x12, 0x67, 0xff,
  4900. 0x02, 0x00, 0x10, 0x27, 0xfe, 0x48, 0x05, 0x1c, 0x34, 0xfe, 0x89, 0x48,
  4901. 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x56, 0x05, 0x26, 0xfe, 0xa8, 0x05,
  4902. 0x12, 0xfe, 0xe3, 0x00, 0x21, 0x53, 0xfe, 0x4a, 0xf0, 0xfe, 0x76, 0x05,
  4903. 0xfe, 0x49, 0xf0, 0xfe, 0x70, 0x05, 0x88, 0x25, 0xfe, 0x21, 0x00, 0xab,
  4904. 0x25, 0xfe, 0x22, 0x00, 0xaa, 0x25, 0x58, 0xfe, 0x09, 0x48, 0xff, 0x02,
  4905. 0x00, 0x10, 0x27, 0xfe, 0x86, 0x05, 0x26, 0xfe, 0xa8, 0x05, 0xfe, 0xe2,
  4906. 0x08, 0x53, 0x05, 0xcb, 0x4d, 0x01, 0xb0, 0x25, 0x06, 0x13, 0xd3, 0x39,
  4907. 0xfe, 0x27, 0x01, 0x08, 0x05, 0x1b, 0xfe, 0x22, 0x12, 0x41, 0x01, 0xb2,
  4908. 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00, 0x01, 0x36,
  4909. 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0xeb,
  4910. 0x03, 0x5c, 0x28, 0xfe, 0x36, 0x13, 0x41, 0x01, 0xb2, 0x26, 0xfe, 0x18,
  4911. 0x06, 0x09, 0x06, 0x53, 0x05, 0x1f, 0xfe, 0x02, 0x12, 0x50, 0x01, 0xfe,
  4912. 0x9e, 0x15, 0x1d, 0xfe, 0x0e, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12, 0xfe,
  4913. 0xe5, 0x00, 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x03, 0xcd, 0x28, 0xfe, 0x62,
  4914. 0x12, 0x03, 0x45, 0x28, 0xfe, 0x5a, 0x13, 0x01, 0xfe, 0x0c, 0x19, 0x01,
  4915. 0xfe, 0x76, 0x19, 0xfe, 0x43, 0x48, 0xc4, 0xcc, 0x0f, 0x71, 0xff, 0x02,
  4916. 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0x8b, 0xc4, 0x6e, 0x41, 0x01, 0xb2,
  4917. 0x26, 0xfe, 0x82, 0x06, 0x53, 0x05, 0x1a, 0xe9, 0x91, 0x09, 0x59, 0x01,
  4918. 0xfe, 0xcc, 0x15, 0x1d, 0xfe, 0x78, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12,
  4919. 0xfe, 0xe5, 0x00, 0x03, 0x45, 0xc1, 0x0c, 0x45, 0x18, 0x06, 0x01, 0xb2,
  4920. 0xfa, 0x76, 0x74, 0x01, 0xaf, 0x8c, 0x12, 0xfe, 0xe2, 0x00, 0x27, 0xdb,
  4921. 0x1c, 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0xb6, 0x06, 0x94, 0xfe, 0x6c, 0x07,
  4922. 0xfe, 0x06, 0xf0, 0xfe, 0x74, 0x07, 0x95, 0x86, 0x02, 0x24, 0x08, 0x05,
  4923. 0x0a, 0xfe, 0x2e, 0x12, 0x16, 0x19, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b,
  4924. 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0xfe, 0x99, 0xa4, 0x01,
  4925. 0x0b, 0x16, 0x00, 0x02, 0xfe, 0x42, 0x08, 0x68, 0x05, 0x1a, 0xfe, 0x38,
  4926. 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x30, 0x13, 0x16, 0xfe, 0x1b, 0x00, 0x01,
  4927. 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01,
  4928. 0x0b, 0x16, 0x06, 0x01, 0x0b, 0x16, 0x00, 0x02, 0xe2, 0x6c, 0x58, 0xbe,
  4929. 0x50, 0xfe, 0x9a, 0x81, 0x55, 0x1b, 0x7a, 0xfe, 0x42, 0x07, 0x09, 0x1b,
  4930. 0xfe, 0x09, 0x6f, 0xba, 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 0x69, 0x6d,
  4931. 0x8b, 0x6c, 0x7f, 0x27, 0xfe, 0x54, 0x07, 0x1c, 0x34, 0xfe, 0x0a, 0xf0,
  4932. 0xfe, 0x42, 0x07, 0x95, 0x86, 0x94, 0xfe, 0x6c, 0x07, 0x02, 0x24, 0x01,
  4933. 0x4b, 0x02, 0xdb, 0x16, 0x1f, 0x02, 0xdb, 0xfe, 0x9c, 0xf7, 0xdc, 0xfe,
  4934. 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x56, 0xfe, 0xda, 0x07, 0x0c, 0x60, 0x14,
  4935. 0x61, 0x08, 0x54, 0x5a, 0x37, 0x22, 0x20, 0x07, 0x11, 0xfe, 0x0e, 0x12,
  4936. 0x8d, 0xfe, 0x80, 0x80, 0x39, 0x20, 0x6a, 0x2a, 0xfe, 0x06, 0x10, 0xfe,
  4937. 0x83, 0xe7, 0xfe, 0x48, 0x00, 0xab, 0xfe, 0x03, 0x40, 0x08, 0x54, 0x5b,
  4938. 0x37, 0x01, 0xb3, 0xb8, 0xfe, 0x1f, 0x40, 0x13, 0x62, 0x01, 0xef, 0xfe,
  4939. 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x88,
  4940. 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90, 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x0c,
  4941. 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x0c, 0x3d,
  4942. 0x14, 0x3e, 0xfe, 0x4a, 0x10, 0x08, 0x05, 0x5a, 0xfe, 0x2a, 0x12, 0xfe,
  4943. 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x60, 0x14, 0x61, 0x08, 0x05, 0x5b,
  4944. 0x8b, 0x01, 0xb3, 0xfe, 0x1f, 0x80, 0x13, 0x62, 0xfe, 0x44, 0x90, 0xfe,
  4945. 0xc6, 0x90, 0x0c, 0x3f, 0x14, 0x40, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90,
  4946. 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90, 0x0c, 0x3d,
  4947. 0x14, 0x3e, 0x0c, 0x2e, 0x14, 0x3c, 0x21, 0x0c, 0x49, 0x0c, 0x63, 0x08,
  4948. 0x54, 0x1f, 0x37, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27, 0xdd, 0xfe, 0x9e,
  4949. 0xf0, 0xfe, 0x76, 0x08, 0xbc, 0x17, 0x34, 0x2c, 0x77, 0xe6, 0xc5, 0xfe,
  4950. 0x9a, 0x08, 0xc6, 0xfe, 0xb8, 0x08, 0x94, 0xfe, 0x8e, 0x08, 0xfe, 0x06,
  4951. 0xf0, 0xfe, 0x94, 0x08, 0x95, 0x86, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xc9,
  4952. 0x10, 0x16, 0x1f, 0xfe, 0xc9, 0x10, 0x68, 0x05, 0x06, 0xfe, 0x10, 0x12,
  4953. 0x68, 0x05, 0x0a, 0x4e, 0x08, 0x05, 0x0a, 0xfe, 0x90, 0x12, 0xfe, 0x2e,
  4954. 0x1c, 0x02, 0xfe, 0x18, 0x0b, 0x68, 0x05, 0x06, 0x4e, 0x68, 0x05, 0x0a,
  4955. 0xfe, 0x7a, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0xd2, 0x09,
  4956. 0xfe, 0xac, 0xf0, 0xfe, 0x00, 0x09, 0x02, 0xfe, 0xde, 0x09, 0xfe, 0xb7,
  4957. 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0x02, 0xf6, 0x1a, 0x50, 0xfe, 0x70, 0x18,
  4958. 0xfe, 0xf1, 0x18, 0xfe, 0x40, 0x55, 0xfe, 0xe1, 0x55, 0xfe, 0x10, 0x58,
  4959. 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x1c, 0x85, 0xfe,
  4960. 0x8c, 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0xac, 0xf0, 0xfe, 0xf0, 0x08, 0xb5,
  4961. 0xfe, 0xcb, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0x0c, 0x09, 0x02, 0xfe, 0x18,
  4962. 0x0b, 0xb6, 0xfe, 0xbf, 0x10, 0xfe, 0x2b, 0xf0, 0x85, 0xf4, 0x1e, 0xfe,
  4963. 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xc2, 0xfe, 0xd2, 0xf0, 0x85, 0xfe, 0x76,
  4964. 0x18, 0x1e, 0x19, 0x17, 0x85, 0x03, 0xd2, 0x1e, 0x06, 0x17, 0x85, 0xc5,
  4965. 0x4a, 0xc6, 0x4a, 0xb5, 0xb6, 0xfe, 0x89, 0x10, 0x74, 0x67, 0x2d, 0x15,
  4966. 0x9d, 0x01, 0x36, 0x10, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x65, 0x10,
  4967. 0x80, 0x02, 0x65, 0xfe, 0x98, 0x80, 0xfe, 0x19, 0xe4, 0x0a, 0xfe, 0x1a,
  4968. 0x12, 0x51, 0xfe, 0x19, 0x82, 0xfe, 0x6c, 0x18, 0xfe, 0x44, 0x54, 0xbe,
  4969. 0xfe, 0x19, 0x81, 0xfe, 0x74, 0x18, 0x8f, 0x90, 0x17, 0xfe, 0xce, 0x08,
  4970. 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xec, 0x03, 0x2e, 0x29, 0x3c, 0x0c, 0x3f,
  4971. 0x14, 0x40, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x6c, 0x18, 0xfe, 0xed, 0x18,
  4972. 0xfe, 0x44, 0x54, 0xfe, 0xe5, 0x54, 0x3a, 0x3f, 0x3b, 0x40, 0x03, 0x49,
  4973. 0x29, 0x63, 0x8f, 0xfe, 0xe3, 0x54, 0xfe, 0x74, 0x18, 0xfe, 0xf5, 0x18,
  4974. 0x8f, 0xfe, 0xe3, 0x54, 0x90, 0xc0, 0x56, 0xfe, 0xce, 0x08, 0x02, 0x4a,
  4975. 0xfe, 0x37, 0xf0, 0xfe, 0xda, 0x09, 0xfe, 0x8b, 0xf0, 0xfe, 0x60, 0x09,
  4976. 0x02, 0x4a, 0x08, 0x05, 0x0a, 0x23, 0xfe, 0xfa, 0x0a, 0x3a, 0x49, 0x3b,
  4977. 0x63, 0x56, 0xfe, 0x3e, 0x0a, 0x0f, 0xfe, 0xc0, 0x07, 0x41, 0x98, 0x00,
  4978. 0xad, 0xfe, 0x01, 0x59, 0xfe, 0x52, 0xf0, 0xfe, 0x0c, 0x0a, 0x8f, 0x7a,
  4979. 0xfe, 0x24, 0x0a, 0x3a, 0x49, 0x8f, 0xfe, 0xe3, 0x54, 0x57, 0x49, 0x7d,
  4980. 0x63, 0xfe, 0x14, 0x58, 0xfe, 0x95, 0x58, 0x02, 0x4a, 0x3a, 0x49, 0x3b,
  4981. 0x63, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0xbe, 0x57, 0x49, 0x57, 0x63,
  4982. 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xfe, 0x82, 0x12, 0x08, 0x05, 0x1f, 0xfe,
  4983. 0x66, 0x13, 0x22, 0x62, 0xb7, 0xfe, 0x03, 0xa1, 0xfe, 0x83, 0x80, 0xfe,
  4984. 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91, 0xfe, 0x86, 0x91, 0x6a,
  4985. 0x2a, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x56, 0xe0, 0x03, 0x60, 0x29,
  4986. 0x61, 0x0c, 0x7f, 0x14, 0x80, 0x57, 0x60, 0x7d, 0x61, 0x01, 0xb3, 0xb8,
  4987. 0x6a, 0x2a, 0x13, 0x62, 0x9b, 0x2e, 0x9c, 0x3c, 0x3a, 0x3f, 0x3b, 0x40,
  4988. 0x90, 0xc0, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0x01, 0xef,
  4989. 0xfe, 0x36, 0x10, 0x21, 0x0c, 0x7f, 0x0c, 0x80, 0x3a, 0x3f, 0x3b, 0x40,
  4990. 0xe4, 0x08, 0x05, 0x1f, 0x17, 0xe0, 0x3a, 0x3d, 0x3b, 0x3e, 0x08, 0x05,
  4991. 0xfe, 0xf7, 0x00, 0x37, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x10, 0x58, 0xfe,
  4992. 0x91, 0x58, 0x57, 0x49, 0x7d, 0x63, 0x02, 0xfe, 0xf4, 0x09, 0x08, 0x05,
  4993. 0x1f, 0x17, 0xe0, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37, 0xbe, 0xfe, 0x19,
  4994. 0x81, 0x50, 0xfe, 0x10, 0x90, 0xfe, 0x92, 0x90, 0xfe, 0xd3, 0x10, 0x32,
  4995. 0x07, 0xa6, 0x17, 0xfe, 0x08, 0x09, 0x12, 0xa6, 0x08, 0x05, 0x0a, 0xfe,
  4996. 0x14, 0x13, 0x03, 0x3d, 0x29, 0x3e, 0x56, 0xfe, 0x08, 0x09, 0xfe, 0x0c,
  4997. 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x4a, 0x21, 0x41, 0xfe, 0x19, 0x80, 0xe7,
  4998. 0x08, 0x05, 0x0a, 0xfe, 0x1a, 0x12, 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41,
  4999. 0xf4, 0xc2, 0xfe, 0xd1, 0xf0, 0xe2, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe,
  5000. 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19, 0x57, 0x3d, 0xfe, 0xed,
  5001. 0x19, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xf4, 0x1e, 0xfe,
  5002. 0x00, 0xff, 0x35, 0xfe, 0x74, 0x10, 0xc2, 0xfe, 0xd2, 0xf0, 0xfe, 0xa6,
  5003. 0x0b, 0xfe, 0x76, 0x18, 0x1e, 0x19, 0x8a, 0x03, 0xd2, 0x1e, 0x06, 0xfe,
  5004. 0x08, 0x13, 0x10, 0xfe, 0x16, 0x00, 0x02, 0x65, 0xfe, 0xd1, 0xf0, 0xfe,
  5005. 0xb8, 0x0b, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe, 0x17, 0x00, 0xfe, 0x42,
  5006. 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xbe, 0x0b, 0xfe, 0x3c, 0x10, 0xfe, 0xcd,
  5007. 0xf0, 0xfe, 0xca, 0x0b, 0x10, 0xfe, 0x22, 0x00, 0x02, 0x65, 0xfe, 0xcb,
  5008. 0xf0, 0xfe, 0xd6, 0x0b, 0x10, 0xfe, 0x24, 0x00, 0x02, 0x65, 0xfe, 0xd0,
  5009. 0xf0, 0xfe, 0xe0, 0x0b, 0x10, 0x9e, 0xe5, 0xfe, 0xcf, 0xf0, 0xfe, 0xea,
  5010. 0x0b, 0x10, 0x58, 0xfe, 0x10, 0x10, 0xfe, 0xcc, 0xf0, 0xe2, 0x68, 0x05,
  5011. 0x1f, 0x4d, 0x10, 0xfe, 0x12, 0x00, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27,
  5012. 0xfe, 0x00, 0x0c, 0xfe, 0x9e, 0xf0, 0xfe, 0x14, 0x0c, 0xbc, 0x17, 0x34,
  5013. 0x2c, 0x77, 0xe6, 0xc5, 0x24, 0xc6, 0x24, 0x2c, 0xfa, 0x27, 0xfe, 0x20,
  5014. 0x0c, 0x1c, 0x34, 0x94, 0xfe, 0x3c, 0x0c, 0x95, 0x86, 0xc5, 0xdc, 0xc6,
  5015. 0xdc, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xdb, 0x10, 0x12, 0xfe, 0xe8, 0x00,
  5016. 0xb5, 0xb6, 0x74, 0xc7, 0x81, 0xc8, 0x83, 0xfe, 0x89, 0xf0, 0x24, 0x33,
  5017. 0x31, 0xe1, 0xc7, 0x81, 0xc8, 0x83, 0x27, 0xfe, 0x66, 0x0c, 0x1d, 0x24,
  5018. 0x33, 0x31, 0xdf, 0xbc, 0x4e, 0x10, 0xfe, 0x42, 0x00, 0x02, 0x65, 0x7c,
  5019. 0x06, 0xfe, 0x81, 0x49, 0x17, 0xfe, 0x2c, 0x0d, 0x08, 0x05, 0x0a, 0xfe,
  5020. 0x44, 0x13, 0x10, 0x00, 0x55, 0x0a, 0xfe, 0x54, 0x12, 0x55, 0xfe, 0x28,
  5021. 0x00, 0x23, 0xfe, 0x9a, 0x0d, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66,
  5022. 0x44, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01, 0xf5, 0x01, 0xf6, 0x09,
  5023. 0xa4, 0x01, 0xfe, 0x26, 0x0f, 0x64, 0x12, 0x2f, 0x01, 0x73, 0x02, 0x2b,
  5024. 0x10, 0xfe, 0x44, 0x00, 0x55, 0x0a, 0xe9, 0x44, 0x0a, 0xfe, 0xb4, 0x10,
  5025. 0x01, 0xb0, 0x44, 0x0a, 0xfe, 0xaa, 0x10, 0x01, 0xb0, 0xfe, 0x19, 0x82,
  5026. 0xfe, 0x34, 0x46, 0xac, 0x44, 0x0a, 0x10, 0xfe, 0x43, 0x00, 0xfe, 0x96,
  5027. 0x10, 0x08, 0x54, 0x0a, 0x37, 0x01, 0xf5, 0x01, 0xf6, 0x64, 0x12, 0x2f,
  5028. 0x01, 0x73, 0x99, 0x0a, 0x64, 0x42, 0x92, 0x02, 0xfe, 0x2e, 0x03, 0x08,
  5029. 0x05, 0x0a, 0x8a, 0x44, 0x0a, 0x10, 0x00, 0xfe, 0x5c, 0x10, 0x68, 0x05,
  5030. 0x1a, 0xfe, 0x58, 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x50, 0x13, 0xfe, 0x1c,
  5031. 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x50, 0x0d, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d,
  5032. 0xf0, 0xfe, 0x56, 0x0d, 0x08, 0x54, 0x1a, 0x37, 0xfe, 0xa9, 0x10, 0x10,
  5033. 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0a, 0x50, 0xfe, 0x2e, 0x10, 0x10,
  5034. 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x10, 0x6f, 0xab, 0x10, 0xfe, 0x41,
  5035. 0x00, 0xaa, 0x10, 0xfe, 0x24, 0x00, 0x8c, 0xb5, 0xb6, 0x74, 0x03, 0x70,
  5036. 0x28, 0x23, 0xd8, 0x50, 0xfe, 0x04, 0xe6, 0x1a, 0xfe, 0x9d, 0x41, 0xfe,
  5037. 0x1c, 0x42, 0x64, 0x01, 0xe3, 0x02, 0x2b, 0xf8, 0x15, 0x0a, 0x39, 0xa0,
  5038. 0xb4, 0x15, 0xfe, 0x31, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10, 0x02,
  5039. 0xd7, 0x42, 0xfe, 0x06, 0xec, 0xd0, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45,
  5040. 0x35, 0x42, 0xfe, 0x06, 0xea, 0xd0, 0xfe, 0x47, 0x4b, 0x91, 0xfe, 0x75,
  5041. 0x57, 0x03, 0x5d, 0xfe, 0x98, 0x56, 0xfe, 0x38, 0x12, 0x09, 0x48, 0x01,
  5042. 0x0e, 0xfe, 0x44, 0x48, 0x4f, 0x08, 0x05, 0x1b, 0xfe, 0x1a, 0x13, 0x09,
  5043. 0x46, 0x01, 0x0e, 0x41, 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe,
  5044. 0x49, 0x54, 0x96, 0xfe, 0x1e, 0x0e, 0x02, 0xfe, 0x2e, 0x03, 0x09, 0x5d,
  5045. 0xfe, 0xee, 0x14, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe,
  5046. 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x2b, 0x22, 0x20, 0x07, 0x11, 0xfe,
  5047. 0x9e, 0x12, 0x21, 0x13, 0x59, 0x13, 0x9f, 0x13, 0xd5, 0x22, 0x2f, 0x41,
  5048. 0x39, 0x2f, 0xbc, 0xad, 0xfe, 0xbc, 0xf0, 0xfe, 0xe0, 0x0e, 0x0f, 0x06,
  5049. 0x13, 0x59, 0x01, 0xfe, 0xda, 0x16, 0x03, 0xfe, 0x38, 0x01, 0x29, 0xfe,
  5050. 0x3a, 0x01, 0x56, 0xfe, 0xe4, 0x0e, 0xfe, 0x02, 0xec, 0xd5, 0x69, 0x00,
  5051. 0x66, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01,
  5052. 0x01, 0xfe, 0x4a, 0x17, 0xfe, 0x08, 0x90, 0xfe, 0x48, 0xf4, 0x0d, 0xfe,
  5053. 0x18, 0x13, 0xba, 0xfe, 0x02, 0xea, 0xd5, 0x69, 0x7e, 0xfe, 0xc5, 0x13,
  5054. 0x15, 0x1a, 0x39, 0xa0, 0xb4, 0xfe, 0x2e, 0x10, 0x03, 0xfe, 0x38, 0x01,
  5055. 0x1e, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x03, 0xfe, 0x3a, 0x01,
  5056. 0x0c, 0xfe, 0x62, 0x01, 0x43, 0x13, 0x20, 0x25, 0x06, 0x13, 0x2f, 0x12,
  5057. 0x2f, 0x92, 0x0f, 0x06, 0x04, 0x21, 0x04, 0x22, 0x59, 0xfe, 0xf7, 0x12,
  5058. 0x22, 0x9f, 0xb7, 0x13, 0x9f, 0x07, 0x7e, 0xfe, 0x71, 0x13, 0xfe, 0x24,
  5059. 0x1c, 0x15, 0x19, 0x39, 0xa0, 0xb4, 0xfe, 0xd9, 0x10, 0xc3, 0xfe, 0x03,
  5060. 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xc3, 0xfe, 0x03, 0xdc,
  5061. 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x21,
  5062. 0xfe, 0x00, 0xcc, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x78, 0x04, 0x08, 0x05,
  5063. 0x58, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
  5064. 0xfe, 0x1e, 0x80, 0xed, 0xfe, 0x1d, 0x80, 0xae, 0xfe, 0x0c, 0x90, 0xfe,
  5065. 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xac, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
  5066. 0x0a, 0xfe, 0x3c, 0x50, 0xaa, 0x01, 0xfe, 0x7a, 0x17, 0x32, 0x07, 0x2f,
  5067. 0xad, 0x01, 0xfe, 0xb4, 0x16, 0x08, 0x05, 0x1b, 0x4e, 0x01, 0xf5, 0x01,
  5068. 0xf6, 0x12, 0xfe, 0xe9, 0x00, 0x08, 0x05, 0x58, 0xfe, 0x2c, 0x13, 0x01,
  5069. 0xfe, 0x0c, 0x17, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
  5070. 0x0c, 0xfe, 0x64, 0x01, 0x14, 0xfe, 0x66, 0x01, 0x08, 0x05, 0x5b, 0xfe,
  5071. 0x12, 0x12, 0xfe, 0x03, 0x80, 0x8d, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
  5072. 0x40, 0x13, 0x20, 0x6a, 0x2a, 0x12, 0xcf, 0x64, 0x22, 0x20, 0xfb, 0x79,
  5073. 0x20, 0x04, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
  5074. 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe,
  5075. 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
  5076. 0x25, 0x6e, 0x13, 0xd0, 0x21, 0x0c, 0x5c, 0x0c, 0x45, 0x0f, 0x46, 0x52,
  5077. 0x50, 0x18, 0x1b, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xfe, 0xfc,
  5078. 0x0f, 0x44, 0x11, 0x0f, 0x48, 0x52, 0x18, 0x58, 0xfe, 0x90, 0x4d, 0xfe,
  5079. 0x91, 0x54, 0x23, 0xe4, 0x25, 0x11, 0x13, 0x20, 0x7c, 0x6f, 0x4f, 0x22,
  5080. 0x20, 0xfb, 0x79, 0x20, 0x12, 0xcf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
  5081. 0xfe, 0x26, 0x10, 0xf8, 0x74, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
  5082. 0x18, 0x1c, 0x04, 0x42, 0xfe, 0x0c, 0x14, 0xfc, 0xfe, 0x07, 0xe6, 0x1b,
  5083. 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x04, 0x01, 0xb0, 0x7c, 0x6f, 0x4f,
  5084. 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42, 0x13, 0x32, 0x07, 0x2f,
  5085. 0xfe, 0x34, 0x13, 0x09, 0x48, 0x01, 0x0e, 0xbb, 0xfe, 0x36, 0x12, 0xfe,
  5086. 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe,
  5087. 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11, 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe,
  5088. 0x80, 0x5c, 0x01, 0x73, 0xfe, 0x0e, 0x10, 0x07, 0x82, 0x4e, 0xfe, 0x14,
  5089. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x60, 0x10, 0x04, 0xfe, 0x44, 0x58, 0x8d,
  5090. 0xfe, 0x01, 0xec, 0xa2, 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe,
  5091. 0x9c, 0xe7, 0x1a, 0x79, 0x2a, 0x01, 0xe3, 0xfe, 0xdd, 0x10, 0x2c, 0xc7,
  5092. 0x81, 0xc8, 0x83, 0x33, 0x31, 0xde, 0x07, 0x1a, 0xfe, 0x48, 0x12, 0x07,
  5093. 0x0a, 0xfe, 0x56, 0x12, 0x07, 0x19, 0xfe, 0x30, 0x12, 0x07, 0xc9, 0x17,
  5094. 0xfe, 0x32, 0x12, 0x07, 0xfe, 0x23, 0x00, 0x17, 0xeb, 0x07, 0x06, 0x17,
  5095. 0xfe, 0x9c, 0x12, 0x07, 0x1f, 0xfe, 0x12, 0x12, 0x07, 0x00, 0x17, 0x24,
  5096. 0x15, 0xc9, 0x01, 0x36, 0xa9, 0x2d, 0x01, 0x0b, 0x94, 0x4b, 0x04, 0x2d,
  5097. 0xdd, 0x09, 0xd1, 0x01, 0xfe, 0x26, 0x0f, 0x12, 0x82, 0x02, 0x2b, 0x2d,
  5098. 0x32, 0x07, 0xa6, 0xfe, 0xd9, 0x13, 0x3a, 0x3d, 0x3b, 0x3e, 0x56, 0xfe,
  5099. 0xf0, 0x11, 0x08, 0x05, 0x5a, 0xfe, 0x72, 0x12, 0x9b, 0x2e, 0x9c, 0x3c,
  5100. 0x90, 0xc0, 0x96, 0xfe, 0xba, 0x11, 0x22, 0x62, 0xfe, 0x26, 0x13, 0x03,
  5101. 0x7f, 0x29, 0x80, 0x56, 0xfe, 0x76, 0x0d, 0x0c, 0x60, 0x14, 0x61, 0x21,
  5102. 0x0c, 0x7f, 0x0c, 0x80, 0x01, 0xb3, 0x25, 0x6e, 0x77, 0x13, 0x62, 0x01,
  5103. 0xef, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe,
  5104. 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0xfe, 0x91, 0x10, 0x03, 0x3f,
  5105. 0x29, 0x40, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x3f, 0x14, 0x40,
  5106. 0x88, 0x9b, 0x2e, 0x9c, 0x3c, 0x90, 0xc0, 0x03, 0x5e, 0x29, 0x5f, 0xfe,
  5107. 0x00, 0x56, 0xfe, 0xa1, 0x56, 0x0c, 0x5e, 0x14, 0x5f, 0x08, 0x05, 0x5a,
  5108. 0xfe, 0x1e, 0x12, 0x22, 0x62, 0xfe, 0x1f, 0x40, 0x03, 0x60, 0x29, 0x61,
  5109. 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x03, 0x3f, 0x29, 0x40, 0xfe, 0x44,
  5110. 0x50, 0xfe, 0xc6, 0x50, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x08, 0x50, 0xfe,
  5111. 0x8a, 0x50, 0x03, 0x3d, 0x29, 0x3e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50,
  5112. 0x02, 0x89, 0x25, 0x06, 0x13, 0xd4, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1d,
  5113. 0x4c, 0x33, 0x31, 0xde, 0x07, 0x06, 0x23, 0x4c, 0x32, 0x07, 0xa6, 0x23,
  5114. 0x72, 0x01, 0xaf, 0x1e, 0x43, 0x17, 0x4c, 0x08, 0x05, 0x0a, 0xee, 0x3a,
  5115. 0x3d, 0x3b, 0x3e, 0xfe, 0x0a, 0x55, 0x35, 0xfe, 0x8b, 0x55, 0x57, 0x3d,
  5116. 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x72, 0xfe, 0x19,
  5117. 0x81, 0xba, 0xfe, 0x19, 0x41, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1c, 0x34,
  5118. 0x1d, 0xe8, 0x33, 0x31, 0xe1, 0x55, 0x19, 0xfe, 0xa6, 0x12, 0x55, 0x0a,
  5119. 0x4d, 0x02, 0x4c, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0xe8, 0x33, 0x31, 0xdf,
  5120. 0x07, 0x19, 0x23, 0x4c, 0x01, 0x0b, 0x1d, 0xe8, 0x33, 0x31, 0xfe, 0xe8,
  5121. 0x09, 0xfe, 0xc2, 0x49, 0x51, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0x8a, 0x53,
  5122. 0x05, 0x1f, 0x35, 0xa9, 0xfe, 0xbb, 0x45, 0x55, 0x00, 0x4e, 0x44, 0x06,
  5123. 0x7c, 0x43, 0xfe, 0xda, 0x14, 0x01, 0xaf, 0x8c, 0xfe, 0x4b, 0x45, 0xee,
  5124. 0x32, 0x07, 0xa5, 0xed, 0x03, 0xcd, 0x28, 0x8a, 0x03, 0x45, 0x28, 0x35,
  5125. 0x67, 0x02, 0x72, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17,
  5126. 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01,
  5127. 0xfe, 0x9e, 0x15, 0x02, 0x89, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0x4c, 0x33,
  5128. 0x31, 0xdf, 0x07, 0x06, 0x23, 0x4c, 0x01, 0xf1, 0xfe, 0x42, 0x58, 0xf1,
  5129. 0xfe, 0xa4, 0x14, 0x8c, 0xfe, 0x4a, 0xf4, 0x0a, 0x17, 0x4c, 0xfe, 0x4a,
  5130. 0xf4, 0x06, 0xea, 0x32, 0x07, 0xa5, 0x8b, 0x02, 0x72, 0x03, 0x45, 0xc1,
  5131. 0x0c, 0x45, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01, 0xfe, 0xcc, 0x15,
  5132. 0x02, 0x89, 0x0f, 0x06, 0x27, 0xfe, 0xbe, 0x13, 0x26, 0xfe, 0xd4, 0x13,
  5133. 0x76, 0xfe, 0x89, 0x48, 0x01, 0x0b, 0x21, 0x76, 0x04, 0x7b, 0xfe, 0xd0,
  5134. 0x13, 0x1c, 0xfe, 0xd0, 0x13, 0x1d, 0xfe, 0xbe, 0x13, 0x67, 0x2d, 0x01,
  5135. 0x0b, 0xfe, 0xd5, 0x10, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
  5136. 0x1e, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x04, 0x0f,
  5137. 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0xfe, 0x30, 0x56,
  5138. 0xfe, 0x00, 0x5c, 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
  5139. 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0xfe, 0x0b, 0x58,
  5140. 0x04, 0x09, 0x5c, 0x01, 0x87, 0x09, 0x45, 0x01, 0x87, 0x04, 0xfe, 0x03,
  5141. 0xa1, 0x1e, 0x11, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x1f, 0x52,
  5142. 0xfe, 0x00, 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c,
  5143. 0x6a, 0x2a, 0x0c, 0x5e, 0x14, 0x5f, 0x57, 0x3f, 0x7d, 0x40, 0x04, 0xdd,
  5144. 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x8d, 0x04, 0x01,
  5145. 0xfe, 0x0c, 0x19, 0xfe, 0x42, 0x48, 0x50, 0x51, 0x91, 0x01, 0x0b, 0x1d,
  5146. 0xfe, 0x96, 0x15, 0x33, 0x31, 0xe1, 0x01, 0x0b, 0x1d, 0xfe, 0x96, 0x15,
  5147. 0x33, 0x31, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0xcd, 0x28, 0xfe,
  5148. 0xcc, 0x12, 0x53, 0x05, 0x1a, 0xfe, 0xc4, 0x13, 0x21, 0x69, 0x1a, 0xee,
  5149. 0x55, 0xca, 0x6b, 0xfe, 0xdc, 0x14, 0x4d, 0x0f, 0x06, 0x18, 0xca, 0x7c,
  5150. 0x30, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xab, 0xff, 0x02, 0x83,
  5151. 0x55, 0x69, 0x19, 0xae, 0x98, 0xfe, 0x30, 0x00, 0x96, 0xf2, 0x18, 0x6d,
  5152. 0x0f, 0x06, 0xfe, 0x56, 0x10, 0x69, 0x0a, 0xed, 0x98, 0xfe, 0x64, 0x00,
  5153. 0x96, 0xf2, 0x09, 0xfe, 0x64, 0x00, 0x18, 0x9e, 0x0f, 0x06, 0xfe, 0x28,
  5154. 0x10, 0x69, 0x06, 0xfe, 0x60, 0x13, 0x98, 0xfe, 0xc8, 0x00, 0x96, 0xf2,
  5155. 0x09, 0xfe, 0xc8, 0x00, 0x18, 0x59, 0x0f, 0x06, 0x88, 0x98, 0xfe, 0x90,
  5156. 0x01, 0x7a, 0xfe, 0x42, 0x15, 0x91, 0xe4, 0xfe, 0x43, 0xf4, 0x9f, 0xfe,
  5157. 0x56, 0xf0, 0xfe, 0x54, 0x15, 0xfe, 0x04, 0xf4, 0x71, 0xfe, 0x43, 0xf4,
  5158. 0x9e, 0xfe, 0xf3, 0x10, 0xfe, 0x40, 0x5c, 0x01, 0xfe, 0x16, 0x14, 0x1e,
  5159. 0x43, 0xec, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x6e, 0x7a, 0xfe, 0x90,
  5160. 0x15, 0xc4, 0x6e, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4,
  5161. 0xcc, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0xcc, 0x88, 0x51, 0x21, 0xfe, 0x4d,
  5162. 0xf4, 0x00, 0xe9, 0x91, 0x0f, 0x06, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58,
  5163. 0x04, 0x51, 0x0f, 0x0a, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xf3, 0x16,
  5164. 0x0a, 0x01, 0x0b, 0x26, 0xf3, 0x16, 0x19, 0x01, 0x0b, 0x26, 0xf3, 0x76,
  5165. 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
  5166. 0x16, 0x19, 0x01, 0x0b, 0x26, 0xb1, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
  5167. 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x26, 0xb1, 0x76, 0xfe, 0x89, 0x4a, 0x01,
  5168. 0x0b, 0x04, 0x51, 0x04, 0x22, 0xd3, 0x07, 0x06, 0xfe, 0x48, 0x13, 0xb8,
  5169. 0x13, 0xd3, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x76, 0xa9, 0x67, 0xfe, 0x01,
  5170. 0xec, 0xfe, 0x27, 0x01, 0xfe, 0x89, 0x48, 0xff, 0x02, 0x00, 0x10, 0x27,
  5171. 0xfe, 0x2e, 0x16, 0x32, 0x07, 0xfe, 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1d,
  5172. 0xfe, 0x52, 0x16, 0x21, 0x13, 0xd4, 0x01, 0x4b, 0x22, 0xd4, 0x07, 0x06,
  5173. 0x4e, 0x08, 0x54, 0x06, 0x37, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfb, 0x8e,
  5174. 0x07, 0x11, 0xae, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0x09, 0x5d, 0x01, 0xa8,
  5175. 0x04, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0xfe, 0x80, 0xe7, 0x11, 0x07, 0x11,
  5176. 0x8a, 0xfe, 0x45, 0x58, 0x01, 0xf0, 0x8e, 0x04, 0x09, 0x48, 0x01, 0x0e,
  5177. 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfe, 0x80,
  5178. 0x80, 0xfe, 0x80, 0x4c, 0xfe, 0x49, 0xe4, 0x11, 0xae, 0x09, 0x84, 0x01,
  5179. 0x0e, 0xfe, 0x80, 0x4c, 0x09, 0x5d, 0x01, 0x87, 0x04, 0x18, 0x11, 0x75,
  5180. 0x6c, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24,
  5181. 0x1c, 0xfe, 0x1d, 0xf7, 0x1b, 0x97, 0xfe, 0xee, 0x16, 0x01, 0xfe, 0xf4,
  5182. 0x17, 0xad, 0x9a, 0x1b, 0x6c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x04,
  5183. 0xb9, 0x23, 0xfe, 0xde, 0x16, 0xfe, 0xda, 0x10, 0x18, 0x11, 0x75, 0x03,
  5184. 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x1f, 0xfe, 0x18, 0x58, 0x03, 0xfe,
  5185. 0x66, 0x01, 0xfe, 0x19, 0x58, 0x9a, 0x1f, 0xfe, 0x3c, 0x90, 0xfe, 0x30,
  5186. 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x6c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79,
  5187. 0xfe, 0x1c, 0xf7, 0x1f, 0x97, 0xfe, 0x38, 0x17, 0xfe, 0xb6, 0x14, 0x35,
  5188. 0x04, 0xb9, 0x23, 0xfe, 0x10, 0x17, 0xfe, 0x9c, 0x10, 0x18, 0x11, 0x75,
  5189. 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7,
  5190. 0x2e, 0x97, 0xfe, 0x5a, 0x17, 0xfe, 0x94, 0x14, 0xec, 0x9a, 0x2e, 0x6c,
  5191. 0x1a, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x04, 0xb9, 0x23, 0xfe,
  5192. 0x4e, 0x17, 0xfe, 0x6c, 0x10, 0x18, 0x11, 0x75, 0xfe, 0x30, 0xbc, 0xfe,
  5193. 0xb2, 0xbc, 0x9a, 0xcb, 0x6c, 0x1a, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7,
  5194. 0xcb, 0x97, 0xfe, 0x92, 0x17, 0xfe, 0x5c, 0x14, 0x35, 0x04, 0xb9, 0x23,
  5195. 0xfe, 0x7e, 0x17, 0xfe, 0x42, 0x10, 0xfe, 0x02, 0xf6, 0x11, 0x75, 0xfe,
  5196. 0x18, 0xfe, 0x60, 0xfe, 0x19, 0xfe, 0x61, 0xfe, 0x03, 0xa1, 0xfe, 0x1d,
  5197. 0xf7, 0x5b, 0x97, 0xfe, 0xb8, 0x17, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13,
  5198. 0x9a, 0x5b, 0x41, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7,
  5199. 0x11, 0xfe, 0x81, 0xe7, 0x11, 0x12, 0xfe, 0xdd, 0x00, 0x6a, 0x2a, 0x04,
  5200. 0x6a, 0x2a, 0xfe, 0x12, 0x45, 0x23, 0xfe, 0xa8, 0x17, 0x15, 0x06, 0x39,
  5201. 0xa0, 0xb4, 0x02, 0x2b, 0xfe, 0x39, 0xf0, 0xfe, 0xfc, 0x17, 0x21, 0x04,
  5202. 0xfe, 0x7e, 0x18, 0x1e, 0x19, 0x66, 0x0f, 0x0d, 0x04, 0x75, 0x03, 0xd2,
  5203. 0x1e, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x7c, 0x6f, 0x4f, 0x32,
  5204. 0x07, 0x2f, 0xfe, 0x3c, 0x13, 0xf1, 0xfe, 0x42, 0x13, 0x42, 0x92, 0x09,
  5205. 0x48, 0x01, 0x0e, 0xbb, 0xeb, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
  5206. 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11,
  5207. 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x4c, 0x01, 0x73, 0xfe, 0x16,
  5208. 0x10, 0x07, 0x82, 0x8b, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xfe, 0x14,
  5209. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x1c, 0x18, 0x18, 0x0a, 0x04, 0xfe, 0x9c,
  5210. 0xe7, 0x0a, 0x10, 0xfe, 0x15, 0x00, 0x64, 0x79, 0x2a, 0x01, 0xe3, 0x18,
  5211. 0x06, 0x04, 0x42, 0x92, 0x08, 0x54, 0x1b, 0x37, 0x12, 0x2f, 0x01, 0x73,
  5212. 0x18, 0x06, 0x04, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x3a, 0xce, 0x3b,
  5213. 0xcf, 0xfe, 0x48, 0x55, 0x35, 0xfe, 0xc9, 0x55, 0x04, 0x22, 0xa3, 0x77,
  5214. 0x13, 0xa3, 0x04, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0x41, 0x48, 0x09, 0x46,
  5215. 0x01, 0x0e, 0xfe, 0x49, 0x44, 0x17, 0xfe, 0xe8, 0x18, 0x77, 0x78, 0x04,
  5216. 0x09, 0x48, 0x01, 0x0e, 0x07, 0x11, 0x4e, 0x09, 0x5d, 0x01, 0xa8, 0x09,
  5217. 0x46, 0x01, 0x0e, 0x77, 0x78, 0x04, 0xfe, 0x4e, 0xe4, 0x19, 0x6b, 0xfe,
  5218. 0x1c, 0x19, 0x03, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10,
  5219. 0xfe, 0x4e, 0xe4, 0xc9, 0x6b, 0xfe, 0x2e, 0x19, 0x03, 0xfe, 0x92, 0x00,
  5220. 0xfe, 0x02, 0xe6, 0x1a, 0xe5, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x6b,
  5221. 0xfe, 0x40, 0x19, 0x03, 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x1f, 0xfe,
  5222. 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x6d, 0xfe, 0x4e,
  5223. 0x45, 0xea, 0xba, 0xff, 0x04, 0x68, 0x54, 0xe7, 0x1e, 0x6e, 0xfe, 0x08,
  5224. 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c, 0xfe, 0x1a, 0xf4, 0xfe, 0x00,
  5225. 0x04, 0xea, 0xfe, 0x48, 0xf4, 0x19, 0x7a, 0xfe, 0x74, 0x19, 0x0f, 0x19,
  5226. 0x04, 0x07, 0x7e, 0xfe, 0x5a, 0xf0, 0xfe, 0x84, 0x19, 0x25, 0xfe, 0x09,
  5227. 0x00, 0xfe, 0x34, 0x10, 0x07, 0x1a, 0xfe, 0x5a, 0xf0, 0xfe, 0x92, 0x19,
  5228. 0x25, 0xca, 0xfe, 0x26, 0x10, 0x07, 0x19, 0x66, 0x25, 0x6d, 0xe5, 0x07,
  5229. 0x0a, 0x66, 0x25, 0x9e, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x66, 0x25, 0x59,
  5230. 0xa9, 0xb8, 0x04, 0x15, 0xfe, 0x09, 0x00, 0x01, 0x36, 0xfe, 0x04, 0xfe,
  5231. 0x81, 0x03, 0x83, 0xfe, 0x40, 0x5c, 0x04, 0x1c, 0xf7, 0xfe, 0x14, 0xf0,
  5232. 0x0b, 0x27, 0xfe, 0xd6, 0x19, 0x1c, 0xf7, 0x7b, 0xf7, 0xfe, 0x82, 0xf0,
  5233. 0xfe, 0xda, 0x19, 0x04, 0xff, 0xcc, 0x00, 0x00,
  5234. };
  5235. static unsigned short _adv_asc38C0800_size = sizeof(_adv_asc38C0800_buf); /* 0x14E1 */
  5236. static ADV_DCNT _adv_asc38C0800_chksum = 0x050D3FD8UL; /* Expanded little-endian checksum. */
  5237. /* Microcode buffer is kept after initialization for error recovery. */
  5238. static unsigned char _adv_asc38C1600_buf[] = {
  5239. 0x00, 0x00, 0x00, 0xf2, 0x00, 0x16, 0x00, 0xfc, 0x00, 0x10, 0x00, 0xf0,
  5240. 0x18, 0xe4, 0x01, 0x00, 0x04, 0x1e, 0x48, 0xe4, 0x03, 0xf6, 0xf7, 0x13,
  5241. 0x2e, 0x1e, 0x02, 0x00, 0x07, 0x17, 0xc0, 0x5f, 0x00, 0xfa, 0xff, 0xff,
  5242. 0x04, 0x00, 0x00, 0xf6, 0x09, 0xe7, 0x82, 0xe7, 0x85, 0xf0, 0x86, 0xf0,
  5243. 0x4e, 0x10, 0x9e, 0xe7, 0xff, 0x00, 0x55, 0xf0, 0x01, 0xf6, 0x03, 0x00,
  5244. 0x98, 0x57, 0x01, 0xe6, 0x00, 0xea, 0x00, 0xec, 0x01, 0xfa, 0x18, 0xf4,
  5245. 0x08, 0x00, 0xf0, 0x1d, 0x38, 0x54, 0x32, 0xf0, 0x10, 0x00, 0xc2, 0x0e,
  5246. 0x1e, 0xf0, 0xd5, 0xf0, 0xbc, 0x00, 0x4b, 0xe4, 0x00, 0xe6, 0xb1, 0xf0,
  5247. 0xb4, 0x00, 0x02, 0x13, 0x3e, 0x1c, 0xc8, 0x47, 0x3e, 0x00, 0xd8, 0x01,
  5248. 0x06, 0x13, 0x0c, 0x1c, 0x5e, 0x1e, 0x00, 0x57, 0xc8, 0x57, 0x01, 0xfc,
  5249. 0xbc, 0x0e, 0xa2, 0x12, 0xb9, 0x54, 0x00, 0x80, 0x62, 0x0a, 0x5a, 0x12,
  5250. 0xc8, 0x15, 0x3e, 0x1e, 0x18, 0x40, 0xbd, 0x56, 0x03, 0xe6, 0x01, 0xea,
  5251. 0x5c, 0xf0, 0x0f, 0x00, 0x20, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
  5252. 0x04, 0x13, 0xbb, 0x55, 0x3c, 0x56, 0x3e, 0x57, 0x03, 0x58, 0x4a, 0xe4,
  5253. 0x40, 0x00, 0xb6, 0x00, 0xbb, 0x00, 0xc0, 0x00, 0x00, 0x01, 0x01, 0x01,
  5254. 0x3e, 0x01, 0x58, 0x0a, 0x44, 0x10, 0x0a, 0x12, 0x4c, 0x1c, 0x4e, 0x1c,
  5255. 0x02, 0x4a, 0x30, 0xe4, 0x05, 0xe6, 0x0c, 0x00, 0x3c, 0x00, 0x80, 0x00,
  5256. 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01,
  5257. 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x7c, 0x01, 0xc6, 0x0e, 0x0c, 0x10,
  5258. 0xac, 0x12, 0xae, 0x12, 0x16, 0x1a, 0x32, 0x1c, 0x6e, 0x1e, 0x02, 0x48,
  5259. 0x3a, 0x55, 0xc9, 0x57, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x06, 0xf7,
  5260. 0x03, 0xfc, 0x06, 0x00, 0x1e, 0x00, 0xbe, 0x00, 0xe1, 0x00, 0x0c, 0x12,
  5261. 0x18, 0x1a, 0x70, 0x1a, 0x30, 0x1c, 0x38, 0x1c, 0x10, 0x44, 0x00, 0x4c,
  5262. 0xb0, 0x57, 0x40, 0x5c, 0x4d, 0xe4, 0x04, 0xea, 0x5d, 0xf0, 0xa7, 0xf0,
  5263. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x09, 0x00, 0x19, 0x00, 0x32, 0x00,
  5264. 0x33, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0x9e, 0x00, 0xcc, 0x00,
  5265. 0x20, 0x01, 0x4e, 0x01, 0x79, 0x01, 0x3c, 0x09, 0x68, 0x0d, 0x02, 0x10,
  5266. 0x04, 0x10, 0x3a, 0x10, 0x08, 0x12, 0x0a, 0x13, 0x40, 0x16, 0x50, 0x16,
  5267. 0x00, 0x17, 0x4a, 0x19, 0x00, 0x4e, 0x00, 0x54, 0x01, 0x58, 0x00, 0xdc,
  5268. 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xb8, 0xf0, 0x48, 0xf4, 0x0e, 0xf7,
  5269. 0x0a, 0x00, 0x9b, 0x00, 0x9c, 0x00, 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00,
  5270. 0xd0, 0x00, 0xe7, 0x00, 0xf0, 0x03, 0x69, 0x08, 0xe9, 0x09, 0x5c, 0x0c,
  5271. 0xb6, 0x12, 0xbc, 0x19, 0xd8, 0x1b, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c,
  5272. 0x42, 0x1d, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46,
  5273. 0x89, 0x48, 0x68, 0x54, 0x83, 0x55, 0x83, 0x59, 0x31, 0xe4, 0x02, 0xe6,
  5274. 0x07, 0xf0, 0x08, 0xf0, 0x0b, 0xf0, 0x0c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8,
  5275. 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa, 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00,
  5276. 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0x22, 0x01,
  5277. 0x26, 0x01, 0x60, 0x01, 0x7a, 0x01, 0x82, 0x01, 0xc8, 0x01, 0xca, 0x01,
  5278. 0x86, 0x02, 0x6a, 0x03, 0x18, 0x05, 0xb2, 0x07, 0x68, 0x08, 0x10, 0x0d,
  5279. 0x06, 0x10, 0x0a, 0x10, 0x0e, 0x10, 0x12, 0x10, 0x60, 0x10, 0xed, 0x10,
  5280. 0xf3, 0x10, 0x06, 0x12, 0x10, 0x12, 0x1e, 0x12, 0x0c, 0x13, 0x0e, 0x13,
  5281. 0x10, 0x13, 0xfe, 0x9c, 0xf0, 0x35, 0x05, 0xfe, 0xec, 0x0e, 0xff, 0x10,
  5282. 0x00, 0x00, 0xe9, 0xfe, 0x34, 0x1f, 0x00, 0xe8, 0xfe, 0x88, 0x01, 0xff,
  5283. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  5284. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x65, 0xff, 0x04, 0x00,
  5285. 0x00, 0x1a, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  5286. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x13,
  5287. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  5288. 0xfe, 0x04, 0xf7, 0xe8, 0x37, 0x7d, 0x0d, 0x01, 0xfe, 0x4a, 0x11, 0xfe,
  5289. 0x04, 0xf7, 0xe8, 0x7d, 0x0d, 0x51, 0x37, 0xfe, 0x3d, 0xf0, 0xfe, 0x0c,
  5290. 0x02, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x91, 0xf0, 0xfe, 0xf8, 0x01, 0xfe,
  5291. 0x90, 0xf0, 0xfe, 0xf8, 0x01, 0xfe, 0x8f, 0xf0, 0xbc, 0x03, 0x67, 0x4d,
  5292. 0x05, 0xfe, 0x08, 0x0f, 0x01, 0xfe, 0x78, 0x0f, 0xfe, 0xdd, 0x12, 0x05,
  5293. 0xfe, 0x0e, 0x03, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd1,
  5294. 0x12, 0x3e, 0x22, 0xfe, 0xa6, 0x00, 0xac, 0xfe, 0x48, 0xf0, 0xfe, 0x90,
  5295. 0x02, 0xfe, 0x49, 0xf0, 0xfe, 0xaa, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc8,
  5296. 0x02, 0xfe, 0x46, 0xf0, 0xfe, 0x5a, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x60,
  5297. 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x4e, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x52,
  5298. 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x56, 0x02, 0x1c, 0x0d, 0xa2, 0x1c, 0x07,
  5299. 0x22, 0xb7, 0x05, 0x35, 0xfe, 0x00, 0x1c, 0xfe, 0xf1, 0x10, 0xfe, 0x02,
  5300. 0x1c, 0xf5, 0xfe, 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0x5f, 0xfe, 0xe7,
  5301. 0x10, 0xfe, 0x06, 0xfc, 0xde, 0x0a, 0x81, 0x01, 0xa3, 0x05, 0x35, 0x1f,
  5302. 0x95, 0x47, 0xb8, 0x01, 0xfe, 0xe4, 0x11, 0x0a, 0x81, 0x01, 0x5c, 0xfe,
  5303. 0xbd, 0x10, 0x0a, 0x81, 0x01, 0x5c, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c,
  5304. 0xfe, 0x58, 0x1c, 0x1c, 0x07, 0x22, 0xb7, 0x37, 0x2a, 0x35, 0xfe, 0x3d,
  5305. 0xf0, 0xfe, 0x0c, 0x02, 0x2b, 0xfe, 0x9e, 0x02, 0xfe, 0x5a, 0x1c, 0xfe,
  5306. 0x12, 0x1c, 0xfe, 0x14, 0x1c, 0x1f, 0xfe, 0x30, 0x00, 0x47, 0xb8, 0x01,
  5307. 0xfe, 0xd4, 0x11, 0x1c, 0x07, 0x22, 0xb7, 0x05, 0xe9, 0x21, 0x2c, 0x09,
  5308. 0x1a, 0x31, 0xfe, 0x69, 0x10, 0x1c, 0x07, 0x22, 0xb7, 0xfe, 0x04, 0xec,
  5309. 0x2c, 0x60, 0x01, 0xfe, 0x1e, 0x1e, 0x20, 0x2c, 0xfe, 0x05, 0xf6, 0xde,
  5310. 0x01, 0xfe, 0x62, 0x1b, 0x01, 0x0c, 0x61, 0x4a, 0x44, 0x15, 0x56, 0x51,
  5311. 0x01, 0xfe, 0x9e, 0x1e, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x0a, 0x57,
  5312. 0x01, 0x18, 0x09, 0x00, 0x36, 0x01, 0x85, 0xfe, 0x18, 0x10, 0xfe, 0x41,
  5313. 0x58, 0x0a, 0xba, 0x01, 0x18, 0xfe, 0xc8, 0x54, 0x7b, 0xfe, 0x1c, 0x03,
  5314. 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x37, 0x60, 0xfe, 0x02, 0xe8, 0x30,
  5315. 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe, 0x27, 0xf0,
  5316. 0xfe, 0xe4, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x40,
  5317. 0x1c, 0x2a, 0xeb, 0xfe, 0x26, 0xf0, 0xfe, 0x66, 0x03, 0xfe, 0xa0, 0xf0,
  5318. 0xfe, 0x54, 0x03, 0xfe, 0x11, 0xf0, 0xbc, 0xfe, 0xef, 0x10, 0xfe, 0x9f,
  5319. 0xf0, 0xfe, 0x74, 0x03, 0xfe, 0x46, 0x1c, 0x19, 0xfe, 0x11, 0x00, 0x05,
  5320. 0x70, 0x37, 0xfe, 0x48, 0x1c, 0xfe, 0x46, 0x1c, 0x01, 0x0c, 0x06, 0x28,
  5321. 0xfe, 0x18, 0x13, 0x26, 0x21, 0xb9, 0xc7, 0x20, 0xb9, 0x0a, 0x57, 0x01,
  5322. 0x18, 0xc7, 0x89, 0x01, 0xfe, 0xc8, 0x1a, 0x15, 0xe1, 0x2a, 0xeb, 0xfe,
  5323. 0x01, 0xf0, 0xeb, 0xfe, 0x82, 0xf0, 0xfe, 0xa4, 0x03, 0xfe, 0x9c, 0x32,
  5324. 0x15, 0xfe, 0xe4, 0x00, 0x2f, 0xfe, 0xb6, 0x03, 0x2a, 0x3c, 0x16, 0xfe,
  5325. 0xc6, 0x03, 0x01, 0x41, 0xfe, 0x06, 0xf0, 0xfe, 0xd6, 0x03, 0xaf, 0xa0,
  5326. 0xfe, 0x0a, 0xf0, 0xfe, 0xa2, 0x07, 0x05, 0x29, 0x03, 0x81, 0x1e, 0x1b,
  5327. 0xfe, 0x24, 0x05, 0x1f, 0x63, 0x01, 0x42, 0x8f, 0xfe, 0x70, 0x02, 0x05,
  5328. 0xea, 0xfe, 0x46, 0x1c, 0x37, 0x7d, 0x1d, 0xfe, 0x67, 0x1b, 0xfe, 0xbf,
  5329. 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c, 0x75, 0x01, 0xa6, 0x86, 0x0a,
  5330. 0x57, 0x01, 0x18, 0x09, 0x00, 0x1b, 0xec, 0x0a, 0xe1, 0x01, 0x18, 0x77,
  5331. 0x50, 0x40, 0x8d, 0x30, 0x03, 0x81, 0x1e, 0xf8, 0x1f, 0x63, 0x01, 0x42,
  5332. 0x8f, 0xfe, 0x70, 0x02, 0x05, 0xea, 0xd7, 0x99, 0xd8, 0x9c, 0x2a, 0x29,
  5333. 0x2f, 0xfe, 0x4e, 0x04, 0x16, 0xfe, 0x4a, 0x04, 0x7e, 0xfe, 0xa0, 0x00,
  5334. 0xfe, 0x9b, 0x57, 0xfe, 0x54, 0x12, 0x32, 0xff, 0x02, 0x00, 0x10, 0x01,
  5335. 0x08, 0x16, 0xfe, 0x02, 0x05, 0x32, 0x01, 0x08, 0x16, 0x29, 0x27, 0x25,
  5336. 0xee, 0xfe, 0x4c, 0x44, 0xfe, 0x58, 0x12, 0x50, 0xfe, 0x44, 0x48, 0x13,
  5337. 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x60, 0x8d, 0x30, 0x01, 0xfe, 0x4e,
  5338. 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x7c, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xfe,
  5339. 0x32, 0x13, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x68, 0x13, 0xfe, 0x26, 0x10,
  5340. 0x13, 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x01, 0xfe, 0x4e, 0x1e, 0xfe,
  5341. 0x48, 0x47, 0xfe, 0x54, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xa5, 0x01, 0x43,
  5342. 0x09, 0x9b, 0xfe, 0x40, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xf9, 0x1f, 0x7f,
  5343. 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42, 0x8f,
  5344. 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x32, 0x15, 0xfe, 0xe6, 0x00, 0x0f, 0xfe,
  5345. 0x1c, 0x90, 0x04, 0xfe, 0x9c, 0x93, 0x3a, 0x0b, 0x0e, 0x8b, 0x02, 0x1f,
  5346. 0x7f, 0x01, 0x42, 0x05, 0x35, 0xfe, 0x42, 0x5b, 0x7d, 0x1d, 0xfe, 0x46,
  5347. 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0x0f, 0xfe, 0x87, 0x80, 0x04,
  5348. 0xfe, 0x87, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xd0, 0x65, 0x01, 0x0c,
  5349. 0x06, 0x0d, 0xfe, 0x98, 0x13, 0x0f, 0xfe, 0x20, 0x80, 0x04, 0xfe, 0xa0,
  5350. 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x1d, 0xfe, 0x84, 0x12, 0x01, 0x38, 0x06,
  5351. 0x07, 0xfe, 0x70, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x1e, 0x1b, 0xfe, 0xda,
  5352. 0x05, 0xd0, 0x54, 0x01, 0x38, 0x06, 0x0d, 0xfe, 0x58, 0x13, 0x03, 0xfe,
  5353. 0xa0, 0x00, 0x1e, 0xfe, 0x50, 0x12, 0x5e, 0xff, 0x02, 0x00, 0x10, 0x2f,
  5354. 0xfe, 0x90, 0x05, 0x2a, 0x3c, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe,
  5355. 0x9e, 0x05, 0x17, 0xfe, 0xf4, 0x05, 0x15, 0xfe, 0xe3, 0x00, 0x26, 0x01,
  5356. 0x38, 0xfe, 0x4a, 0xf0, 0xfe, 0xc0, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0xba,
  5357. 0x05, 0x71, 0x2e, 0xfe, 0x21, 0x00, 0xf1, 0x2e, 0xfe, 0x22, 0x00, 0xa2,
  5358. 0x2e, 0x4a, 0xfe, 0x09, 0x48, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe, 0xd0,
  5359. 0x05, 0x17, 0xfe, 0xf4, 0x05, 0xfe, 0xe2, 0x08, 0x01, 0x38, 0x06, 0xfe,
  5360. 0x1c, 0x00, 0x4d, 0x01, 0xa7, 0x2e, 0x07, 0x20, 0xe4, 0x47, 0xfe, 0x27,
  5361. 0x01, 0x01, 0x0c, 0x06, 0x28, 0xfe, 0x24, 0x12, 0x3e, 0x01, 0x84, 0x1f,
  5362. 0x7f, 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42,
  5363. 0x8f, 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x03, 0xe6, 0x1e, 0xfe, 0xca, 0x13,
  5364. 0x03, 0xb6, 0x1e, 0xfe, 0x40, 0x12, 0x03, 0x66, 0x1e, 0xfe, 0x38, 0x13,
  5365. 0x3e, 0x01, 0x84, 0x17, 0xfe, 0x72, 0x06, 0x0a, 0x07, 0x01, 0x38, 0x06,
  5366. 0x24, 0xfe, 0x02, 0x12, 0x4f, 0x01, 0xfe, 0x56, 0x19, 0x16, 0xfe, 0x68,
  5367. 0x06, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x66, 0x8a, 0x10, 0x66,
  5368. 0x03, 0x9a, 0x1e, 0xfe, 0x70, 0x12, 0x03, 0x55, 0x1e, 0xfe, 0x68, 0x13,
  5369. 0x01, 0xc6, 0x09, 0x12, 0x48, 0xfe, 0x92, 0x06, 0x2e, 0x12, 0x01, 0xfe,
  5370. 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0x13, 0x58, 0xff, 0x02, 0x00,
  5371. 0x57, 0x52, 0xad, 0x23, 0x3f, 0x4e, 0x62, 0x49, 0x3e, 0x01, 0x84, 0x17,
  5372. 0xfe, 0xea, 0x06, 0x01, 0x38, 0x06, 0x12, 0xf7, 0x45, 0x0a, 0x95, 0x01,
  5373. 0xfe, 0x84, 0x19, 0x16, 0xfe, 0xe0, 0x06, 0x15, 0x82, 0x01, 0x41, 0x15,
  5374. 0xe2, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x1c, 0x07, 0x01, 0x84, 0xfe, 0xae,
  5375. 0x10, 0x03, 0x6f, 0x1e, 0xfe, 0x9e, 0x13, 0x3e, 0x01, 0x84, 0x03, 0x9a,
  5376. 0x1e, 0xfe, 0x1a, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfc, 0x01, 0xc6, 0x01,
  5377. 0xfe, 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0xf0, 0x45, 0x0a, 0x95,
  5378. 0x03, 0xb6, 0x1e, 0xf8, 0x01, 0x38, 0x06, 0x24, 0x36, 0xfe, 0x02, 0xf6,
  5379. 0x07, 0x71, 0x78, 0x8c, 0x00, 0x4d, 0x62, 0x49, 0x3e, 0x2d, 0x93, 0x4e,
  5380. 0xd0, 0x0d, 0x17, 0xfe, 0x9a, 0x07, 0x01, 0xfe, 0xc0, 0x19, 0x16, 0xfe,
  5381. 0x90, 0x07, 0x26, 0x20, 0x9e, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x21,
  5382. 0x9e, 0x09, 0x07, 0xfb, 0x03, 0xe6, 0xfe, 0x58, 0x57, 0x10, 0xe6, 0x05,
  5383. 0xfe, 0x2a, 0x06, 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x1c, 0x07, 0x01, 0x84,
  5384. 0xfe, 0x9c, 0x32, 0x5f, 0x75, 0x01, 0xa6, 0x86, 0x15, 0xfe, 0xe2, 0x00,
  5385. 0x2f, 0xed, 0x2a, 0x3c, 0xfe, 0x0a, 0xf0, 0xfe, 0xce, 0x07, 0xae, 0xfe,
  5386. 0x96, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x9e, 0x08, 0xaf, 0xa0, 0x05, 0x29,
  5387. 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x2e, 0x12, 0x14, 0x1d, 0x01, 0x08, 0x14,
  5388. 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0xfe,
  5389. 0x99, 0xa4, 0x01, 0x08, 0x14, 0x00, 0x05, 0xfe, 0xc6, 0x09, 0x01, 0x76,
  5390. 0x06, 0x12, 0xfe, 0x3a, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x30, 0x13,
  5391. 0x14, 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00,
  5392. 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x07, 0x01, 0x08, 0x14, 0x00,
  5393. 0x05, 0xef, 0x7c, 0x4a, 0x78, 0x4f, 0x0f, 0xfe, 0x9a, 0x81, 0x04, 0xfe,
  5394. 0x9a, 0x83, 0xfe, 0xcb, 0x47, 0x0b, 0x0e, 0x2d, 0x28, 0x48, 0xfe, 0x6c,
  5395. 0x08, 0x0a, 0x28, 0xfe, 0x09, 0x6f, 0xca, 0xfe, 0xca, 0x45, 0xfe, 0x32,
  5396. 0x12, 0x53, 0x63, 0x4e, 0x7c, 0x97, 0x2f, 0xfe, 0x7e, 0x08, 0x2a, 0x3c,
  5397. 0xfe, 0x0a, 0xf0, 0xfe, 0x6c, 0x08, 0xaf, 0xa0, 0xae, 0xfe, 0x96, 0x08,
  5398. 0x05, 0x29, 0x01, 0x41, 0x05, 0xed, 0x14, 0x24, 0x05, 0xed, 0xfe, 0x9c,
  5399. 0xf7, 0x9f, 0x01, 0xfe, 0xae, 0x1e, 0xfe, 0x18, 0x58, 0x01, 0xfe, 0xbe,
  5400. 0x1e, 0xfe, 0x99, 0x58, 0xfe, 0x78, 0x18, 0xfe, 0xf9, 0x18, 0x8e, 0xfe,
  5401. 0x16, 0x09, 0x10, 0x6a, 0x22, 0x6b, 0x01, 0x0c, 0x61, 0x54, 0x44, 0x21,
  5402. 0x2c, 0x09, 0x1a, 0xf8, 0x77, 0x01, 0xfe, 0x7e, 0x1e, 0x47, 0x2c, 0x7a,
  5403. 0x30, 0xf0, 0xfe, 0x83, 0xe7, 0xfe, 0x3f, 0x00, 0x71, 0xfe, 0x03, 0x40,
  5404. 0x01, 0x0c, 0x61, 0x65, 0x44, 0x01, 0xc2, 0xc8, 0xfe, 0x1f, 0x40, 0x20,
  5405. 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
  5406. 0x44, 0x51, 0xfe, 0xc6, 0x51, 0xfe, 0x10, 0x10, 0x01, 0xfe, 0xce, 0x1e,
  5407. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x01, 0xfe, 0xee, 0x1e,
  5408. 0x01, 0xfe, 0xfe, 0x1e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x10, 0x4b,
  5409. 0x22, 0x4c, 0xfe, 0x8a, 0x10, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x50, 0x12,
  5410. 0x01, 0xfe, 0xae, 0x1e, 0x01, 0xfe, 0xbe, 0x1e, 0x10, 0x6a, 0x22, 0x6b,
  5411. 0x01, 0x0c, 0x06, 0x65, 0x4e, 0x01, 0xc2, 0x0f, 0xfe, 0x1f, 0x80, 0x04,
  5412. 0xfe, 0x9f, 0x83, 0x33, 0x0b, 0x0e, 0x20, 0x6e, 0x0f, 0xfe, 0x44, 0x90,
  5413. 0x04, 0xfe, 0xc4, 0x93, 0x3a, 0x0b, 0xfe, 0xc6, 0x90, 0x04, 0xfe, 0xc6,
  5414. 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x6c, 0x22, 0x6d, 0x01, 0xfe, 0xce, 0x1e,
  5415. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x0f, 0xfe, 0x40, 0x90,
  5416. 0x04, 0xfe, 0xc0, 0x93, 0x3a, 0x0b, 0xfe, 0xc2, 0x90, 0x04, 0xfe, 0xc2,
  5417. 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x4b, 0x22, 0x4c, 0x10, 0x64, 0x22, 0x34,
  5418. 0x01, 0x0c, 0x61, 0x24, 0x44, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe,
  5419. 0xde, 0x09, 0xfe, 0x9e, 0xf0, 0xfe, 0xf2, 0x09, 0xfe, 0x01, 0x48, 0x1b,
  5420. 0x3c, 0x37, 0x88, 0xf5, 0xd4, 0xfe, 0x1e, 0x0a, 0xd5, 0xfe, 0x42, 0x0a,
  5421. 0xd2, 0xfe, 0x1e, 0x0a, 0xd3, 0xfe, 0x42, 0x0a, 0xae, 0xfe, 0x12, 0x0a,
  5422. 0xfe, 0x06, 0xf0, 0xfe, 0x18, 0x0a, 0xaf, 0xa0, 0x05, 0x29, 0x01, 0x41,
  5423. 0xfe, 0xc1, 0x10, 0x14, 0x24, 0xfe, 0xc1, 0x10, 0x01, 0x76, 0x06, 0x07,
  5424. 0xfe, 0x14, 0x12, 0x01, 0x76, 0x06, 0x0d, 0x5d, 0x01, 0x0c, 0x06, 0x0d,
  5425. 0xfe, 0x74, 0x12, 0xfe, 0x2e, 0x1c, 0x05, 0xfe, 0x1a, 0x0c, 0x01, 0x76,
  5426. 0x06, 0x07, 0x5d, 0x01, 0x76, 0x06, 0x0d, 0x41, 0xfe, 0x2c, 0x1c, 0xfe,
  5427. 0xaa, 0xf0, 0xfe, 0xce, 0x0a, 0xfe, 0xac, 0xf0, 0xfe, 0x66, 0x0a, 0xfe,
  5428. 0x92, 0x10, 0xc4, 0xf6, 0xfe, 0xad, 0xf0, 0xfe, 0x72, 0x0a, 0x05, 0xfe,
  5429. 0x1a, 0x0c, 0xc5, 0xfe, 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0xbf, 0xfe, 0x6b,
  5430. 0x18, 0x23, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xac, 0xfe, 0xd2, 0xf0,
  5431. 0xbf, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x1b, 0xbf, 0x03, 0xe3, 0x23, 0x07,
  5432. 0x1b, 0xbf, 0xd4, 0x5b, 0xd5, 0x5b, 0xd2, 0x5b, 0xd3, 0x5b, 0xc4, 0xc5,
  5433. 0xfe, 0xa9, 0x10, 0x75, 0x5e, 0x32, 0x1f, 0x7f, 0x01, 0x42, 0x19, 0xfe,
  5434. 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x70, 0x19, 0x98, 0x05, 0x70, 0xfe, 0x74,
  5435. 0x18, 0x23, 0xfe, 0x00, 0xf8, 0x1b, 0x5b, 0x7d, 0x12, 0x01, 0xfe, 0x78,
  5436. 0x0f, 0x4d, 0x01, 0xfe, 0x96, 0x1a, 0x21, 0x30, 0x77, 0x7d, 0x1d, 0x05,
  5437. 0x5b, 0x01, 0x0c, 0x06, 0x0d, 0x2b, 0xfe, 0xe2, 0x0b, 0x01, 0x0c, 0x06,
  5438. 0x54, 0xfe, 0xa6, 0x12, 0x01, 0x0c, 0x06, 0x24, 0xfe, 0x88, 0x13, 0x21,
  5439. 0x6e, 0xc7, 0x01, 0xfe, 0x1e, 0x1f, 0x0f, 0xfe, 0x83, 0x80, 0x04, 0xfe,
  5440. 0x83, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xfe, 0xc8, 0x44, 0xfe, 0x42,
  5441. 0x13, 0x0f, 0xfe, 0x04, 0x91, 0x04, 0xfe, 0x84, 0x93, 0xfe, 0xca, 0x57,
  5442. 0x0b, 0xfe, 0x86, 0x91, 0x04, 0xfe, 0x86, 0x93, 0xfe, 0xcb, 0x57, 0x0b,
  5443. 0x0e, 0x7a, 0x30, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x8e, 0x40, 0x03,
  5444. 0x6a, 0x3b, 0x6b, 0x10, 0x97, 0x22, 0x98, 0xd9, 0x6a, 0xda, 0x6b, 0x01,
  5445. 0xc2, 0xc8, 0x7a, 0x30, 0x20, 0x6e, 0xdb, 0x64, 0xdc, 0x34, 0x91, 0x6c,
  5446. 0x7e, 0x6d, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xfe, 0x04, 0xfa, 0x64,
  5447. 0xfe, 0x05, 0xfa, 0x34, 0x01, 0xfe, 0x6a, 0x16, 0xa3, 0x26, 0x10, 0x97,
  5448. 0x10, 0x98, 0x91, 0x6c, 0x7e, 0x6d, 0xfe, 0x14, 0x10, 0x01, 0x0c, 0x06,
  5449. 0x24, 0x1b, 0x40, 0x91, 0x4b, 0x7e, 0x4c, 0x01, 0x0c, 0x06, 0xfe, 0xf7,
  5450. 0x00, 0x44, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58,
  5451. 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x05, 0x5b, 0x01, 0x0c, 0x06, 0x24,
  5452. 0x1b, 0x40, 0x01, 0x0c, 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x78, 0x01, 0xfe,
  5453. 0x8e, 0x1e, 0x4f, 0x0f, 0xfe, 0x10, 0x90, 0x04, 0xfe, 0x90, 0x93, 0x3a,
  5454. 0x0b, 0xfe, 0x92, 0x90, 0x04, 0xfe, 0x92, 0x93, 0x79, 0x0b, 0x0e, 0xfe,
  5455. 0xbd, 0x10, 0x01, 0x43, 0x09, 0xbb, 0x1b, 0xfe, 0x6e, 0x0a, 0x15, 0xbb,
  5456. 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x14, 0x13, 0x03, 0x4b, 0x3b, 0x4c, 0x8e,
  5457. 0xfe, 0x6e, 0x0a, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x05, 0x5b, 0x26,
  5458. 0x3e, 0x0f, 0xfe, 0x19, 0x80, 0x04, 0xfe, 0x99, 0x83, 0x33, 0x0b, 0x0e,
  5459. 0xfe, 0xe5, 0x10, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1a, 0x12, 0xfe, 0x6c,
  5460. 0x19, 0xfe, 0x19, 0x41, 0xfe, 0x6b, 0x18, 0xac, 0xfe, 0xd1, 0xf0, 0xef,
  5461. 0x1f, 0x92, 0x01, 0x42, 0x19, 0xfe, 0x44, 0x00, 0xfe, 0x90, 0x10, 0xfe,
  5462. 0x6c, 0x19, 0xd9, 0x4b, 0xfe, 0xed, 0x19, 0xda, 0x4c, 0xfe, 0x0c, 0x51,
  5463. 0xfe, 0x8e, 0x51, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xff, 0x31, 0xfe,
  5464. 0x76, 0x10, 0xac, 0xfe, 0xd2, 0xf0, 0xfe, 0xba, 0x0c, 0xfe, 0x76, 0x18,
  5465. 0x23, 0x1d, 0x5d, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0x08, 0x13, 0x19, 0xfe,
  5466. 0x16, 0x00, 0x05, 0x70, 0xfe, 0xd1, 0xf0, 0xfe, 0xcc, 0x0c, 0x1f, 0x92,
  5467. 0x01, 0x42, 0x19, 0xfe, 0x17, 0x00, 0x5c, 0xfe, 0xce, 0xf0, 0xfe, 0xd2,
  5468. 0x0c, 0xfe, 0x3e, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xde, 0x0c, 0x19, 0xfe,
  5469. 0x22, 0x00, 0x05, 0x70, 0xfe, 0xcb, 0xf0, 0xfe, 0xea, 0x0c, 0x19, 0xfe,
  5470. 0x24, 0x00, 0x05, 0x70, 0xfe, 0xd0, 0xf0, 0xfe, 0xf4, 0x0c, 0x19, 0x94,
  5471. 0xfe, 0x1c, 0x10, 0xfe, 0xcf, 0xf0, 0xfe, 0xfe, 0x0c, 0x19, 0x4a, 0xf3,
  5472. 0xfe, 0xcc, 0xf0, 0xef, 0x01, 0x76, 0x06, 0x24, 0x4d, 0x19, 0xfe, 0x12,
  5473. 0x00, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe, 0x16, 0x0d, 0xfe, 0x9e,
  5474. 0xf0, 0xfe, 0x2a, 0x0d, 0xfe, 0x01, 0x48, 0x1b, 0x3c, 0x37, 0x88, 0xf5,
  5475. 0xd4, 0x29, 0xd5, 0x29, 0xd2, 0x29, 0xd3, 0x29, 0x37, 0xfe, 0x9c, 0x32,
  5476. 0x2f, 0xfe, 0x3e, 0x0d, 0x2a, 0x3c, 0xae, 0xfe, 0x62, 0x0d, 0xaf, 0xa0,
  5477. 0xd4, 0x9f, 0xd5, 0x9f, 0xd2, 0x9f, 0xd3, 0x9f, 0x05, 0x29, 0x01, 0x41,
  5478. 0xfe, 0xd3, 0x10, 0x15, 0xfe, 0xe8, 0x00, 0xc4, 0xc5, 0x75, 0xd7, 0x99,
  5479. 0xd8, 0x9c, 0xfe, 0x89, 0xf0, 0x29, 0x27, 0x25, 0xbe, 0xd7, 0x99, 0xd8,
  5480. 0x9c, 0x2f, 0xfe, 0x8c, 0x0d, 0x16, 0x29, 0x27, 0x25, 0xbd, 0xfe, 0x01,
  5481. 0x48, 0xa4, 0x19, 0xfe, 0x42, 0x00, 0x05, 0x70, 0x90, 0x07, 0xfe, 0x81,
  5482. 0x49, 0x1b, 0xfe, 0x64, 0x0e, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x44, 0x13,
  5483. 0x19, 0x00, 0x2d, 0x0d, 0xfe, 0x54, 0x12, 0x2d, 0xfe, 0x28, 0x00, 0x2b,
  5484. 0xfe, 0xda, 0x0e, 0x0a, 0x57, 0x01, 0x18, 0x09, 0x00, 0x36, 0x46, 0xfe,
  5485. 0x28, 0x00, 0xfe, 0xfa, 0x10, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00,
  5486. 0x1d, 0x0a, 0xba, 0x01, 0xfe, 0x58, 0x10, 0x40, 0x15, 0x56, 0x01, 0x85,
  5487. 0x05, 0x35, 0x19, 0xfe, 0x44, 0x00, 0x2d, 0x0d, 0xf7, 0x46, 0x0d, 0xfe,
  5488. 0xcc, 0x10, 0x01, 0xa7, 0x46, 0x0d, 0xfe, 0xc2, 0x10, 0x01, 0xa7, 0x0f,
  5489. 0xfe, 0x19, 0x82, 0x04, 0xfe, 0x99, 0x83, 0xfe, 0xcc, 0x47, 0x0b, 0x0e,
  5490. 0xfe, 0x34, 0x46, 0xa5, 0x46, 0x0d, 0x19, 0xfe, 0x43, 0x00, 0xfe, 0xa2,
  5491. 0x10, 0x01, 0x0c, 0x61, 0x0d, 0x44, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe,
  5492. 0x00, 0x1d, 0x40, 0x15, 0x56, 0x01, 0x85, 0x7d, 0x0d, 0x40, 0x51, 0x01,
  5493. 0xfe, 0x9e, 0x1e, 0x05, 0xfe, 0x3a, 0x03, 0x01, 0x0c, 0x06, 0x0d, 0x5d,
  5494. 0x46, 0x0d, 0x19, 0x00, 0xfe, 0x62, 0x10, 0x01, 0x76, 0x06, 0x12, 0xfe,
  5495. 0x5c, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x52, 0x13, 0xfe, 0x1c, 0x1c,
  5496. 0xfe, 0x9d, 0xf0, 0xfe, 0x8e, 0x0e, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0,
  5497. 0xfe, 0x94, 0x0e, 0x01, 0x0c, 0x61, 0x12, 0x44, 0xfe, 0x9f, 0x10, 0x19,
  5498. 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0d, 0x4f, 0xfe, 0x2e, 0x10, 0x19,
  5499. 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x19, 0xfe, 0x47, 0x00, 0xf1, 0x19,
  5500. 0xfe, 0x41, 0x00, 0xa2, 0x19, 0xfe, 0x24, 0x00, 0x86, 0xc4, 0xc5, 0x75,
  5501. 0x03, 0x81, 0x1e, 0x2b, 0xea, 0x4f, 0xfe, 0x04, 0xe6, 0x12, 0xfe, 0x9d,
  5502. 0x41, 0xfe, 0x1c, 0x42, 0x40, 0x01, 0xf4, 0x05, 0x35, 0xfe, 0x12, 0x1c,
  5503. 0x1f, 0x0d, 0x47, 0xb5, 0xc3, 0x1f, 0xfe, 0x31, 0x00, 0x47, 0xb8, 0x01,
  5504. 0xfe, 0xd4, 0x11, 0x05, 0xe9, 0x51, 0xfe, 0x06, 0xec, 0xe0, 0xfe, 0x0e,
  5505. 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0x06, 0xea, 0xe0,
  5506. 0xfe, 0x47, 0x4b, 0x45, 0xfe, 0x75, 0x57, 0x03, 0x67, 0xfe, 0x98, 0x56,
  5507. 0xfe, 0x38, 0x12, 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x44, 0x48, 0x60, 0x01,
  5508. 0x0c, 0x06, 0x28, 0xfe, 0x18, 0x13, 0x0a, 0x57, 0x01, 0x18, 0x3e, 0xfe,
  5509. 0x41, 0x58, 0x0a, 0xba, 0xfe, 0xfa, 0x14, 0xfe, 0x49, 0x54, 0xb0, 0xfe,
  5510. 0x5e, 0x0f, 0x05, 0xfe, 0x3a, 0x03, 0x0a, 0x67, 0xfe, 0xe0, 0x14, 0xfe,
  5511. 0x0e, 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0xce, 0x47,
  5512. 0xfe, 0xad, 0x13, 0x05, 0x35, 0x21, 0x2c, 0x09, 0x1a, 0xfe, 0x98, 0x12,
  5513. 0x26, 0x20, 0x96, 0x20, 0xe7, 0xfe, 0x08, 0x1c, 0xfe, 0x7c, 0x19, 0xfe,
  5514. 0xfd, 0x19, 0xfe, 0x0a, 0x1c, 0x03, 0xe5, 0xfe, 0x48, 0x55, 0xa5, 0x3b,
  5515. 0xfe, 0x62, 0x01, 0xfe, 0xc9, 0x55, 0x31, 0xfe, 0x74, 0x10, 0x01, 0xfe,
  5516. 0xf0, 0x1a, 0x03, 0xfe, 0x38, 0x01, 0x3b, 0xfe, 0x3a, 0x01, 0x8e, 0xfe,
  5517. 0x1e, 0x10, 0xfe, 0x02, 0xec, 0xe7, 0x53, 0x00, 0x36, 0xfe, 0x04, 0xec,
  5518. 0x2c, 0x60, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x62, 0x1b,
  5519. 0x01, 0xfe, 0xce, 0x1e, 0xb2, 0x11, 0xfe, 0x18, 0x13, 0xca, 0xfe, 0x02,
  5520. 0xea, 0xe7, 0x53, 0x92, 0xfe, 0xc3, 0x13, 0x1f, 0x12, 0x47, 0xb5, 0xc3,
  5521. 0xfe, 0x2a, 0x10, 0x03, 0xfe, 0x38, 0x01, 0x23, 0xfe, 0xf0, 0xff, 0x10,
  5522. 0xe5, 0x03, 0xfe, 0x3a, 0x01, 0x10, 0xfe, 0x62, 0x01, 0x01, 0xfe, 0x1e,
  5523. 0x1e, 0x20, 0x2c, 0x15, 0x56, 0x01, 0xfe, 0x9e, 0x1e, 0x13, 0x07, 0x02,
  5524. 0x26, 0x02, 0x21, 0x96, 0xc7, 0x20, 0x96, 0x09, 0x92, 0xfe, 0x79, 0x13,
  5525. 0x1f, 0x1d, 0x47, 0xb5, 0xc3, 0xfe, 0xe1, 0x10, 0xcf, 0xfe, 0x03, 0xdc,
  5526. 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xcf, 0xfe, 0x03, 0xdc, 0xfe,
  5527. 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x26, 0xfe,
  5528. 0x00, 0xcc, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x89, 0x02, 0x01, 0x0c, 0x06,
  5529. 0x4a, 0xfe, 0x4e, 0x13, 0x0f, 0xfe, 0x1c, 0x80, 0x04, 0xfe, 0x9c, 0x83,
  5530. 0x33, 0x0b, 0x0e, 0x09, 0x07, 0xfe, 0x3a, 0x13, 0x0f, 0xfe, 0x1e, 0x80,
  5531. 0x04, 0xfe, 0x9e, 0x83, 0x33, 0x0b, 0x0e, 0xfe, 0x2a, 0x13, 0x0f, 0xfe,
  5532. 0x1d, 0x80, 0x04, 0xfe, 0x9d, 0x83, 0xfe, 0xf9, 0x13, 0x0e, 0xfe, 0x1c,
  5533. 0x13, 0x01, 0xfe, 0xee, 0x1e, 0xac, 0xfe, 0x14, 0x13, 0x01, 0xfe, 0xfe,
  5534. 0x1e, 0xfe, 0x81, 0x58, 0xfa, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4,
  5535. 0x0d, 0xfe, 0x3c, 0x50, 0xa2, 0x01, 0xfe, 0x92, 0x1b, 0x01, 0x43, 0x09,
  5536. 0x56, 0xfb, 0x01, 0xfe, 0xc8, 0x1a, 0x01, 0x0c, 0x06, 0x28, 0xa4, 0x01,
  5537. 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x15, 0xfe, 0xe9, 0x00, 0x01,
  5538. 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13, 0x01, 0xfe, 0x22, 0x1b, 0xfe, 0x1e,
  5539. 0x1c, 0x0f, 0xfe, 0x14, 0x90, 0x04, 0xfe, 0x94, 0x93, 0x3a, 0x0b, 0xfe,
  5540. 0x96, 0x90, 0x04, 0xfe, 0x96, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0xfe, 0x64,
  5541. 0x01, 0x22, 0xfe, 0x66, 0x01, 0x01, 0x0c, 0x06, 0x65, 0xf9, 0x0f, 0xfe,
  5542. 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x0e, 0x77, 0xfe, 0x01,
  5543. 0xec, 0x2c, 0xfe, 0x80, 0x40, 0x20, 0x2c, 0x7a, 0x30, 0x15, 0xdf, 0x40,
  5544. 0x21, 0x2c, 0xfe, 0x00, 0x40, 0x8d, 0x2c, 0x02, 0xfe, 0x08, 0x1c, 0x03,
  5545. 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58, 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07,
  5546. 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00,
  5547. 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c, 0x2e, 0x49, 0x20, 0xe0, 0x26, 0x10,
  5548. 0x66, 0x10, 0x55, 0x10, 0x6f, 0x13, 0x57, 0x52, 0x4f, 0x1c, 0x28, 0xfe,
  5549. 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe, 0x88, 0x11, 0x46, 0x1a, 0x13,
  5550. 0x5a, 0x52, 0x1c, 0x4a, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe,
  5551. 0x9e, 0x11, 0x2e, 0x1a, 0x20, 0x2c, 0x90, 0x34, 0x60, 0x21, 0x2c, 0xfe,
  5552. 0x00, 0x40, 0x8d, 0x2c, 0x15, 0xdf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
  5553. 0xfe, 0xb2, 0x11, 0xfe, 0x12, 0x1c, 0x75, 0xfe, 0x14, 0x1c, 0xfe, 0x10,
  5554. 0x1c, 0xfe, 0x18, 0x1c, 0x02, 0x51, 0xfe, 0x0c, 0x14, 0xfe, 0x0e, 0x47,
  5555. 0xfe, 0x07, 0xe6, 0x28, 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x02, 0x01,
  5556. 0xa7, 0x90, 0x34, 0x60, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42,
  5557. 0x13, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x34, 0x13, 0x0a, 0x5a, 0x01,
  5558. 0x18, 0xcb, 0xfe, 0x36, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
  5559. 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f, 0x89,
  5560. 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x5c, 0x01, 0x85,
  5561. 0xf2, 0x09, 0x9b, 0xa4, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0xec,
  5562. 0x11, 0x02, 0xfe, 0x44, 0x58, 0x77, 0xfe, 0x01, 0xec, 0xb8, 0xfe, 0x9e,
  5563. 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x12, 0x8d, 0x30, 0x01,
  5564. 0xf4, 0xfe, 0xdd, 0x10, 0x37, 0xd7, 0x99, 0xd8, 0x9c, 0x27, 0x25, 0xee,
  5565. 0x09, 0x12, 0xfe, 0x48, 0x12, 0x09, 0x0d, 0xfe, 0x56, 0x12, 0x09, 0x1d,
  5566. 0xfe, 0x30, 0x12, 0x09, 0xdd, 0x1b, 0xfe, 0xc4, 0x13, 0x09, 0xfe, 0x23,
  5567. 0x00, 0x1b, 0xfe, 0xd0, 0x13, 0x09, 0x07, 0x1b, 0xfe, 0x34, 0x14, 0x09,
  5568. 0x24, 0xfe, 0x12, 0x12, 0x09, 0x00, 0x1b, 0x29, 0x1f, 0xdd, 0x01, 0x42,
  5569. 0xa1, 0x32, 0x01, 0x08, 0xae, 0x41, 0x02, 0x32, 0xfe, 0x62, 0x08, 0x0a,
  5570. 0xe1, 0x01, 0xfe, 0x58, 0x10, 0x15, 0x9b, 0x05, 0x35, 0x32, 0x01, 0x43,
  5571. 0x09, 0xbb, 0xfe, 0xd7, 0x13, 0x91, 0x4b, 0x7e, 0x4c, 0x8e, 0xfe, 0x80,
  5572. 0x13, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x72, 0x12, 0xdb, 0x64, 0xdc, 0x34,
  5573. 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xb0, 0xfe, 0x4a, 0x13, 0x21, 0x6e,
  5574. 0xfe, 0x26, 0x13, 0x03, 0x97, 0x3b, 0x98, 0x8e, 0xfe, 0xb6, 0x0e, 0x10,
  5575. 0x6a, 0x22, 0x6b, 0x26, 0x10, 0x97, 0x10, 0x98, 0x01, 0xc2, 0x2e, 0x49,
  5576. 0x88, 0x20, 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
  5577. 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x64, 0xfe, 0x05, 0xfa,
  5578. 0x34, 0xfe, 0x8f, 0x10, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x40, 0x56, 0xfe,
  5579. 0xe1, 0x56, 0x10, 0x6c, 0x22, 0x6d, 0x71, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
  5580. 0x44, 0x55, 0xfe, 0xe5, 0x55, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x00, 0x56,
  5581. 0xfe, 0xa1, 0x56, 0x10, 0x68, 0x22, 0x69, 0x01, 0x0c, 0x06, 0x54, 0xf9,
  5582. 0x21, 0x6e, 0xfe, 0x1f, 0x40, 0x03, 0x6a, 0x3b, 0x6b, 0xfe, 0x2c, 0x50,
  5583. 0xfe, 0xae, 0x50, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x44, 0x50, 0xfe, 0xc6,
  5584. 0x50, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03,
  5585. 0x4b, 0x3b, 0x4c, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x05, 0x73, 0x2e,
  5586. 0x07, 0x20, 0x9e, 0x05, 0x72, 0x32, 0x01, 0x08, 0x16, 0x3d, 0x27, 0x25,
  5587. 0xee, 0x09, 0x07, 0x2b, 0x3d, 0x01, 0x43, 0x09, 0xbb, 0x2b, 0x72, 0x01,
  5588. 0xa6, 0x23, 0x3f, 0x1b, 0x3d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1e, 0x13,
  5589. 0x91, 0x4b, 0x7e, 0x4c, 0xfe, 0x0a, 0x55, 0x31, 0xfe, 0x8b, 0x55, 0xd9,
  5590. 0x4b, 0xda, 0x4c, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x05, 0x72, 0x01,
  5591. 0xfe, 0x8e, 0x1e, 0xca, 0xfe, 0x19, 0x41, 0x05, 0x72, 0x32, 0x01, 0x08,
  5592. 0x2a, 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbe, 0x2d, 0x1d, 0xc0, 0x2d, 0x0d,
  5593. 0x83, 0x2d, 0x7f, 0x1b, 0xfe, 0x66, 0x15, 0x05, 0x3d, 0x01, 0x08, 0x2a,
  5594. 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbd, 0x09, 0x1d, 0x2b, 0x3d, 0x01, 0x08,
  5595. 0x16, 0xc0, 0x27, 0x25, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x50, 0x03,
  5596. 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa1, 0xfe, 0xbb, 0x45,
  5597. 0x2d, 0x00, 0xa4, 0x46, 0x07, 0x90, 0x3f, 0x01, 0xfe, 0xf8, 0x15, 0x01,
  5598. 0xa6, 0x86, 0xfe, 0x4b, 0x45, 0xfe, 0x20, 0x13, 0x01, 0x43, 0x09, 0x82,
  5599. 0xfe, 0x16, 0x13, 0x03, 0x9a, 0x1e, 0x5d, 0x03, 0x55, 0x1e, 0x31, 0x5e,
  5600. 0x05, 0x72, 0xfe, 0xc0, 0x5d, 0x01, 0xa7, 0xfe, 0x03, 0x17, 0x03, 0x66,
  5601. 0x8a, 0x10, 0x66, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01, 0xfe, 0x56,
  5602. 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d, 0x27, 0x25, 0xbd,
  5603. 0x09, 0x07, 0x2b, 0x3d, 0x01, 0xfe, 0xbe, 0x16, 0xfe, 0x42, 0x58, 0xfe,
  5604. 0xe8, 0x14, 0x01, 0xa6, 0x86, 0xfe, 0x4a, 0xf4, 0x0d, 0x1b, 0x3d, 0xfe,
  5605. 0x4a, 0xf4, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05,
  5606. 0x72, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73,
  5607. 0x01, 0xfe, 0x84, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d,
  5608. 0x27, 0x25, 0xbd, 0x09, 0x12, 0x2b, 0x3d, 0x01, 0xfe, 0xe8, 0x17, 0x8b,
  5609. 0xfe, 0xaa, 0x14, 0xfe, 0xb6, 0x14, 0x86, 0xa8, 0xb2, 0x0d, 0x1b, 0x3d,
  5610. 0xb2, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05, 0x72,
  5611. 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01,
  5612. 0xfe, 0xc0, 0x19, 0x05, 0x73, 0x13, 0x07, 0x2f, 0xfe, 0xcc, 0x15, 0x17,
  5613. 0xfe, 0xe2, 0x15, 0x5f, 0xcc, 0x01, 0x08, 0x26, 0x5f, 0x02, 0x8f, 0xfe,
  5614. 0xde, 0x15, 0x2a, 0xfe, 0xde, 0x15, 0x16, 0xfe, 0xcc, 0x15, 0x5e, 0x32,
  5615. 0x01, 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
  5616. 0xad, 0x23, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02,
  5617. 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0x23, 0x3f, 0xfe, 0x30,
  5618. 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
  5619. 0xad, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xfe, 0x00, 0x5e,
  5620. 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0xfe, 0x0b, 0x58,
  5621. 0x02, 0x0a, 0x66, 0x01, 0x5c, 0x0a, 0x55, 0x01, 0x5c, 0x0a, 0x6f, 0x01,
  5622. 0x5c, 0x02, 0x01, 0xfe, 0x1e, 0x1f, 0x23, 0x1a, 0xff, 0x03, 0x00, 0x54,
  5623. 0xfe, 0x00, 0xf4, 0x24, 0x52, 0x0f, 0xfe, 0x00, 0x7c, 0x04, 0xfe, 0x07,
  5624. 0x7c, 0x3a, 0x0b, 0x0e, 0xfe, 0x00, 0x71, 0xfe, 0xf9, 0x18, 0xfe, 0x7a,
  5625. 0x19, 0xfe, 0xfb, 0x19, 0xfe, 0x1a, 0xf7, 0x00, 0xfe, 0x1b, 0xf7, 0x00,
  5626. 0x7a, 0x30, 0x10, 0x68, 0x22, 0x69, 0xd9, 0x6c, 0xda, 0x6d, 0x02, 0xfe,
  5627. 0x62, 0x08, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x77,
  5628. 0x02, 0x01, 0xc6, 0xfe, 0x42, 0x48, 0x4f, 0x50, 0x45, 0x01, 0x08, 0x16,
  5629. 0xfe, 0xe0, 0x17, 0x27, 0x25, 0xbe, 0x01, 0x08, 0x16, 0xfe, 0xe0, 0x17,
  5630. 0x27, 0x25, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0x9a, 0x1e, 0xfe,
  5631. 0xda, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfe, 0xd0, 0x13, 0x26, 0x53, 0x12,
  5632. 0x48, 0xfe, 0x08, 0x17, 0xd1, 0x12, 0x53, 0x12, 0xfe, 0x1e, 0x13, 0x2d,
  5633. 0xb4, 0x7b, 0xfe, 0x26, 0x17, 0x4d, 0x13, 0x07, 0x1c, 0xb4, 0x90, 0x04,
  5634. 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xf1, 0xff, 0x02, 0x83, 0x55,
  5635. 0x53, 0x1d, 0xfe, 0x12, 0x13, 0xd6, 0xfe, 0x30, 0x00, 0xb0, 0xfe, 0x80,
  5636. 0x17, 0x1c, 0x63, 0x13, 0x07, 0xfe, 0x56, 0x10, 0x53, 0x0d, 0xfe, 0x16,
  5637. 0x13, 0xd6, 0xfe, 0x64, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0x64,
  5638. 0x00, 0x1c, 0x94, 0x13, 0x07, 0xfe, 0x28, 0x10, 0x53, 0x07, 0xfe, 0x60,
  5639. 0x13, 0xd6, 0xfe, 0xc8, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0xc8,
  5640. 0x00, 0x1c, 0x95, 0x13, 0x07, 0x71, 0xd6, 0xfe, 0x90, 0x01, 0x48, 0xfe,
  5641. 0x8c, 0x17, 0x45, 0xf3, 0xfe, 0x43, 0xf4, 0x96, 0xfe, 0x56, 0xf0, 0xfe,
  5642. 0x9e, 0x17, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x43, 0xf4, 0x94, 0xf6, 0x8b,
  5643. 0x01, 0xfe, 0x24, 0x16, 0x23, 0x3f, 0xfc, 0xa8, 0x8c, 0x49, 0x48, 0xfe,
  5644. 0xda, 0x17, 0x62, 0x49, 0xfe, 0x1c, 0x10, 0xa8, 0x8c, 0x80, 0x48, 0xfe,
  5645. 0xda, 0x17, 0x62, 0x80, 0x71, 0x50, 0x26, 0xfe, 0x4d, 0xf4, 0x00, 0xf7,
  5646. 0x45, 0x13, 0x07, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58, 0x02, 0x50, 0x13,
  5647. 0x0d, 0x02, 0x50, 0x3e, 0x78, 0x4f, 0x45, 0x01, 0x08, 0x16, 0xa9, 0x27,
  5648. 0x25, 0xbe, 0xfe, 0x03, 0xea, 0xfe, 0x7e, 0x01, 0x01, 0x08, 0x16, 0xa9,
  5649. 0x27, 0x25, 0xfe, 0xe9, 0x0a, 0x01, 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe,
  5650. 0xe9, 0x0a, 0xfe, 0x05, 0xea, 0xfe, 0x7f, 0x01, 0x01, 0x08, 0x16, 0xa9,
  5651. 0x27, 0x25, 0xfe, 0x69, 0x09, 0xfe, 0x02, 0xea, 0xfe, 0x80, 0x01, 0x01,
  5652. 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe, 0xe8, 0x08, 0x47, 0xfe, 0x81, 0x01,
  5653. 0x03, 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa2, 0x78, 0xf2,
  5654. 0x53, 0x07, 0x36, 0xfe, 0x34, 0xf4, 0x3f, 0xa1, 0x78, 0x03, 0x9a, 0x1e,
  5655. 0x83, 0x01, 0x38, 0x06, 0x12, 0x31, 0xf0, 0x4f, 0x45, 0xfe, 0x90, 0x10,
  5656. 0xfe, 0x40, 0x5a, 0x23, 0x3f, 0xfb, 0x8c, 0x49, 0x48, 0xfe, 0xaa, 0x18,
  5657. 0x62, 0x49, 0x71, 0x8c, 0x80, 0x48, 0xfe, 0xaa, 0x18, 0x62, 0x80, 0xfe,
  5658. 0xb4, 0x56, 0xfe, 0x40, 0x5d, 0x01, 0xc6, 0x01, 0xfe, 0xac, 0x1d, 0xfe,
  5659. 0x02, 0x17, 0xfe, 0xc8, 0x45, 0xfe, 0x5a, 0xf0, 0xfe, 0xc0, 0x18, 0xfe,
  5660. 0x43, 0x48, 0x2d, 0x93, 0x36, 0xfe, 0x34, 0xf4, 0xfe, 0x00, 0x11, 0xfe,
  5661. 0x40, 0x10, 0x2d, 0xb4, 0x36, 0xfe, 0x34, 0xf4, 0x04, 0xfe, 0x34, 0x10,
  5662. 0x2d, 0xfe, 0x0b, 0x00, 0x36, 0x46, 0x63, 0xfe, 0x28, 0x10, 0xfe, 0xc0,
  5663. 0x49, 0xff, 0x02, 0x00, 0x54, 0xb2, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0xfa,
  5664. 0x18, 0x45, 0xfe, 0x1c, 0xf4, 0x3f, 0xf3, 0xfe, 0x40, 0xf4, 0x96, 0xfe,
  5665. 0x56, 0xf0, 0xfe, 0x0c, 0x19, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x40, 0xf4,
  5666. 0x94, 0xf6, 0x3e, 0x2d, 0x93, 0x4e, 0xd0, 0x0d, 0x21, 0xfe, 0x7f, 0x01,
  5667. 0xfe, 0xc8, 0x46, 0xfe, 0x24, 0x13, 0x8c, 0x00, 0x5d, 0x26, 0x21, 0xfe,
  5668. 0x7e, 0x01, 0xfe, 0xc8, 0x45, 0xfe, 0x14, 0x13, 0x21, 0xfe, 0x80, 0x01,
  5669. 0xfe, 0x48, 0x45, 0xfa, 0x21, 0xfe, 0x81, 0x01, 0xfe, 0xc8, 0x44, 0x4e,
  5670. 0x26, 0x02, 0x13, 0x07, 0x02, 0x78, 0x45, 0x50, 0x13, 0x0d, 0x02, 0x14,
  5671. 0x07, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x14, 0x0d, 0x01, 0x08, 0x17,
  5672. 0xfe, 0x82, 0x19, 0x14, 0x1d, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x5f,
  5673. 0xfe, 0x89, 0x49, 0x01, 0x08, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
  5674. 0x14, 0x1d, 0x01, 0x08, 0x17, 0xc1, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
  5675. 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0xc1, 0x5f, 0xfe, 0x89, 0x4a, 0x01,
  5676. 0x08, 0x02, 0x50, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0x74, 0x14, 0x7f,
  5677. 0x01, 0x08, 0x17, 0x74, 0x14, 0x12, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x89,
  5678. 0x49, 0x01, 0x08, 0x17, 0x74, 0x14, 0x00, 0x01, 0x08, 0x17, 0x74, 0xfe,
  5679. 0x89, 0x4a, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x09, 0x49, 0x01, 0x08, 0x17,
  5680. 0x74, 0x5f, 0xcc, 0x01, 0x08, 0x02, 0x21, 0xe4, 0x09, 0x07, 0xfe, 0x4c,
  5681. 0x13, 0xc8, 0x20, 0xe4, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x5f, 0xa1, 0x5e,
  5682. 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f,
  5683. 0xfe, 0x3e, 0x1a, 0x01, 0x43, 0x09, 0xfe, 0xe3, 0x00, 0xfe, 0x22, 0x13,
  5684. 0x16, 0xfe, 0x64, 0x1a, 0x26, 0x20, 0x9e, 0x01, 0x41, 0x21, 0x9e, 0x09,
  5685. 0x07, 0x5d, 0x01, 0x0c, 0x61, 0x07, 0x44, 0x02, 0x0a, 0x5a, 0x01, 0x18,
  5686. 0xfe, 0x00, 0x40, 0xaa, 0x09, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01,
  5687. 0x18, 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x9d, 0x01, 0x18, 0xaa,
  5688. 0xfe, 0x80, 0xe7, 0x1a, 0x09, 0x1a, 0x5d, 0xfe, 0x45, 0x58, 0x01, 0xfe,
  5689. 0xb2, 0x16, 0xaa, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0xaa, 0x0a, 0x67, 0x01,
  5690. 0xa3, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x01, 0xfe, 0x7e, 0x1e, 0xfe, 0x80,
  5691. 0x4c, 0xfe, 0x49, 0xe4, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01, 0x18,
  5692. 0xfe, 0x80, 0x4c, 0x0a, 0x67, 0x01, 0x5c, 0x02, 0x1c, 0x1a, 0x87, 0x7c,
  5693. 0xe5, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24, 0x1c, 0xfe, 0x1d,
  5694. 0xf7, 0x28, 0xb1, 0xfe, 0x04, 0x1b, 0x01, 0xfe, 0x2a, 0x1c, 0xfa, 0xb3,
  5695. 0x28, 0x7c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x02, 0xc9, 0x2b, 0xfe,
  5696. 0xf4, 0x1a, 0xfe, 0xfa, 0x10, 0x1c, 0x1a, 0x87, 0x03, 0xfe, 0x64, 0x01,
  5697. 0xfe, 0x00, 0xf4, 0x24, 0xfe, 0x18, 0x58, 0x03, 0xfe, 0x66, 0x01, 0xfe,
  5698. 0x19, 0x58, 0xb3, 0x24, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4, 0x07,
  5699. 0xfe, 0x3c, 0x50, 0x7c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c,
  5700. 0xf7, 0x24, 0xb1, 0xfe, 0x50, 0x1b, 0xfe, 0xd4, 0x14, 0x31, 0x02, 0xc9,
  5701. 0x2b, 0xfe, 0x26, 0x1b, 0xfe, 0xba, 0x10, 0x1c, 0x1a, 0x87, 0xfe, 0x83,
  5702. 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x54, 0xb1,
  5703. 0xfe, 0x72, 0x1b, 0xfe, 0xb2, 0x14, 0xfc, 0xb3, 0x54, 0x7c, 0x12, 0xfe,
  5704. 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x02, 0xc9, 0x2b, 0xfe, 0x66, 0x1b,
  5705. 0xfe, 0x8a, 0x10, 0x1c, 0x1a, 0x87, 0x8b, 0x0f, 0xfe, 0x30, 0x90, 0x04,
  5706. 0xfe, 0xb0, 0x93, 0x3a, 0x0b, 0xfe, 0x18, 0x58, 0xfe, 0x32, 0x90, 0x04,
  5707. 0xfe, 0xb2, 0x93, 0x3a, 0x0b, 0xfe, 0x19, 0x58, 0x0e, 0xa8, 0xb3, 0x4a,
  5708. 0x7c, 0x12, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x4a, 0xb1, 0xfe, 0xc6,
  5709. 0x1b, 0xfe, 0x5e, 0x14, 0x31, 0x02, 0xc9, 0x2b, 0xfe, 0x96, 0x1b, 0x5c,
  5710. 0xfe, 0x02, 0xf6, 0x1a, 0x87, 0xfe, 0x18, 0xfe, 0x6a, 0xfe, 0x19, 0xfe,
  5711. 0x6b, 0x01, 0xfe, 0x1e, 0x1f, 0xfe, 0x1d, 0xf7, 0x65, 0xb1, 0xfe, 0xee,
  5712. 0x1b, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13, 0xb3, 0x65, 0x3e, 0xfe, 0x83,
  5713. 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x1a, 0xfe, 0x81, 0xe7, 0x1a,
  5714. 0x15, 0xfe, 0xdd, 0x00, 0x7a, 0x30, 0x02, 0x7a, 0x30, 0xfe, 0x12, 0x45,
  5715. 0x2b, 0xfe, 0xdc, 0x1b, 0x1f, 0x07, 0x47, 0xb5, 0xc3, 0x05, 0x35, 0xfe,
  5716. 0x39, 0xf0, 0x75, 0x26, 0x02, 0xfe, 0x7e, 0x18, 0x23, 0x1d, 0x36, 0x13,
  5717. 0x11, 0x02, 0x87, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0xef, 0x12, 0xfe, 0xe1,
  5718. 0x10, 0x90, 0x34, 0x60, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x3c, 0x13,
  5719. 0xfe, 0x82, 0x14, 0xfe, 0x42, 0x13, 0x51, 0xfe, 0x06, 0x83, 0x0a, 0x5a,
  5720. 0x01, 0x18, 0xcb, 0xfe, 0x3e, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48,
  5721. 0x01, 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f,
  5722. 0x89, 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x4c, 0x01,
  5723. 0x85, 0xfe, 0x16, 0x10, 0x09, 0x9b, 0x4e, 0xfe, 0x40, 0x14, 0xfe, 0x24,
  5724. 0x12, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x52, 0x1c, 0x1c, 0x0d,
  5725. 0x02, 0xfe, 0x9c, 0xe7, 0x0d, 0x19, 0xfe, 0x15, 0x00, 0x40, 0x8d, 0x30,
  5726. 0x01, 0xf4, 0x1c, 0x07, 0x02, 0x51, 0xfe, 0x06, 0x83, 0xfe, 0x18, 0x80,
  5727. 0x61, 0x28, 0x44, 0x15, 0x56, 0x01, 0x85, 0x1c, 0x07, 0x02, 0xfe, 0x38,
  5728. 0x90, 0xfe, 0xba, 0x90, 0x91, 0xde, 0x7e, 0xdf, 0xfe, 0x48, 0x55, 0x31,
  5729. 0xfe, 0xc9, 0x55, 0x02, 0x21, 0xb9, 0x88, 0x20, 0xb9, 0x02, 0x0a, 0xba,
  5730. 0x01, 0x18, 0xfe, 0x41, 0x48, 0x0a, 0x57, 0x01, 0x18, 0xfe, 0x49, 0x44,
  5731. 0x1b, 0xfe, 0x1e, 0x1d, 0x88, 0x89, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x09,
  5732. 0x1a, 0xa4, 0x0a, 0x67, 0x01, 0xa3, 0x0a, 0x57, 0x01, 0x18, 0x88, 0x89,
  5733. 0x02, 0xfe, 0x4e, 0xe4, 0x1d, 0x7b, 0xfe, 0x52, 0x1d, 0x03, 0xfe, 0x90,
  5734. 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe, 0x4e, 0xe4, 0xdd, 0x7b,
  5735. 0xfe, 0x64, 0x1d, 0x03, 0xfe, 0x92, 0x00, 0xd1, 0x12, 0xfe, 0x1a, 0x10,
  5736. 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x7b, 0xfe, 0x76, 0x1d, 0x03, 0xfe,
  5737. 0x94, 0x00, 0xd1, 0x24, 0xfe, 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xd1,
  5738. 0x63, 0xfe, 0x4e, 0x45, 0x83, 0xca, 0xff, 0x04, 0x68, 0x54, 0xfe, 0xf1,
  5739. 0x10, 0x23, 0x49, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c,
  5740. 0xfe, 0x1a, 0xf4, 0xfe, 0x00, 0x04, 0x83, 0xb2, 0x1d, 0x48, 0xfe, 0xaa,
  5741. 0x1d, 0x13, 0x1d, 0x02, 0x09, 0x92, 0xfe, 0x5a, 0xf0, 0xfe, 0xba, 0x1d,
  5742. 0x2e, 0x93, 0xfe, 0x34, 0x10, 0x09, 0x12, 0xfe, 0x5a, 0xf0, 0xfe, 0xc8,
  5743. 0x1d, 0x2e, 0xb4, 0xfe, 0x26, 0x10, 0x09, 0x1d, 0x36, 0x2e, 0x63, 0xfe,
  5744. 0x1a, 0x10, 0x09, 0x0d, 0x36, 0x2e, 0x94, 0xf2, 0x09, 0x07, 0x36, 0x2e,
  5745. 0x95, 0xa1, 0xc8, 0x02, 0x1f, 0x93, 0x01, 0x42, 0xfe, 0x04, 0xfe, 0x99,
  5746. 0x03, 0x9c, 0x8b, 0x02, 0x2a, 0xfe, 0x1c, 0x1e, 0xfe, 0x14, 0xf0, 0x08,
  5747. 0x2f, 0xfe, 0x0c, 0x1e, 0x2a, 0xfe, 0x1c, 0x1e, 0x8f, 0xfe, 0x1c, 0x1e,
  5748. 0xfe, 0x82, 0xf0, 0xfe, 0x10, 0x1e, 0x02, 0x0f, 0x3f, 0x04, 0xfe, 0x80,
  5749. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x18, 0x80, 0x04, 0xfe, 0x98,
  5750. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x02, 0x80, 0x04, 0xfe, 0x82,
  5751. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x80, 0x04, 0xfe, 0x86,
  5752. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x1b, 0x80, 0x04, 0xfe, 0x9b,
  5753. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x04, 0x80, 0x04, 0xfe, 0x84,
  5754. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x80, 0x80, 0x04, 0xfe, 0x80,
  5755. 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x19, 0x81, 0x04,
  5756. 0xfe, 0x99, 0x83, 0xfe, 0xca, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06,
  5757. 0x83, 0x04, 0xfe, 0x86, 0x83, 0xfe, 0xce, 0x47, 0x0b, 0x0e, 0x02, 0x0f,
  5758. 0xfe, 0x2c, 0x90, 0x04, 0xfe, 0xac, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  5759. 0xfe, 0xae, 0x90, 0x04, 0xfe, 0xae, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  5760. 0xfe, 0x08, 0x90, 0x04, 0xfe, 0x88, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  5761. 0xfe, 0x8a, 0x90, 0x04, 0xfe, 0x8a, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  5762. 0xfe, 0x0c, 0x90, 0x04, 0xfe, 0x8c, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  5763. 0xfe, 0x8e, 0x90, 0x04, 0xfe, 0x8e, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  5764. 0xfe, 0x3c, 0x90, 0x04, 0xfe, 0xbc, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x8b,
  5765. 0x0f, 0xfe, 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x77, 0x0e,
  5766. 0xa8, 0x02, 0xff, 0x66, 0x00, 0x00,
  5767. };
  5768. static unsigned short _adv_asc38C1600_size = sizeof(_adv_asc38C1600_buf); /* 0x1673 */
  5769. static ADV_DCNT _adv_asc38C1600_chksum = 0x0604EF77UL; /* Expanded little-endian checksum. */
  5770. static void AscInitQLinkVar(ASC_DVC_VAR *asc_dvc)
  5771. {
  5772. PortAddr iop_base;
  5773. int i;
  5774. ushort lram_addr;
  5775. iop_base = asc_dvc->iop_base;
  5776. AscPutRiscVarFreeQHead(iop_base, 1);
  5777. AscPutRiscVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  5778. AscPutVarFreeQHead(iop_base, 1);
  5779. AscPutVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  5780. AscWriteLramByte(iop_base, ASCV_BUSY_QHEAD_B,
  5781. (uchar)((int)asc_dvc->max_total_qng + 1));
  5782. AscWriteLramByte(iop_base, ASCV_DISC1_QHEAD_B,
  5783. (uchar)((int)asc_dvc->max_total_qng + 2));
  5784. AscWriteLramByte(iop_base, (ushort)ASCV_TOTAL_READY_Q_B,
  5785. asc_dvc->max_total_qng);
  5786. AscWriteLramWord(iop_base, ASCV_ASCDVC_ERR_CODE_W, 0);
  5787. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  5788. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, 0);
  5789. AscWriteLramByte(iop_base, ASCV_SCSIBUSY_B, 0);
  5790. AscWriteLramByte(iop_base, ASCV_WTM_FLAG_B, 0);
  5791. AscPutQDoneInProgress(iop_base, 0);
  5792. lram_addr = ASC_QADR_BEG;
  5793. for (i = 0; i < 32; i++, lram_addr += 2) {
  5794. AscWriteLramWord(iop_base, lram_addr, 0);
  5795. }
  5796. }
  5797. static ushort AscInitMicroCodeVar(ASC_DVC_VAR *asc_dvc)
  5798. {
  5799. int i;
  5800. ushort warn_code;
  5801. PortAddr iop_base;
  5802. ASC_PADDR phy_addr;
  5803. ASC_DCNT phy_size;
  5804. iop_base = asc_dvc->iop_base;
  5805. warn_code = 0;
  5806. for (i = 0; i <= ASC_MAX_TID; i++) {
  5807. AscPutMCodeInitSDTRAtID(iop_base, i,
  5808. asc_dvc->cfg->sdtr_period_offset[i]);
  5809. }
  5810. AscInitQLinkVar(asc_dvc);
  5811. AscWriteLramByte(iop_base, ASCV_DISC_ENABLE_B,
  5812. asc_dvc->cfg->disc_enable);
  5813. AscWriteLramByte(iop_base, ASCV_HOSTSCSI_ID_B,
  5814. ASC_TID_TO_TARGET_ID(asc_dvc->cfg->chip_scsi_id));
  5815. /* Align overrun buffer on an 8 byte boundary. */
  5816. phy_addr = virt_to_bus(asc_dvc->cfg->overrun_buf);
  5817. phy_addr = cpu_to_le32((phy_addr + 7) & ~0x7);
  5818. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_PADDR_D,
  5819. (uchar *)&phy_addr, 1);
  5820. phy_size = cpu_to_le32(ASC_OVERRUN_BSIZE - 8);
  5821. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_BSIZE_D,
  5822. (uchar *)&phy_size, 1);
  5823. asc_dvc->cfg->mcode_date =
  5824. AscReadLramWord(iop_base, (ushort)ASCV_MC_DATE_W);
  5825. asc_dvc->cfg->mcode_version =
  5826. AscReadLramWord(iop_base, (ushort)ASCV_MC_VER_W);
  5827. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  5828. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  5829. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  5830. return warn_code;
  5831. }
  5832. if (AscStartChip(iop_base) != 1) {
  5833. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  5834. return warn_code;
  5835. }
  5836. return warn_code;
  5837. }
  5838. static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
  5839. {
  5840. ushort warn_code;
  5841. PortAddr iop_base;
  5842. iop_base = asc_dvc->iop_base;
  5843. warn_code = 0;
  5844. if ((asc_dvc->dvc_cntl & ASC_CNTL_RESET_SCSI) &&
  5845. !(asc_dvc->init_state & ASC_INIT_RESET_SCSI_DONE)) {
  5846. AscResetChipAndScsiBus(asc_dvc);
  5847. mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
  5848. }
  5849. asc_dvc->init_state |= ASC_INIT_STATE_BEG_LOAD_MC;
  5850. if (asc_dvc->err_code != 0)
  5851. return UW_ERR;
  5852. if (!AscFindSignature(asc_dvc->iop_base)) {
  5853. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  5854. return warn_code;
  5855. }
  5856. AscDisableInterrupt(iop_base);
  5857. warn_code |= AscInitLram(asc_dvc);
  5858. if (asc_dvc->err_code != 0)
  5859. return UW_ERR;
  5860. ASC_DBG(1, "_asc_mcode_chksum 0x%lx\n", (ulong)_asc_mcode_chksum);
  5861. if (AscLoadMicroCode(iop_base, 0, _asc_mcode_buf,
  5862. _asc_mcode_size) != _asc_mcode_chksum) {
  5863. asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
  5864. return warn_code;
  5865. }
  5866. warn_code |= AscInitMicroCodeVar(asc_dvc);
  5867. asc_dvc->init_state |= ASC_INIT_STATE_END_LOAD_MC;
  5868. AscEnableInterrupt(iop_base);
  5869. return warn_code;
  5870. }
  5871. /*
  5872. * Load the Microcode
  5873. *
  5874. * Write the microcode image to RISC memory starting at address 0.
  5875. *
  5876. * The microcode is stored compressed in the following format:
  5877. *
  5878. * 254 word (508 byte) table indexed by byte code followed
  5879. * by the following byte codes:
  5880. *
  5881. * 1-Byte Code:
  5882. * 00: Emit word 0 in table.
  5883. * 01: Emit word 1 in table.
  5884. * .
  5885. * FD: Emit word 253 in table.
  5886. *
  5887. * Multi-Byte Code:
  5888. * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
  5889. * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
  5890. *
  5891. * Returns 0 or an error if the checksum doesn't match
  5892. */
  5893. static int AdvLoadMicrocode(AdvPortAddr iop_base, unsigned char *buf, int size,
  5894. int memsize, int chksum)
  5895. {
  5896. int i, j, end, len = 0;
  5897. ADV_DCNT sum;
  5898. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  5899. for (i = 253 * 2; i < size; i++) {
  5900. if (buf[i] == 0xff) {
  5901. unsigned short word = (buf[i + 3] << 8) | buf[i + 2];
  5902. for (j = 0; j < buf[i + 1]; j++) {
  5903. AdvWriteWordAutoIncLram(iop_base, word);
  5904. len += 2;
  5905. }
  5906. i += 3;
  5907. } else if (buf[i] == 0xfe) {
  5908. unsigned short word = (buf[i + 2] << 8) | buf[i + 1];
  5909. AdvWriteWordAutoIncLram(iop_base, word);
  5910. i += 2;
  5911. len += 2;
  5912. } else {
  5913. unsigned char off = buf[i] * 2;
  5914. unsigned short word = (buf[off + 1] << 8) | buf[off];
  5915. AdvWriteWordAutoIncLram(iop_base, word);
  5916. len += 2;
  5917. }
  5918. }
  5919. end = len;
  5920. while (len < memsize) {
  5921. AdvWriteWordAutoIncLram(iop_base, 0);
  5922. len += 2;
  5923. }
  5924. /* Verify the microcode checksum. */
  5925. sum = 0;
  5926. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  5927. for (len = 0; len < end; len += 2) {
  5928. sum += AdvReadWordAutoIncLram(iop_base);
  5929. }
  5930. if (sum != chksum)
  5931. return ASC_IERR_MCODE_CHKSUM;
  5932. return 0;
  5933. }
  5934. static void AdvBuildCarrierFreelist(struct adv_dvc_var *asc_dvc)
  5935. {
  5936. ADV_CARR_T *carrp;
  5937. ADV_SDCNT buf_size;
  5938. ADV_PADDR carr_paddr;
  5939. carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
  5940. asc_dvc->carr_freelist = NULL;
  5941. if (carrp == asc_dvc->carrier_buf) {
  5942. buf_size = ADV_CARRIER_BUFSIZE;
  5943. } else {
  5944. buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
  5945. }
  5946. do {
  5947. /* Get physical address of the carrier 'carrp'. */
  5948. carr_paddr = cpu_to_le32(virt_to_bus(carrp));
  5949. buf_size -= sizeof(ADV_CARR_T);
  5950. carrp->carr_pa = carr_paddr;
  5951. carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
  5952. /*
  5953. * Insert the carrier at the beginning of the freelist.
  5954. */
  5955. carrp->next_vpa =
  5956. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  5957. asc_dvc->carr_freelist = carrp;
  5958. carrp++;
  5959. } while (buf_size > 0);
  5960. }
  5961. /*
  5962. * Send an idle command to the chip and wait for completion.
  5963. *
  5964. * Command completion is polled for once per microsecond.
  5965. *
  5966. * The function can be called from anywhere including an interrupt handler.
  5967. * But the function is not re-entrant, so it uses the DvcEnter/LeaveCritical()
  5968. * functions to prevent reentrancy.
  5969. *
  5970. * Return Values:
  5971. * ADV_TRUE - command completed successfully
  5972. * ADV_FALSE - command failed
  5973. * ADV_ERROR - command timed out
  5974. */
  5975. static int
  5976. AdvSendIdleCmd(ADV_DVC_VAR *asc_dvc,
  5977. ushort idle_cmd, ADV_DCNT idle_cmd_parameter)
  5978. {
  5979. int result;
  5980. ADV_DCNT i, j;
  5981. AdvPortAddr iop_base;
  5982. iop_base = asc_dvc->iop_base;
  5983. /*
  5984. * Clear the idle command status which is set by the microcode
  5985. * to a non-zero value to indicate when the command is completed.
  5986. * The non-zero result is one of the IDLE_CMD_STATUS_* values
  5987. */
  5988. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS, (ushort)0);
  5989. /*
  5990. * Write the idle command value after the idle command parameter
  5991. * has been written to avoid a race condition. If the order is not
  5992. * followed, the microcode may process the idle command before the
  5993. * parameters have been written to LRAM.
  5994. */
  5995. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IDLE_CMD_PARAMETER,
  5996. cpu_to_le32(idle_cmd_parameter));
  5997. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD, idle_cmd);
  5998. /*
  5999. * Tickle the RISC to tell it to process the idle command.
  6000. */
  6001. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_B);
  6002. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  6003. /*
  6004. * Clear the tickle value. In the ASC-3550 the RISC flag
  6005. * command 'clr_tickle_b' does not work unless the host
  6006. * value is cleared.
  6007. */
  6008. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
  6009. }
  6010. /* Wait for up to 100 millisecond for the idle command to timeout. */
  6011. for (i = 0; i < SCSI_WAIT_100_MSEC; i++) {
  6012. /* Poll once each microsecond for command completion. */
  6013. for (j = 0; j < SCSI_US_PER_MSEC; j++) {
  6014. AdvReadWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS,
  6015. result);
  6016. if (result != 0)
  6017. return result;
  6018. udelay(1);
  6019. }
  6020. }
  6021. BUG(); /* The idle command should never timeout. */
  6022. return ADV_ERROR;
  6023. }
  6024. /*
  6025. * Reset SCSI Bus and purge all outstanding requests.
  6026. *
  6027. * Return Value:
  6028. * ADV_TRUE(1) - All requests are purged and SCSI Bus is reset.
  6029. * ADV_FALSE(0) - Microcode command failed.
  6030. * ADV_ERROR(-1) - Microcode command timed-out. Microcode or IC
  6031. * may be hung which requires driver recovery.
  6032. */
  6033. static int AdvResetSB(ADV_DVC_VAR *asc_dvc)
  6034. {
  6035. int status;
  6036. /*
  6037. * Send the SCSI Bus Reset idle start idle command which asserts
  6038. * the SCSI Bus Reset signal.
  6039. */
  6040. status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_START, 0L);
  6041. if (status != ADV_TRUE) {
  6042. return status;
  6043. }
  6044. /*
  6045. * Delay for the specified SCSI Bus Reset hold time.
  6046. *
  6047. * The hold time delay is done on the host because the RISC has no
  6048. * microsecond accurate timer.
  6049. */
  6050. udelay(ASC_SCSI_RESET_HOLD_TIME_US);
  6051. /*
  6052. * Send the SCSI Bus Reset end idle command which de-asserts
  6053. * the SCSI Bus Reset signal and purges any pending requests.
  6054. */
  6055. status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_END, 0L);
  6056. if (status != ADV_TRUE) {
  6057. return status;
  6058. }
  6059. mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
  6060. return status;
  6061. }
  6062. /*
  6063. * Initialize the ASC-3550.
  6064. *
  6065. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  6066. *
  6067. * For a non-fatal error return a warning code. If there are no warnings
  6068. * then 0 is returned.
  6069. *
  6070. * Needed after initialization for error recovery.
  6071. */
  6072. static int AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
  6073. {
  6074. AdvPortAddr iop_base;
  6075. ushort warn_code;
  6076. int begin_addr;
  6077. int end_addr;
  6078. ushort code_sum;
  6079. int word;
  6080. int i;
  6081. ushort scsi_cfg1;
  6082. uchar tid;
  6083. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  6084. ushort wdtr_able = 0, sdtr_able, tagqng_able;
  6085. uchar max_cmd[ADV_MAX_TID + 1];
  6086. /* If there is already an error, don't continue. */
  6087. if (asc_dvc->err_code != 0)
  6088. return ADV_ERROR;
  6089. /*
  6090. * The caller must set 'chip_type' to ADV_CHIP_ASC3550.
  6091. */
  6092. if (asc_dvc->chip_type != ADV_CHIP_ASC3550) {
  6093. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  6094. return ADV_ERROR;
  6095. }
  6096. warn_code = 0;
  6097. iop_base = asc_dvc->iop_base;
  6098. /*
  6099. * Save the RISC memory BIOS region before writing the microcode.
  6100. * The BIOS may already be loaded and using its RISC LRAM region
  6101. * so its region must be saved and restored.
  6102. *
  6103. * Note: This code makes the assumption, which is currently true,
  6104. * that a chip reset does not clear RISC LRAM.
  6105. */
  6106. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6107. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6108. bios_mem[i]);
  6109. }
  6110. /*
  6111. * Save current per TID negotiated values.
  6112. */
  6113. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] == 0x55AA) {
  6114. ushort bios_version, major, minor;
  6115. bios_version =
  6116. bios_mem[(ASC_MC_BIOS_VERSION - ASC_MC_BIOSMEM) / 2];
  6117. major = (bios_version >> 12) & 0xF;
  6118. minor = (bios_version >> 8) & 0xF;
  6119. if (major < 3 || (major == 3 && minor == 1)) {
  6120. /* BIOS 3.1 and earlier location of 'wdtr_able' variable. */
  6121. AdvReadWordLram(iop_base, 0x120, wdtr_able);
  6122. } else {
  6123. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6124. }
  6125. }
  6126. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6127. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  6128. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6129. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6130. max_cmd[tid]);
  6131. }
  6132. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc3550_buf,
  6133. _adv_asc3550_size, ADV_3550_MEMSIZE,
  6134. _adv_asc3550_chksum);
  6135. if (asc_dvc->err_code)
  6136. return ADV_ERROR;
  6137. /*
  6138. * Restore the RISC memory BIOS region.
  6139. */
  6140. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6141. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6142. bios_mem[i]);
  6143. }
  6144. /*
  6145. * Calculate and write the microcode code checksum to the microcode
  6146. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  6147. */
  6148. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  6149. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  6150. code_sum = 0;
  6151. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  6152. for (word = begin_addr; word < end_addr; word += 2) {
  6153. code_sum += AdvReadWordAutoIncLram(iop_base);
  6154. }
  6155. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  6156. /*
  6157. * Read and save microcode version and date.
  6158. */
  6159. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  6160. asc_dvc->cfg->mcode_date);
  6161. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  6162. asc_dvc->cfg->mcode_version);
  6163. /*
  6164. * Set the chip type to indicate the ASC3550.
  6165. */
  6166. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC3550);
  6167. /*
  6168. * If the PCI Configuration Command Register "Parity Error Response
  6169. * Control" Bit was clear (0), then set the microcode variable
  6170. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  6171. * to ignore DMA parity errors.
  6172. */
  6173. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  6174. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6175. word |= CONTROL_FLAG_IGNORE_PERR;
  6176. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6177. }
  6178. /*
  6179. * For ASC-3550, setting the START_CTL_EMFU [3:2] bits sets a FIFO
  6180. * threshold of 128 bytes. This register is only accessible to the host.
  6181. */
  6182. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  6183. START_CTL_EMFU | READ_CMD_MRM);
  6184. /*
  6185. * Microcode operating variables for WDTR, SDTR, and command tag
  6186. * queuing will be set in slave_configure() based on what a
  6187. * device reports it is capable of in Inquiry byte 7.
  6188. *
  6189. * If SCSI Bus Resets have been disabled, then directly set
  6190. * SDTR and WDTR from the EEPROM configuration. This will allow
  6191. * the BIOS and warm boot to work without a SCSI bus hang on
  6192. * the Inquiry caused by host and target mismatched DTR values.
  6193. * Without the SCSI Bus Reset, before an Inquiry a device can't
  6194. * be assumed to be in Asynchronous, Narrow mode.
  6195. */
  6196. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  6197. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  6198. asc_dvc->wdtr_able);
  6199. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  6200. asc_dvc->sdtr_able);
  6201. }
  6202. /*
  6203. * Set microcode operating variables for SDTR_SPEED1, SDTR_SPEED2,
  6204. * SDTR_SPEED3, and SDTR_SPEED4 based on the ULTRA EEPROM per TID
  6205. * bitmask. These values determine the maximum SDTR speed negotiated
  6206. * with a device.
  6207. *
  6208. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  6209. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  6210. * without determining here whether the device supports SDTR.
  6211. *
  6212. * 4-bit speed SDTR speed name
  6213. * =========== ===============
  6214. * 0000b (0x0) SDTR disabled
  6215. * 0001b (0x1) 5 Mhz
  6216. * 0010b (0x2) 10 Mhz
  6217. * 0011b (0x3) 20 Mhz (Ultra)
  6218. * 0100b (0x4) 40 Mhz (LVD/Ultra2)
  6219. * 0101b (0x5) 80 Mhz (LVD2/Ultra3)
  6220. * 0110b (0x6) Undefined
  6221. * .
  6222. * 1111b (0xF) Undefined
  6223. */
  6224. word = 0;
  6225. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6226. if (ADV_TID_TO_TIDMASK(tid) & asc_dvc->ultra_able) {
  6227. /* Set Ultra speed for TID 'tid'. */
  6228. word |= (0x3 << (4 * (tid % 4)));
  6229. } else {
  6230. /* Set Fast speed for TID 'tid'. */
  6231. word |= (0x2 << (4 * (tid % 4)));
  6232. }
  6233. if (tid == 3) { /* Check if done with sdtr_speed1. */
  6234. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, word);
  6235. word = 0;
  6236. } else if (tid == 7) { /* Check if done with sdtr_speed2. */
  6237. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, word);
  6238. word = 0;
  6239. } else if (tid == 11) { /* Check if done with sdtr_speed3. */
  6240. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, word);
  6241. word = 0;
  6242. } else if (tid == 15) { /* Check if done with sdtr_speed4. */
  6243. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, word);
  6244. /* End of loop. */
  6245. }
  6246. }
  6247. /*
  6248. * Set microcode operating variable for the disconnect per TID bitmask.
  6249. */
  6250. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  6251. asc_dvc->cfg->disc_enable);
  6252. /*
  6253. * Set SCSI_CFG0 Microcode Default Value.
  6254. *
  6255. * The microcode will set the SCSI_CFG0 register using this value
  6256. * after it is started below.
  6257. */
  6258. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  6259. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  6260. asc_dvc->chip_scsi_id);
  6261. /*
  6262. * Determine SCSI_CFG1 Microcode Default Value.
  6263. *
  6264. * The microcode will set the SCSI_CFG1 register using this value
  6265. * after it is started below.
  6266. */
  6267. /* Read current SCSI_CFG1 Register value. */
  6268. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  6269. /*
  6270. * If all three connectors are in use, return an error.
  6271. */
  6272. if ((scsi_cfg1 & CABLE_ILLEGAL_A) == 0 ||
  6273. (scsi_cfg1 & CABLE_ILLEGAL_B) == 0) {
  6274. asc_dvc->err_code |= ASC_IERR_ILLEGAL_CONNECTION;
  6275. return ADV_ERROR;
  6276. }
  6277. /*
  6278. * If the internal narrow cable is reversed all of the SCSI_CTRL
  6279. * register signals will be set. Check for and return an error if
  6280. * this condition is found.
  6281. */
  6282. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  6283. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  6284. return ADV_ERROR;
  6285. }
  6286. /*
  6287. * If this is a differential board and a single-ended device
  6288. * is attached to one of the connectors, return an error.
  6289. */
  6290. if ((scsi_cfg1 & DIFF_MODE) && (scsi_cfg1 & DIFF_SENSE) == 0) {
  6291. asc_dvc->err_code |= ASC_IERR_SINGLE_END_DEVICE;
  6292. return ADV_ERROR;
  6293. }
  6294. /*
  6295. * If automatic termination control is enabled, then set the
  6296. * termination value based on a table listed in a_condor.h.
  6297. *
  6298. * If manual termination was specified with an EEPROM setting
  6299. * then 'termination' was set-up in AdvInitFrom3550EEPROM() and
  6300. * is ready to be 'ored' into SCSI_CFG1.
  6301. */
  6302. if (asc_dvc->cfg->termination == 0) {
  6303. /*
  6304. * The software always controls termination by setting TERM_CTL_SEL.
  6305. * If TERM_CTL_SEL were set to 0, the hardware would set termination.
  6306. */
  6307. asc_dvc->cfg->termination |= TERM_CTL_SEL;
  6308. switch (scsi_cfg1 & CABLE_DETECT) {
  6309. /* TERM_CTL_H: on, TERM_CTL_L: on */
  6310. case 0x3:
  6311. case 0x7:
  6312. case 0xB:
  6313. case 0xD:
  6314. case 0xE:
  6315. case 0xF:
  6316. asc_dvc->cfg->termination |= (TERM_CTL_H | TERM_CTL_L);
  6317. break;
  6318. /* TERM_CTL_H: on, TERM_CTL_L: off */
  6319. case 0x1:
  6320. case 0x5:
  6321. case 0x9:
  6322. case 0xA:
  6323. case 0xC:
  6324. asc_dvc->cfg->termination |= TERM_CTL_H;
  6325. break;
  6326. /* TERM_CTL_H: off, TERM_CTL_L: off */
  6327. case 0x2:
  6328. case 0x6:
  6329. break;
  6330. }
  6331. }
  6332. /*
  6333. * Clear any set TERM_CTL_H and TERM_CTL_L bits.
  6334. */
  6335. scsi_cfg1 &= ~TERM_CTL;
  6336. /*
  6337. * Invert the TERM_CTL_H and TERM_CTL_L bits and then
  6338. * set 'scsi_cfg1'. The TERM_POL bit does not need to be
  6339. * referenced, because the hardware internally inverts
  6340. * the Termination High and Low bits if TERM_POL is set.
  6341. */
  6342. scsi_cfg1 |= (TERM_CTL_SEL | (~asc_dvc->cfg->termination & TERM_CTL));
  6343. /*
  6344. * Set SCSI_CFG1 Microcode Default Value
  6345. *
  6346. * Set filter value and possibly modified termination control
  6347. * bits in the Microcode SCSI_CFG1 Register Value.
  6348. *
  6349. * The microcode will set the SCSI_CFG1 register using this value
  6350. * after it is started below.
  6351. */
  6352. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1,
  6353. FLTR_DISABLE | scsi_cfg1);
  6354. /*
  6355. * Set MEM_CFG Microcode Default Value
  6356. *
  6357. * The microcode will set the MEM_CFG register using this value
  6358. * after it is started below.
  6359. *
  6360. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  6361. * are defined.
  6362. *
  6363. * ASC-3550 has 8KB internal memory.
  6364. */
  6365. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  6366. BIOS_EN | RAM_SZ_8KB);
  6367. /*
  6368. * Set SEL_MASK Microcode Default Value
  6369. *
  6370. * The microcode will set the SEL_MASK register using this value
  6371. * after it is started below.
  6372. */
  6373. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  6374. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  6375. AdvBuildCarrierFreelist(asc_dvc);
  6376. /*
  6377. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  6378. */
  6379. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  6380. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  6381. return ADV_ERROR;
  6382. }
  6383. asc_dvc->carr_freelist = (ADV_CARR_T *)
  6384. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  6385. /*
  6386. * The first command issued will be placed in the stopper carrier.
  6387. */
  6388. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  6389. /*
  6390. * Set RISC ICQ physical address start value.
  6391. */
  6392. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  6393. /*
  6394. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  6395. */
  6396. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  6397. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  6398. return ADV_ERROR;
  6399. }
  6400. asc_dvc->carr_freelist = (ADV_CARR_T *)
  6401. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  6402. /*
  6403. * The first command completed by the RISC will be placed in
  6404. * the stopper.
  6405. *
  6406. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  6407. * completed the RISC will set the ASC_RQ_STOPPER bit.
  6408. */
  6409. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  6410. /*
  6411. * Set RISC IRQ physical address start value.
  6412. */
  6413. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  6414. asc_dvc->carr_pending_cnt = 0;
  6415. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  6416. (ADV_INTR_ENABLE_HOST_INTR |
  6417. ADV_INTR_ENABLE_GLOBAL_INTR));
  6418. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  6419. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  6420. /* finally, finally, gentlemen, start your engine */
  6421. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  6422. /*
  6423. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  6424. * Resets should be performed. The RISC has to be running
  6425. * to issue a SCSI Bus Reset.
  6426. */
  6427. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  6428. /*
  6429. * If the BIOS Signature is present in memory, restore the
  6430. * BIOS Handshake Configuration Table and do not perform
  6431. * a SCSI Bus Reset.
  6432. */
  6433. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  6434. 0x55AA) {
  6435. /*
  6436. * Restore per TID negotiated values.
  6437. */
  6438. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6439. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6440. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  6441. tagqng_able);
  6442. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6443. AdvWriteByteLram(iop_base,
  6444. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6445. max_cmd[tid]);
  6446. }
  6447. } else {
  6448. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  6449. warn_code = ASC_WARN_BUSRESET_ERROR;
  6450. }
  6451. }
  6452. }
  6453. return warn_code;
  6454. }
  6455. /*
  6456. * Initialize the ASC-38C0800.
  6457. *
  6458. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  6459. *
  6460. * For a non-fatal error return a warning code. If there are no warnings
  6461. * then 0 is returned.
  6462. *
  6463. * Needed after initialization for error recovery.
  6464. */
  6465. static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
  6466. {
  6467. AdvPortAddr iop_base;
  6468. ushort warn_code;
  6469. int begin_addr;
  6470. int end_addr;
  6471. ushort code_sum;
  6472. int word;
  6473. int i;
  6474. ushort scsi_cfg1;
  6475. uchar byte;
  6476. uchar tid;
  6477. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  6478. ushort wdtr_able, sdtr_able, tagqng_able;
  6479. uchar max_cmd[ADV_MAX_TID + 1];
  6480. /* If there is already an error, don't continue. */
  6481. if (asc_dvc->err_code != 0)
  6482. return ADV_ERROR;
  6483. /*
  6484. * The caller must set 'chip_type' to ADV_CHIP_ASC38C0800.
  6485. */
  6486. if (asc_dvc->chip_type != ADV_CHIP_ASC38C0800) {
  6487. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  6488. return ADV_ERROR;
  6489. }
  6490. warn_code = 0;
  6491. iop_base = asc_dvc->iop_base;
  6492. /*
  6493. * Save the RISC memory BIOS region before writing the microcode.
  6494. * The BIOS may already be loaded and using its RISC LRAM region
  6495. * so its region must be saved and restored.
  6496. *
  6497. * Note: This code makes the assumption, which is currently true,
  6498. * that a chip reset does not clear RISC LRAM.
  6499. */
  6500. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6501. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6502. bios_mem[i]);
  6503. }
  6504. /*
  6505. * Save current per TID negotiated values.
  6506. */
  6507. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6508. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6509. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  6510. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6511. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6512. max_cmd[tid]);
  6513. }
  6514. /*
  6515. * RAM BIST (RAM Built-In Self Test)
  6516. *
  6517. * Address : I/O base + offset 0x38h register (byte).
  6518. * Function: Bit 7-6(RW) : RAM mode
  6519. * Normal Mode : 0x00
  6520. * Pre-test Mode : 0x40
  6521. * RAM Test Mode : 0x80
  6522. * Bit 5 : unused
  6523. * Bit 4(RO) : Done bit
  6524. * Bit 3-0(RO) : Status
  6525. * Host Error : 0x08
  6526. * Int_RAM Error : 0x04
  6527. * RISC Error : 0x02
  6528. * SCSI Error : 0x01
  6529. * No Error : 0x00
  6530. *
  6531. * Note: RAM BIST code should be put right here, before loading the
  6532. * microcode and after saving the RISC memory BIOS region.
  6533. */
  6534. /*
  6535. * LRAM Pre-test
  6536. *
  6537. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  6538. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  6539. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  6540. * to NORMAL_MODE, return an error too.
  6541. */
  6542. for (i = 0; i < 2; i++) {
  6543. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  6544. mdelay(10); /* Wait for 10ms before reading back. */
  6545. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  6546. if ((byte & RAM_TEST_DONE) == 0
  6547. || (byte & 0x0F) != PRE_TEST_VALUE) {
  6548. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  6549. return ADV_ERROR;
  6550. }
  6551. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  6552. mdelay(10); /* Wait for 10ms before reading back. */
  6553. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  6554. != NORMAL_VALUE) {
  6555. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  6556. return ADV_ERROR;
  6557. }
  6558. }
  6559. /*
  6560. * LRAM Test - It takes about 1.5 ms to run through the test.
  6561. *
  6562. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  6563. * If Done bit not set or Status not 0, save register byte, set the
  6564. * err_code, and return an error.
  6565. */
  6566. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  6567. mdelay(10); /* Wait for 10ms before checking status. */
  6568. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  6569. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
  6570. /* Get here if Done bit not set or Status not 0. */
  6571. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  6572. asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
  6573. return ADV_ERROR;
  6574. }
  6575. /* We need to reset back to normal mode after LRAM test passes. */
  6576. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  6577. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C0800_buf,
  6578. _adv_asc38C0800_size, ADV_38C0800_MEMSIZE,
  6579. _adv_asc38C0800_chksum);
  6580. if (asc_dvc->err_code)
  6581. return ADV_ERROR;
  6582. /*
  6583. * Restore the RISC memory BIOS region.
  6584. */
  6585. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6586. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6587. bios_mem[i]);
  6588. }
  6589. /*
  6590. * Calculate and write the microcode code checksum to the microcode
  6591. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  6592. */
  6593. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  6594. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  6595. code_sum = 0;
  6596. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  6597. for (word = begin_addr; word < end_addr; word += 2) {
  6598. code_sum += AdvReadWordAutoIncLram(iop_base);
  6599. }
  6600. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  6601. /*
  6602. * Read microcode version and date.
  6603. */
  6604. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  6605. asc_dvc->cfg->mcode_date);
  6606. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  6607. asc_dvc->cfg->mcode_version);
  6608. /*
  6609. * Set the chip type to indicate the ASC38C0800.
  6610. */
  6611. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C0800);
  6612. /*
  6613. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  6614. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  6615. * cable detection and then we are able to read C_DET[3:0].
  6616. *
  6617. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  6618. * Microcode Default Value' section below.
  6619. */
  6620. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  6621. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
  6622. scsi_cfg1 | DIS_TERM_DRV);
  6623. /*
  6624. * If the PCI Configuration Command Register "Parity Error Response
  6625. * Control" Bit was clear (0), then set the microcode variable
  6626. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  6627. * to ignore DMA parity errors.
  6628. */
  6629. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  6630. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6631. word |= CONTROL_FLAG_IGNORE_PERR;
  6632. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6633. }
  6634. /*
  6635. * For ASC-38C0800, set FIFO_THRESH_80B [6:4] bits and START_CTL_TH [3:2]
  6636. * bits for the default FIFO threshold.
  6637. *
  6638. * Note: ASC-38C0800 FIFO threshold has been changed to 256 bytes.
  6639. *
  6640. * For DMA Errata #4 set the BC_THRESH_ENB bit.
  6641. */
  6642. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  6643. BC_THRESH_ENB | FIFO_THRESH_80B | START_CTL_TH |
  6644. READ_CMD_MRM);
  6645. /*
  6646. * Microcode operating variables for WDTR, SDTR, and command tag
  6647. * queuing will be set in slave_configure() based on what a
  6648. * device reports it is capable of in Inquiry byte 7.
  6649. *
  6650. * If SCSI Bus Resets have been disabled, then directly set
  6651. * SDTR and WDTR from the EEPROM configuration. This will allow
  6652. * the BIOS and warm boot to work without a SCSI bus hang on
  6653. * the Inquiry caused by host and target mismatched DTR values.
  6654. * Without the SCSI Bus Reset, before an Inquiry a device can't
  6655. * be assumed to be in Asynchronous, Narrow mode.
  6656. */
  6657. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  6658. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  6659. asc_dvc->wdtr_able);
  6660. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  6661. asc_dvc->sdtr_able);
  6662. }
  6663. /*
  6664. * Set microcode operating variables for DISC and SDTR_SPEED1,
  6665. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  6666. * configuration values.
  6667. *
  6668. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  6669. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  6670. * without determining here whether the device supports SDTR.
  6671. */
  6672. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  6673. asc_dvc->cfg->disc_enable);
  6674. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  6675. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  6676. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  6677. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  6678. /*
  6679. * Set SCSI_CFG0 Microcode Default Value.
  6680. *
  6681. * The microcode will set the SCSI_CFG0 register using this value
  6682. * after it is started below.
  6683. */
  6684. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  6685. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  6686. asc_dvc->chip_scsi_id);
  6687. /*
  6688. * Determine SCSI_CFG1 Microcode Default Value.
  6689. *
  6690. * The microcode will set the SCSI_CFG1 register using this value
  6691. * after it is started below.
  6692. */
  6693. /* Read current SCSI_CFG1 Register value. */
  6694. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  6695. /*
  6696. * If the internal narrow cable is reversed all of the SCSI_CTRL
  6697. * register signals will be set. Check for and return an error if
  6698. * this condition is found.
  6699. */
  6700. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  6701. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  6702. return ADV_ERROR;
  6703. }
  6704. /*
  6705. * All kind of combinations of devices attached to one of four
  6706. * connectors are acceptable except HVD device attached. For example,
  6707. * LVD device can be attached to SE connector while SE device attached
  6708. * to LVD connector. If LVD device attached to SE connector, it only
  6709. * runs up to Ultra speed.
  6710. *
  6711. * If an HVD device is attached to one of LVD connectors, return an
  6712. * error. However, there is no way to detect HVD device attached to
  6713. * SE connectors.
  6714. */
  6715. if (scsi_cfg1 & HVD) {
  6716. asc_dvc->err_code = ASC_IERR_HVD_DEVICE;
  6717. return ADV_ERROR;
  6718. }
  6719. /*
  6720. * If either SE or LVD automatic termination control is enabled, then
  6721. * set the termination value based on a table listed in a_condor.h.
  6722. *
  6723. * If manual termination was specified with an EEPROM setting then
  6724. * 'termination' was set-up in AdvInitFrom38C0800EEPROM() and is ready
  6725. * to be 'ored' into SCSI_CFG1.
  6726. */
  6727. if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
  6728. /* SE automatic termination control is enabled. */
  6729. switch (scsi_cfg1 & C_DET_SE) {
  6730. /* TERM_SE_HI: on, TERM_SE_LO: on */
  6731. case 0x1:
  6732. case 0x2:
  6733. case 0x3:
  6734. asc_dvc->cfg->termination |= TERM_SE;
  6735. break;
  6736. /* TERM_SE_HI: on, TERM_SE_LO: off */
  6737. case 0x0:
  6738. asc_dvc->cfg->termination |= TERM_SE_HI;
  6739. break;
  6740. }
  6741. }
  6742. if ((asc_dvc->cfg->termination & TERM_LVD) == 0) {
  6743. /* LVD automatic termination control is enabled. */
  6744. switch (scsi_cfg1 & C_DET_LVD) {
  6745. /* TERM_LVD_HI: on, TERM_LVD_LO: on */
  6746. case 0x4:
  6747. case 0x8:
  6748. case 0xC:
  6749. asc_dvc->cfg->termination |= TERM_LVD;
  6750. break;
  6751. /* TERM_LVD_HI: off, TERM_LVD_LO: off */
  6752. case 0x0:
  6753. break;
  6754. }
  6755. }
  6756. /*
  6757. * Clear any set TERM_SE and TERM_LVD bits.
  6758. */
  6759. scsi_cfg1 &= (~TERM_SE & ~TERM_LVD);
  6760. /*
  6761. * Invert the TERM_SE and TERM_LVD bits and then set 'scsi_cfg1'.
  6762. */
  6763. scsi_cfg1 |= (~asc_dvc->cfg->termination & 0xF0);
  6764. /*
  6765. * Clear BIG_ENDIAN, DIS_TERM_DRV, Terminator Polarity and HVD/LVD/SE
  6766. * bits and set possibly modified termination control bits in the
  6767. * Microcode SCSI_CFG1 Register Value.
  6768. */
  6769. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL & ~HVD_LVD_SE);
  6770. /*
  6771. * Set SCSI_CFG1 Microcode Default Value
  6772. *
  6773. * Set possibly modified termination control and reset DIS_TERM_DRV
  6774. * bits in the Microcode SCSI_CFG1 Register Value.
  6775. *
  6776. * The microcode will set the SCSI_CFG1 register using this value
  6777. * after it is started below.
  6778. */
  6779. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  6780. /*
  6781. * Set MEM_CFG Microcode Default Value
  6782. *
  6783. * The microcode will set the MEM_CFG register using this value
  6784. * after it is started below.
  6785. *
  6786. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  6787. * are defined.
  6788. *
  6789. * ASC-38C0800 has 16KB internal memory.
  6790. */
  6791. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  6792. BIOS_EN | RAM_SZ_16KB);
  6793. /*
  6794. * Set SEL_MASK Microcode Default Value
  6795. *
  6796. * The microcode will set the SEL_MASK register using this value
  6797. * after it is started below.
  6798. */
  6799. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  6800. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  6801. AdvBuildCarrierFreelist(asc_dvc);
  6802. /*
  6803. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  6804. */
  6805. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  6806. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  6807. return ADV_ERROR;
  6808. }
  6809. asc_dvc->carr_freelist = (ADV_CARR_T *)
  6810. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  6811. /*
  6812. * The first command issued will be placed in the stopper carrier.
  6813. */
  6814. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  6815. /*
  6816. * Set RISC ICQ physical address start value.
  6817. * carr_pa is LE, must be native before write
  6818. */
  6819. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  6820. /*
  6821. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  6822. */
  6823. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  6824. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  6825. return ADV_ERROR;
  6826. }
  6827. asc_dvc->carr_freelist = (ADV_CARR_T *)
  6828. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  6829. /*
  6830. * The first command completed by the RISC will be placed in
  6831. * the stopper.
  6832. *
  6833. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  6834. * completed the RISC will set the ASC_RQ_STOPPER bit.
  6835. */
  6836. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  6837. /*
  6838. * Set RISC IRQ physical address start value.
  6839. *
  6840. * carr_pa is LE, must be native before write *
  6841. */
  6842. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  6843. asc_dvc->carr_pending_cnt = 0;
  6844. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  6845. (ADV_INTR_ENABLE_HOST_INTR |
  6846. ADV_INTR_ENABLE_GLOBAL_INTR));
  6847. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  6848. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  6849. /* finally, finally, gentlemen, start your engine */
  6850. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  6851. /*
  6852. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  6853. * Resets should be performed. The RISC has to be running
  6854. * to issue a SCSI Bus Reset.
  6855. */
  6856. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  6857. /*
  6858. * If the BIOS Signature is present in memory, restore the
  6859. * BIOS Handshake Configuration Table and do not perform
  6860. * a SCSI Bus Reset.
  6861. */
  6862. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  6863. 0x55AA) {
  6864. /*
  6865. * Restore per TID negotiated values.
  6866. */
  6867. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6868. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6869. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  6870. tagqng_able);
  6871. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6872. AdvWriteByteLram(iop_base,
  6873. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6874. max_cmd[tid]);
  6875. }
  6876. } else {
  6877. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  6878. warn_code = ASC_WARN_BUSRESET_ERROR;
  6879. }
  6880. }
  6881. }
  6882. return warn_code;
  6883. }
  6884. /*
  6885. * Initialize the ASC-38C1600.
  6886. *
  6887. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  6888. *
  6889. * For a non-fatal error return a warning code. If there are no warnings
  6890. * then 0 is returned.
  6891. *
  6892. * Needed after initialization for error recovery.
  6893. */
  6894. static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
  6895. {
  6896. AdvPortAddr iop_base;
  6897. ushort warn_code;
  6898. int begin_addr;
  6899. int end_addr;
  6900. ushort code_sum;
  6901. long word;
  6902. int i;
  6903. ushort scsi_cfg1;
  6904. uchar byte;
  6905. uchar tid;
  6906. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  6907. ushort wdtr_able, sdtr_able, ppr_able, tagqng_able;
  6908. uchar max_cmd[ASC_MAX_TID + 1];
  6909. /* If there is already an error, don't continue. */
  6910. if (asc_dvc->err_code != 0) {
  6911. return ADV_ERROR;
  6912. }
  6913. /*
  6914. * The caller must set 'chip_type' to ADV_CHIP_ASC38C1600.
  6915. */
  6916. if (asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
  6917. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  6918. return ADV_ERROR;
  6919. }
  6920. warn_code = 0;
  6921. iop_base = asc_dvc->iop_base;
  6922. /*
  6923. * Save the RISC memory BIOS region before writing the microcode.
  6924. * The BIOS may already be loaded and using its RISC LRAM region
  6925. * so its region must be saved and restored.
  6926. *
  6927. * Note: This code makes the assumption, which is currently true,
  6928. * that a chip reset does not clear RISC LRAM.
  6929. */
  6930. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6931. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6932. bios_mem[i]);
  6933. }
  6934. /*
  6935. * Save current per TID negotiated values.
  6936. */
  6937. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6938. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6939. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  6940. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  6941. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  6942. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6943. max_cmd[tid]);
  6944. }
  6945. /*
  6946. * RAM BIST (Built-In Self Test)
  6947. *
  6948. * Address : I/O base + offset 0x38h register (byte).
  6949. * Function: Bit 7-6(RW) : RAM mode
  6950. * Normal Mode : 0x00
  6951. * Pre-test Mode : 0x40
  6952. * RAM Test Mode : 0x80
  6953. * Bit 5 : unused
  6954. * Bit 4(RO) : Done bit
  6955. * Bit 3-0(RO) : Status
  6956. * Host Error : 0x08
  6957. * Int_RAM Error : 0x04
  6958. * RISC Error : 0x02
  6959. * SCSI Error : 0x01
  6960. * No Error : 0x00
  6961. *
  6962. * Note: RAM BIST code should be put right here, before loading the
  6963. * microcode and after saving the RISC memory BIOS region.
  6964. */
  6965. /*
  6966. * LRAM Pre-test
  6967. *
  6968. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  6969. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  6970. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  6971. * to NORMAL_MODE, return an error too.
  6972. */
  6973. for (i = 0; i < 2; i++) {
  6974. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  6975. mdelay(10); /* Wait for 10ms before reading back. */
  6976. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  6977. if ((byte & RAM_TEST_DONE) == 0
  6978. || (byte & 0x0F) != PRE_TEST_VALUE) {
  6979. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  6980. return ADV_ERROR;
  6981. }
  6982. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  6983. mdelay(10); /* Wait for 10ms before reading back. */
  6984. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  6985. != NORMAL_VALUE) {
  6986. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  6987. return ADV_ERROR;
  6988. }
  6989. }
  6990. /*
  6991. * LRAM Test - It takes about 1.5 ms to run through the test.
  6992. *
  6993. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  6994. * If Done bit not set or Status not 0, save register byte, set the
  6995. * err_code, and return an error.
  6996. */
  6997. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  6998. mdelay(10); /* Wait for 10ms before checking status. */
  6999. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  7000. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
  7001. /* Get here if Done bit not set or Status not 0. */
  7002. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  7003. asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
  7004. return ADV_ERROR;
  7005. }
  7006. /* We need to reset back to normal mode after LRAM test passes. */
  7007. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  7008. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C1600_buf,
  7009. _adv_asc38C1600_size, ADV_38C1600_MEMSIZE,
  7010. _adv_asc38C1600_chksum);
  7011. if (asc_dvc->err_code)
  7012. return ADV_ERROR;
  7013. /*
  7014. * Restore the RISC memory BIOS region.
  7015. */
  7016. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  7017. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  7018. bios_mem[i]);
  7019. }
  7020. /*
  7021. * Calculate and write the microcode code checksum to the microcode
  7022. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  7023. */
  7024. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  7025. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  7026. code_sum = 0;
  7027. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  7028. for (word = begin_addr; word < end_addr; word += 2) {
  7029. code_sum += AdvReadWordAutoIncLram(iop_base);
  7030. }
  7031. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  7032. /*
  7033. * Read microcode version and date.
  7034. */
  7035. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  7036. asc_dvc->cfg->mcode_date);
  7037. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  7038. asc_dvc->cfg->mcode_version);
  7039. /*
  7040. * Set the chip type to indicate the ASC38C1600.
  7041. */
  7042. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C1600);
  7043. /*
  7044. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  7045. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  7046. * cable detection and then we are able to read C_DET[3:0].
  7047. *
  7048. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  7049. * Microcode Default Value' section below.
  7050. */
  7051. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  7052. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
  7053. scsi_cfg1 | DIS_TERM_DRV);
  7054. /*
  7055. * If the PCI Configuration Command Register "Parity Error Response
  7056. * Control" Bit was clear (0), then set the microcode variable
  7057. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  7058. * to ignore DMA parity errors.
  7059. */
  7060. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  7061. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7062. word |= CONTROL_FLAG_IGNORE_PERR;
  7063. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7064. }
  7065. /*
  7066. * If the BIOS control flag AIPP (Asynchronous Information
  7067. * Phase Protection) disable bit is not set, then set the firmware
  7068. * 'control_flag' CONTROL_FLAG_ENABLE_AIPP bit to enable
  7069. * AIPP checking and encoding.
  7070. */
  7071. if ((asc_dvc->bios_ctrl & BIOS_CTRL_AIPP_DIS) == 0) {
  7072. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7073. word |= CONTROL_FLAG_ENABLE_AIPP;
  7074. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7075. }
  7076. /*
  7077. * For ASC-38C1600 use DMA_CFG0 default values: FIFO_THRESH_80B [6:4],
  7078. * and START_CTL_TH [3:2].
  7079. */
  7080. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  7081. FIFO_THRESH_80B | START_CTL_TH | READ_CMD_MRM);
  7082. /*
  7083. * Microcode operating variables for WDTR, SDTR, and command tag
  7084. * queuing will be set in slave_configure() based on what a
  7085. * device reports it is capable of in Inquiry byte 7.
  7086. *
  7087. * If SCSI Bus Resets have been disabled, then directly set
  7088. * SDTR and WDTR from the EEPROM configuration. This will allow
  7089. * the BIOS and warm boot to work without a SCSI bus hang on
  7090. * the Inquiry caused by host and target mismatched DTR values.
  7091. * Without the SCSI Bus Reset, before an Inquiry a device can't
  7092. * be assumed to be in Asynchronous, Narrow mode.
  7093. */
  7094. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  7095. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  7096. asc_dvc->wdtr_able);
  7097. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  7098. asc_dvc->sdtr_able);
  7099. }
  7100. /*
  7101. * Set microcode operating variables for DISC and SDTR_SPEED1,
  7102. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  7103. * configuration values.
  7104. *
  7105. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  7106. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  7107. * without determining here whether the device supports SDTR.
  7108. */
  7109. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  7110. asc_dvc->cfg->disc_enable);
  7111. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  7112. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  7113. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  7114. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  7115. /*
  7116. * Set SCSI_CFG0 Microcode Default Value.
  7117. *
  7118. * The microcode will set the SCSI_CFG0 register using this value
  7119. * after it is started below.
  7120. */
  7121. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  7122. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  7123. asc_dvc->chip_scsi_id);
  7124. /*
  7125. * Calculate SCSI_CFG1 Microcode Default Value.
  7126. *
  7127. * The microcode will set the SCSI_CFG1 register using this value
  7128. * after it is started below.
  7129. *
  7130. * Each ASC-38C1600 function has only two cable detect bits.
  7131. * The bus mode override bits are in IOPB_SOFT_OVER_WR.
  7132. */
  7133. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  7134. /*
  7135. * If the cable is reversed all of the SCSI_CTRL register signals
  7136. * will be set. Check for and return an error if this condition is
  7137. * found.
  7138. */
  7139. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  7140. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  7141. return ADV_ERROR;
  7142. }
  7143. /*
  7144. * Each ASC-38C1600 function has two connectors. Only an HVD device
  7145. * can not be connected to either connector. An LVD device or SE device
  7146. * may be connected to either connecor. If an SE device is connected,
  7147. * then at most Ultra speed (20 Mhz) can be used on both connectors.
  7148. *
  7149. * If an HVD device is attached, return an error.
  7150. */
  7151. if (scsi_cfg1 & HVD) {
  7152. asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
  7153. return ADV_ERROR;
  7154. }
  7155. /*
  7156. * Each function in the ASC-38C1600 uses only the SE cable detect and
  7157. * termination because there are two connectors for each function. Each
  7158. * function may use either LVD or SE mode. Corresponding the SE automatic
  7159. * termination control EEPROM bits are used for each function. Each
  7160. * function has its own EEPROM. If SE automatic control is enabled for
  7161. * the function, then set the termination value based on a table listed
  7162. * in a_condor.h.
  7163. *
  7164. * If manual termination is specified in the EEPROM for the function,
  7165. * then 'termination' was set-up in AscInitFrom38C1600EEPROM() and is
  7166. * ready to be 'ored' into SCSI_CFG1.
  7167. */
  7168. if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
  7169. struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
  7170. /* SE automatic termination control is enabled. */
  7171. switch (scsi_cfg1 & C_DET_SE) {
  7172. /* TERM_SE_HI: on, TERM_SE_LO: on */
  7173. case 0x1:
  7174. case 0x2:
  7175. case 0x3:
  7176. asc_dvc->cfg->termination |= TERM_SE;
  7177. break;
  7178. case 0x0:
  7179. if (PCI_FUNC(pdev->devfn) == 0) {
  7180. /* Function 0 - TERM_SE_HI: off, TERM_SE_LO: off */
  7181. } else {
  7182. /* Function 1 - TERM_SE_HI: on, TERM_SE_LO: off */
  7183. asc_dvc->cfg->termination |= TERM_SE_HI;
  7184. }
  7185. break;
  7186. }
  7187. }
  7188. /*
  7189. * Clear any set TERM_SE bits.
  7190. */
  7191. scsi_cfg1 &= ~TERM_SE;
  7192. /*
  7193. * Invert the TERM_SE bits and then set 'scsi_cfg1'.
  7194. */
  7195. scsi_cfg1 |= (~asc_dvc->cfg->termination & TERM_SE);
  7196. /*
  7197. * Clear Big Endian and Terminator Polarity bits and set possibly
  7198. * modified termination control bits in the Microcode SCSI_CFG1
  7199. * Register Value.
  7200. *
  7201. * Big Endian bit is not used even on big endian machines.
  7202. */
  7203. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL);
  7204. /*
  7205. * Set SCSI_CFG1 Microcode Default Value
  7206. *
  7207. * Set possibly modified termination control bits in the Microcode
  7208. * SCSI_CFG1 Register Value.
  7209. *
  7210. * The microcode will set the SCSI_CFG1 register using this value
  7211. * after it is started below.
  7212. */
  7213. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  7214. /*
  7215. * Set MEM_CFG Microcode Default Value
  7216. *
  7217. * The microcode will set the MEM_CFG register using this value
  7218. * after it is started below.
  7219. *
  7220. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  7221. * are defined.
  7222. *
  7223. * ASC-38C1600 has 32KB internal memory.
  7224. *
  7225. * XXX - Since ASC38C1600 Rev.3 has a Local RAM failure issue, we come
  7226. * out a special 16K Adv Library and Microcode version. After the issue
  7227. * resolved, we should turn back to the 32K support. Both a_condor.h and
  7228. * mcode.sas files also need to be updated.
  7229. *
  7230. * AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  7231. * BIOS_EN | RAM_SZ_32KB);
  7232. */
  7233. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  7234. BIOS_EN | RAM_SZ_16KB);
  7235. /*
  7236. * Set SEL_MASK Microcode Default Value
  7237. *
  7238. * The microcode will set the SEL_MASK register using this value
  7239. * after it is started below.
  7240. */
  7241. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  7242. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  7243. AdvBuildCarrierFreelist(asc_dvc);
  7244. /*
  7245. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  7246. */
  7247. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  7248. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  7249. return ADV_ERROR;
  7250. }
  7251. asc_dvc->carr_freelist = (ADV_CARR_T *)
  7252. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  7253. /*
  7254. * The first command issued will be placed in the stopper carrier.
  7255. */
  7256. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  7257. /*
  7258. * Set RISC ICQ physical address start value. Initialize the
  7259. * COMMA register to the same value otherwise the RISC will
  7260. * prematurely detect a command is available.
  7261. */
  7262. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  7263. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  7264. le32_to_cpu(asc_dvc->icq_sp->carr_pa));
  7265. /*
  7266. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  7267. */
  7268. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  7269. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  7270. return ADV_ERROR;
  7271. }
  7272. asc_dvc->carr_freelist = (ADV_CARR_T *)
  7273. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  7274. /*
  7275. * The first command completed by the RISC will be placed in
  7276. * the stopper.
  7277. *
  7278. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  7279. * completed the RISC will set the ASC_RQ_STOPPER bit.
  7280. */
  7281. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  7282. /*
  7283. * Set RISC IRQ physical address start value.
  7284. */
  7285. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  7286. asc_dvc->carr_pending_cnt = 0;
  7287. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  7288. (ADV_INTR_ENABLE_HOST_INTR |
  7289. ADV_INTR_ENABLE_GLOBAL_INTR));
  7290. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  7291. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  7292. /* finally, finally, gentlemen, start your engine */
  7293. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  7294. /*
  7295. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  7296. * Resets should be performed. The RISC has to be running
  7297. * to issue a SCSI Bus Reset.
  7298. */
  7299. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  7300. /*
  7301. * If the BIOS Signature is present in memory, restore the
  7302. * per TID microcode operating variables.
  7303. */
  7304. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  7305. 0x55AA) {
  7306. /*
  7307. * Restore per TID negotiated values.
  7308. */
  7309. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7310. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7311. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  7312. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  7313. tagqng_able);
  7314. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  7315. AdvWriteByteLram(iop_base,
  7316. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7317. max_cmd[tid]);
  7318. }
  7319. } else {
  7320. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  7321. warn_code = ASC_WARN_BUSRESET_ERROR;
  7322. }
  7323. }
  7324. }
  7325. return warn_code;
  7326. }
  7327. /*
  7328. * Reset chip and SCSI Bus.
  7329. *
  7330. * Return Value:
  7331. * ADV_TRUE(1) - Chip re-initialization and SCSI Bus Reset successful.
  7332. * ADV_FALSE(0) - Chip re-initialization and SCSI Bus Reset failure.
  7333. */
  7334. static int AdvResetChipAndSB(ADV_DVC_VAR *asc_dvc)
  7335. {
  7336. int status;
  7337. ushort wdtr_able, sdtr_able, tagqng_able;
  7338. ushort ppr_able = 0;
  7339. uchar tid, max_cmd[ADV_MAX_TID + 1];
  7340. AdvPortAddr iop_base;
  7341. ushort bios_sig;
  7342. iop_base = asc_dvc->iop_base;
  7343. /*
  7344. * Save current per TID negotiated values.
  7345. */
  7346. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7347. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7348. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  7349. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  7350. }
  7351. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  7352. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  7353. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7354. max_cmd[tid]);
  7355. }
  7356. /*
  7357. * Force the AdvInitAsc3550/38C0800Driver() function to
  7358. * perform a SCSI Bus Reset by clearing the BIOS signature word.
  7359. * The initialization functions assumes a SCSI Bus Reset is not
  7360. * needed if the BIOS signature word is present.
  7361. */
  7362. AdvReadWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  7363. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, 0);
  7364. /*
  7365. * Stop chip and reset it.
  7366. */
  7367. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_STOP);
  7368. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, ADV_CTRL_REG_CMD_RESET);
  7369. mdelay(100);
  7370. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  7371. ADV_CTRL_REG_CMD_WR_IO_REG);
  7372. /*
  7373. * Reset Adv Library error code, if any, and try
  7374. * re-initializing the chip.
  7375. */
  7376. asc_dvc->err_code = 0;
  7377. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  7378. status = AdvInitAsc38C1600Driver(asc_dvc);
  7379. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  7380. status = AdvInitAsc38C0800Driver(asc_dvc);
  7381. } else {
  7382. status = AdvInitAsc3550Driver(asc_dvc);
  7383. }
  7384. /* Translate initialization return value to status value. */
  7385. if (status == 0) {
  7386. status = ADV_TRUE;
  7387. } else {
  7388. status = ADV_FALSE;
  7389. }
  7390. /*
  7391. * Restore the BIOS signature word.
  7392. */
  7393. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  7394. /*
  7395. * Restore per TID negotiated values.
  7396. */
  7397. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7398. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7399. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  7400. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  7401. }
  7402. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  7403. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  7404. AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7405. max_cmd[tid]);
  7406. }
  7407. return status;
  7408. }
  7409. /*
  7410. * adv_async_callback() - Adv Library asynchronous event callback function.
  7411. */
  7412. static void adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
  7413. {
  7414. switch (code) {
  7415. case ADV_ASYNC_SCSI_BUS_RESET_DET:
  7416. /*
  7417. * The firmware detected a SCSI Bus reset.
  7418. */
  7419. ASC_DBG(0, "ADV_ASYNC_SCSI_BUS_RESET_DET\n");
  7420. break;
  7421. case ADV_ASYNC_RDMA_FAILURE:
  7422. /*
  7423. * Handle RDMA failure by resetting the SCSI Bus and
  7424. * possibly the chip if it is unresponsive. Log the error
  7425. * with a unique code.
  7426. */
  7427. ASC_DBG(0, "ADV_ASYNC_RDMA_FAILURE\n");
  7428. AdvResetChipAndSB(adv_dvc_varp);
  7429. break;
  7430. case ADV_HOST_SCSI_BUS_RESET:
  7431. /*
  7432. * Host generated SCSI bus reset occurred.
  7433. */
  7434. ASC_DBG(0, "ADV_HOST_SCSI_BUS_RESET\n");
  7435. break;
  7436. default:
  7437. ASC_DBG(0, "unknown code 0x%x\n", code);
  7438. break;
  7439. }
  7440. }
  7441. /*
  7442. * adv_isr_callback() - Second Level Interrupt Handler called by AdvISR().
  7443. *
  7444. * Callback function for the Wide SCSI Adv Library.
  7445. */
  7446. static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
  7447. {
  7448. struct asc_board *boardp;
  7449. adv_req_t *reqp;
  7450. adv_sgblk_t *sgblkp;
  7451. struct scsi_cmnd *scp;
  7452. struct Scsi_Host *shost;
  7453. ADV_DCNT resid_cnt;
  7454. ASC_DBG(1, "adv_dvc_varp 0x%lx, scsiqp 0x%lx\n",
  7455. (ulong)adv_dvc_varp, (ulong)scsiqp);
  7456. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  7457. /*
  7458. * Get the adv_req_t structure for the command that has been
  7459. * completed. The adv_req_t structure actually contains the
  7460. * completed ADV_SCSI_REQ_Q structure.
  7461. */
  7462. reqp = (adv_req_t *)ADV_U32_TO_VADDR(scsiqp->srb_ptr);
  7463. ASC_DBG(1, "reqp 0x%lx\n", (ulong)reqp);
  7464. if (reqp == NULL) {
  7465. ASC_PRINT("adv_isr_callback: reqp is NULL\n");
  7466. return;
  7467. }
  7468. /*
  7469. * Get the struct scsi_cmnd structure and Scsi_Host structure for the
  7470. * command that has been completed.
  7471. *
  7472. * Note: The adv_req_t request structure and adv_sgblk_t structure,
  7473. * if any, are dropped, because a board structure pointer can not be
  7474. * determined.
  7475. */
  7476. scp = reqp->cmndp;
  7477. ASC_DBG(1, "scp 0x%p\n", scp);
  7478. if (scp == NULL) {
  7479. ASC_PRINT
  7480. ("adv_isr_callback: scp is NULL; adv_req_t dropped.\n");
  7481. return;
  7482. }
  7483. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  7484. shost = scp->device->host;
  7485. ASC_STATS(shost, callback);
  7486. ASC_DBG(1, "shost 0x%p\n", shost);
  7487. boardp = shost_priv(shost);
  7488. BUG_ON(adv_dvc_varp != &boardp->dvc_var.adv_dvc_var);
  7489. /*
  7490. * 'done_status' contains the command's ending status.
  7491. */
  7492. switch (scsiqp->done_status) {
  7493. case QD_NO_ERROR:
  7494. ASC_DBG(2, "QD_NO_ERROR\n");
  7495. scp->result = 0;
  7496. /*
  7497. * Check for an underrun condition.
  7498. *
  7499. * If there was no error and an underrun condition, then
  7500. * then return the number of underrun bytes.
  7501. */
  7502. resid_cnt = le32_to_cpu(scsiqp->data_cnt);
  7503. if (scsi_bufflen(scp) != 0 && resid_cnt != 0 &&
  7504. resid_cnt <= scsi_bufflen(scp)) {
  7505. ASC_DBG(1, "underrun condition %lu bytes\n",
  7506. (ulong)resid_cnt);
  7507. scsi_set_resid(scp, resid_cnt);
  7508. }
  7509. break;
  7510. case QD_WITH_ERROR:
  7511. ASC_DBG(2, "QD_WITH_ERROR\n");
  7512. switch (scsiqp->host_status) {
  7513. case QHSTA_NO_ERROR:
  7514. if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
  7515. ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");
  7516. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  7517. sizeof(scp->sense_buffer));
  7518. /*
  7519. * Note: The 'status_byte()' macro used by
  7520. * target drivers defined in scsi.h shifts the
  7521. * status byte returned by host drivers right
  7522. * by 1 bit. This is why target drivers also
  7523. * use right shifted status byte definitions.
  7524. * For instance target drivers use
  7525. * CHECK_CONDITION, defined to 0x1, instead of
  7526. * the SCSI defined check condition value of
  7527. * 0x2. Host drivers are supposed to return
  7528. * the status byte as it is defined by SCSI.
  7529. */
  7530. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  7531. STATUS_BYTE(scsiqp->scsi_status);
  7532. } else {
  7533. scp->result = STATUS_BYTE(scsiqp->scsi_status);
  7534. }
  7535. break;
  7536. default:
  7537. /* Some other QHSTA error occurred. */
  7538. ASC_DBG(1, "host_status 0x%x\n", scsiqp->host_status);
  7539. scp->result = HOST_BYTE(DID_BAD_TARGET);
  7540. break;
  7541. }
  7542. break;
  7543. case QD_ABORTED_BY_HOST:
  7544. ASC_DBG(1, "QD_ABORTED_BY_HOST\n");
  7545. scp->result =
  7546. HOST_BYTE(DID_ABORT) | STATUS_BYTE(scsiqp->scsi_status);
  7547. break;
  7548. default:
  7549. ASC_DBG(1, "done_status 0x%x\n", scsiqp->done_status);
  7550. scp->result =
  7551. HOST_BYTE(DID_ERROR) | STATUS_BYTE(scsiqp->scsi_status);
  7552. break;
  7553. }
  7554. /*
  7555. * If the 'init_tidmask' bit isn't already set for the target and the
  7556. * current request finished normally, then set the bit for the target
  7557. * to indicate that a device is present.
  7558. */
  7559. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  7560. scsiqp->done_status == QD_NO_ERROR &&
  7561. scsiqp->host_status == QHSTA_NO_ERROR) {
  7562. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  7563. }
  7564. asc_scsi_done(scp);
  7565. /*
  7566. * Free all 'adv_sgblk_t' structures allocated for the request.
  7567. */
  7568. while ((sgblkp = reqp->sgblkp) != NULL) {
  7569. /* Remove 'sgblkp' from the request list. */
  7570. reqp->sgblkp = sgblkp->next_sgblkp;
  7571. /* Add 'sgblkp' to the board free list. */
  7572. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  7573. boardp->adv_sgblkp = sgblkp;
  7574. }
  7575. /*
  7576. * Free the adv_req_t structure used with the command by adding
  7577. * it back to the board free list.
  7578. */
  7579. reqp->next_reqp = boardp->adv_reqp;
  7580. boardp->adv_reqp = reqp;
  7581. ASC_DBG(1, "done\n");
  7582. }
  7583. /*
  7584. * Adv Library Interrupt Service Routine
  7585. *
  7586. * This function is called by a driver's interrupt service routine.
  7587. * The function disables and re-enables interrupts.
  7588. *
  7589. * When a microcode idle command is completed, the ADV_DVC_VAR
  7590. * 'idle_cmd_done' field is set to ADV_TRUE.
  7591. *
  7592. * Note: AdvISR() can be called when interrupts are disabled or even
  7593. * when there is no hardware interrupt condition present. It will
  7594. * always check for completed idle commands and microcode requests.
  7595. * This is an important feature that shouldn't be changed because it
  7596. * allows commands to be completed from polling mode loops.
  7597. *
  7598. * Return:
  7599. * ADV_TRUE(1) - interrupt was pending
  7600. * ADV_FALSE(0) - no interrupt was pending
  7601. */
  7602. static int AdvISR(ADV_DVC_VAR *asc_dvc)
  7603. {
  7604. AdvPortAddr iop_base;
  7605. uchar int_stat;
  7606. ushort target_bit;
  7607. ADV_CARR_T *free_carrp;
  7608. ADV_VADDR irq_next_vpa;
  7609. ADV_SCSI_REQ_Q *scsiq;
  7610. iop_base = asc_dvc->iop_base;
  7611. /* Reading the register clears the interrupt. */
  7612. int_stat = AdvReadByteRegister(iop_base, IOPB_INTR_STATUS_REG);
  7613. if ((int_stat & (ADV_INTR_STATUS_INTRA | ADV_INTR_STATUS_INTRB |
  7614. ADV_INTR_STATUS_INTRC)) == 0) {
  7615. return ADV_FALSE;
  7616. }
  7617. /*
  7618. * Notify the driver of an asynchronous microcode condition by
  7619. * calling the adv_async_callback function. The function
  7620. * is passed the microcode ASC_MC_INTRB_CODE byte value.
  7621. */
  7622. if (int_stat & ADV_INTR_STATUS_INTRB) {
  7623. uchar intrb_code;
  7624. AdvReadByteLram(iop_base, ASC_MC_INTRB_CODE, intrb_code);
  7625. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  7626. asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  7627. if (intrb_code == ADV_ASYNC_CARRIER_READY_FAILURE &&
  7628. asc_dvc->carr_pending_cnt != 0) {
  7629. AdvWriteByteRegister(iop_base, IOPB_TICKLE,
  7630. ADV_TICKLE_A);
  7631. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  7632. AdvWriteByteRegister(iop_base,
  7633. IOPB_TICKLE,
  7634. ADV_TICKLE_NOP);
  7635. }
  7636. }
  7637. }
  7638. adv_async_callback(asc_dvc, intrb_code);
  7639. }
  7640. /*
  7641. * Check if the IRQ stopper carrier contains a completed request.
  7642. */
  7643. while (((irq_next_vpa =
  7644. le32_to_cpu(asc_dvc->irq_sp->next_vpa)) & ASC_RQ_DONE) != 0) {
  7645. /*
  7646. * Get a pointer to the newly completed ADV_SCSI_REQ_Q structure.
  7647. * The RISC will have set 'areq_vpa' to a virtual address.
  7648. *
  7649. * The firmware will have copied the ASC_SCSI_REQ_Q.scsiq_ptr
  7650. * field to the carrier ADV_CARR_T.areq_vpa field. The conversion
  7651. * below complements the conversion of ASC_SCSI_REQ_Q.scsiq_ptr'
  7652. * in AdvExeScsiQueue().
  7653. */
  7654. scsiq = (ADV_SCSI_REQ_Q *)
  7655. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->areq_vpa));
  7656. /*
  7657. * Request finished with good status and the queue was not
  7658. * DMAed to host memory by the firmware. Set all status fields
  7659. * to indicate good status.
  7660. */
  7661. if ((irq_next_vpa & ASC_RQ_GOOD) != 0) {
  7662. scsiq->done_status = QD_NO_ERROR;
  7663. scsiq->host_status = scsiq->scsi_status = 0;
  7664. scsiq->data_cnt = 0L;
  7665. }
  7666. /*
  7667. * Advance the stopper pointer to the next carrier
  7668. * ignoring the lower four bits. Free the previous
  7669. * stopper carrier.
  7670. */
  7671. free_carrp = asc_dvc->irq_sp;
  7672. asc_dvc->irq_sp = (ADV_CARR_T *)
  7673. ADV_U32_TO_VADDR(ASC_GET_CARRP(irq_next_vpa));
  7674. free_carrp->next_vpa =
  7675. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  7676. asc_dvc->carr_freelist = free_carrp;
  7677. asc_dvc->carr_pending_cnt--;
  7678. target_bit = ADV_TID_TO_TIDMASK(scsiq->target_id);
  7679. /*
  7680. * Clear request microcode control flag.
  7681. */
  7682. scsiq->cntl = 0;
  7683. /*
  7684. * Notify the driver of the completed request by passing
  7685. * the ADV_SCSI_REQ_Q pointer to its callback function.
  7686. */
  7687. scsiq->a_flag |= ADV_SCSIQ_DONE;
  7688. adv_isr_callback(asc_dvc, scsiq);
  7689. /*
  7690. * Note: After the driver callback function is called, 'scsiq'
  7691. * can no longer be referenced.
  7692. *
  7693. * Fall through and continue processing other completed
  7694. * requests...
  7695. */
  7696. }
  7697. return ADV_TRUE;
  7698. }
  7699. static int AscSetLibErrorCode(ASC_DVC_VAR *asc_dvc, ushort err_code)
  7700. {
  7701. if (asc_dvc->err_code == 0) {
  7702. asc_dvc->err_code = err_code;
  7703. AscWriteLramWord(asc_dvc->iop_base, ASCV_ASCDVC_ERR_CODE_W,
  7704. err_code);
  7705. }
  7706. return err_code;
  7707. }
  7708. static void AscAckInterrupt(PortAddr iop_base)
  7709. {
  7710. uchar host_flag;
  7711. uchar risc_flag;
  7712. ushort loop;
  7713. loop = 0;
  7714. do {
  7715. risc_flag = AscReadLramByte(iop_base, ASCV_RISC_FLAG_B);
  7716. if (loop++ > 0x7FFF) {
  7717. break;
  7718. }
  7719. } while ((risc_flag & ASC_RISC_FLAG_GEN_INT) != 0);
  7720. host_flag =
  7721. AscReadLramByte(iop_base,
  7722. ASCV_HOST_FLAG_B) & (~ASC_HOST_FLAG_ACK_INT);
  7723. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  7724. (uchar)(host_flag | ASC_HOST_FLAG_ACK_INT));
  7725. AscSetChipStatus(iop_base, CIW_INT_ACK);
  7726. loop = 0;
  7727. while (AscGetChipStatus(iop_base) & CSW_INT_PENDING) {
  7728. AscSetChipStatus(iop_base, CIW_INT_ACK);
  7729. if (loop++ > 3) {
  7730. break;
  7731. }
  7732. }
  7733. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  7734. }
  7735. static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *asc_dvc, uchar syn_time)
  7736. {
  7737. const uchar *period_table;
  7738. int max_index;
  7739. int min_index;
  7740. int i;
  7741. period_table = asc_dvc->sdtr_period_tbl;
  7742. max_index = (int)asc_dvc->max_sdtr_index;
  7743. min_index = (int)asc_dvc->min_sdtr_index;
  7744. if ((syn_time <= period_table[max_index])) {
  7745. for (i = min_index; i < (max_index - 1); i++) {
  7746. if (syn_time <= period_table[i]) {
  7747. return (uchar)i;
  7748. }
  7749. }
  7750. return (uchar)max_index;
  7751. } else {
  7752. return (uchar)(max_index + 1);
  7753. }
  7754. }
  7755. static uchar
  7756. AscMsgOutSDTR(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar sdtr_offset)
  7757. {
  7758. EXT_MSG sdtr_buf;
  7759. uchar sdtr_period_index;
  7760. PortAddr iop_base;
  7761. iop_base = asc_dvc->iop_base;
  7762. sdtr_buf.msg_type = EXTENDED_MESSAGE;
  7763. sdtr_buf.msg_len = MS_SDTR_LEN;
  7764. sdtr_buf.msg_req = EXTENDED_SDTR;
  7765. sdtr_buf.xfer_period = sdtr_period;
  7766. sdtr_offset &= ASC_SYN_MAX_OFFSET;
  7767. sdtr_buf.req_ack_offset = sdtr_offset;
  7768. sdtr_period_index = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
  7769. if (sdtr_period_index <= asc_dvc->max_sdtr_index) {
  7770. AscMemWordCopyPtrToLram(iop_base, ASCV_MSGOUT_BEG,
  7771. (uchar *)&sdtr_buf,
  7772. sizeof(EXT_MSG) >> 1);
  7773. return ((sdtr_period_index << 4) | sdtr_offset);
  7774. } else {
  7775. sdtr_buf.req_ack_offset = 0;
  7776. AscMemWordCopyPtrToLram(iop_base, ASCV_MSGOUT_BEG,
  7777. (uchar *)&sdtr_buf,
  7778. sizeof(EXT_MSG) >> 1);
  7779. return 0;
  7780. }
  7781. }
  7782. static uchar
  7783. AscCalSDTRData(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar syn_offset)
  7784. {
  7785. uchar byte;
  7786. uchar sdtr_period_ix;
  7787. sdtr_period_ix = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
  7788. if (sdtr_period_ix > asc_dvc->max_sdtr_index)
  7789. return 0xFF;
  7790. byte = (sdtr_period_ix << 4) | (syn_offset & ASC_SYN_MAX_OFFSET);
  7791. return byte;
  7792. }
  7793. static int AscSetChipSynRegAtID(PortAddr iop_base, uchar id, uchar sdtr_data)
  7794. {
  7795. ASC_SCSI_BIT_ID_TYPE org_id;
  7796. int i;
  7797. int sta = TRUE;
  7798. AscSetBank(iop_base, 1);
  7799. org_id = AscReadChipDvcID(iop_base);
  7800. for (i = 0; i <= ASC_MAX_TID; i++) {
  7801. if (org_id == (0x01 << i))
  7802. break;
  7803. }
  7804. org_id = (ASC_SCSI_BIT_ID_TYPE) i;
  7805. AscWriteChipDvcID(iop_base, id);
  7806. if (AscReadChipDvcID(iop_base) == (0x01 << id)) {
  7807. AscSetBank(iop_base, 0);
  7808. AscSetChipSyn(iop_base, sdtr_data);
  7809. if (AscGetChipSyn(iop_base) != sdtr_data) {
  7810. sta = FALSE;
  7811. }
  7812. } else {
  7813. sta = FALSE;
  7814. }
  7815. AscSetBank(iop_base, 1);
  7816. AscWriteChipDvcID(iop_base, org_id);
  7817. AscSetBank(iop_base, 0);
  7818. return (sta);
  7819. }
  7820. static void AscSetChipSDTR(PortAddr iop_base, uchar sdtr_data, uchar tid_no)
  7821. {
  7822. AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  7823. AscPutMCodeSDTRDoneAtID(iop_base, tid_no, sdtr_data);
  7824. }
  7825. static int AscIsrChipHalted(ASC_DVC_VAR *asc_dvc)
  7826. {
  7827. EXT_MSG ext_msg;
  7828. EXT_MSG out_msg;
  7829. ushort halt_q_addr;
  7830. int sdtr_accept;
  7831. ushort int_halt_code;
  7832. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  7833. ASC_SCSI_BIT_ID_TYPE target_id;
  7834. PortAddr iop_base;
  7835. uchar tag_code;
  7836. uchar q_status;
  7837. uchar halt_qp;
  7838. uchar sdtr_data;
  7839. uchar target_ix;
  7840. uchar q_cntl, tid_no;
  7841. uchar cur_dvc_qng;
  7842. uchar asyn_sdtr;
  7843. uchar scsi_status;
  7844. struct asc_board *boardp;
  7845. BUG_ON(!asc_dvc->drv_ptr);
  7846. boardp = asc_dvc->drv_ptr;
  7847. iop_base = asc_dvc->iop_base;
  7848. int_halt_code = AscReadLramWord(iop_base, ASCV_HALTCODE_W);
  7849. halt_qp = AscReadLramByte(iop_base, ASCV_CURCDB_B);
  7850. halt_q_addr = ASC_QNO_TO_QADDR(halt_qp);
  7851. target_ix = AscReadLramByte(iop_base,
  7852. (ushort)(halt_q_addr +
  7853. (ushort)ASC_SCSIQ_B_TARGET_IX));
  7854. q_cntl = AscReadLramByte(iop_base,
  7855. (ushort)(halt_q_addr + (ushort)ASC_SCSIQ_B_CNTL));
  7856. tid_no = ASC_TIX_TO_TID(target_ix);
  7857. target_id = (uchar)ASC_TID_TO_TARGET_ID(tid_no);
  7858. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  7859. asyn_sdtr = ASYN_SDTR_DATA_FIX_PCI_REV_AB;
  7860. } else {
  7861. asyn_sdtr = 0;
  7862. }
  7863. if (int_halt_code == ASC_HALT_DISABLE_ASYN_USE_SYN_FIX) {
  7864. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  7865. AscSetChipSDTR(iop_base, 0, tid_no);
  7866. boardp->sdtr_data[tid_no] = 0;
  7867. }
  7868. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  7869. return (0);
  7870. } else if (int_halt_code == ASC_HALT_ENABLE_ASYN_USE_SYN_FIX) {
  7871. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  7872. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  7873. boardp->sdtr_data[tid_no] = asyn_sdtr;
  7874. }
  7875. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  7876. return (0);
  7877. } else if (int_halt_code == ASC_HALT_EXTMSG_IN) {
  7878. AscMemWordCopyPtrFromLram(iop_base,
  7879. ASCV_MSGIN_BEG,
  7880. (uchar *)&ext_msg,
  7881. sizeof(EXT_MSG) >> 1);
  7882. if (ext_msg.msg_type == EXTENDED_MESSAGE &&
  7883. ext_msg.msg_req == EXTENDED_SDTR &&
  7884. ext_msg.msg_len == MS_SDTR_LEN) {
  7885. sdtr_accept = TRUE;
  7886. if ((ext_msg.req_ack_offset > ASC_SYN_MAX_OFFSET)) {
  7887. sdtr_accept = FALSE;
  7888. ext_msg.req_ack_offset = ASC_SYN_MAX_OFFSET;
  7889. }
  7890. if ((ext_msg.xfer_period <
  7891. asc_dvc->sdtr_period_tbl[asc_dvc->min_sdtr_index])
  7892. || (ext_msg.xfer_period >
  7893. asc_dvc->sdtr_period_tbl[asc_dvc->
  7894. max_sdtr_index])) {
  7895. sdtr_accept = FALSE;
  7896. ext_msg.xfer_period =
  7897. asc_dvc->sdtr_period_tbl[asc_dvc->
  7898. min_sdtr_index];
  7899. }
  7900. if (sdtr_accept) {
  7901. sdtr_data =
  7902. AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
  7903. ext_msg.req_ack_offset);
  7904. if ((sdtr_data == 0xFF)) {
  7905. q_cntl |= QC_MSG_OUT;
  7906. asc_dvc->init_sdtr &= ~target_id;
  7907. asc_dvc->sdtr_done &= ~target_id;
  7908. AscSetChipSDTR(iop_base, asyn_sdtr,
  7909. tid_no);
  7910. boardp->sdtr_data[tid_no] = asyn_sdtr;
  7911. }
  7912. }
  7913. if (ext_msg.req_ack_offset == 0) {
  7914. q_cntl &= ~QC_MSG_OUT;
  7915. asc_dvc->init_sdtr &= ~target_id;
  7916. asc_dvc->sdtr_done &= ~target_id;
  7917. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  7918. } else {
  7919. if (sdtr_accept && (q_cntl & QC_MSG_OUT)) {
  7920. q_cntl &= ~QC_MSG_OUT;
  7921. asc_dvc->sdtr_done |= target_id;
  7922. asc_dvc->init_sdtr |= target_id;
  7923. asc_dvc->pci_fix_asyn_xfer &=
  7924. ~target_id;
  7925. sdtr_data =
  7926. AscCalSDTRData(asc_dvc,
  7927. ext_msg.xfer_period,
  7928. ext_msg.
  7929. req_ack_offset);
  7930. AscSetChipSDTR(iop_base, sdtr_data,
  7931. tid_no);
  7932. boardp->sdtr_data[tid_no] = sdtr_data;
  7933. } else {
  7934. q_cntl |= QC_MSG_OUT;
  7935. AscMsgOutSDTR(asc_dvc,
  7936. ext_msg.xfer_period,
  7937. ext_msg.req_ack_offset);
  7938. asc_dvc->pci_fix_asyn_xfer &=
  7939. ~target_id;
  7940. sdtr_data =
  7941. AscCalSDTRData(asc_dvc,
  7942. ext_msg.xfer_period,
  7943. ext_msg.
  7944. req_ack_offset);
  7945. AscSetChipSDTR(iop_base, sdtr_data,
  7946. tid_no);
  7947. boardp->sdtr_data[tid_no] = sdtr_data;
  7948. asc_dvc->sdtr_done |= target_id;
  7949. asc_dvc->init_sdtr |= target_id;
  7950. }
  7951. }
  7952. AscWriteLramByte(iop_base,
  7953. (ushort)(halt_q_addr +
  7954. (ushort)ASC_SCSIQ_B_CNTL),
  7955. q_cntl);
  7956. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  7957. return (0);
  7958. } else if (ext_msg.msg_type == EXTENDED_MESSAGE &&
  7959. ext_msg.msg_req == EXTENDED_WDTR &&
  7960. ext_msg.msg_len == MS_WDTR_LEN) {
  7961. ext_msg.wdtr_width = 0;
  7962. AscMemWordCopyPtrToLram(iop_base,
  7963. ASCV_MSGOUT_BEG,
  7964. (uchar *)&ext_msg,
  7965. sizeof(EXT_MSG) >> 1);
  7966. q_cntl |= QC_MSG_OUT;
  7967. AscWriteLramByte(iop_base,
  7968. (ushort)(halt_q_addr +
  7969. (ushort)ASC_SCSIQ_B_CNTL),
  7970. q_cntl);
  7971. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  7972. return (0);
  7973. } else {
  7974. ext_msg.msg_type = MESSAGE_REJECT;
  7975. AscMemWordCopyPtrToLram(iop_base,
  7976. ASCV_MSGOUT_BEG,
  7977. (uchar *)&ext_msg,
  7978. sizeof(EXT_MSG) >> 1);
  7979. q_cntl |= QC_MSG_OUT;
  7980. AscWriteLramByte(iop_base,
  7981. (ushort)(halt_q_addr +
  7982. (ushort)ASC_SCSIQ_B_CNTL),
  7983. q_cntl);
  7984. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  7985. return (0);
  7986. }
  7987. } else if (int_halt_code == ASC_HALT_CHK_CONDITION) {
  7988. q_cntl |= QC_REQ_SENSE;
  7989. if ((asc_dvc->init_sdtr & target_id) != 0) {
  7990. asc_dvc->sdtr_done &= ~target_id;
  7991. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  7992. q_cntl |= QC_MSG_OUT;
  7993. AscMsgOutSDTR(asc_dvc,
  7994. asc_dvc->
  7995. sdtr_period_tbl[(sdtr_data >> 4) &
  7996. (uchar)(asc_dvc->
  7997. max_sdtr_index -
  7998. 1)],
  7999. (uchar)(sdtr_data & (uchar)
  8000. ASC_SYN_MAX_OFFSET));
  8001. }
  8002. AscWriteLramByte(iop_base,
  8003. (ushort)(halt_q_addr +
  8004. (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
  8005. tag_code = AscReadLramByte(iop_base,
  8006. (ushort)(halt_q_addr + (ushort)
  8007. ASC_SCSIQ_B_TAG_CODE));
  8008. tag_code &= 0xDC;
  8009. if ((asc_dvc->pci_fix_asyn_xfer & target_id)
  8010. && !(asc_dvc->pci_fix_asyn_xfer_always & target_id)
  8011. ) {
  8012. tag_code |= (ASC_TAG_FLAG_DISABLE_DISCONNECT
  8013. | ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX);
  8014. }
  8015. AscWriteLramByte(iop_base,
  8016. (ushort)(halt_q_addr +
  8017. (ushort)ASC_SCSIQ_B_TAG_CODE),
  8018. tag_code);
  8019. q_status = AscReadLramByte(iop_base,
  8020. (ushort)(halt_q_addr + (ushort)
  8021. ASC_SCSIQ_B_STATUS));
  8022. q_status |= (QS_READY | QS_BUSY);
  8023. AscWriteLramByte(iop_base,
  8024. (ushort)(halt_q_addr +
  8025. (ushort)ASC_SCSIQ_B_STATUS),
  8026. q_status);
  8027. scsi_busy = AscReadLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B);
  8028. scsi_busy &= ~target_id;
  8029. AscWriteLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B, scsi_busy);
  8030. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8031. return (0);
  8032. } else if (int_halt_code == ASC_HALT_SDTR_REJECTED) {
  8033. AscMemWordCopyPtrFromLram(iop_base,
  8034. ASCV_MSGOUT_BEG,
  8035. (uchar *)&out_msg,
  8036. sizeof(EXT_MSG) >> 1);
  8037. if ((out_msg.msg_type == EXTENDED_MESSAGE) &&
  8038. (out_msg.msg_len == MS_SDTR_LEN) &&
  8039. (out_msg.msg_req == EXTENDED_SDTR)) {
  8040. asc_dvc->init_sdtr &= ~target_id;
  8041. asc_dvc->sdtr_done &= ~target_id;
  8042. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  8043. boardp->sdtr_data[tid_no] = asyn_sdtr;
  8044. }
  8045. q_cntl &= ~QC_MSG_OUT;
  8046. AscWriteLramByte(iop_base,
  8047. (ushort)(halt_q_addr +
  8048. (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
  8049. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8050. return (0);
  8051. } else if (int_halt_code == ASC_HALT_SS_QUEUE_FULL) {
  8052. scsi_status = AscReadLramByte(iop_base,
  8053. (ushort)((ushort)halt_q_addr +
  8054. (ushort)
  8055. ASC_SCSIQ_SCSI_STATUS));
  8056. cur_dvc_qng =
  8057. AscReadLramByte(iop_base,
  8058. (ushort)((ushort)ASC_QADR_BEG +
  8059. (ushort)target_ix));
  8060. if ((cur_dvc_qng > 0) && (asc_dvc->cur_dvc_qng[tid_no] > 0)) {
  8061. scsi_busy = AscReadLramByte(iop_base,
  8062. (ushort)ASCV_SCSIBUSY_B);
  8063. scsi_busy |= target_id;
  8064. AscWriteLramByte(iop_base,
  8065. (ushort)ASCV_SCSIBUSY_B, scsi_busy);
  8066. asc_dvc->queue_full_or_busy |= target_id;
  8067. if (scsi_status == SAM_STAT_TASK_SET_FULL) {
  8068. if (cur_dvc_qng > ASC_MIN_TAGGED_CMD) {
  8069. cur_dvc_qng -= 1;
  8070. asc_dvc->max_dvc_qng[tid_no] =
  8071. cur_dvc_qng;
  8072. AscWriteLramByte(iop_base,
  8073. (ushort)((ushort)
  8074. ASCV_MAX_DVC_QNG_BEG
  8075. + (ushort)
  8076. tid_no),
  8077. cur_dvc_qng);
  8078. /*
  8079. * Set the device queue depth to the
  8080. * number of active requests when the
  8081. * QUEUE FULL condition was encountered.
  8082. */
  8083. boardp->queue_full |= target_id;
  8084. boardp->queue_full_cnt[tid_no] =
  8085. cur_dvc_qng;
  8086. }
  8087. }
  8088. }
  8089. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8090. return (0);
  8091. }
  8092. #if CC_VERY_LONG_SG_LIST
  8093. else if (int_halt_code == ASC_HALT_HOST_COPY_SG_LIST_TO_RISC) {
  8094. uchar q_no;
  8095. ushort q_addr;
  8096. uchar sg_wk_q_no;
  8097. uchar first_sg_wk_q_no;
  8098. ASC_SCSI_Q *scsiq; /* Ptr to driver request. */
  8099. ASC_SG_HEAD *sg_head; /* Ptr to driver SG request. */
  8100. ASC_SG_LIST_Q scsi_sg_q; /* Structure written to queue. */
  8101. ushort sg_list_dwords;
  8102. ushort sg_entry_cnt;
  8103. uchar next_qp;
  8104. int i;
  8105. q_no = AscReadLramByte(iop_base, (ushort)ASCV_REQ_SG_LIST_QP);
  8106. if (q_no == ASC_QLINK_END)
  8107. return 0;
  8108. q_addr = ASC_QNO_TO_QADDR(q_no);
  8109. /*
  8110. * Convert the request's SRB pointer to a host ASC_SCSI_REQ
  8111. * structure pointer using a macro provided by the driver.
  8112. * The ASC_SCSI_REQ pointer provides a pointer to the
  8113. * host ASC_SG_HEAD structure.
  8114. */
  8115. /* Read request's SRB pointer. */
  8116. scsiq = (ASC_SCSI_Q *)
  8117. ASC_SRB2SCSIQ(ASC_U32_TO_VADDR(AscReadLramDWord(iop_base,
  8118. (ushort)
  8119. (q_addr +
  8120. ASC_SCSIQ_D_SRBPTR))));
  8121. /*
  8122. * Get request's first and working SG queue.
  8123. */
  8124. sg_wk_q_no = AscReadLramByte(iop_base,
  8125. (ushort)(q_addr +
  8126. ASC_SCSIQ_B_SG_WK_QP));
  8127. first_sg_wk_q_no = AscReadLramByte(iop_base,
  8128. (ushort)(q_addr +
  8129. ASC_SCSIQ_B_FIRST_SG_WK_QP));
  8130. /*
  8131. * Reset request's working SG queue back to the
  8132. * first SG queue.
  8133. */
  8134. AscWriteLramByte(iop_base,
  8135. (ushort)(q_addr +
  8136. (ushort)ASC_SCSIQ_B_SG_WK_QP),
  8137. first_sg_wk_q_no);
  8138. sg_head = scsiq->sg_head;
  8139. /*
  8140. * Set sg_entry_cnt to the number of SG elements
  8141. * that will be completed on this interrupt.
  8142. *
  8143. * Note: The allocated SG queues contain ASC_MAX_SG_LIST - 1
  8144. * SG elements. The data_cnt and data_addr fields which
  8145. * add 1 to the SG element capacity are not used when
  8146. * restarting SG handling after a halt.
  8147. */
  8148. if (scsiq->remain_sg_entry_cnt > (ASC_MAX_SG_LIST - 1)) {
  8149. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  8150. /*
  8151. * Keep track of remaining number of SG elements that
  8152. * will need to be handled on the next interrupt.
  8153. */
  8154. scsiq->remain_sg_entry_cnt -= (ASC_MAX_SG_LIST - 1);
  8155. } else {
  8156. sg_entry_cnt = scsiq->remain_sg_entry_cnt;
  8157. scsiq->remain_sg_entry_cnt = 0;
  8158. }
  8159. /*
  8160. * Copy SG elements into the list of allocated SG queues.
  8161. *
  8162. * Last index completed is saved in scsiq->next_sg_index.
  8163. */
  8164. next_qp = first_sg_wk_q_no;
  8165. q_addr = ASC_QNO_TO_QADDR(next_qp);
  8166. scsi_sg_q.sg_head_qp = q_no;
  8167. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  8168. for (i = 0; i < sg_head->queue_cnt; i++) {
  8169. scsi_sg_q.seq_no = i + 1;
  8170. if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
  8171. sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
  8172. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  8173. /*
  8174. * After very first SG queue RISC FW uses next
  8175. * SG queue first element then checks sg_list_cnt
  8176. * against zero and then decrements, so set
  8177. * sg_list_cnt 1 less than number of SG elements
  8178. * in each SG queue.
  8179. */
  8180. scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q - 1;
  8181. scsi_sg_q.sg_cur_list_cnt =
  8182. ASC_SG_LIST_PER_Q - 1;
  8183. } else {
  8184. /*
  8185. * This is the last SG queue in the list of
  8186. * allocated SG queues. If there are more
  8187. * SG elements than will fit in the allocated
  8188. * queues, then set the QCSG_SG_XFER_MORE flag.
  8189. */
  8190. if (scsiq->remain_sg_entry_cnt != 0) {
  8191. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  8192. } else {
  8193. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  8194. }
  8195. /* equals sg_entry_cnt * 2 */
  8196. sg_list_dwords = sg_entry_cnt << 1;
  8197. scsi_sg_q.sg_list_cnt = sg_entry_cnt - 1;
  8198. scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt - 1;
  8199. sg_entry_cnt = 0;
  8200. }
  8201. scsi_sg_q.q_no = next_qp;
  8202. AscMemWordCopyPtrToLram(iop_base,
  8203. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  8204. (uchar *)&scsi_sg_q,
  8205. sizeof(ASC_SG_LIST_Q) >> 1);
  8206. AscMemDWordCopyPtrToLram(iop_base,
  8207. q_addr + ASC_SGQ_LIST_BEG,
  8208. (uchar *)&sg_head->
  8209. sg_list[scsiq->next_sg_index],
  8210. sg_list_dwords);
  8211. scsiq->next_sg_index += ASC_SG_LIST_PER_Q;
  8212. /*
  8213. * If the just completed SG queue contained the
  8214. * last SG element, then no more SG queues need
  8215. * to be written.
  8216. */
  8217. if (scsi_sg_q.cntl & QCSG_SG_XFER_END) {
  8218. break;
  8219. }
  8220. next_qp = AscReadLramByte(iop_base,
  8221. (ushort)(q_addr +
  8222. ASC_SCSIQ_B_FWD));
  8223. q_addr = ASC_QNO_TO_QADDR(next_qp);
  8224. }
  8225. /*
  8226. * Clear the halt condition so the RISC will be restarted
  8227. * after the return.
  8228. */
  8229. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8230. return (0);
  8231. }
  8232. #endif /* CC_VERY_LONG_SG_LIST */
  8233. return (0);
  8234. }
  8235. /*
  8236. * void
  8237. * DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  8238. *
  8239. * Calling/Exit State:
  8240. * none
  8241. *
  8242. * Description:
  8243. * Input an ASC_QDONE_INFO structure from the chip
  8244. */
  8245. static void
  8246. DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  8247. {
  8248. int i;
  8249. ushort word;
  8250. AscSetChipLramAddr(iop_base, s_addr);
  8251. for (i = 0; i < 2 * words; i += 2) {
  8252. if (i == 10) {
  8253. continue;
  8254. }
  8255. word = inpw(iop_base + IOP_RAM_DATA);
  8256. inbuf[i] = word & 0xff;
  8257. inbuf[i + 1] = (word >> 8) & 0xff;
  8258. }
  8259. ASC_DBG_PRT_HEX(2, "DvcGetQinfo", inbuf, 2 * words);
  8260. }
  8261. static uchar
  8262. _AscCopyLramScsiDoneQ(PortAddr iop_base,
  8263. ushort q_addr,
  8264. ASC_QDONE_INFO *scsiq, ASC_DCNT max_dma_count)
  8265. {
  8266. ushort _val;
  8267. uchar sg_queue_cnt;
  8268. DvcGetQinfo(iop_base,
  8269. q_addr + ASC_SCSIQ_DONE_INFO_BEG,
  8270. (uchar *)scsiq,
  8271. (sizeof(ASC_SCSIQ_2) + sizeof(ASC_SCSIQ_3)) / 2);
  8272. _val = AscReadLramWord(iop_base,
  8273. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS));
  8274. scsiq->q_status = (uchar)_val;
  8275. scsiq->q_no = (uchar)(_val >> 8);
  8276. _val = AscReadLramWord(iop_base,
  8277. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_CNTL));
  8278. scsiq->cntl = (uchar)_val;
  8279. sg_queue_cnt = (uchar)(_val >> 8);
  8280. _val = AscReadLramWord(iop_base,
  8281. (ushort)(q_addr +
  8282. (ushort)ASC_SCSIQ_B_SENSE_LEN));
  8283. scsiq->sense_len = (uchar)_val;
  8284. scsiq->extra_bytes = (uchar)(_val >> 8);
  8285. /*
  8286. * Read high word of remain bytes from alternate location.
  8287. */
  8288. scsiq->remain_bytes = (((ADV_DCNT)AscReadLramWord(iop_base,
  8289. (ushort)(q_addr +
  8290. (ushort)
  8291. ASC_SCSIQ_W_ALT_DC1)))
  8292. << 16);
  8293. /*
  8294. * Read low word of remain bytes from original location.
  8295. */
  8296. scsiq->remain_bytes += AscReadLramWord(iop_base,
  8297. (ushort)(q_addr + (ushort)
  8298. ASC_SCSIQ_DW_REMAIN_XFER_CNT));
  8299. scsiq->remain_bytes &= max_dma_count;
  8300. return sg_queue_cnt;
  8301. }
  8302. /*
  8303. * asc_isr_callback() - Second Level Interrupt Handler called by AscISR().
  8304. *
  8305. * Interrupt callback function for the Narrow SCSI Asc Library.
  8306. */
  8307. static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
  8308. {
  8309. struct asc_board *boardp;
  8310. struct scsi_cmnd *scp;
  8311. struct Scsi_Host *shost;
  8312. ASC_DBG(1, "asc_dvc_varp 0x%p, qdonep 0x%p\n", asc_dvc_varp, qdonep);
  8313. ASC_DBG_PRT_ASC_QDONE_INFO(2, qdonep);
  8314. /*
  8315. * Get the struct scsi_cmnd structure and Scsi_Host structure for the
  8316. * command that has been completed.
  8317. */
  8318. scp = (struct scsi_cmnd *)ASC_U32_TO_VADDR(qdonep->d2.srb_ptr);
  8319. ASC_DBG(1, "scp 0x%p\n", scp);
  8320. if (scp == NULL) {
  8321. ASC_PRINT("asc_isr_callback: scp is NULL\n");
  8322. return;
  8323. }
  8324. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  8325. shost = scp->device->host;
  8326. ASC_STATS(shost, callback);
  8327. ASC_DBG(1, "shost 0x%p\n", shost);
  8328. boardp = shost_priv(shost);
  8329. BUG_ON(asc_dvc_varp != &boardp->dvc_var.asc_dvc_var);
  8330. /*
  8331. * 'qdonep' contains the command's ending status.
  8332. */
  8333. switch (qdonep->d3.done_stat) {
  8334. case QD_NO_ERROR:
  8335. ASC_DBG(2, "QD_NO_ERROR\n");
  8336. scp->result = 0;
  8337. /*
  8338. * Check for an underrun condition.
  8339. *
  8340. * If there was no error and an underrun condition, then
  8341. * return the number of underrun bytes.
  8342. */
  8343. if (scsi_bufflen(scp) != 0 && qdonep->remain_bytes != 0 &&
  8344. qdonep->remain_bytes <= scsi_bufflen(scp)) {
  8345. ASC_DBG(1, "underrun condition %u bytes\n",
  8346. (unsigned)qdonep->remain_bytes);
  8347. scsi_set_resid(scp, qdonep->remain_bytes);
  8348. }
  8349. break;
  8350. case QD_WITH_ERROR:
  8351. ASC_DBG(2, "QD_WITH_ERROR\n");
  8352. switch (qdonep->d3.host_stat) {
  8353. case QHSTA_NO_ERROR:
  8354. if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
  8355. ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n");
  8356. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  8357. sizeof(scp->sense_buffer));
  8358. /*
  8359. * Note: The 'status_byte()' macro used by
  8360. * target drivers defined in scsi.h shifts the
  8361. * status byte returned by host drivers right
  8362. * by 1 bit. This is why target drivers also
  8363. * use right shifted status byte definitions.
  8364. * For instance target drivers use
  8365. * CHECK_CONDITION, defined to 0x1, instead of
  8366. * the SCSI defined check condition value of
  8367. * 0x2. Host drivers are supposed to return
  8368. * the status byte as it is defined by SCSI.
  8369. */
  8370. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  8371. STATUS_BYTE(qdonep->d3.scsi_stat);
  8372. } else {
  8373. scp->result = STATUS_BYTE(qdonep->d3.scsi_stat);
  8374. }
  8375. break;
  8376. default:
  8377. /* QHSTA error occurred */
  8378. ASC_DBG(1, "host_stat 0x%x\n", qdonep->d3.host_stat);
  8379. scp->result = HOST_BYTE(DID_BAD_TARGET);
  8380. break;
  8381. }
  8382. break;
  8383. case QD_ABORTED_BY_HOST:
  8384. ASC_DBG(1, "QD_ABORTED_BY_HOST\n");
  8385. scp->result =
  8386. HOST_BYTE(DID_ABORT) | MSG_BYTE(qdonep->d3.
  8387. scsi_msg) |
  8388. STATUS_BYTE(qdonep->d3.scsi_stat);
  8389. break;
  8390. default:
  8391. ASC_DBG(1, "done_stat 0x%x\n", qdonep->d3.done_stat);
  8392. scp->result =
  8393. HOST_BYTE(DID_ERROR) | MSG_BYTE(qdonep->d3.
  8394. scsi_msg) |
  8395. STATUS_BYTE(qdonep->d3.scsi_stat);
  8396. break;
  8397. }
  8398. /*
  8399. * If the 'init_tidmask' bit isn't already set for the target and the
  8400. * current request finished normally, then set the bit for the target
  8401. * to indicate that a device is present.
  8402. */
  8403. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  8404. qdonep->d3.done_stat == QD_NO_ERROR &&
  8405. qdonep->d3.host_stat == QHSTA_NO_ERROR) {
  8406. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  8407. }
  8408. asc_scsi_done(scp);
  8409. }
  8410. static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
  8411. {
  8412. uchar next_qp;
  8413. uchar n_q_used;
  8414. uchar sg_list_qp;
  8415. uchar sg_queue_cnt;
  8416. uchar q_cnt;
  8417. uchar done_q_tail;
  8418. uchar tid_no;
  8419. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  8420. ASC_SCSI_BIT_ID_TYPE target_id;
  8421. PortAddr iop_base;
  8422. ushort q_addr;
  8423. ushort sg_q_addr;
  8424. uchar cur_target_qng;
  8425. ASC_QDONE_INFO scsiq_buf;
  8426. ASC_QDONE_INFO *scsiq;
  8427. int false_overrun;
  8428. iop_base = asc_dvc->iop_base;
  8429. n_q_used = 1;
  8430. scsiq = (ASC_QDONE_INFO *)&scsiq_buf;
  8431. done_q_tail = (uchar)AscGetVarDoneQTail(iop_base);
  8432. q_addr = ASC_QNO_TO_QADDR(done_q_tail);
  8433. next_qp = AscReadLramByte(iop_base,
  8434. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_FWD));
  8435. if (next_qp != ASC_QLINK_END) {
  8436. AscPutVarDoneQTail(iop_base, next_qp);
  8437. q_addr = ASC_QNO_TO_QADDR(next_qp);
  8438. sg_queue_cnt = _AscCopyLramScsiDoneQ(iop_base, q_addr, scsiq,
  8439. asc_dvc->max_dma_count);
  8440. AscWriteLramByte(iop_base,
  8441. (ushort)(q_addr +
  8442. (ushort)ASC_SCSIQ_B_STATUS),
  8443. (uchar)(scsiq->
  8444. q_status & (uchar)~(QS_READY |
  8445. QS_ABORTED)));
  8446. tid_no = ASC_TIX_TO_TID(scsiq->d2.target_ix);
  8447. target_id = ASC_TIX_TO_TARGET_ID(scsiq->d2.target_ix);
  8448. if ((scsiq->cntl & QC_SG_HEAD) != 0) {
  8449. sg_q_addr = q_addr;
  8450. sg_list_qp = next_qp;
  8451. for (q_cnt = 0; q_cnt < sg_queue_cnt; q_cnt++) {
  8452. sg_list_qp = AscReadLramByte(iop_base,
  8453. (ushort)(sg_q_addr
  8454. + (ushort)
  8455. ASC_SCSIQ_B_FWD));
  8456. sg_q_addr = ASC_QNO_TO_QADDR(sg_list_qp);
  8457. if (sg_list_qp == ASC_QLINK_END) {
  8458. AscSetLibErrorCode(asc_dvc,
  8459. ASCQ_ERR_SG_Q_LINKS);
  8460. scsiq->d3.done_stat = QD_WITH_ERROR;
  8461. scsiq->d3.host_stat =
  8462. QHSTA_D_QDONE_SG_LIST_CORRUPTED;
  8463. goto FATAL_ERR_QDONE;
  8464. }
  8465. AscWriteLramByte(iop_base,
  8466. (ushort)(sg_q_addr + (ushort)
  8467. ASC_SCSIQ_B_STATUS),
  8468. QS_FREE);
  8469. }
  8470. n_q_used = sg_queue_cnt + 1;
  8471. AscPutVarDoneQTail(iop_base, sg_list_qp);
  8472. }
  8473. if (asc_dvc->queue_full_or_busy & target_id) {
  8474. cur_target_qng = AscReadLramByte(iop_base,
  8475. (ushort)((ushort)
  8476. ASC_QADR_BEG
  8477. + (ushort)
  8478. scsiq->d2.
  8479. target_ix));
  8480. if (cur_target_qng < asc_dvc->max_dvc_qng[tid_no]) {
  8481. scsi_busy = AscReadLramByte(iop_base, (ushort)
  8482. ASCV_SCSIBUSY_B);
  8483. scsi_busy &= ~target_id;
  8484. AscWriteLramByte(iop_base,
  8485. (ushort)ASCV_SCSIBUSY_B,
  8486. scsi_busy);
  8487. asc_dvc->queue_full_or_busy &= ~target_id;
  8488. }
  8489. }
  8490. if (asc_dvc->cur_total_qng >= n_q_used) {
  8491. asc_dvc->cur_total_qng -= n_q_used;
  8492. if (asc_dvc->cur_dvc_qng[tid_no] != 0) {
  8493. asc_dvc->cur_dvc_qng[tid_no]--;
  8494. }
  8495. } else {
  8496. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CUR_QNG);
  8497. scsiq->d3.done_stat = QD_WITH_ERROR;
  8498. goto FATAL_ERR_QDONE;
  8499. }
  8500. if ((scsiq->d2.srb_ptr == 0UL) ||
  8501. ((scsiq->q_status & QS_ABORTED) != 0)) {
  8502. return (0x11);
  8503. } else if (scsiq->q_status == QS_DONE) {
  8504. false_overrun = FALSE;
  8505. if (scsiq->extra_bytes != 0) {
  8506. scsiq->remain_bytes +=
  8507. (ADV_DCNT)scsiq->extra_bytes;
  8508. }
  8509. if (scsiq->d3.done_stat == QD_WITH_ERROR) {
  8510. if (scsiq->d3.host_stat ==
  8511. QHSTA_M_DATA_OVER_RUN) {
  8512. if ((scsiq->
  8513. cntl & (QC_DATA_IN | QC_DATA_OUT))
  8514. == 0) {
  8515. scsiq->d3.done_stat =
  8516. QD_NO_ERROR;
  8517. scsiq->d3.host_stat =
  8518. QHSTA_NO_ERROR;
  8519. } else if (false_overrun) {
  8520. scsiq->d3.done_stat =
  8521. QD_NO_ERROR;
  8522. scsiq->d3.host_stat =
  8523. QHSTA_NO_ERROR;
  8524. }
  8525. } else if (scsiq->d3.host_stat ==
  8526. QHSTA_M_HUNG_REQ_SCSI_BUS_RESET) {
  8527. AscStopChip(iop_base);
  8528. AscSetChipControl(iop_base,
  8529. (uchar)(CC_SCSI_RESET
  8530. | CC_HALT));
  8531. udelay(60);
  8532. AscSetChipControl(iop_base, CC_HALT);
  8533. AscSetChipStatus(iop_base,
  8534. CIW_CLR_SCSI_RESET_INT);
  8535. AscSetChipStatus(iop_base, 0);
  8536. AscSetChipControl(iop_base, 0);
  8537. }
  8538. }
  8539. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  8540. asc_isr_callback(asc_dvc, scsiq);
  8541. } else {
  8542. if ((AscReadLramByte(iop_base,
  8543. (ushort)(q_addr + (ushort)
  8544. ASC_SCSIQ_CDB_BEG))
  8545. == START_STOP)) {
  8546. asc_dvc->unit_not_ready &= ~target_id;
  8547. if (scsiq->d3.done_stat != QD_NO_ERROR) {
  8548. asc_dvc->start_motor &=
  8549. ~target_id;
  8550. }
  8551. }
  8552. }
  8553. return (1);
  8554. } else {
  8555. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_Q_STATUS);
  8556. FATAL_ERR_QDONE:
  8557. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  8558. asc_isr_callback(asc_dvc, scsiq);
  8559. }
  8560. return (0x80);
  8561. }
  8562. }
  8563. return (0);
  8564. }
  8565. static int AscISR(ASC_DVC_VAR *asc_dvc)
  8566. {
  8567. ASC_CS_TYPE chipstat;
  8568. PortAddr iop_base;
  8569. ushort saved_ram_addr;
  8570. uchar ctrl_reg;
  8571. uchar saved_ctrl_reg;
  8572. int int_pending;
  8573. int status;
  8574. uchar host_flag;
  8575. iop_base = asc_dvc->iop_base;
  8576. int_pending = FALSE;
  8577. if (AscIsIntPending(iop_base) == 0)
  8578. return int_pending;
  8579. if ((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0) {
  8580. return ERR;
  8581. }
  8582. if (asc_dvc->in_critical_cnt != 0) {
  8583. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_ON_CRITICAL);
  8584. return ERR;
  8585. }
  8586. if (asc_dvc->is_in_int) {
  8587. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_RE_ENTRY);
  8588. return ERR;
  8589. }
  8590. asc_dvc->is_in_int = TRUE;
  8591. ctrl_reg = AscGetChipControl(iop_base);
  8592. saved_ctrl_reg = ctrl_reg & (~(CC_SCSI_RESET | CC_CHIP_RESET |
  8593. CC_SINGLE_STEP | CC_DIAG | CC_TEST));
  8594. chipstat = AscGetChipStatus(iop_base);
  8595. if (chipstat & CSW_SCSI_RESET_LATCH) {
  8596. if (!(asc_dvc->bus_type & (ASC_IS_VL | ASC_IS_EISA))) {
  8597. int i = 10;
  8598. int_pending = TRUE;
  8599. asc_dvc->sdtr_done = 0;
  8600. saved_ctrl_reg &= (uchar)(~CC_HALT);
  8601. while ((AscGetChipStatus(iop_base) &
  8602. CSW_SCSI_RESET_ACTIVE) && (i-- > 0)) {
  8603. mdelay(100);
  8604. }
  8605. AscSetChipControl(iop_base, (CC_CHIP_RESET | CC_HALT));
  8606. AscSetChipControl(iop_base, CC_HALT);
  8607. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  8608. AscSetChipStatus(iop_base, 0);
  8609. chipstat = AscGetChipStatus(iop_base);
  8610. }
  8611. }
  8612. saved_ram_addr = AscGetChipLramAddr(iop_base);
  8613. host_flag = AscReadLramByte(iop_base,
  8614. ASCV_HOST_FLAG_B) &
  8615. (uchar)(~ASC_HOST_FLAG_IN_ISR);
  8616. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  8617. (uchar)(host_flag | (uchar)ASC_HOST_FLAG_IN_ISR));
  8618. if ((chipstat & CSW_INT_PENDING) || (int_pending)) {
  8619. AscAckInterrupt(iop_base);
  8620. int_pending = TRUE;
  8621. if ((chipstat & CSW_HALTED) && (ctrl_reg & CC_SINGLE_STEP)) {
  8622. if (AscIsrChipHalted(asc_dvc) == ERR) {
  8623. goto ISR_REPORT_QDONE_FATAL_ERROR;
  8624. } else {
  8625. saved_ctrl_reg &= (uchar)(~CC_HALT);
  8626. }
  8627. } else {
  8628. ISR_REPORT_QDONE_FATAL_ERROR:
  8629. if ((asc_dvc->dvc_cntl & ASC_CNTL_INT_MULTI_Q) != 0) {
  8630. while (((status =
  8631. AscIsrQDone(asc_dvc)) & 0x01) != 0) {
  8632. }
  8633. } else {
  8634. do {
  8635. if ((status =
  8636. AscIsrQDone(asc_dvc)) == 1) {
  8637. break;
  8638. }
  8639. } while (status == 0x11);
  8640. }
  8641. if ((status & 0x80) != 0)
  8642. int_pending = ERR;
  8643. }
  8644. }
  8645. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  8646. AscSetChipLramAddr(iop_base, saved_ram_addr);
  8647. AscSetChipControl(iop_base, saved_ctrl_reg);
  8648. asc_dvc->is_in_int = FALSE;
  8649. return int_pending;
  8650. }
  8651. /*
  8652. * advansys_reset()
  8653. *
  8654. * Reset the bus associated with the command 'scp'.
  8655. *
  8656. * This function runs its own thread. Interrupts must be blocked but
  8657. * sleeping is allowed and no locking other than for host structures is
  8658. * required. Returns SUCCESS or FAILED.
  8659. */
  8660. static int advansys_reset(struct scsi_cmnd *scp)
  8661. {
  8662. struct Scsi_Host *shost = scp->device->host;
  8663. struct asc_board *boardp = shost_priv(shost);
  8664. unsigned long flags;
  8665. int status;
  8666. int ret = SUCCESS;
  8667. ASC_DBG(1, "0x%p\n", scp);
  8668. ASC_STATS(shost, reset);
  8669. scmd_printk(KERN_INFO, scp, "SCSI bus reset started...\n");
  8670. if (ASC_NARROW_BOARD(boardp)) {
  8671. ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  8672. /* Reset the chip and SCSI bus. */
  8673. ASC_DBG(1, "before AscInitAsc1000Driver()\n");
  8674. status = AscInitAsc1000Driver(asc_dvc);
  8675. /* Refer to ASC_IERR_* defintions for meaning of 'err_code'. */
  8676. if (asc_dvc->err_code) {
  8677. scmd_printk(KERN_INFO, scp, "SCSI bus reset error: "
  8678. "0x%x\n", asc_dvc->err_code);
  8679. ret = FAILED;
  8680. } else if (status) {
  8681. scmd_printk(KERN_INFO, scp, "SCSI bus reset warning: "
  8682. "0x%x\n", status);
  8683. } else {
  8684. scmd_printk(KERN_INFO, scp, "SCSI bus reset "
  8685. "successful\n");
  8686. }
  8687. ASC_DBG(1, "after AscInitAsc1000Driver()\n");
  8688. spin_lock_irqsave(shost->host_lock, flags);
  8689. } else {
  8690. /*
  8691. * If the suggest reset bus flags are set, then reset the bus.
  8692. * Otherwise only reset the device.
  8693. */
  8694. ADV_DVC_VAR *adv_dvc = &boardp->dvc_var.adv_dvc_var;
  8695. /*
  8696. * Reset the target's SCSI bus.
  8697. */
  8698. ASC_DBG(1, "before AdvResetChipAndSB()\n");
  8699. switch (AdvResetChipAndSB(adv_dvc)) {
  8700. case ASC_TRUE:
  8701. scmd_printk(KERN_INFO, scp, "SCSI bus reset "
  8702. "successful\n");
  8703. break;
  8704. case ASC_FALSE:
  8705. default:
  8706. scmd_printk(KERN_INFO, scp, "SCSI bus reset error\n");
  8707. ret = FAILED;
  8708. break;
  8709. }
  8710. spin_lock_irqsave(shost->host_lock, flags);
  8711. AdvISR(adv_dvc);
  8712. }
  8713. /* Save the time of the most recently completed reset. */
  8714. boardp->last_reset = jiffies;
  8715. spin_unlock_irqrestore(shost->host_lock, flags);
  8716. ASC_DBG(1, "ret %d\n", ret);
  8717. return ret;
  8718. }
  8719. /*
  8720. * advansys_biosparam()
  8721. *
  8722. * Translate disk drive geometry if the "BIOS greater than 1 GB"
  8723. * support is enabled for a drive.
  8724. *
  8725. * ip (information pointer) is an int array with the following definition:
  8726. * ip[0]: heads
  8727. * ip[1]: sectors
  8728. * ip[2]: cylinders
  8729. */
  8730. static int
  8731. advansys_biosparam(struct scsi_device *sdev, struct block_device *bdev,
  8732. sector_t capacity, int ip[])
  8733. {
  8734. struct asc_board *boardp = shost_priv(sdev->host);
  8735. ASC_DBG(1, "begin\n");
  8736. ASC_STATS(sdev->host, biosparam);
  8737. if (ASC_NARROW_BOARD(boardp)) {
  8738. if ((boardp->dvc_var.asc_dvc_var.dvc_cntl &
  8739. ASC_CNTL_BIOS_GT_1GB) && capacity > 0x200000) {
  8740. ip[0] = 255;
  8741. ip[1] = 63;
  8742. } else {
  8743. ip[0] = 64;
  8744. ip[1] = 32;
  8745. }
  8746. } else {
  8747. if ((boardp->dvc_var.adv_dvc_var.bios_ctrl &
  8748. BIOS_CTRL_EXTENDED_XLAT) && capacity > 0x200000) {
  8749. ip[0] = 255;
  8750. ip[1] = 63;
  8751. } else {
  8752. ip[0] = 64;
  8753. ip[1] = 32;
  8754. }
  8755. }
  8756. ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
  8757. ASC_DBG(1, "end\n");
  8758. return 0;
  8759. }
  8760. /*
  8761. * First-level interrupt handler.
  8762. *
  8763. * 'dev_id' is a pointer to the interrupting adapter's Scsi_Host.
  8764. */
  8765. static irqreturn_t advansys_interrupt(int irq, void *dev_id)
  8766. {
  8767. struct Scsi_Host *shost = dev_id;
  8768. struct asc_board *boardp = shost_priv(shost);
  8769. irqreturn_t result = IRQ_NONE;
  8770. ASC_DBG(2, "boardp 0x%p\n", boardp);
  8771. spin_lock(shost->host_lock);
  8772. if (ASC_NARROW_BOARD(boardp)) {
  8773. if (AscIsIntPending(shost->io_port)) {
  8774. result = IRQ_HANDLED;
  8775. ASC_STATS(shost, interrupt);
  8776. ASC_DBG(1, "before AscISR()\n");
  8777. AscISR(&boardp->dvc_var.asc_dvc_var);
  8778. }
  8779. } else {
  8780. ASC_DBG(1, "before AdvISR()\n");
  8781. if (AdvISR(&boardp->dvc_var.adv_dvc_var)) {
  8782. result = IRQ_HANDLED;
  8783. ASC_STATS(shost, interrupt);
  8784. }
  8785. }
  8786. spin_unlock(shost->host_lock);
  8787. ASC_DBG(1, "end\n");
  8788. return result;
  8789. }
  8790. static int AscHostReqRiscHalt(PortAddr iop_base)
  8791. {
  8792. int count = 0;
  8793. int sta = 0;
  8794. uchar saved_stop_code;
  8795. if (AscIsChipHalted(iop_base))
  8796. return (1);
  8797. saved_stop_code = AscReadLramByte(iop_base, ASCV_STOP_CODE_B);
  8798. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  8799. ASC_STOP_HOST_REQ_RISC_HALT | ASC_STOP_REQ_RISC_STOP);
  8800. do {
  8801. if (AscIsChipHalted(iop_base)) {
  8802. sta = 1;
  8803. break;
  8804. }
  8805. mdelay(100);
  8806. } while (count++ < 20);
  8807. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, saved_stop_code);
  8808. return (sta);
  8809. }
  8810. static int
  8811. AscSetRunChipSynRegAtID(PortAddr iop_base, uchar tid_no, uchar sdtr_data)
  8812. {
  8813. int sta = FALSE;
  8814. if (AscHostReqRiscHalt(iop_base)) {
  8815. sta = AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  8816. AscStartChip(iop_base);
  8817. }
  8818. return sta;
  8819. }
  8820. static void AscAsyncFix(ASC_DVC_VAR *asc_dvc, struct scsi_device *sdev)
  8821. {
  8822. char type = sdev->type;
  8823. ASC_SCSI_BIT_ID_TYPE tid_bits = 1 << sdev->id;
  8824. if (!(asc_dvc->bug_fix_cntl & ASC_BUG_FIX_ASYN_USE_SYN))
  8825. return;
  8826. if (asc_dvc->init_sdtr & tid_bits)
  8827. return;
  8828. if ((type == TYPE_ROM) && (strncmp(sdev->vendor, "HP ", 3) == 0))
  8829. asc_dvc->pci_fix_asyn_xfer_always |= tid_bits;
  8830. asc_dvc->pci_fix_asyn_xfer |= tid_bits;
  8831. if ((type == TYPE_PROCESSOR) || (type == TYPE_SCANNER) ||
  8832. (type == TYPE_ROM) || (type == TYPE_TAPE))
  8833. asc_dvc->pci_fix_asyn_xfer &= ~tid_bits;
  8834. if (asc_dvc->pci_fix_asyn_xfer & tid_bits)
  8835. AscSetRunChipSynRegAtID(asc_dvc->iop_base, sdev->id,
  8836. ASYN_SDTR_DATA_FIX_PCI_REV_AB);
  8837. }
  8838. static void
  8839. advansys_narrow_slave_configure(struct scsi_device *sdev, ASC_DVC_VAR *asc_dvc)
  8840. {
  8841. ASC_SCSI_BIT_ID_TYPE tid_bit = 1 << sdev->id;
  8842. ASC_SCSI_BIT_ID_TYPE orig_use_tagged_qng = asc_dvc->use_tagged_qng;
  8843. if (sdev->lun == 0) {
  8844. ASC_SCSI_BIT_ID_TYPE orig_init_sdtr = asc_dvc->init_sdtr;
  8845. if ((asc_dvc->cfg->sdtr_enable & tid_bit) && sdev->sdtr) {
  8846. asc_dvc->init_sdtr |= tid_bit;
  8847. } else {
  8848. asc_dvc->init_sdtr &= ~tid_bit;
  8849. }
  8850. if (orig_init_sdtr != asc_dvc->init_sdtr)
  8851. AscAsyncFix(asc_dvc, sdev);
  8852. }
  8853. if (sdev->tagged_supported) {
  8854. if (asc_dvc->cfg->cmd_qng_enabled & tid_bit) {
  8855. if (sdev->lun == 0) {
  8856. asc_dvc->cfg->can_tagged_qng |= tid_bit;
  8857. asc_dvc->use_tagged_qng |= tid_bit;
  8858. }
  8859. scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
  8860. asc_dvc->max_dvc_qng[sdev->id]);
  8861. }
  8862. } else {
  8863. if (sdev->lun == 0) {
  8864. asc_dvc->cfg->can_tagged_qng &= ~tid_bit;
  8865. asc_dvc->use_tagged_qng &= ~tid_bit;
  8866. }
  8867. scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
  8868. }
  8869. if ((sdev->lun == 0) &&
  8870. (orig_use_tagged_qng != asc_dvc->use_tagged_qng)) {
  8871. AscWriteLramByte(asc_dvc->iop_base, ASCV_DISC_ENABLE_B,
  8872. asc_dvc->cfg->disc_enable);
  8873. AscWriteLramByte(asc_dvc->iop_base, ASCV_USE_TAGGED_QNG_B,
  8874. asc_dvc->use_tagged_qng);
  8875. AscWriteLramByte(asc_dvc->iop_base, ASCV_CAN_TAGGED_QNG_B,
  8876. asc_dvc->cfg->can_tagged_qng);
  8877. asc_dvc->max_dvc_qng[sdev->id] =
  8878. asc_dvc->cfg->max_tag_qng[sdev->id];
  8879. AscWriteLramByte(asc_dvc->iop_base,
  8880. (ushort)(ASCV_MAX_DVC_QNG_BEG + sdev->id),
  8881. asc_dvc->max_dvc_qng[sdev->id]);
  8882. }
  8883. }
  8884. /*
  8885. * Wide Transfers
  8886. *
  8887. * If the EEPROM enabled WDTR for the device and the device supports wide
  8888. * bus (16 bit) transfers, then turn on the device's 'wdtr_able' bit and
  8889. * write the new value to the microcode.
  8890. */
  8891. static void
  8892. advansys_wide_enable_wdtr(AdvPortAddr iop_base, unsigned short tidmask)
  8893. {
  8894. unsigned short cfg_word;
  8895. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
  8896. if ((cfg_word & tidmask) != 0)
  8897. return;
  8898. cfg_word |= tidmask;
  8899. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
  8900. /*
  8901. * Clear the microcode SDTR and WDTR negotiation done indicators for
  8902. * the target to cause it to negotiate with the new setting set above.
  8903. * WDTR when accepted causes the target to enter asynchronous mode, so
  8904. * SDTR must be negotiated.
  8905. */
  8906. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  8907. cfg_word &= ~tidmask;
  8908. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  8909. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
  8910. cfg_word &= ~tidmask;
  8911. AdvWriteWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
  8912. }
  8913. /*
  8914. * Synchronous Transfers
  8915. *
  8916. * If the EEPROM enabled SDTR for the device and the device
  8917. * supports synchronous transfers, then turn on the device's
  8918. * 'sdtr_able' bit. Write the new value to the microcode.
  8919. */
  8920. static void
  8921. advansys_wide_enable_sdtr(AdvPortAddr iop_base, unsigned short tidmask)
  8922. {
  8923. unsigned short cfg_word;
  8924. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
  8925. if ((cfg_word & tidmask) != 0)
  8926. return;
  8927. cfg_word |= tidmask;
  8928. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
  8929. /*
  8930. * Clear the microcode "SDTR negotiation" done indicator for the
  8931. * target to cause it to negotiate with the new setting set above.
  8932. */
  8933. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  8934. cfg_word &= ~tidmask;
  8935. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  8936. }
  8937. /*
  8938. * PPR (Parallel Protocol Request) Capable
  8939. *
  8940. * If the device supports DT mode, then it must be PPR capable.
  8941. * The PPR message will be used in place of the SDTR and WDTR
  8942. * messages to negotiate synchronous speed and offset, transfer
  8943. * width, and protocol options.
  8944. */
  8945. static void advansys_wide_enable_ppr(ADV_DVC_VAR *adv_dvc,
  8946. AdvPortAddr iop_base, unsigned short tidmask)
  8947. {
  8948. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
  8949. adv_dvc->ppr_able |= tidmask;
  8950. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
  8951. }
  8952. static void
  8953. advansys_wide_slave_configure(struct scsi_device *sdev, ADV_DVC_VAR *adv_dvc)
  8954. {
  8955. AdvPortAddr iop_base = adv_dvc->iop_base;
  8956. unsigned short tidmask = 1 << sdev->id;
  8957. if (sdev->lun == 0) {
  8958. /*
  8959. * Handle WDTR, SDTR, and Tag Queuing. If the feature
  8960. * is enabled in the EEPROM and the device supports the
  8961. * feature, then enable it in the microcode.
  8962. */
  8963. if ((adv_dvc->wdtr_able & tidmask) && sdev->wdtr)
  8964. advansys_wide_enable_wdtr(iop_base, tidmask);
  8965. if ((adv_dvc->sdtr_able & tidmask) && sdev->sdtr)
  8966. advansys_wide_enable_sdtr(iop_base, tidmask);
  8967. if (adv_dvc->chip_type == ADV_CHIP_ASC38C1600 && sdev->ppr)
  8968. advansys_wide_enable_ppr(adv_dvc, iop_base, tidmask);
  8969. /*
  8970. * Tag Queuing is disabled for the BIOS which runs in polled
  8971. * mode and would see no benefit from Tag Queuing. Also by
  8972. * disabling Tag Queuing in the BIOS devices with Tag Queuing
  8973. * bugs will at least work with the BIOS.
  8974. */
  8975. if ((adv_dvc->tagqng_able & tidmask) &&
  8976. sdev->tagged_supported) {
  8977. unsigned short cfg_word;
  8978. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, cfg_word);
  8979. cfg_word |= tidmask;
  8980. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  8981. cfg_word);
  8982. AdvWriteByteLram(iop_base,
  8983. ASC_MC_NUMBER_OF_MAX_CMD + sdev->id,
  8984. adv_dvc->max_dvc_qng);
  8985. }
  8986. }
  8987. if ((adv_dvc->tagqng_able & tidmask) && sdev->tagged_supported) {
  8988. scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
  8989. adv_dvc->max_dvc_qng);
  8990. } else {
  8991. scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
  8992. }
  8993. }
  8994. /*
  8995. * Set the number of commands to queue per device for the
  8996. * specified host adapter.
  8997. */
  8998. static int advansys_slave_configure(struct scsi_device *sdev)
  8999. {
  9000. struct asc_board *boardp = shost_priv(sdev->host);
  9001. if (ASC_NARROW_BOARD(boardp))
  9002. advansys_narrow_slave_configure(sdev,
  9003. &boardp->dvc_var.asc_dvc_var);
  9004. else
  9005. advansys_wide_slave_configure(sdev,
  9006. &boardp->dvc_var.adv_dvc_var);
  9007. return 0;
  9008. }
  9009. static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
  9010. struct asc_scsi_q *asc_scsi_q)
  9011. {
  9012. int use_sg;
  9013. memset(asc_scsi_q, 0, sizeof(*asc_scsi_q));
  9014. /*
  9015. * Point the ASC_SCSI_Q to the 'struct scsi_cmnd'.
  9016. */
  9017. asc_scsi_q->q2.srb_ptr = ASC_VADDR_TO_U32(scp);
  9018. /*
  9019. * Build the ASC_SCSI_Q request.
  9020. */
  9021. asc_scsi_q->cdbptr = &scp->cmnd[0];
  9022. asc_scsi_q->q2.cdb_len = scp->cmd_len;
  9023. asc_scsi_q->q1.target_id = ASC_TID_TO_TARGET_ID(scp->device->id);
  9024. asc_scsi_q->q1.target_lun = scp->device->lun;
  9025. asc_scsi_q->q2.target_ix =
  9026. ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
  9027. asc_scsi_q->q1.sense_addr =
  9028. cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
  9029. asc_scsi_q->q1.sense_len = sizeof(scp->sense_buffer);
  9030. /*
  9031. * If there are any outstanding requests for the current target,
  9032. * then every 255th request send an ORDERED request. This heuristic
  9033. * tries to retain the benefit of request sorting while preventing
  9034. * request starvation. 255 is the max number of tags or pending commands
  9035. * a device may have outstanding.
  9036. *
  9037. * The request count is incremented below for every successfully
  9038. * started request.
  9039. *
  9040. */
  9041. if ((boardp->dvc_var.asc_dvc_var.cur_dvc_qng[scp->device->id] > 0) &&
  9042. (boardp->reqcnt[scp->device->id] % 255) == 0) {
  9043. asc_scsi_q->q2.tag_code = MSG_ORDERED_TAG;
  9044. } else {
  9045. asc_scsi_q->q2.tag_code = MSG_SIMPLE_TAG;
  9046. }
  9047. /* Build ASC_SCSI_Q */
  9048. use_sg = scsi_dma_map(scp);
  9049. if (use_sg != 0) {
  9050. int sgcnt;
  9051. struct scatterlist *slp;
  9052. struct asc_sg_head *asc_sg_head;
  9053. if (use_sg > scp->device->host->sg_tablesize) {
  9054. scmd_printk(KERN_ERR, scp, "use_sg %d > "
  9055. "sg_tablesize %d\n", use_sg,
  9056. scp->device->host->sg_tablesize);
  9057. scsi_dma_unmap(scp);
  9058. scp->result = HOST_BYTE(DID_ERROR);
  9059. return ASC_ERROR;
  9060. }
  9061. asc_sg_head = kzalloc(sizeof(asc_scsi_q->sg_head) +
  9062. use_sg * sizeof(struct asc_sg_list), GFP_ATOMIC);
  9063. if (!asc_sg_head) {
  9064. scsi_dma_unmap(scp);
  9065. scp->result = HOST_BYTE(DID_SOFT_ERROR);
  9066. return ASC_ERROR;
  9067. }
  9068. asc_scsi_q->q1.cntl |= QC_SG_HEAD;
  9069. asc_scsi_q->sg_head = asc_sg_head;
  9070. asc_scsi_q->q1.data_cnt = 0;
  9071. asc_scsi_q->q1.data_addr = 0;
  9072. /* This is a byte value, otherwise it would need to be swapped. */
  9073. asc_sg_head->entry_cnt = asc_scsi_q->q1.sg_queue_cnt = use_sg;
  9074. ASC_STATS_ADD(scp->device->host, xfer_elem,
  9075. asc_sg_head->entry_cnt);
  9076. /*
  9077. * Convert scatter-gather list into ASC_SG_HEAD list.
  9078. */
  9079. scsi_for_each_sg(scp, slp, use_sg, sgcnt) {
  9080. asc_sg_head->sg_list[sgcnt].addr =
  9081. cpu_to_le32(sg_dma_address(slp));
  9082. asc_sg_head->sg_list[sgcnt].bytes =
  9083. cpu_to_le32(sg_dma_len(slp));
  9084. ASC_STATS_ADD(scp->device->host, xfer_sect,
  9085. DIV_ROUND_UP(sg_dma_len(slp), 512));
  9086. }
  9087. }
  9088. ASC_STATS(scp->device->host, xfer_cnt);
  9089. ASC_DBG_PRT_ASC_SCSI_Q(2, asc_scsi_q);
  9090. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  9091. return ASC_NOERROR;
  9092. }
  9093. /*
  9094. * Build scatter-gather list for Adv Library (Wide Board).
  9095. *
  9096. * Additional ADV_SG_BLOCK structures will need to be allocated
  9097. * if the total number of scatter-gather elements exceeds
  9098. * NO_OF_SG_PER_BLOCK (15). The ADV_SG_BLOCK structures are
  9099. * assumed to be physically contiguous.
  9100. *
  9101. * Return:
  9102. * ADV_SUCCESS(1) - SG List successfully created
  9103. * ADV_ERROR(-1) - SG List creation failed
  9104. */
  9105. static int
  9106. adv_get_sglist(struct asc_board *boardp, adv_req_t *reqp, struct scsi_cmnd *scp,
  9107. int use_sg)
  9108. {
  9109. adv_sgblk_t *sgblkp;
  9110. ADV_SCSI_REQ_Q *scsiqp;
  9111. struct scatterlist *slp;
  9112. int sg_elem_cnt;
  9113. ADV_SG_BLOCK *sg_block, *prev_sg_block;
  9114. ADV_PADDR sg_block_paddr;
  9115. int i;
  9116. scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
  9117. slp = scsi_sglist(scp);
  9118. sg_elem_cnt = use_sg;
  9119. prev_sg_block = NULL;
  9120. reqp->sgblkp = NULL;
  9121. for (;;) {
  9122. /*
  9123. * Allocate a 'adv_sgblk_t' structure from the board free
  9124. * list. One 'adv_sgblk_t' structure holds NO_OF_SG_PER_BLOCK
  9125. * (15) scatter-gather elements.
  9126. */
  9127. if ((sgblkp = boardp->adv_sgblkp) == NULL) {
  9128. ASC_DBG(1, "no free adv_sgblk_t\n");
  9129. ASC_STATS(scp->device->host, adv_build_nosg);
  9130. /*
  9131. * Allocation failed. Free 'adv_sgblk_t' structures
  9132. * already allocated for the request.
  9133. */
  9134. while ((sgblkp = reqp->sgblkp) != NULL) {
  9135. /* Remove 'sgblkp' from the request list. */
  9136. reqp->sgblkp = sgblkp->next_sgblkp;
  9137. /* Add 'sgblkp' to the board free list. */
  9138. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  9139. boardp->adv_sgblkp = sgblkp;
  9140. }
  9141. return ASC_BUSY;
  9142. }
  9143. /* Complete 'adv_sgblk_t' board allocation. */
  9144. boardp->adv_sgblkp = sgblkp->next_sgblkp;
  9145. sgblkp->next_sgblkp = NULL;
  9146. /*
  9147. * Get 8 byte aligned virtual and physical addresses
  9148. * for the allocated ADV_SG_BLOCK structure.
  9149. */
  9150. sg_block = (ADV_SG_BLOCK *)ADV_8BALIGN(&sgblkp->sg_block);
  9151. sg_block_paddr = virt_to_bus(sg_block);
  9152. /*
  9153. * Check if this is the first 'adv_sgblk_t' for the
  9154. * request.
  9155. */
  9156. if (reqp->sgblkp == NULL) {
  9157. /* Request's first scatter-gather block. */
  9158. reqp->sgblkp = sgblkp;
  9159. /*
  9160. * Set ADV_SCSI_REQ_T ADV_SG_BLOCK virtual and physical
  9161. * address pointers.
  9162. */
  9163. scsiqp->sg_list_ptr = sg_block;
  9164. scsiqp->sg_real_addr = cpu_to_le32(sg_block_paddr);
  9165. } else {
  9166. /* Request's second or later scatter-gather block. */
  9167. sgblkp->next_sgblkp = reqp->sgblkp;
  9168. reqp->sgblkp = sgblkp;
  9169. /*
  9170. * Point the previous ADV_SG_BLOCK structure to
  9171. * the newly allocated ADV_SG_BLOCK structure.
  9172. */
  9173. prev_sg_block->sg_ptr = cpu_to_le32(sg_block_paddr);
  9174. }
  9175. for (i = 0; i < NO_OF_SG_PER_BLOCK; i++) {
  9176. sg_block->sg_list[i].sg_addr =
  9177. cpu_to_le32(sg_dma_address(slp));
  9178. sg_block->sg_list[i].sg_count =
  9179. cpu_to_le32(sg_dma_len(slp));
  9180. ASC_STATS_ADD(scp->device->host, xfer_sect,
  9181. DIV_ROUND_UP(sg_dma_len(slp), 512));
  9182. if (--sg_elem_cnt == 0) { /* Last ADV_SG_BLOCK and scatter-gather entry. */
  9183. sg_block->sg_cnt = i + 1;
  9184. sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in list. */
  9185. return ADV_SUCCESS;
  9186. }
  9187. slp++;
  9188. }
  9189. sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
  9190. prev_sg_block = sg_block;
  9191. }
  9192. }
  9193. /*
  9194. * Build a request structure for the Adv Library (Wide Board).
  9195. *
  9196. * If an adv_req_t can not be allocated to issue the request,
  9197. * then return ASC_BUSY. If an error occurs, then return ASC_ERROR.
  9198. *
  9199. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the
  9200. * microcode for DMA addresses or math operations are byte swapped
  9201. * to little-endian order.
  9202. */
  9203. static int
  9204. adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
  9205. ADV_SCSI_REQ_Q **adv_scsiqpp)
  9206. {
  9207. adv_req_t *reqp;
  9208. ADV_SCSI_REQ_Q *scsiqp;
  9209. int i;
  9210. int ret;
  9211. int use_sg;
  9212. /*
  9213. * Allocate an adv_req_t structure from the board to execute
  9214. * the command.
  9215. */
  9216. if (boardp->adv_reqp == NULL) {
  9217. ASC_DBG(1, "no free adv_req_t\n");
  9218. ASC_STATS(scp->device->host, adv_build_noreq);
  9219. return ASC_BUSY;
  9220. } else {
  9221. reqp = boardp->adv_reqp;
  9222. boardp->adv_reqp = reqp->next_reqp;
  9223. reqp->next_reqp = NULL;
  9224. }
  9225. /*
  9226. * Get 32-byte aligned ADV_SCSI_REQ_Q and ADV_SG_BLOCK pointers.
  9227. */
  9228. scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
  9229. /*
  9230. * Initialize the structure.
  9231. */
  9232. scsiqp->cntl = scsiqp->scsi_cntl = scsiqp->done_status = 0;
  9233. /*
  9234. * Set the ADV_SCSI_REQ_Q 'srb_ptr' to point to the adv_req_t structure.
  9235. */
  9236. scsiqp->srb_ptr = ASC_VADDR_TO_U32(reqp);
  9237. /*
  9238. * Set the adv_req_t 'cmndp' to point to the struct scsi_cmnd structure.
  9239. */
  9240. reqp->cmndp = scp;
  9241. /*
  9242. * Build the ADV_SCSI_REQ_Q request.
  9243. */
  9244. /* Set CDB length and copy it to the request structure. */
  9245. scsiqp->cdb_len = scp->cmd_len;
  9246. /* Copy first 12 CDB bytes to cdb[]. */
  9247. for (i = 0; i < scp->cmd_len && i < 12; i++) {
  9248. scsiqp->cdb[i] = scp->cmnd[i];
  9249. }
  9250. /* Copy last 4 CDB bytes, if present, to cdb16[]. */
  9251. for (; i < scp->cmd_len; i++) {
  9252. scsiqp->cdb16[i - 12] = scp->cmnd[i];
  9253. }
  9254. scsiqp->target_id = scp->device->id;
  9255. scsiqp->target_lun = scp->device->lun;
  9256. scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
  9257. scsiqp->sense_len = sizeof(scp->sense_buffer);
  9258. /* Build ADV_SCSI_REQ_Q */
  9259. use_sg = scsi_dma_map(scp);
  9260. if (use_sg == 0) {
  9261. /* Zero-length transfer */
  9262. reqp->sgblkp = NULL;
  9263. scsiqp->data_cnt = 0;
  9264. scsiqp->vdata_addr = NULL;
  9265. scsiqp->data_addr = 0;
  9266. scsiqp->sg_list_ptr = NULL;
  9267. scsiqp->sg_real_addr = 0;
  9268. } else {
  9269. if (use_sg > ADV_MAX_SG_LIST) {
  9270. scmd_printk(KERN_ERR, scp, "use_sg %d > "
  9271. "ADV_MAX_SG_LIST %d\n", use_sg,
  9272. scp->device->host->sg_tablesize);
  9273. scsi_dma_unmap(scp);
  9274. scp->result = HOST_BYTE(DID_ERROR);
  9275. /*
  9276. * Free the 'adv_req_t' structure by adding it back
  9277. * to the board free list.
  9278. */
  9279. reqp->next_reqp = boardp->adv_reqp;
  9280. boardp->adv_reqp = reqp;
  9281. return ASC_ERROR;
  9282. }
  9283. scsiqp->data_cnt = cpu_to_le32(scsi_bufflen(scp));
  9284. ret = adv_get_sglist(boardp, reqp, scp, use_sg);
  9285. if (ret != ADV_SUCCESS) {
  9286. /*
  9287. * Free the adv_req_t structure by adding it back to
  9288. * the board free list.
  9289. */
  9290. reqp->next_reqp = boardp->adv_reqp;
  9291. boardp->adv_reqp = reqp;
  9292. return ret;
  9293. }
  9294. ASC_STATS_ADD(scp->device->host, xfer_elem, use_sg);
  9295. }
  9296. ASC_STATS(scp->device->host, xfer_cnt);
  9297. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  9298. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  9299. *adv_scsiqpp = scsiqp;
  9300. return ASC_NOERROR;
  9301. }
  9302. static int AscSgListToQueue(int sg_list)
  9303. {
  9304. int n_sg_list_qs;
  9305. n_sg_list_qs = ((sg_list - 1) / ASC_SG_LIST_PER_Q);
  9306. if (((sg_list - 1) % ASC_SG_LIST_PER_Q) != 0)
  9307. n_sg_list_qs++;
  9308. return n_sg_list_qs + 1;
  9309. }
  9310. static uint
  9311. AscGetNumOfFreeQueue(ASC_DVC_VAR *asc_dvc, uchar target_ix, uchar n_qs)
  9312. {
  9313. uint cur_used_qs;
  9314. uint cur_free_qs;
  9315. ASC_SCSI_BIT_ID_TYPE target_id;
  9316. uchar tid_no;
  9317. target_id = ASC_TIX_TO_TARGET_ID(target_ix);
  9318. tid_no = ASC_TIX_TO_TID(target_ix);
  9319. if ((asc_dvc->unit_not_ready & target_id) ||
  9320. (asc_dvc->queue_full_or_busy & target_id)) {
  9321. return 0;
  9322. }
  9323. if (n_qs == 1) {
  9324. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  9325. (uint) asc_dvc->last_q_shortage + (uint) ASC_MIN_FREE_Q;
  9326. } else {
  9327. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  9328. (uint) ASC_MIN_FREE_Q;
  9329. }
  9330. if ((uint) (cur_used_qs + n_qs) <= (uint) asc_dvc->max_total_qng) {
  9331. cur_free_qs = (uint) asc_dvc->max_total_qng - cur_used_qs;
  9332. if (asc_dvc->cur_dvc_qng[tid_no] >=
  9333. asc_dvc->max_dvc_qng[tid_no]) {
  9334. return 0;
  9335. }
  9336. return cur_free_qs;
  9337. }
  9338. if (n_qs > 1) {
  9339. if ((n_qs > asc_dvc->last_q_shortage)
  9340. && (n_qs <= (asc_dvc->max_total_qng - ASC_MIN_FREE_Q))) {
  9341. asc_dvc->last_q_shortage = n_qs;
  9342. }
  9343. }
  9344. return 0;
  9345. }
  9346. static uchar AscAllocFreeQueue(PortAddr iop_base, uchar free_q_head)
  9347. {
  9348. ushort q_addr;
  9349. uchar next_qp;
  9350. uchar q_status;
  9351. q_addr = ASC_QNO_TO_QADDR(free_q_head);
  9352. q_status = (uchar)AscReadLramByte(iop_base,
  9353. (ushort)(q_addr +
  9354. ASC_SCSIQ_B_STATUS));
  9355. next_qp = AscReadLramByte(iop_base, (ushort)(q_addr + ASC_SCSIQ_B_FWD));
  9356. if (((q_status & QS_READY) == 0) && (next_qp != ASC_QLINK_END))
  9357. return next_qp;
  9358. return ASC_QLINK_END;
  9359. }
  9360. static uchar
  9361. AscAllocMultipleFreeQueue(PortAddr iop_base, uchar free_q_head, uchar n_free_q)
  9362. {
  9363. uchar i;
  9364. for (i = 0; i < n_free_q; i++) {
  9365. free_q_head = AscAllocFreeQueue(iop_base, free_q_head);
  9366. if (free_q_head == ASC_QLINK_END)
  9367. break;
  9368. }
  9369. return free_q_head;
  9370. }
  9371. /*
  9372. * void
  9373. * DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  9374. *
  9375. * Calling/Exit State:
  9376. * none
  9377. *
  9378. * Description:
  9379. * Output an ASC_SCSI_Q structure to the chip
  9380. */
  9381. static void
  9382. DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  9383. {
  9384. int i;
  9385. ASC_DBG_PRT_HEX(2, "DvcPutScsiQ", outbuf, 2 * words);
  9386. AscSetChipLramAddr(iop_base, s_addr);
  9387. for (i = 0; i < 2 * words; i += 2) {
  9388. if (i == 4 || i == 20) {
  9389. continue;
  9390. }
  9391. outpw(iop_base + IOP_RAM_DATA,
  9392. ((ushort)outbuf[i + 1] << 8) | outbuf[i]);
  9393. }
  9394. }
  9395. static int AscPutReadyQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
  9396. {
  9397. ushort q_addr;
  9398. uchar tid_no;
  9399. uchar sdtr_data;
  9400. uchar syn_period_ix;
  9401. uchar syn_offset;
  9402. PortAddr iop_base;
  9403. iop_base = asc_dvc->iop_base;
  9404. if (((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) &&
  9405. ((asc_dvc->sdtr_done & scsiq->q1.target_id) == 0)) {
  9406. tid_no = ASC_TIX_TO_TID(scsiq->q2.target_ix);
  9407. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  9408. syn_period_ix =
  9409. (sdtr_data >> 4) & (asc_dvc->max_sdtr_index - 1);
  9410. syn_offset = sdtr_data & ASC_SYN_MAX_OFFSET;
  9411. AscMsgOutSDTR(asc_dvc,
  9412. asc_dvc->sdtr_period_tbl[syn_period_ix],
  9413. syn_offset);
  9414. scsiq->q1.cntl |= QC_MSG_OUT;
  9415. }
  9416. q_addr = ASC_QNO_TO_QADDR(q_no);
  9417. if ((scsiq->q1.target_id & asc_dvc->use_tagged_qng) == 0) {
  9418. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
  9419. }
  9420. scsiq->q1.status = QS_FREE;
  9421. AscMemWordCopyPtrToLram(iop_base,
  9422. q_addr + ASC_SCSIQ_CDB_BEG,
  9423. (uchar *)scsiq->cdbptr, scsiq->q2.cdb_len >> 1);
  9424. DvcPutScsiQ(iop_base,
  9425. q_addr + ASC_SCSIQ_CPY_BEG,
  9426. (uchar *)&scsiq->q1.cntl,
  9427. ((sizeof(ASC_SCSIQ_1) + sizeof(ASC_SCSIQ_2)) / 2) - 1);
  9428. AscWriteLramWord(iop_base,
  9429. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS),
  9430. (ushort)(((ushort)scsiq->q1.
  9431. q_no << 8) | (ushort)QS_READY));
  9432. return 1;
  9433. }
  9434. static int
  9435. AscPutReadySgListQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
  9436. {
  9437. int sta;
  9438. int i;
  9439. ASC_SG_HEAD *sg_head;
  9440. ASC_SG_LIST_Q scsi_sg_q;
  9441. ASC_DCNT saved_data_addr;
  9442. ASC_DCNT saved_data_cnt;
  9443. PortAddr iop_base;
  9444. ushort sg_list_dwords;
  9445. ushort sg_index;
  9446. ushort sg_entry_cnt;
  9447. ushort q_addr;
  9448. uchar next_qp;
  9449. iop_base = asc_dvc->iop_base;
  9450. sg_head = scsiq->sg_head;
  9451. saved_data_addr = scsiq->q1.data_addr;
  9452. saved_data_cnt = scsiq->q1.data_cnt;
  9453. scsiq->q1.data_addr = (ASC_PADDR) sg_head->sg_list[0].addr;
  9454. scsiq->q1.data_cnt = (ASC_DCNT) sg_head->sg_list[0].bytes;
  9455. #if CC_VERY_LONG_SG_LIST
  9456. /*
  9457. * If sg_head->entry_cnt is greater than ASC_MAX_SG_LIST
  9458. * then not all SG elements will fit in the allocated queues.
  9459. * The rest of the SG elements will be copied when the RISC
  9460. * completes the SG elements that fit and halts.
  9461. */
  9462. if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
  9463. /*
  9464. * Set sg_entry_cnt to be the number of SG elements that
  9465. * will fit in the allocated SG queues. It is minus 1, because
  9466. * the first SG element is handled above. ASC_MAX_SG_LIST is
  9467. * already inflated by 1 to account for this. For example it
  9468. * may be 50 which is 1 + 7 queues * 7 SG elements.
  9469. */
  9470. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  9471. /*
  9472. * Keep track of remaining number of SG elements that will
  9473. * need to be handled from a_isr.c.
  9474. */
  9475. scsiq->remain_sg_entry_cnt =
  9476. sg_head->entry_cnt - ASC_MAX_SG_LIST;
  9477. } else {
  9478. #endif /* CC_VERY_LONG_SG_LIST */
  9479. /*
  9480. * Set sg_entry_cnt to be the number of SG elements that
  9481. * will fit in the allocated SG queues. It is minus 1, because
  9482. * the first SG element is handled above.
  9483. */
  9484. sg_entry_cnt = sg_head->entry_cnt - 1;
  9485. #if CC_VERY_LONG_SG_LIST
  9486. }
  9487. #endif /* CC_VERY_LONG_SG_LIST */
  9488. if (sg_entry_cnt != 0) {
  9489. scsiq->q1.cntl |= QC_SG_HEAD;
  9490. q_addr = ASC_QNO_TO_QADDR(q_no);
  9491. sg_index = 1;
  9492. scsiq->q1.sg_queue_cnt = sg_head->queue_cnt;
  9493. scsi_sg_q.sg_head_qp = q_no;
  9494. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  9495. for (i = 0; i < sg_head->queue_cnt; i++) {
  9496. scsi_sg_q.seq_no = i + 1;
  9497. if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
  9498. sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
  9499. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  9500. if (i == 0) {
  9501. scsi_sg_q.sg_list_cnt =
  9502. ASC_SG_LIST_PER_Q;
  9503. scsi_sg_q.sg_cur_list_cnt =
  9504. ASC_SG_LIST_PER_Q;
  9505. } else {
  9506. scsi_sg_q.sg_list_cnt =
  9507. ASC_SG_LIST_PER_Q - 1;
  9508. scsi_sg_q.sg_cur_list_cnt =
  9509. ASC_SG_LIST_PER_Q - 1;
  9510. }
  9511. } else {
  9512. #if CC_VERY_LONG_SG_LIST
  9513. /*
  9514. * This is the last SG queue in the list of
  9515. * allocated SG queues. If there are more
  9516. * SG elements than will fit in the allocated
  9517. * queues, then set the QCSG_SG_XFER_MORE flag.
  9518. */
  9519. if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
  9520. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  9521. } else {
  9522. #endif /* CC_VERY_LONG_SG_LIST */
  9523. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  9524. #if CC_VERY_LONG_SG_LIST
  9525. }
  9526. #endif /* CC_VERY_LONG_SG_LIST */
  9527. sg_list_dwords = sg_entry_cnt << 1;
  9528. if (i == 0) {
  9529. scsi_sg_q.sg_list_cnt = sg_entry_cnt;
  9530. scsi_sg_q.sg_cur_list_cnt =
  9531. sg_entry_cnt;
  9532. } else {
  9533. scsi_sg_q.sg_list_cnt =
  9534. sg_entry_cnt - 1;
  9535. scsi_sg_q.sg_cur_list_cnt =
  9536. sg_entry_cnt - 1;
  9537. }
  9538. sg_entry_cnt = 0;
  9539. }
  9540. next_qp = AscReadLramByte(iop_base,
  9541. (ushort)(q_addr +
  9542. ASC_SCSIQ_B_FWD));
  9543. scsi_sg_q.q_no = next_qp;
  9544. q_addr = ASC_QNO_TO_QADDR(next_qp);
  9545. AscMemWordCopyPtrToLram(iop_base,
  9546. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  9547. (uchar *)&scsi_sg_q,
  9548. sizeof(ASC_SG_LIST_Q) >> 1);
  9549. AscMemDWordCopyPtrToLram(iop_base,
  9550. q_addr + ASC_SGQ_LIST_BEG,
  9551. (uchar *)&sg_head->
  9552. sg_list[sg_index],
  9553. sg_list_dwords);
  9554. sg_index += ASC_SG_LIST_PER_Q;
  9555. scsiq->next_sg_index = sg_index;
  9556. }
  9557. } else {
  9558. scsiq->q1.cntl &= ~QC_SG_HEAD;
  9559. }
  9560. sta = AscPutReadyQueue(asc_dvc, scsiq, q_no);
  9561. scsiq->q1.data_addr = saved_data_addr;
  9562. scsiq->q1.data_cnt = saved_data_cnt;
  9563. return (sta);
  9564. }
  9565. static int
  9566. AscSendScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar n_q_required)
  9567. {
  9568. PortAddr iop_base;
  9569. uchar free_q_head;
  9570. uchar next_qp;
  9571. uchar tid_no;
  9572. uchar target_ix;
  9573. int sta;
  9574. iop_base = asc_dvc->iop_base;
  9575. target_ix = scsiq->q2.target_ix;
  9576. tid_no = ASC_TIX_TO_TID(target_ix);
  9577. sta = 0;
  9578. free_q_head = (uchar)AscGetVarFreeQHead(iop_base);
  9579. if (n_q_required > 1) {
  9580. next_qp = AscAllocMultipleFreeQueue(iop_base, free_q_head,
  9581. (uchar)n_q_required);
  9582. if (next_qp != ASC_QLINK_END) {
  9583. asc_dvc->last_q_shortage = 0;
  9584. scsiq->sg_head->queue_cnt = n_q_required - 1;
  9585. scsiq->q1.q_no = free_q_head;
  9586. sta = AscPutReadySgListQueue(asc_dvc, scsiq,
  9587. free_q_head);
  9588. }
  9589. } else if (n_q_required == 1) {
  9590. next_qp = AscAllocFreeQueue(iop_base, free_q_head);
  9591. if (next_qp != ASC_QLINK_END) {
  9592. scsiq->q1.q_no = free_q_head;
  9593. sta = AscPutReadyQueue(asc_dvc, scsiq, free_q_head);
  9594. }
  9595. }
  9596. if (sta == 1) {
  9597. AscPutVarFreeQHead(iop_base, next_qp);
  9598. asc_dvc->cur_total_qng += n_q_required;
  9599. asc_dvc->cur_dvc_qng[tid_no]++;
  9600. }
  9601. return sta;
  9602. }
  9603. #define ASC_SYN_OFFSET_ONE_DISABLE_LIST 16
  9604. static uchar _syn_offset_one_disable_cmd[ASC_SYN_OFFSET_ONE_DISABLE_LIST] = {
  9605. INQUIRY,
  9606. REQUEST_SENSE,
  9607. READ_CAPACITY,
  9608. READ_TOC,
  9609. MODE_SELECT,
  9610. MODE_SENSE,
  9611. MODE_SELECT_10,
  9612. MODE_SENSE_10,
  9613. 0xFF,
  9614. 0xFF,
  9615. 0xFF,
  9616. 0xFF,
  9617. 0xFF,
  9618. 0xFF,
  9619. 0xFF,
  9620. 0xFF
  9621. };
  9622. static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
  9623. {
  9624. PortAddr iop_base;
  9625. int sta;
  9626. int n_q_required;
  9627. int disable_syn_offset_one_fix;
  9628. int i;
  9629. ASC_PADDR addr;
  9630. ushort sg_entry_cnt = 0;
  9631. ushort sg_entry_cnt_minus_one = 0;
  9632. uchar target_ix;
  9633. uchar tid_no;
  9634. uchar sdtr_data;
  9635. uchar extra_bytes;
  9636. uchar scsi_cmd;
  9637. uchar disable_cmd;
  9638. ASC_SG_HEAD *sg_head;
  9639. ASC_DCNT data_cnt;
  9640. iop_base = asc_dvc->iop_base;
  9641. sg_head = scsiq->sg_head;
  9642. if (asc_dvc->err_code != 0)
  9643. return (ERR);
  9644. scsiq->q1.q_no = 0;
  9645. if ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES) == 0) {
  9646. scsiq->q1.extra_bytes = 0;
  9647. }
  9648. sta = 0;
  9649. target_ix = scsiq->q2.target_ix;
  9650. tid_no = ASC_TIX_TO_TID(target_ix);
  9651. n_q_required = 1;
  9652. if (scsiq->cdbptr[0] == REQUEST_SENSE) {
  9653. if ((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) {
  9654. asc_dvc->sdtr_done &= ~scsiq->q1.target_id;
  9655. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  9656. AscMsgOutSDTR(asc_dvc,
  9657. asc_dvc->
  9658. sdtr_period_tbl[(sdtr_data >> 4) &
  9659. (uchar)(asc_dvc->
  9660. max_sdtr_index -
  9661. 1)],
  9662. (uchar)(sdtr_data & (uchar)
  9663. ASC_SYN_MAX_OFFSET));
  9664. scsiq->q1.cntl |= (QC_MSG_OUT | QC_URGENT);
  9665. }
  9666. }
  9667. if (asc_dvc->in_critical_cnt != 0) {
  9668. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CRITICAL_RE_ENTRY);
  9669. return (ERR);
  9670. }
  9671. asc_dvc->in_critical_cnt++;
  9672. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  9673. if ((sg_entry_cnt = sg_head->entry_cnt) == 0) {
  9674. asc_dvc->in_critical_cnt--;
  9675. return (ERR);
  9676. }
  9677. #if !CC_VERY_LONG_SG_LIST
  9678. if (sg_entry_cnt > ASC_MAX_SG_LIST) {
  9679. asc_dvc->in_critical_cnt--;
  9680. return (ERR);
  9681. }
  9682. #endif /* !CC_VERY_LONG_SG_LIST */
  9683. if (sg_entry_cnt == 1) {
  9684. scsiq->q1.data_addr =
  9685. (ADV_PADDR)sg_head->sg_list[0].addr;
  9686. scsiq->q1.data_cnt =
  9687. (ADV_DCNT)sg_head->sg_list[0].bytes;
  9688. scsiq->q1.cntl &= ~(QC_SG_HEAD | QC_SG_SWAP_QUEUE);
  9689. }
  9690. sg_entry_cnt_minus_one = sg_entry_cnt - 1;
  9691. }
  9692. scsi_cmd = scsiq->cdbptr[0];
  9693. disable_syn_offset_one_fix = FALSE;
  9694. if ((asc_dvc->pci_fix_asyn_xfer & scsiq->q1.target_id) &&
  9695. !(asc_dvc->pci_fix_asyn_xfer_always & scsiq->q1.target_id)) {
  9696. if (scsiq->q1.cntl & QC_SG_HEAD) {
  9697. data_cnt = 0;
  9698. for (i = 0; i < sg_entry_cnt; i++) {
  9699. data_cnt +=
  9700. (ADV_DCNT)le32_to_cpu(sg_head->sg_list[i].
  9701. bytes);
  9702. }
  9703. } else {
  9704. data_cnt = le32_to_cpu(scsiq->q1.data_cnt);
  9705. }
  9706. if (data_cnt != 0UL) {
  9707. if (data_cnt < 512UL) {
  9708. disable_syn_offset_one_fix = TRUE;
  9709. } else {
  9710. for (i = 0; i < ASC_SYN_OFFSET_ONE_DISABLE_LIST;
  9711. i++) {
  9712. disable_cmd =
  9713. _syn_offset_one_disable_cmd[i];
  9714. if (disable_cmd == 0xFF) {
  9715. break;
  9716. }
  9717. if (scsi_cmd == disable_cmd) {
  9718. disable_syn_offset_one_fix =
  9719. TRUE;
  9720. break;
  9721. }
  9722. }
  9723. }
  9724. }
  9725. }
  9726. if (disable_syn_offset_one_fix) {
  9727. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
  9728. scsiq->q2.tag_code |= (ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX |
  9729. ASC_TAG_FLAG_DISABLE_DISCONNECT);
  9730. } else {
  9731. scsiq->q2.tag_code &= 0x27;
  9732. }
  9733. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  9734. if (asc_dvc->bug_fix_cntl) {
  9735. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  9736. if ((scsi_cmd == READ_6) ||
  9737. (scsi_cmd == READ_10)) {
  9738. addr =
  9739. (ADV_PADDR)le32_to_cpu(sg_head->
  9740. sg_list
  9741. [sg_entry_cnt_minus_one].
  9742. addr) +
  9743. (ADV_DCNT)le32_to_cpu(sg_head->
  9744. sg_list
  9745. [sg_entry_cnt_minus_one].
  9746. bytes);
  9747. extra_bytes =
  9748. (uchar)((ushort)addr & 0x0003);
  9749. if ((extra_bytes != 0)
  9750. &&
  9751. ((scsiq->q2.
  9752. tag_code &
  9753. ASC_TAG_FLAG_EXTRA_BYTES)
  9754. == 0)) {
  9755. scsiq->q2.tag_code |=
  9756. ASC_TAG_FLAG_EXTRA_BYTES;
  9757. scsiq->q1.extra_bytes =
  9758. extra_bytes;
  9759. data_cnt =
  9760. le32_to_cpu(sg_head->
  9761. sg_list
  9762. [sg_entry_cnt_minus_one].
  9763. bytes);
  9764. data_cnt -=
  9765. (ASC_DCNT) extra_bytes;
  9766. sg_head->
  9767. sg_list
  9768. [sg_entry_cnt_minus_one].
  9769. bytes =
  9770. cpu_to_le32(data_cnt);
  9771. }
  9772. }
  9773. }
  9774. }
  9775. sg_head->entry_to_copy = sg_head->entry_cnt;
  9776. #if CC_VERY_LONG_SG_LIST
  9777. /*
  9778. * Set the sg_entry_cnt to the maximum possible. The rest of
  9779. * the SG elements will be copied when the RISC completes the
  9780. * SG elements that fit and halts.
  9781. */
  9782. if (sg_entry_cnt > ASC_MAX_SG_LIST) {
  9783. sg_entry_cnt = ASC_MAX_SG_LIST;
  9784. }
  9785. #endif /* CC_VERY_LONG_SG_LIST */
  9786. n_q_required = AscSgListToQueue(sg_entry_cnt);
  9787. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, n_q_required) >=
  9788. (uint) n_q_required)
  9789. || ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  9790. if ((sta =
  9791. AscSendScsiQueue(asc_dvc, scsiq,
  9792. n_q_required)) == 1) {
  9793. asc_dvc->in_critical_cnt--;
  9794. return (sta);
  9795. }
  9796. }
  9797. } else {
  9798. if (asc_dvc->bug_fix_cntl) {
  9799. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  9800. if ((scsi_cmd == READ_6) ||
  9801. (scsi_cmd == READ_10)) {
  9802. addr =
  9803. le32_to_cpu(scsiq->q1.data_addr) +
  9804. le32_to_cpu(scsiq->q1.data_cnt);
  9805. extra_bytes =
  9806. (uchar)((ushort)addr & 0x0003);
  9807. if ((extra_bytes != 0)
  9808. &&
  9809. ((scsiq->q2.
  9810. tag_code &
  9811. ASC_TAG_FLAG_EXTRA_BYTES)
  9812. == 0)) {
  9813. data_cnt =
  9814. le32_to_cpu(scsiq->q1.
  9815. data_cnt);
  9816. if (((ushort)data_cnt & 0x01FF)
  9817. == 0) {
  9818. scsiq->q2.tag_code |=
  9819. ASC_TAG_FLAG_EXTRA_BYTES;
  9820. data_cnt -= (ASC_DCNT)
  9821. extra_bytes;
  9822. scsiq->q1.data_cnt =
  9823. cpu_to_le32
  9824. (data_cnt);
  9825. scsiq->q1.extra_bytes =
  9826. extra_bytes;
  9827. }
  9828. }
  9829. }
  9830. }
  9831. }
  9832. n_q_required = 1;
  9833. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, 1) >= 1) ||
  9834. ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  9835. if ((sta = AscSendScsiQueue(asc_dvc, scsiq,
  9836. n_q_required)) == 1) {
  9837. asc_dvc->in_critical_cnt--;
  9838. return (sta);
  9839. }
  9840. }
  9841. }
  9842. asc_dvc->in_critical_cnt--;
  9843. return (sta);
  9844. }
  9845. /*
  9846. * AdvExeScsiQueue() - Send a request to the RISC microcode program.
  9847. *
  9848. * Allocate a carrier structure, point the carrier to the ADV_SCSI_REQ_Q,
  9849. * add the carrier to the ICQ (Initiator Command Queue), and tickle the
  9850. * RISC to notify it a new command is ready to be executed.
  9851. *
  9852. * If 'done_status' is not set to QD_DO_RETRY, then 'error_retry' will be
  9853. * set to SCSI_MAX_RETRY.
  9854. *
  9855. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the microcode
  9856. * for DMA addresses or math operations are byte swapped to little-endian
  9857. * order.
  9858. *
  9859. * Return:
  9860. * ADV_SUCCESS(1) - The request was successfully queued.
  9861. * ADV_BUSY(0) - Resource unavailable; Retry again after pending
  9862. * request completes.
  9863. * ADV_ERROR(-1) - Invalid ADV_SCSI_REQ_Q request structure
  9864. * host IC error.
  9865. */
  9866. static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
  9867. {
  9868. AdvPortAddr iop_base;
  9869. ADV_PADDR req_paddr;
  9870. ADV_CARR_T *new_carrp;
  9871. /*
  9872. * The ADV_SCSI_REQ_Q 'target_id' field should never exceed ADV_MAX_TID.
  9873. */
  9874. if (scsiq->target_id > ADV_MAX_TID) {
  9875. scsiq->host_status = QHSTA_M_INVALID_DEVICE;
  9876. scsiq->done_status = QD_WITH_ERROR;
  9877. return ADV_ERROR;
  9878. }
  9879. iop_base = asc_dvc->iop_base;
  9880. /*
  9881. * Allocate a carrier ensuring at least one carrier always
  9882. * remains on the freelist and initialize fields.
  9883. */
  9884. if ((new_carrp = asc_dvc->carr_freelist) == NULL) {
  9885. return ADV_BUSY;
  9886. }
  9887. asc_dvc->carr_freelist = (ADV_CARR_T *)
  9888. ADV_U32_TO_VADDR(le32_to_cpu(new_carrp->next_vpa));
  9889. asc_dvc->carr_pending_cnt++;
  9890. /*
  9891. * Set the carrier to be a stopper by setting 'next_vpa'
  9892. * to the stopper value. The current stopper will be changed
  9893. * below to point to the new stopper.
  9894. */
  9895. new_carrp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  9896. /*
  9897. * Clear the ADV_SCSI_REQ_Q done flag.
  9898. */
  9899. scsiq->a_flag &= ~ADV_SCSIQ_DONE;
  9900. req_paddr = virt_to_bus(scsiq);
  9901. BUG_ON(req_paddr & 31);
  9902. /* Wait for assertion before making little-endian */
  9903. req_paddr = cpu_to_le32(req_paddr);
  9904. /* Save virtual and physical address of ADV_SCSI_REQ_Q and carrier. */
  9905. scsiq->scsiq_ptr = cpu_to_le32(ADV_VADDR_TO_U32(scsiq));
  9906. scsiq->scsiq_rptr = req_paddr;
  9907. scsiq->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->icq_sp));
  9908. /*
  9909. * Every ADV_CARR_T.carr_pa is byte swapped to little-endian
  9910. * order during initialization.
  9911. */
  9912. scsiq->carr_pa = asc_dvc->icq_sp->carr_pa;
  9913. /*
  9914. * Use the current stopper to send the ADV_SCSI_REQ_Q command to
  9915. * the microcode. The newly allocated stopper will become the new
  9916. * stopper.
  9917. */
  9918. asc_dvc->icq_sp->areq_vpa = req_paddr;
  9919. /*
  9920. * Set the 'next_vpa' pointer for the old stopper to be the
  9921. * physical address of the new stopper. The RISC can only
  9922. * follow physical addresses.
  9923. */
  9924. asc_dvc->icq_sp->next_vpa = new_carrp->carr_pa;
  9925. /*
  9926. * Set the host adapter stopper pointer to point to the new carrier.
  9927. */
  9928. asc_dvc->icq_sp = new_carrp;
  9929. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  9930. asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  9931. /*
  9932. * Tickle the RISC to tell it to read its Command Queue Head pointer.
  9933. */
  9934. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_A);
  9935. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  9936. /*
  9937. * Clear the tickle value. In the ASC-3550 the RISC flag
  9938. * command 'clr_tickle_a' does not work unless the host
  9939. * value is cleared.
  9940. */
  9941. AdvWriteByteRegister(iop_base, IOPB_TICKLE,
  9942. ADV_TICKLE_NOP);
  9943. }
  9944. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  9945. /*
  9946. * Notify the RISC a carrier is ready by writing the physical
  9947. * address of the new carrier stopper to the COMMA register.
  9948. */
  9949. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  9950. le32_to_cpu(new_carrp->carr_pa));
  9951. }
  9952. return ADV_SUCCESS;
  9953. }
  9954. /*
  9955. * Execute a single 'Scsi_Cmnd'.
  9956. */
  9957. static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
  9958. {
  9959. int ret, err_code;
  9960. struct asc_board *boardp = shost_priv(scp->device->host);
  9961. ASC_DBG(1, "scp 0x%p\n", scp);
  9962. if (ASC_NARROW_BOARD(boardp)) {
  9963. ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  9964. struct asc_scsi_q asc_scsi_q;
  9965. /* asc_build_req() can not return ASC_BUSY. */
  9966. ret = asc_build_req(boardp, scp, &asc_scsi_q);
  9967. if (ret == ASC_ERROR) {
  9968. ASC_STATS(scp->device->host, build_error);
  9969. return ASC_ERROR;
  9970. }
  9971. ret = AscExeScsiQueue(asc_dvc, &asc_scsi_q);
  9972. kfree(asc_scsi_q.sg_head);
  9973. err_code = asc_dvc->err_code;
  9974. } else {
  9975. ADV_DVC_VAR *adv_dvc = &boardp->dvc_var.adv_dvc_var;
  9976. ADV_SCSI_REQ_Q *adv_scsiqp;
  9977. switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
  9978. case ASC_NOERROR:
  9979. ASC_DBG(3, "adv_build_req ASC_NOERROR\n");
  9980. break;
  9981. case ASC_BUSY:
  9982. ASC_DBG(1, "adv_build_req ASC_BUSY\n");
  9983. /*
  9984. * The asc_stats fields 'adv_build_noreq' and
  9985. * 'adv_build_nosg' count wide board busy conditions.
  9986. * They are updated in adv_build_req and
  9987. * adv_get_sglist, respectively.
  9988. */
  9989. return ASC_BUSY;
  9990. case ASC_ERROR:
  9991. default:
  9992. ASC_DBG(1, "adv_build_req ASC_ERROR\n");
  9993. ASC_STATS(scp->device->host, build_error);
  9994. return ASC_ERROR;
  9995. }
  9996. ret = AdvExeScsiQueue(adv_dvc, adv_scsiqp);
  9997. err_code = adv_dvc->err_code;
  9998. }
  9999. switch (ret) {
  10000. case ASC_NOERROR:
  10001. ASC_STATS(scp->device->host, exe_noerror);
  10002. /*
  10003. * Increment monotonically increasing per device
  10004. * successful request counter. Wrapping doesn't matter.
  10005. */
  10006. boardp->reqcnt[scp->device->id]++;
  10007. ASC_DBG(1, "ExeScsiQueue() ASC_NOERROR\n");
  10008. break;
  10009. case ASC_BUSY:
  10010. ASC_STATS(scp->device->host, exe_busy);
  10011. break;
  10012. case ASC_ERROR:
  10013. scmd_printk(KERN_ERR, scp, "ExeScsiQueue() ASC_ERROR, "
  10014. "err_code 0x%x\n", err_code);
  10015. ASC_STATS(scp->device->host, exe_error);
  10016. scp->result = HOST_BYTE(DID_ERROR);
  10017. break;
  10018. default:
  10019. scmd_printk(KERN_ERR, scp, "ExeScsiQueue() unknown, "
  10020. "err_code 0x%x\n", err_code);
  10021. ASC_STATS(scp->device->host, exe_unknown);
  10022. scp->result = HOST_BYTE(DID_ERROR);
  10023. break;
  10024. }
  10025. ASC_DBG(1, "end\n");
  10026. return ret;
  10027. }
  10028. /*
  10029. * advansys_queuecommand() - interrupt-driven I/O entrypoint.
  10030. *
  10031. * This function always returns 0. Command return status is saved
  10032. * in the 'scp' result field.
  10033. */
  10034. static int
  10035. advansys_queuecommand(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *))
  10036. {
  10037. struct Scsi_Host *shost = scp->device->host;
  10038. int asc_res, result = 0;
  10039. ASC_STATS(shost, queuecommand);
  10040. scp->scsi_done = done;
  10041. asc_res = asc_execute_scsi_cmnd(scp);
  10042. switch (asc_res) {
  10043. case ASC_NOERROR:
  10044. break;
  10045. case ASC_BUSY:
  10046. result = SCSI_MLQUEUE_HOST_BUSY;
  10047. break;
  10048. case ASC_ERROR:
  10049. default:
  10050. asc_scsi_done(scp);
  10051. break;
  10052. }
  10053. return result;
  10054. }
  10055. static ushort __devinit AscGetEisaChipCfg(PortAddr iop_base)
  10056. {
  10057. PortAddr eisa_cfg_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  10058. (PortAddr) (ASC_EISA_CFG_IOP_MASK);
  10059. return inpw(eisa_cfg_iop);
  10060. }
  10061. /*
  10062. * Return the BIOS address of the adapter at the specified
  10063. * I/O port and with the specified bus type.
  10064. */
  10065. static unsigned short __devinit
  10066. AscGetChipBiosAddress(PortAddr iop_base, unsigned short bus_type)
  10067. {
  10068. unsigned short cfg_lsw;
  10069. unsigned short bios_addr;
  10070. /*
  10071. * The PCI BIOS is re-located by the motherboard BIOS. Because
  10072. * of this the driver can not determine where a PCI BIOS is
  10073. * loaded and executes.
  10074. */
  10075. if (bus_type & ASC_IS_PCI)
  10076. return 0;
  10077. if ((bus_type & ASC_IS_EISA) != 0) {
  10078. cfg_lsw = AscGetEisaChipCfg(iop_base);
  10079. cfg_lsw &= 0x000F;
  10080. bios_addr = ASC_BIOS_MIN_ADDR + cfg_lsw * ASC_BIOS_BANK_SIZE;
  10081. return bios_addr;
  10082. }
  10083. cfg_lsw = AscGetChipCfgLsw(iop_base);
  10084. /*
  10085. * ISA PnP uses the top bit as the 32K BIOS flag
  10086. */
  10087. if (bus_type == ASC_IS_ISAPNP)
  10088. cfg_lsw &= 0x7FFF;
  10089. bios_addr = ASC_BIOS_MIN_ADDR + (cfg_lsw >> 12) * ASC_BIOS_BANK_SIZE;
  10090. return bios_addr;
  10091. }
  10092. static uchar __devinit AscSetChipScsiID(PortAddr iop_base, uchar new_host_id)
  10093. {
  10094. ushort cfg_lsw;
  10095. if (AscGetChipScsiID(iop_base) == new_host_id) {
  10096. return (new_host_id);
  10097. }
  10098. cfg_lsw = AscGetChipCfgLsw(iop_base);
  10099. cfg_lsw &= 0xF8FF;
  10100. cfg_lsw |= (ushort)((new_host_id & ASC_MAX_TID) << 8);
  10101. AscSetChipCfgLsw(iop_base, cfg_lsw);
  10102. return (AscGetChipScsiID(iop_base));
  10103. }
  10104. static unsigned char __devinit AscGetChipScsiCtrl(PortAddr iop_base)
  10105. {
  10106. unsigned char sc;
  10107. AscSetBank(iop_base, 1);
  10108. sc = inp(iop_base + IOP_REG_SC);
  10109. AscSetBank(iop_base, 0);
  10110. return sc;
  10111. }
  10112. static unsigned char __devinit
  10113. AscGetChipVersion(PortAddr iop_base, unsigned short bus_type)
  10114. {
  10115. if (bus_type & ASC_IS_EISA) {
  10116. PortAddr eisa_iop;
  10117. unsigned char revision;
  10118. eisa_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  10119. (PortAddr) ASC_EISA_REV_IOP_MASK;
  10120. revision = inp(eisa_iop);
  10121. return ASC_CHIP_MIN_VER_EISA - 1 + revision;
  10122. }
  10123. return AscGetChipVerNo(iop_base);
  10124. }
  10125. #ifdef CONFIG_ISA
  10126. static void __devinit AscEnableIsaDma(uchar dma_channel)
  10127. {
  10128. if (dma_channel < 4) {
  10129. outp(0x000B, (ushort)(0xC0 | dma_channel));
  10130. outp(0x000A, dma_channel);
  10131. } else if (dma_channel < 8) {
  10132. outp(0x00D6, (ushort)(0xC0 | (dma_channel - 4)));
  10133. outp(0x00D4, (ushort)(dma_channel - 4));
  10134. }
  10135. }
  10136. #endif /* CONFIG_ISA */
  10137. static int AscStopQueueExe(PortAddr iop_base)
  10138. {
  10139. int count = 0;
  10140. if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) == 0) {
  10141. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  10142. ASC_STOP_REQ_RISC_STOP);
  10143. do {
  10144. if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) &
  10145. ASC_STOP_ACK_RISC_STOP) {
  10146. return (1);
  10147. }
  10148. mdelay(100);
  10149. } while (count++ < 20);
  10150. }
  10151. return (0);
  10152. }
  10153. static ASC_DCNT __devinit AscGetMaxDmaCount(ushort bus_type)
  10154. {
  10155. if (bus_type & ASC_IS_ISA)
  10156. return ASC_MAX_ISA_DMA_COUNT;
  10157. else if (bus_type & (ASC_IS_EISA | ASC_IS_VL))
  10158. return ASC_MAX_VL_DMA_COUNT;
  10159. return ASC_MAX_PCI_DMA_COUNT;
  10160. }
  10161. #ifdef CONFIG_ISA
  10162. static ushort __devinit AscGetIsaDmaChannel(PortAddr iop_base)
  10163. {
  10164. ushort channel;
  10165. channel = AscGetChipCfgLsw(iop_base) & 0x0003;
  10166. if (channel == 0x03)
  10167. return (0);
  10168. else if (channel == 0x00)
  10169. return (7);
  10170. return (channel + 4);
  10171. }
  10172. static ushort __devinit AscSetIsaDmaChannel(PortAddr iop_base, ushort dma_channel)
  10173. {
  10174. ushort cfg_lsw;
  10175. uchar value;
  10176. if ((dma_channel >= 5) && (dma_channel <= 7)) {
  10177. if (dma_channel == 7)
  10178. value = 0x00;
  10179. else
  10180. value = dma_channel - 4;
  10181. cfg_lsw = AscGetChipCfgLsw(iop_base) & 0xFFFC;
  10182. cfg_lsw |= value;
  10183. AscSetChipCfgLsw(iop_base, cfg_lsw);
  10184. return (AscGetIsaDmaChannel(iop_base));
  10185. }
  10186. return 0;
  10187. }
  10188. static uchar __devinit AscGetIsaDmaSpeed(PortAddr iop_base)
  10189. {
  10190. uchar speed_value;
  10191. AscSetBank(iop_base, 1);
  10192. speed_value = AscReadChipDmaSpeed(iop_base);
  10193. speed_value &= 0x07;
  10194. AscSetBank(iop_base, 0);
  10195. return speed_value;
  10196. }
  10197. static uchar __devinit AscSetIsaDmaSpeed(PortAddr iop_base, uchar speed_value)
  10198. {
  10199. speed_value &= 0x07;
  10200. AscSetBank(iop_base, 1);
  10201. AscWriteChipDmaSpeed(iop_base, speed_value);
  10202. AscSetBank(iop_base, 0);
  10203. return AscGetIsaDmaSpeed(iop_base);
  10204. }
  10205. #endif /* CONFIG_ISA */
  10206. static ushort __devinit AscInitAscDvcVar(ASC_DVC_VAR *asc_dvc)
  10207. {
  10208. int i;
  10209. PortAddr iop_base;
  10210. ushort warn_code;
  10211. uchar chip_version;
  10212. iop_base = asc_dvc->iop_base;
  10213. warn_code = 0;
  10214. asc_dvc->err_code = 0;
  10215. if ((asc_dvc->bus_type &
  10216. (ASC_IS_ISA | ASC_IS_PCI | ASC_IS_EISA | ASC_IS_VL)) == 0) {
  10217. asc_dvc->err_code |= ASC_IERR_NO_BUS_TYPE;
  10218. }
  10219. AscSetChipControl(iop_base, CC_HALT);
  10220. AscSetChipStatus(iop_base, 0);
  10221. asc_dvc->bug_fix_cntl = 0;
  10222. asc_dvc->pci_fix_asyn_xfer = 0;
  10223. asc_dvc->pci_fix_asyn_xfer_always = 0;
  10224. /* asc_dvc->init_state initalized in AscInitGetConfig(). */
  10225. asc_dvc->sdtr_done = 0;
  10226. asc_dvc->cur_total_qng = 0;
  10227. asc_dvc->is_in_int = 0;
  10228. asc_dvc->in_critical_cnt = 0;
  10229. asc_dvc->last_q_shortage = 0;
  10230. asc_dvc->use_tagged_qng = 0;
  10231. asc_dvc->no_scam = 0;
  10232. asc_dvc->unit_not_ready = 0;
  10233. asc_dvc->queue_full_or_busy = 0;
  10234. asc_dvc->redo_scam = 0;
  10235. asc_dvc->res2 = 0;
  10236. asc_dvc->min_sdtr_index = 0;
  10237. asc_dvc->cfg->can_tagged_qng = 0;
  10238. asc_dvc->cfg->cmd_qng_enabled = 0;
  10239. asc_dvc->dvc_cntl = ASC_DEF_DVC_CNTL;
  10240. asc_dvc->init_sdtr = 0;
  10241. asc_dvc->max_total_qng = ASC_DEF_MAX_TOTAL_QNG;
  10242. asc_dvc->scsi_reset_wait = 3;
  10243. asc_dvc->start_motor = ASC_SCSI_WIDTH_BIT_SET;
  10244. asc_dvc->max_dma_count = AscGetMaxDmaCount(asc_dvc->bus_type);
  10245. asc_dvc->cfg->sdtr_enable = ASC_SCSI_WIDTH_BIT_SET;
  10246. asc_dvc->cfg->disc_enable = ASC_SCSI_WIDTH_BIT_SET;
  10247. asc_dvc->cfg->chip_scsi_id = ASC_DEF_CHIP_SCSI_ID;
  10248. chip_version = AscGetChipVersion(iop_base, asc_dvc->bus_type);
  10249. asc_dvc->cfg->chip_version = chip_version;
  10250. asc_dvc->sdtr_period_tbl = asc_syn_xfer_period;
  10251. asc_dvc->max_sdtr_index = 7;
  10252. if ((asc_dvc->bus_type & ASC_IS_PCI) &&
  10253. (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3150)) {
  10254. asc_dvc->bus_type = ASC_IS_PCI_ULTRA;
  10255. asc_dvc->sdtr_period_tbl = asc_syn_ultra_xfer_period;
  10256. asc_dvc->max_sdtr_index = 15;
  10257. if (chip_version == ASC_CHIP_VER_PCI_ULTRA_3150) {
  10258. AscSetExtraControl(iop_base,
  10259. (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  10260. } else if (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3050) {
  10261. AscSetExtraControl(iop_base,
  10262. (SEC_ACTIVE_NEGATE |
  10263. SEC_ENABLE_FILTER));
  10264. }
  10265. }
  10266. if (asc_dvc->bus_type == ASC_IS_PCI) {
  10267. AscSetExtraControl(iop_base,
  10268. (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  10269. }
  10270. asc_dvc->cfg->isa_dma_speed = ASC_DEF_ISA_DMA_SPEED;
  10271. #ifdef CONFIG_ISA
  10272. if ((asc_dvc->bus_type & ASC_IS_ISA) != 0) {
  10273. if (chip_version >= ASC_CHIP_MIN_VER_ISA_PNP) {
  10274. AscSetChipIFC(iop_base, IFC_INIT_DEFAULT);
  10275. asc_dvc->bus_type = ASC_IS_ISAPNP;
  10276. }
  10277. asc_dvc->cfg->isa_dma_channel =
  10278. (uchar)AscGetIsaDmaChannel(iop_base);
  10279. }
  10280. #endif /* CONFIG_ISA */
  10281. for (i = 0; i <= ASC_MAX_TID; i++) {
  10282. asc_dvc->cur_dvc_qng[i] = 0;
  10283. asc_dvc->max_dvc_qng[i] = ASC_MAX_SCSI1_QNG;
  10284. asc_dvc->scsiq_busy_head[i] = (ASC_SCSI_Q *)0L;
  10285. asc_dvc->scsiq_busy_tail[i] = (ASC_SCSI_Q *)0L;
  10286. asc_dvc->cfg->max_tag_qng[i] = ASC_MAX_INRAM_TAG_QNG;
  10287. }
  10288. return warn_code;
  10289. }
  10290. static int __devinit AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg)
  10291. {
  10292. int retry;
  10293. for (retry = 0; retry < ASC_EEP_MAX_RETRY; retry++) {
  10294. unsigned char read_back;
  10295. AscSetChipEEPCmd(iop_base, cmd_reg);
  10296. mdelay(1);
  10297. read_back = AscGetChipEEPCmd(iop_base);
  10298. if (read_back == cmd_reg)
  10299. return 1;
  10300. }
  10301. return 0;
  10302. }
  10303. static void __devinit AscWaitEEPRead(void)
  10304. {
  10305. mdelay(1);
  10306. }
  10307. static ushort __devinit AscReadEEPWord(PortAddr iop_base, uchar addr)
  10308. {
  10309. ushort read_wval;
  10310. uchar cmd_reg;
  10311. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  10312. AscWaitEEPRead();
  10313. cmd_reg = addr | ASC_EEP_CMD_READ;
  10314. AscWriteEEPCmdReg(iop_base, cmd_reg);
  10315. AscWaitEEPRead();
  10316. read_wval = AscGetChipEEPData(iop_base);
  10317. AscWaitEEPRead();
  10318. return read_wval;
  10319. }
  10320. static ushort __devinit
  10321. AscGetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  10322. {
  10323. ushort wval;
  10324. ushort sum;
  10325. ushort *wbuf;
  10326. int cfg_beg;
  10327. int cfg_end;
  10328. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  10329. int s_addr;
  10330. wbuf = (ushort *)cfg_buf;
  10331. sum = 0;
  10332. /* Read two config words; Byte-swapping done by AscReadEEPWord(). */
  10333. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  10334. *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
  10335. sum += *wbuf;
  10336. }
  10337. if (bus_type & ASC_IS_VL) {
  10338. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  10339. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  10340. } else {
  10341. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  10342. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  10343. }
  10344. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  10345. wval = AscReadEEPWord(iop_base, (uchar)s_addr);
  10346. if (s_addr <= uchar_end_in_config) {
  10347. /*
  10348. * Swap all char fields - must unswap bytes already swapped
  10349. * by AscReadEEPWord().
  10350. */
  10351. *wbuf = le16_to_cpu(wval);
  10352. } else {
  10353. /* Don't swap word field at the end - cntl field. */
  10354. *wbuf = wval;
  10355. }
  10356. sum += wval; /* Checksum treats all EEPROM data as words. */
  10357. }
  10358. /*
  10359. * Read the checksum word which will be compared against 'sum'
  10360. * by the caller. Word field already swapped.
  10361. */
  10362. *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
  10363. return sum;
  10364. }
  10365. static int __devinit AscTestExternalLram(ASC_DVC_VAR *asc_dvc)
  10366. {
  10367. PortAddr iop_base;
  10368. ushort q_addr;
  10369. ushort saved_word;
  10370. int sta;
  10371. iop_base = asc_dvc->iop_base;
  10372. sta = 0;
  10373. q_addr = ASC_QNO_TO_QADDR(241);
  10374. saved_word = AscReadLramWord(iop_base, q_addr);
  10375. AscSetChipLramAddr(iop_base, q_addr);
  10376. AscSetChipLramData(iop_base, 0x55AA);
  10377. mdelay(10);
  10378. AscSetChipLramAddr(iop_base, q_addr);
  10379. if (AscGetChipLramData(iop_base) == 0x55AA) {
  10380. sta = 1;
  10381. AscWriteLramWord(iop_base, q_addr, saved_word);
  10382. }
  10383. return (sta);
  10384. }
  10385. static void __devinit AscWaitEEPWrite(void)
  10386. {
  10387. mdelay(20);
  10388. }
  10389. static int __devinit AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg)
  10390. {
  10391. ushort read_back;
  10392. int retry;
  10393. retry = 0;
  10394. while (TRUE) {
  10395. AscSetChipEEPData(iop_base, data_reg);
  10396. mdelay(1);
  10397. read_back = AscGetChipEEPData(iop_base);
  10398. if (read_back == data_reg) {
  10399. return (1);
  10400. }
  10401. if (retry++ > ASC_EEP_MAX_RETRY) {
  10402. return (0);
  10403. }
  10404. }
  10405. }
  10406. static ushort __devinit
  10407. AscWriteEEPWord(PortAddr iop_base, uchar addr, ushort word_val)
  10408. {
  10409. ushort read_wval;
  10410. read_wval = AscReadEEPWord(iop_base, addr);
  10411. if (read_wval != word_val) {
  10412. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_ABLE);
  10413. AscWaitEEPRead();
  10414. AscWriteEEPDataReg(iop_base, word_val);
  10415. AscWaitEEPRead();
  10416. AscWriteEEPCmdReg(iop_base,
  10417. (uchar)((uchar)ASC_EEP_CMD_WRITE | addr));
  10418. AscWaitEEPWrite();
  10419. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  10420. AscWaitEEPRead();
  10421. return (AscReadEEPWord(iop_base, addr));
  10422. }
  10423. return (read_wval);
  10424. }
  10425. static int __devinit
  10426. AscSetEEPConfigOnce(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  10427. {
  10428. int n_error;
  10429. ushort *wbuf;
  10430. ushort word;
  10431. ushort sum;
  10432. int s_addr;
  10433. int cfg_beg;
  10434. int cfg_end;
  10435. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  10436. wbuf = (ushort *)cfg_buf;
  10437. n_error = 0;
  10438. sum = 0;
  10439. /* Write two config words; AscWriteEEPWord() will swap bytes. */
  10440. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  10441. sum += *wbuf;
  10442. if (*wbuf != AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
  10443. n_error++;
  10444. }
  10445. }
  10446. if (bus_type & ASC_IS_VL) {
  10447. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  10448. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  10449. } else {
  10450. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  10451. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  10452. }
  10453. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  10454. if (s_addr <= uchar_end_in_config) {
  10455. /*
  10456. * This is a char field. Swap char fields before they are
  10457. * swapped again by AscWriteEEPWord().
  10458. */
  10459. word = cpu_to_le16(*wbuf);
  10460. if (word !=
  10461. AscWriteEEPWord(iop_base, (uchar)s_addr, word)) {
  10462. n_error++;
  10463. }
  10464. } else {
  10465. /* Don't swap word field at the end - cntl field. */
  10466. if (*wbuf !=
  10467. AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
  10468. n_error++;
  10469. }
  10470. }
  10471. sum += *wbuf; /* Checksum calculated from word values. */
  10472. }
  10473. /* Write checksum word. It will be swapped by AscWriteEEPWord(). */
  10474. *wbuf = sum;
  10475. if (sum != AscWriteEEPWord(iop_base, (uchar)s_addr, sum)) {
  10476. n_error++;
  10477. }
  10478. /* Read EEPROM back again. */
  10479. wbuf = (ushort *)cfg_buf;
  10480. /*
  10481. * Read two config words; Byte-swapping done by AscReadEEPWord().
  10482. */
  10483. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  10484. if (*wbuf != AscReadEEPWord(iop_base, (uchar)s_addr)) {
  10485. n_error++;
  10486. }
  10487. }
  10488. if (bus_type & ASC_IS_VL) {
  10489. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  10490. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  10491. } else {
  10492. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  10493. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  10494. }
  10495. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  10496. if (s_addr <= uchar_end_in_config) {
  10497. /*
  10498. * Swap all char fields. Must unswap bytes already swapped
  10499. * by AscReadEEPWord().
  10500. */
  10501. word =
  10502. le16_to_cpu(AscReadEEPWord
  10503. (iop_base, (uchar)s_addr));
  10504. } else {
  10505. /* Don't swap word field at the end - cntl field. */
  10506. word = AscReadEEPWord(iop_base, (uchar)s_addr);
  10507. }
  10508. if (*wbuf != word) {
  10509. n_error++;
  10510. }
  10511. }
  10512. /* Read checksum; Byte swapping not needed. */
  10513. if (AscReadEEPWord(iop_base, (uchar)s_addr) != sum) {
  10514. n_error++;
  10515. }
  10516. return n_error;
  10517. }
  10518. static int __devinit
  10519. AscSetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  10520. {
  10521. int retry;
  10522. int n_error;
  10523. retry = 0;
  10524. while (TRUE) {
  10525. if ((n_error = AscSetEEPConfigOnce(iop_base, cfg_buf,
  10526. bus_type)) == 0) {
  10527. break;
  10528. }
  10529. if (++retry > ASC_EEP_MAX_RETRY) {
  10530. break;
  10531. }
  10532. }
  10533. return n_error;
  10534. }
  10535. static ushort __devinit AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
  10536. {
  10537. ASCEEP_CONFIG eep_config_buf;
  10538. ASCEEP_CONFIG *eep_config;
  10539. PortAddr iop_base;
  10540. ushort chksum;
  10541. ushort warn_code;
  10542. ushort cfg_msw, cfg_lsw;
  10543. int i;
  10544. int write_eep = 0;
  10545. iop_base = asc_dvc->iop_base;
  10546. warn_code = 0;
  10547. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0x00FE);
  10548. AscStopQueueExe(iop_base);
  10549. if ((AscStopChip(iop_base) == FALSE) ||
  10550. (AscGetChipScsiCtrl(iop_base) != 0)) {
  10551. asc_dvc->init_state |= ASC_INIT_RESET_SCSI_DONE;
  10552. AscResetChipAndScsiBus(asc_dvc);
  10553. mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
  10554. }
  10555. if (AscIsChipHalted(iop_base) == FALSE) {
  10556. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  10557. return (warn_code);
  10558. }
  10559. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  10560. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  10561. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  10562. return (warn_code);
  10563. }
  10564. eep_config = (ASCEEP_CONFIG *)&eep_config_buf;
  10565. cfg_msw = AscGetChipCfgMsw(iop_base);
  10566. cfg_lsw = AscGetChipCfgLsw(iop_base);
  10567. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  10568. cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  10569. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  10570. AscSetChipCfgMsw(iop_base, cfg_msw);
  10571. }
  10572. chksum = AscGetEEPConfig(iop_base, eep_config, asc_dvc->bus_type);
  10573. ASC_DBG(1, "chksum 0x%x\n", chksum);
  10574. if (chksum == 0) {
  10575. chksum = 0xaa55;
  10576. }
  10577. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  10578. warn_code |= ASC_WARN_AUTO_CONFIG;
  10579. if (asc_dvc->cfg->chip_version == 3) {
  10580. if (eep_config->cfg_lsw != cfg_lsw) {
  10581. warn_code |= ASC_WARN_EEPROM_RECOVER;
  10582. eep_config->cfg_lsw =
  10583. AscGetChipCfgLsw(iop_base);
  10584. }
  10585. if (eep_config->cfg_msw != cfg_msw) {
  10586. warn_code |= ASC_WARN_EEPROM_RECOVER;
  10587. eep_config->cfg_msw =
  10588. AscGetChipCfgMsw(iop_base);
  10589. }
  10590. }
  10591. }
  10592. eep_config->cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  10593. eep_config->cfg_lsw |= ASC_CFG0_HOST_INT_ON;
  10594. ASC_DBG(1, "eep_config->chksum 0x%x\n", eep_config->chksum);
  10595. if (chksum != eep_config->chksum) {
  10596. if (AscGetChipVersion(iop_base, asc_dvc->bus_type) ==
  10597. ASC_CHIP_VER_PCI_ULTRA_3050) {
  10598. ASC_DBG(1, "chksum error ignored; EEPROM-less board\n");
  10599. eep_config->init_sdtr = 0xFF;
  10600. eep_config->disc_enable = 0xFF;
  10601. eep_config->start_motor = 0xFF;
  10602. eep_config->use_cmd_qng = 0;
  10603. eep_config->max_total_qng = 0xF0;
  10604. eep_config->max_tag_qng = 0x20;
  10605. eep_config->cntl = 0xBFFF;
  10606. ASC_EEP_SET_CHIP_ID(eep_config, 7);
  10607. eep_config->no_scam = 0;
  10608. eep_config->adapter_info[0] = 0;
  10609. eep_config->adapter_info[1] = 0;
  10610. eep_config->adapter_info[2] = 0;
  10611. eep_config->adapter_info[3] = 0;
  10612. eep_config->adapter_info[4] = 0;
  10613. /* Indicate EEPROM-less board. */
  10614. eep_config->adapter_info[5] = 0xBB;
  10615. } else {
  10616. ASC_PRINT
  10617. ("AscInitFromEEP: EEPROM checksum error; Will try to re-write EEPROM.\n");
  10618. write_eep = 1;
  10619. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  10620. }
  10621. }
  10622. asc_dvc->cfg->sdtr_enable = eep_config->init_sdtr;
  10623. asc_dvc->cfg->disc_enable = eep_config->disc_enable;
  10624. asc_dvc->cfg->cmd_qng_enabled = eep_config->use_cmd_qng;
  10625. asc_dvc->cfg->isa_dma_speed = ASC_EEP_GET_DMA_SPD(eep_config);
  10626. asc_dvc->start_motor = eep_config->start_motor;
  10627. asc_dvc->dvc_cntl = eep_config->cntl;
  10628. asc_dvc->no_scam = eep_config->no_scam;
  10629. asc_dvc->cfg->adapter_info[0] = eep_config->adapter_info[0];
  10630. asc_dvc->cfg->adapter_info[1] = eep_config->adapter_info[1];
  10631. asc_dvc->cfg->adapter_info[2] = eep_config->adapter_info[2];
  10632. asc_dvc->cfg->adapter_info[3] = eep_config->adapter_info[3];
  10633. asc_dvc->cfg->adapter_info[4] = eep_config->adapter_info[4];
  10634. asc_dvc->cfg->adapter_info[5] = eep_config->adapter_info[5];
  10635. if (!AscTestExternalLram(asc_dvc)) {
  10636. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) ==
  10637. ASC_IS_PCI_ULTRA)) {
  10638. eep_config->max_total_qng =
  10639. ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG;
  10640. eep_config->max_tag_qng =
  10641. ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG;
  10642. } else {
  10643. eep_config->cfg_msw |= 0x0800;
  10644. cfg_msw |= 0x0800;
  10645. AscSetChipCfgMsw(iop_base, cfg_msw);
  10646. eep_config->max_total_qng = ASC_MAX_PCI_INRAM_TOTAL_QNG;
  10647. eep_config->max_tag_qng = ASC_MAX_INRAM_TAG_QNG;
  10648. }
  10649. } else {
  10650. }
  10651. if (eep_config->max_total_qng < ASC_MIN_TOTAL_QNG) {
  10652. eep_config->max_total_qng = ASC_MIN_TOTAL_QNG;
  10653. }
  10654. if (eep_config->max_total_qng > ASC_MAX_TOTAL_QNG) {
  10655. eep_config->max_total_qng = ASC_MAX_TOTAL_QNG;
  10656. }
  10657. if (eep_config->max_tag_qng > eep_config->max_total_qng) {
  10658. eep_config->max_tag_qng = eep_config->max_total_qng;
  10659. }
  10660. if (eep_config->max_tag_qng < ASC_MIN_TAG_Q_PER_DVC) {
  10661. eep_config->max_tag_qng = ASC_MIN_TAG_Q_PER_DVC;
  10662. }
  10663. asc_dvc->max_total_qng = eep_config->max_total_qng;
  10664. if ((eep_config->use_cmd_qng & eep_config->disc_enable) !=
  10665. eep_config->use_cmd_qng) {
  10666. eep_config->disc_enable = eep_config->use_cmd_qng;
  10667. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  10668. }
  10669. ASC_EEP_SET_CHIP_ID(eep_config,
  10670. ASC_EEP_GET_CHIP_ID(eep_config) & ASC_MAX_TID);
  10671. asc_dvc->cfg->chip_scsi_id = ASC_EEP_GET_CHIP_ID(eep_config);
  10672. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) &&
  10673. !(asc_dvc->dvc_cntl & ASC_CNTL_SDTR_ENABLE_ULTRA)) {
  10674. asc_dvc->min_sdtr_index = ASC_SDTR_ULTRA_PCI_10MB_INDEX;
  10675. }
  10676. for (i = 0; i <= ASC_MAX_TID; i++) {
  10677. asc_dvc->dos_int13_table[i] = eep_config->dos_int13_table[i];
  10678. asc_dvc->cfg->max_tag_qng[i] = eep_config->max_tag_qng;
  10679. asc_dvc->cfg->sdtr_period_offset[i] =
  10680. (uchar)(ASC_DEF_SDTR_OFFSET |
  10681. (asc_dvc->min_sdtr_index << 4));
  10682. }
  10683. eep_config->cfg_msw = AscGetChipCfgMsw(iop_base);
  10684. if (write_eep) {
  10685. if ((i = AscSetEEPConfig(iop_base, eep_config,
  10686. asc_dvc->bus_type)) != 0) {
  10687. ASC_PRINT1
  10688. ("AscInitFromEEP: Failed to re-write EEPROM with %d errors.\n",
  10689. i);
  10690. } else {
  10691. ASC_PRINT
  10692. ("AscInitFromEEP: Successfully re-wrote EEPROM.\n");
  10693. }
  10694. }
  10695. return (warn_code);
  10696. }
  10697. static int __devinit AscInitGetConfig(struct Scsi_Host *shost)
  10698. {
  10699. struct asc_board *board = shost_priv(shost);
  10700. ASC_DVC_VAR *asc_dvc = &board->dvc_var.asc_dvc_var;
  10701. unsigned short warn_code = 0;
  10702. asc_dvc->init_state = ASC_INIT_STATE_BEG_GET_CFG;
  10703. if (asc_dvc->err_code != 0)
  10704. return asc_dvc->err_code;
  10705. if (AscFindSignature(asc_dvc->iop_base)) {
  10706. warn_code |= AscInitAscDvcVar(asc_dvc);
  10707. warn_code |= AscInitFromEEP(asc_dvc);
  10708. asc_dvc->init_state |= ASC_INIT_STATE_END_GET_CFG;
  10709. if (asc_dvc->scsi_reset_wait > ASC_MAX_SCSI_RESET_WAIT)
  10710. asc_dvc->scsi_reset_wait = ASC_MAX_SCSI_RESET_WAIT;
  10711. } else {
  10712. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  10713. }
  10714. switch (warn_code) {
  10715. case 0: /* No error */
  10716. break;
  10717. case ASC_WARN_IO_PORT_ROTATE:
  10718. shost_printk(KERN_WARNING, shost, "I/O port address "
  10719. "modified\n");
  10720. break;
  10721. case ASC_WARN_AUTO_CONFIG:
  10722. shost_printk(KERN_WARNING, shost, "I/O port increment switch "
  10723. "enabled\n");
  10724. break;
  10725. case ASC_WARN_EEPROM_CHKSUM:
  10726. shost_printk(KERN_WARNING, shost, "EEPROM checksum error\n");
  10727. break;
  10728. case ASC_WARN_IRQ_MODIFIED:
  10729. shost_printk(KERN_WARNING, shost, "IRQ modified\n");
  10730. break;
  10731. case ASC_WARN_CMD_QNG_CONFLICT:
  10732. shost_printk(KERN_WARNING, shost, "tag queuing enabled w/o "
  10733. "disconnects\n");
  10734. break;
  10735. default:
  10736. shost_printk(KERN_WARNING, shost, "unknown warning: 0x%x\n",
  10737. warn_code);
  10738. break;
  10739. }
  10740. if (asc_dvc->err_code != 0)
  10741. shost_printk(KERN_ERR, shost, "error 0x%x at init_state "
  10742. "0x%x\n", asc_dvc->err_code, asc_dvc->init_state);
  10743. return asc_dvc->err_code;
  10744. }
  10745. static int __devinit AscInitSetConfig(struct pci_dev *pdev, struct Scsi_Host *shost)
  10746. {
  10747. struct asc_board *board = shost_priv(shost);
  10748. ASC_DVC_VAR *asc_dvc = &board->dvc_var.asc_dvc_var;
  10749. PortAddr iop_base = asc_dvc->iop_base;
  10750. unsigned short cfg_msw;
  10751. unsigned short warn_code = 0;
  10752. asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
  10753. if (asc_dvc->err_code != 0)
  10754. return asc_dvc->err_code;
  10755. if (!AscFindSignature(asc_dvc->iop_base)) {
  10756. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  10757. return asc_dvc->err_code;
  10758. }
  10759. cfg_msw = AscGetChipCfgMsw(iop_base);
  10760. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  10761. cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  10762. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  10763. AscSetChipCfgMsw(iop_base, cfg_msw);
  10764. }
  10765. if ((asc_dvc->cfg->cmd_qng_enabled & asc_dvc->cfg->disc_enable) !=
  10766. asc_dvc->cfg->cmd_qng_enabled) {
  10767. asc_dvc->cfg->disc_enable = asc_dvc->cfg->cmd_qng_enabled;
  10768. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  10769. }
  10770. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  10771. warn_code |= ASC_WARN_AUTO_CONFIG;
  10772. }
  10773. #ifdef CONFIG_PCI
  10774. if (asc_dvc->bus_type & ASC_IS_PCI) {
  10775. cfg_msw &= 0xFFC0;
  10776. AscSetChipCfgMsw(iop_base, cfg_msw);
  10777. if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) {
  10778. } else {
  10779. if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
  10780. (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
  10781. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_IF_NOT_DWB;
  10782. asc_dvc->bug_fix_cntl |=
  10783. ASC_BUG_FIX_ASYN_USE_SYN;
  10784. }
  10785. }
  10786. } else
  10787. #endif /* CONFIG_PCI */
  10788. if (asc_dvc->bus_type == ASC_IS_ISAPNP) {
  10789. if (AscGetChipVersion(iop_base, asc_dvc->bus_type)
  10790. == ASC_CHIP_VER_ASYN_BUG) {
  10791. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN;
  10792. }
  10793. }
  10794. if (AscSetChipScsiID(iop_base, asc_dvc->cfg->chip_scsi_id) !=
  10795. asc_dvc->cfg->chip_scsi_id) {
  10796. asc_dvc->err_code |= ASC_IERR_SET_SCSI_ID;
  10797. }
  10798. #ifdef CONFIG_ISA
  10799. if (asc_dvc->bus_type & ASC_IS_ISA) {
  10800. AscSetIsaDmaChannel(iop_base, asc_dvc->cfg->isa_dma_channel);
  10801. AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed);
  10802. }
  10803. #endif /* CONFIG_ISA */
  10804. asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
  10805. switch (warn_code) {
  10806. case 0: /* No error. */
  10807. break;
  10808. case ASC_WARN_IO_PORT_ROTATE:
  10809. shost_printk(KERN_WARNING, shost, "I/O port address "
  10810. "modified\n");
  10811. break;
  10812. case ASC_WARN_AUTO_CONFIG:
  10813. shost_printk(KERN_WARNING, shost, "I/O port increment switch "
  10814. "enabled\n");
  10815. break;
  10816. case ASC_WARN_EEPROM_CHKSUM:
  10817. shost_printk(KERN_WARNING, shost, "EEPROM checksum error\n");
  10818. break;
  10819. case ASC_WARN_IRQ_MODIFIED:
  10820. shost_printk(KERN_WARNING, shost, "IRQ modified\n");
  10821. break;
  10822. case ASC_WARN_CMD_QNG_CONFLICT:
  10823. shost_printk(KERN_WARNING, shost, "tag queuing w/o "
  10824. "disconnects\n");
  10825. break;
  10826. default:
  10827. shost_printk(KERN_WARNING, shost, "unknown warning: 0x%x\n",
  10828. warn_code);
  10829. break;
  10830. }
  10831. if (asc_dvc->err_code != 0)
  10832. shost_printk(KERN_ERR, shost, "error 0x%x at init_state "
  10833. "0x%x\n", asc_dvc->err_code, asc_dvc->init_state);
  10834. return asc_dvc->err_code;
  10835. }
  10836. /*
  10837. * EEPROM Configuration.
  10838. *
  10839. * All drivers should use this structure to set the default EEPROM
  10840. * configuration. The BIOS now uses this structure when it is built.
  10841. * Additional structure information can be found in a_condor.h where
  10842. * the structure is defined.
  10843. *
  10844. * The *_Field_IsChar structs are needed to correct for endianness.
  10845. * These values are read from the board 16 bits at a time directly
  10846. * into the structs. Because some fields are char, the values will be
  10847. * in the wrong order. The *_Field_IsChar tells when to flip the
  10848. * bytes. Data read and written to PCI memory is automatically swapped
  10849. * on big-endian platforms so char fields read as words are actually being
  10850. * unswapped on big-endian platforms.
  10851. */
  10852. static ADVEEP_3550_CONFIG Default_3550_EEPROM_Config __devinitdata = {
  10853. ADV_EEPROM_BIOS_ENABLE, /* cfg_lsw */
  10854. 0x0000, /* cfg_msw */
  10855. 0xFFFF, /* disc_enable */
  10856. 0xFFFF, /* wdtr_able */
  10857. 0xFFFF, /* sdtr_able */
  10858. 0xFFFF, /* start_motor */
  10859. 0xFFFF, /* tagqng_able */
  10860. 0xFFFF, /* bios_scan */
  10861. 0, /* scam_tolerant */
  10862. 7, /* adapter_scsi_id */
  10863. 0, /* bios_boot_delay */
  10864. 3, /* scsi_reset_delay */
  10865. 0, /* bios_id_lun */
  10866. 0, /* termination */
  10867. 0, /* reserved1 */
  10868. 0xFFE7, /* bios_ctrl */
  10869. 0xFFFF, /* ultra_able */
  10870. 0, /* reserved2 */
  10871. ASC_DEF_MAX_HOST_QNG, /* max_host_qng */
  10872. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  10873. 0, /* dvc_cntl */
  10874. 0, /* bug_fix */
  10875. 0, /* serial_number_word1 */
  10876. 0, /* serial_number_word2 */
  10877. 0, /* serial_number_word3 */
  10878. 0, /* check_sum */
  10879. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  10880. , /* oem_name[16] */
  10881. 0, /* dvc_err_code */
  10882. 0, /* adv_err_code */
  10883. 0, /* adv_err_addr */
  10884. 0, /* saved_dvc_err_code */
  10885. 0, /* saved_adv_err_code */
  10886. 0, /* saved_adv_err_addr */
  10887. 0 /* num_of_err */
  10888. };
  10889. static ADVEEP_3550_CONFIG ADVEEP_3550_Config_Field_IsChar __devinitdata = {
  10890. 0, /* cfg_lsw */
  10891. 0, /* cfg_msw */
  10892. 0, /* -disc_enable */
  10893. 0, /* wdtr_able */
  10894. 0, /* sdtr_able */
  10895. 0, /* start_motor */
  10896. 0, /* tagqng_able */
  10897. 0, /* bios_scan */
  10898. 0, /* scam_tolerant */
  10899. 1, /* adapter_scsi_id */
  10900. 1, /* bios_boot_delay */
  10901. 1, /* scsi_reset_delay */
  10902. 1, /* bios_id_lun */
  10903. 1, /* termination */
  10904. 1, /* reserved1 */
  10905. 0, /* bios_ctrl */
  10906. 0, /* ultra_able */
  10907. 0, /* reserved2 */
  10908. 1, /* max_host_qng */
  10909. 1, /* max_dvc_qng */
  10910. 0, /* dvc_cntl */
  10911. 0, /* bug_fix */
  10912. 0, /* serial_number_word1 */
  10913. 0, /* serial_number_word2 */
  10914. 0, /* serial_number_word3 */
  10915. 0, /* check_sum */
  10916. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  10917. , /* oem_name[16] */
  10918. 0, /* dvc_err_code */
  10919. 0, /* adv_err_code */
  10920. 0, /* adv_err_addr */
  10921. 0, /* saved_dvc_err_code */
  10922. 0, /* saved_adv_err_code */
  10923. 0, /* saved_adv_err_addr */
  10924. 0 /* num_of_err */
  10925. };
  10926. static ADVEEP_38C0800_CONFIG Default_38C0800_EEPROM_Config __devinitdata = {
  10927. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  10928. 0x0000, /* 01 cfg_msw */
  10929. 0xFFFF, /* 02 disc_enable */
  10930. 0xFFFF, /* 03 wdtr_able */
  10931. 0x4444, /* 04 sdtr_speed1 */
  10932. 0xFFFF, /* 05 start_motor */
  10933. 0xFFFF, /* 06 tagqng_able */
  10934. 0xFFFF, /* 07 bios_scan */
  10935. 0, /* 08 scam_tolerant */
  10936. 7, /* 09 adapter_scsi_id */
  10937. 0, /* bios_boot_delay */
  10938. 3, /* 10 scsi_reset_delay */
  10939. 0, /* bios_id_lun */
  10940. 0, /* 11 termination_se */
  10941. 0, /* termination_lvd */
  10942. 0xFFE7, /* 12 bios_ctrl */
  10943. 0x4444, /* 13 sdtr_speed2 */
  10944. 0x4444, /* 14 sdtr_speed3 */
  10945. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  10946. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  10947. 0, /* 16 dvc_cntl */
  10948. 0x4444, /* 17 sdtr_speed4 */
  10949. 0, /* 18 serial_number_word1 */
  10950. 0, /* 19 serial_number_word2 */
  10951. 0, /* 20 serial_number_word3 */
  10952. 0, /* 21 check_sum */
  10953. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  10954. , /* 22-29 oem_name[16] */
  10955. 0, /* 30 dvc_err_code */
  10956. 0, /* 31 adv_err_code */
  10957. 0, /* 32 adv_err_addr */
  10958. 0, /* 33 saved_dvc_err_code */
  10959. 0, /* 34 saved_adv_err_code */
  10960. 0, /* 35 saved_adv_err_addr */
  10961. 0, /* 36 reserved */
  10962. 0, /* 37 reserved */
  10963. 0, /* 38 reserved */
  10964. 0, /* 39 reserved */
  10965. 0, /* 40 reserved */
  10966. 0, /* 41 reserved */
  10967. 0, /* 42 reserved */
  10968. 0, /* 43 reserved */
  10969. 0, /* 44 reserved */
  10970. 0, /* 45 reserved */
  10971. 0, /* 46 reserved */
  10972. 0, /* 47 reserved */
  10973. 0, /* 48 reserved */
  10974. 0, /* 49 reserved */
  10975. 0, /* 50 reserved */
  10976. 0, /* 51 reserved */
  10977. 0, /* 52 reserved */
  10978. 0, /* 53 reserved */
  10979. 0, /* 54 reserved */
  10980. 0, /* 55 reserved */
  10981. 0, /* 56 cisptr_lsw */
  10982. 0, /* 57 cisprt_msw */
  10983. PCI_VENDOR_ID_ASP, /* 58 subsysvid */
  10984. PCI_DEVICE_ID_38C0800_REV1, /* 59 subsysid */
  10985. 0, /* 60 reserved */
  10986. 0, /* 61 reserved */
  10987. 0, /* 62 reserved */
  10988. 0 /* 63 reserved */
  10989. };
  10990. static ADVEEP_38C0800_CONFIG ADVEEP_38C0800_Config_Field_IsChar __devinitdata = {
  10991. 0, /* 00 cfg_lsw */
  10992. 0, /* 01 cfg_msw */
  10993. 0, /* 02 disc_enable */
  10994. 0, /* 03 wdtr_able */
  10995. 0, /* 04 sdtr_speed1 */
  10996. 0, /* 05 start_motor */
  10997. 0, /* 06 tagqng_able */
  10998. 0, /* 07 bios_scan */
  10999. 0, /* 08 scam_tolerant */
  11000. 1, /* 09 adapter_scsi_id */
  11001. 1, /* bios_boot_delay */
  11002. 1, /* 10 scsi_reset_delay */
  11003. 1, /* bios_id_lun */
  11004. 1, /* 11 termination_se */
  11005. 1, /* termination_lvd */
  11006. 0, /* 12 bios_ctrl */
  11007. 0, /* 13 sdtr_speed2 */
  11008. 0, /* 14 sdtr_speed3 */
  11009. 1, /* 15 max_host_qng */
  11010. 1, /* max_dvc_qng */
  11011. 0, /* 16 dvc_cntl */
  11012. 0, /* 17 sdtr_speed4 */
  11013. 0, /* 18 serial_number_word1 */
  11014. 0, /* 19 serial_number_word2 */
  11015. 0, /* 20 serial_number_word3 */
  11016. 0, /* 21 check_sum */
  11017. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  11018. , /* 22-29 oem_name[16] */
  11019. 0, /* 30 dvc_err_code */
  11020. 0, /* 31 adv_err_code */
  11021. 0, /* 32 adv_err_addr */
  11022. 0, /* 33 saved_dvc_err_code */
  11023. 0, /* 34 saved_adv_err_code */
  11024. 0, /* 35 saved_adv_err_addr */
  11025. 0, /* 36 reserved */
  11026. 0, /* 37 reserved */
  11027. 0, /* 38 reserved */
  11028. 0, /* 39 reserved */
  11029. 0, /* 40 reserved */
  11030. 0, /* 41 reserved */
  11031. 0, /* 42 reserved */
  11032. 0, /* 43 reserved */
  11033. 0, /* 44 reserved */
  11034. 0, /* 45 reserved */
  11035. 0, /* 46 reserved */
  11036. 0, /* 47 reserved */
  11037. 0, /* 48 reserved */
  11038. 0, /* 49 reserved */
  11039. 0, /* 50 reserved */
  11040. 0, /* 51 reserved */
  11041. 0, /* 52 reserved */
  11042. 0, /* 53 reserved */
  11043. 0, /* 54 reserved */
  11044. 0, /* 55 reserved */
  11045. 0, /* 56 cisptr_lsw */
  11046. 0, /* 57 cisprt_msw */
  11047. 0, /* 58 subsysvid */
  11048. 0, /* 59 subsysid */
  11049. 0, /* 60 reserved */
  11050. 0, /* 61 reserved */
  11051. 0, /* 62 reserved */
  11052. 0 /* 63 reserved */
  11053. };
  11054. static ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config __devinitdata = {
  11055. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  11056. 0x0000, /* 01 cfg_msw */
  11057. 0xFFFF, /* 02 disc_enable */
  11058. 0xFFFF, /* 03 wdtr_able */
  11059. 0x5555, /* 04 sdtr_speed1 */
  11060. 0xFFFF, /* 05 start_motor */
  11061. 0xFFFF, /* 06 tagqng_able */
  11062. 0xFFFF, /* 07 bios_scan */
  11063. 0, /* 08 scam_tolerant */
  11064. 7, /* 09 adapter_scsi_id */
  11065. 0, /* bios_boot_delay */
  11066. 3, /* 10 scsi_reset_delay */
  11067. 0, /* bios_id_lun */
  11068. 0, /* 11 termination_se */
  11069. 0, /* termination_lvd */
  11070. 0xFFE7, /* 12 bios_ctrl */
  11071. 0x5555, /* 13 sdtr_speed2 */
  11072. 0x5555, /* 14 sdtr_speed3 */
  11073. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  11074. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  11075. 0, /* 16 dvc_cntl */
  11076. 0x5555, /* 17 sdtr_speed4 */
  11077. 0, /* 18 serial_number_word1 */
  11078. 0, /* 19 serial_number_word2 */
  11079. 0, /* 20 serial_number_word3 */
  11080. 0, /* 21 check_sum */
  11081. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  11082. , /* 22-29 oem_name[16] */
  11083. 0, /* 30 dvc_err_code */
  11084. 0, /* 31 adv_err_code */
  11085. 0, /* 32 adv_err_addr */
  11086. 0, /* 33 saved_dvc_err_code */
  11087. 0, /* 34 saved_adv_err_code */
  11088. 0, /* 35 saved_adv_err_addr */
  11089. 0, /* 36 reserved */
  11090. 0, /* 37 reserved */
  11091. 0, /* 38 reserved */
  11092. 0, /* 39 reserved */
  11093. 0, /* 40 reserved */
  11094. 0, /* 41 reserved */
  11095. 0, /* 42 reserved */
  11096. 0, /* 43 reserved */
  11097. 0, /* 44 reserved */
  11098. 0, /* 45 reserved */
  11099. 0, /* 46 reserved */
  11100. 0, /* 47 reserved */
  11101. 0, /* 48 reserved */
  11102. 0, /* 49 reserved */
  11103. 0, /* 50 reserved */
  11104. 0, /* 51 reserved */
  11105. 0, /* 52 reserved */
  11106. 0, /* 53 reserved */
  11107. 0, /* 54 reserved */
  11108. 0, /* 55 reserved */
  11109. 0, /* 56 cisptr_lsw */
  11110. 0, /* 57 cisprt_msw */
  11111. PCI_VENDOR_ID_ASP, /* 58 subsysvid */
  11112. PCI_DEVICE_ID_38C1600_REV1, /* 59 subsysid */
  11113. 0, /* 60 reserved */
  11114. 0, /* 61 reserved */
  11115. 0, /* 62 reserved */
  11116. 0 /* 63 reserved */
  11117. };
  11118. static ADVEEP_38C1600_CONFIG ADVEEP_38C1600_Config_Field_IsChar __devinitdata = {
  11119. 0, /* 00 cfg_lsw */
  11120. 0, /* 01 cfg_msw */
  11121. 0, /* 02 disc_enable */
  11122. 0, /* 03 wdtr_able */
  11123. 0, /* 04 sdtr_speed1 */
  11124. 0, /* 05 start_motor */
  11125. 0, /* 06 tagqng_able */
  11126. 0, /* 07 bios_scan */
  11127. 0, /* 08 scam_tolerant */
  11128. 1, /* 09 adapter_scsi_id */
  11129. 1, /* bios_boot_delay */
  11130. 1, /* 10 scsi_reset_delay */
  11131. 1, /* bios_id_lun */
  11132. 1, /* 11 termination_se */
  11133. 1, /* termination_lvd */
  11134. 0, /* 12 bios_ctrl */
  11135. 0, /* 13 sdtr_speed2 */
  11136. 0, /* 14 sdtr_speed3 */
  11137. 1, /* 15 max_host_qng */
  11138. 1, /* max_dvc_qng */
  11139. 0, /* 16 dvc_cntl */
  11140. 0, /* 17 sdtr_speed4 */
  11141. 0, /* 18 serial_number_word1 */
  11142. 0, /* 19 serial_number_word2 */
  11143. 0, /* 20 serial_number_word3 */
  11144. 0, /* 21 check_sum */
  11145. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  11146. , /* 22-29 oem_name[16] */
  11147. 0, /* 30 dvc_err_code */
  11148. 0, /* 31 adv_err_code */
  11149. 0, /* 32 adv_err_addr */
  11150. 0, /* 33 saved_dvc_err_code */
  11151. 0, /* 34 saved_adv_err_code */
  11152. 0, /* 35 saved_adv_err_addr */
  11153. 0, /* 36 reserved */
  11154. 0, /* 37 reserved */
  11155. 0, /* 38 reserved */
  11156. 0, /* 39 reserved */
  11157. 0, /* 40 reserved */
  11158. 0, /* 41 reserved */
  11159. 0, /* 42 reserved */
  11160. 0, /* 43 reserved */
  11161. 0, /* 44 reserved */
  11162. 0, /* 45 reserved */
  11163. 0, /* 46 reserved */
  11164. 0, /* 47 reserved */
  11165. 0, /* 48 reserved */
  11166. 0, /* 49 reserved */
  11167. 0, /* 50 reserved */
  11168. 0, /* 51 reserved */
  11169. 0, /* 52 reserved */
  11170. 0, /* 53 reserved */
  11171. 0, /* 54 reserved */
  11172. 0, /* 55 reserved */
  11173. 0, /* 56 cisptr_lsw */
  11174. 0, /* 57 cisprt_msw */
  11175. 0, /* 58 subsysvid */
  11176. 0, /* 59 subsysid */
  11177. 0, /* 60 reserved */
  11178. 0, /* 61 reserved */
  11179. 0, /* 62 reserved */
  11180. 0 /* 63 reserved */
  11181. };
  11182. #ifdef CONFIG_PCI
  11183. /*
  11184. * Wait for EEPROM command to complete
  11185. */
  11186. static void __devinit AdvWaitEEPCmd(AdvPortAddr iop_base)
  11187. {
  11188. int eep_delay_ms;
  11189. for (eep_delay_ms = 0; eep_delay_ms < ADV_EEP_DELAY_MS; eep_delay_ms++) {
  11190. if (AdvReadWordRegister(iop_base, IOPW_EE_CMD) &
  11191. ASC_EEP_CMD_DONE) {
  11192. break;
  11193. }
  11194. mdelay(1);
  11195. }
  11196. if ((AdvReadWordRegister(iop_base, IOPW_EE_CMD) & ASC_EEP_CMD_DONE) ==
  11197. 0)
  11198. BUG();
  11199. }
  11200. /*
  11201. * Read the EEPROM from specified location
  11202. */
  11203. static ushort __devinit AdvReadEEPWord(AdvPortAddr iop_base, int eep_word_addr)
  11204. {
  11205. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11206. ASC_EEP_CMD_READ | eep_word_addr);
  11207. AdvWaitEEPCmd(iop_base);
  11208. return AdvReadWordRegister(iop_base, IOPW_EE_DATA);
  11209. }
  11210. /*
  11211. * Write the EEPROM from 'cfg_buf'.
  11212. */
  11213. void __devinit
  11214. AdvSet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  11215. {
  11216. ushort *wbuf;
  11217. ushort addr, chksum;
  11218. ushort *charfields;
  11219. wbuf = (ushort *)cfg_buf;
  11220. charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
  11221. chksum = 0;
  11222. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  11223. AdvWaitEEPCmd(iop_base);
  11224. /*
  11225. * Write EEPROM from word 0 to word 20.
  11226. */
  11227. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  11228. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  11229. ushort word;
  11230. if (*charfields++) {
  11231. word = cpu_to_le16(*wbuf);
  11232. } else {
  11233. word = *wbuf;
  11234. }
  11235. chksum += *wbuf; /* Checksum is calculated from word values. */
  11236. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11237. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11238. ASC_EEP_CMD_WRITE | addr);
  11239. AdvWaitEEPCmd(iop_base);
  11240. mdelay(ADV_EEP_DELAY_MS);
  11241. }
  11242. /*
  11243. * Write EEPROM checksum at word 21.
  11244. */
  11245. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  11246. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  11247. AdvWaitEEPCmd(iop_base);
  11248. wbuf++;
  11249. charfields++;
  11250. /*
  11251. * Write EEPROM OEM name at words 22 to 29.
  11252. */
  11253. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  11254. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  11255. ushort word;
  11256. if (*charfields++) {
  11257. word = cpu_to_le16(*wbuf);
  11258. } else {
  11259. word = *wbuf;
  11260. }
  11261. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11262. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11263. ASC_EEP_CMD_WRITE | addr);
  11264. AdvWaitEEPCmd(iop_base);
  11265. }
  11266. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  11267. AdvWaitEEPCmd(iop_base);
  11268. }
  11269. /*
  11270. * Write the EEPROM from 'cfg_buf'.
  11271. */
  11272. void __devinit
  11273. AdvSet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
  11274. {
  11275. ushort *wbuf;
  11276. ushort *charfields;
  11277. ushort addr, chksum;
  11278. wbuf = (ushort *)cfg_buf;
  11279. charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
  11280. chksum = 0;
  11281. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  11282. AdvWaitEEPCmd(iop_base);
  11283. /*
  11284. * Write EEPROM from word 0 to word 20.
  11285. */
  11286. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  11287. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  11288. ushort word;
  11289. if (*charfields++) {
  11290. word = cpu_to_le16(*wbuf);
  11291. } else {
  11292. word = *wbuf;
  11293. }
  11294. chksum += *wbuf; /* Checksum is calculated from word values. */
  11295. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11296. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11297. ASC_EEP_CMD_WRITE | addr);
  11298. AdvWaitEEPCmd(iop_base);
  11299. mdelay(ADV_EEP_DELAY_MS);
  11300. }
  11301. /*
  11302. * Write EEPROM checksum at word 21.
  11303. */
  11304. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  11305. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  11306. AdvWaitEEPCmd(iop_base);
  11307. wbuf++;
  11308. charfields++;
  11309. /*
  11310. * Write EEPROM OEM name at words 22 to 29.
  11311. */
  11312. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  11313. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  11314. ushort word;
  11315. if (*charfields++) {
  11316. word = cpu_to_le16(*wbuf);
  11317. } else {
  11318. word = *wbuf;
  11319. }
  11320. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11321. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11322. ASC_EEP_CMD_WRITE | addr);
  11323. AdvWaitEEPCmd(iop_base);
  11324. }
  11325. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  11326. AdvWaitEEPCmd(iop_base);
  11327. }
  11328. /*
  11329. * Write the EEPROM from 'cfg_buf'.
  11330. */
  11331. void __devinit
  11332. AdvSet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
  11333. {
  11334. ushort *wbuf;
  11335. ushort *charfields;
  11336. ushort addr, chksum;
  11337. wbuf = (ushort *)cfg_buf;
  11338. charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
  11339. chksum = 0;
  11340. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  11341. AdvWaitEEPCmd(iop_base);
  11342. /*
  11343. * Write EEPROM from word 0 to word 20.
  11344. */
  11345. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  11346. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  11347. ushort word;
  11348. if (*charfields++) {
  11349. word = cpu_to_le16(*wbuf);
  11350. } else {
  11351. word = *wbuf;
  11352. }
  11353. chksum += *wbuf; /* Checksum is calculated from word values. */
  11354. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11355. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11356. ASC_EEP_CMD_WRITE | addr);
  11357. AdvWaitEEPCmd(iop_base);
  11358. mdelay(ADV_EEP_DELAY_MS);
  11359. }
  11360. /*
  11361. * Write EEPROM checksum at word 21.
  11362. */
  11363. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  11364. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  11365. AdvWaitEEPCmd(iop_base);
  11366. wbuf++;
  11367. charfields++;
  11368. /*
  11369. * Write EEPROM OEM name at words 22 to 29.
  11370. */
  11371. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  11372. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  11373. ushort word;
  11374. if (*charfields++) {
  11375. word = cpu_to_le16(*wbuf);
  11376. } else {
  11377. word = *wbuf;
  11378. }
  11379. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11380. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11381. ASC_EEP_CMD_WRITE | addr);
  11382. AdvWaitEEPCmd(iop_base);
  11383. }
  11384. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  11385. AdvWaitEEPCmd(iop_base);
  11386. }
  11387. /*
  11388. * Read EEPROM configuration into the specified buffer.
  11389. *
  11390. * Return a checksum based on the EEPROM configuration read.
  11391. */
  11392. static ushort __devinit
  11393. AdvGet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  11394. {
  11395. ushort wval, chksum;
  11396. ushort *wbuf;
  11397. int eep_addr;
  11398. ushort *charfields;
  11399. charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
  11400. wbuf = (ushort *)cfg_buf;
  11401. chksum = 0;
  11402. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  11403. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  11404. wval = AdvReadEEPWord(iop_base, eep_addr);
  11405. chksum += wval; /* Checksum is calculated from word values. */
  11406. if (*charfields++) {
  11407. *wbuf = le16_to_cpu(wval);
  11408. } else {
  11409. *wbuf = wval;
  11410. }
  11411. }
  11412. /* Read checksum word. */
  11413. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11414. wbuf++;
  11415. charfields++;
  11416. /* Read rest of EEPROM not covered by the checksum. */
  11417. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  11418. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  11419. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11420. if (*charfields++) {
  11421. *wbuf = le16_to_cpu(*wbuf);
  11422. }
  11423. }
  11424. return chksum;
  11425. }
  11426. /*
  11427. * Read EEPROM configuration into the specified buffer.
  11428. *
  11429. * Return a checksum based on the EEPROM configuration read.
  11430. */
  11431. static ushort __devinit
  11432. AdvGet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
  11433. {
  11434. ushort wval, chksum;
  11435. ushort *wbuf;
  11436. int eep_addr;
  11437. ushort *charfields;
  11438. charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
  11439. wbuf = (ushort *)cfg_buf;
  11440. chksum = 0;
  11441. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  11442. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  11443. wval = AdvReadEEPWord(iop_base, eep_addr);
  11444. chksum += wval; /* Checksum is calculated from word values. */
  11445. if (*charfields++) {
  11446. *wbuf = le16_to_cpu(wval);
  11447. } else {
  11448. *wbuf = wval;
  11449. }
  11450. }
  11451. /* Read checksum word. */
  11452. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11453. wbuf++;
  11454. charfields++;
  11455. /* Read rest of EEPROM not covered by the checksum. */
  11456. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  11457. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  11458. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11459. if (*charfields++) {
  11460. *wbuf = le16_to_cpu(*wbuf);
  11461. }
  11462. }
  11463. return chksum;
  11464. }
  11465. /*
  11466. * Read EEPROM configuration into the specified buffer.
  11467. *
  11468. * Return a checksum based on the EEPROM configuration read.
  11469. */
  11470. static ushort __devinit
  11471. AdvGet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
  11472. {
  11473. ushort wval, chksum;
  11474. ushort *wbuf;
  11475. int eep_addr;
  11476. ushort *charfields;
  11477. charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
  11478. wbuf = (ushort *)cfg_buf;
  11479. chksum = 0;
  11480. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  11481. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  11482. wval = AdvReadEEPWord(iop_base, eep_addr);
  11483. chksum += wval; /* Checksum is calculated from word values. */
  11484. if (*charfields++) {
  11485. *wbuf = le16_to_cpu(wval);
  11486. } else {
  11487. *wbuf = wval;
  11488. }
  11489. }
  11490. /* Read checksum word. */
  11491. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11492. wbuf++;
  11493. charfields++;
  11494. /* Read rest of EEPROM not covered by the checksum. */
  11495. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  11496. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  11497. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11498. if (*charfields++) {
  11499. *wbuf = le16_to_cpu(*wbuf);
  11500. }
  11501. }
  11502. return chksum;
  11503. }
  11504. /*
  11505. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  11506. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  11507. * all of this is done.
  11508. *
  11509. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  11510. *
  11511. * For a non-fatal error return a warning code. If there are no warnings
  11512. * then 0 is returned.
  11513. *
  11514. * Note: Chip is stopped on entry.
  11515. */
  11516. static int __devinit AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
  11517. {
  11518. AdvPortAddr iop_base;
  11519. ushort warn_code;
  11520. ADVEEP_3550_CONFIG eep_config;
  11521. iop_base = asc_dvc->iop_base;
  11522. warn_code = 0;
  11523. /*
  11524. * Read the board's EEPROM configuration.
  11525. *
  11526. * Set default values if a bad checksum is found.
  11527. */
  11528. if (AdvGet3550EEPConfig(iop_base, &eep_config) != eep_config.check_sum) {
  11529. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  11530. /*
  11531. * Set EEPROM default values.
  11532. */
  11533. memcpy(&eep_config, &Default_3550_EEPROM_Config,
  11534. sizeof(ADVEEP_3550_CONFIG));
  11535. /*
  11536. * Assume the 6 byte board serial number that was read from
  11537. * EEPROM is correct even if the EEPROM checksum failed.
  11538. */
  11539. eep_config.serial_number_word3 =
  11540. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  11541. eep_config.serial_number_word2 =
  11542. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  11543. eep_config.serial_number_word1 =
  11544. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  11545. AdvSet3550EEPConfig(iop_base, &eep_config);
  11546. }
  11547. /*
  11548. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  11549. * EEPROM configuration that was read.
  11550. *
  11551. * This is the mapping of EEPROM fields to Adv Library fields.
  11552. */
  11553. asc_dvc->wdtr_able = eep_config.wdtr_able;
  11554. asc_dvc->sdtr_able = eep_config.sdtr_able;
  11555. asc_dvc->ultra_able = eep_config.ultra_able;
  11556. asc_dvc->tagqng_able = eep_config.tagqng_able;
  11557. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  11558. asc_dvc->max_host_qng = eep_config.max_host_qng;
  11559. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  11560. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  11561. asc_dvc->start_motor = eep_config.start_motor;
  11562. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  11563. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  11564. asc_dvc->no_scam = eep_config.scam_tolerant;
  11565. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  11566. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  11567. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  11568. /*
  11569. * Set the host maximum queuing (max. 253, min. 16) and the per device
  11570. * maximum queuing (max. 63, min. 4).
  11571. */
  11572. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  11573. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11574. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  11575. /* If the value is zero, assume it is uninitialized. */
  11576. if (eep_config.max_host_qng == 0) {
  11577. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11578. } else {
  11579. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  11580. }
  11581. }
  11582. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  11583. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  11584. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  11585. /* If the value is zero, assume it is uninitialized. */
  11586. if (eep_config.max_dvc_qng == 0) {
  11587. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  11588. } else {
  11589. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  11590. }
  11591. }
  11592. /*
  11593. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  11594. * set 'max_dvc_qng' to 'max_host_qng'.
  11595. */
  11596. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  11597. eep_config.max_dvc_qng = eep_config.max_host_qng;
  11598. }
  11599. /*
  11600. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  11601. * values based on possibly adjusted EEPROM values.
  11602. */
  11603. asc_dvc->max_host_qng = eep_config.max_host_qng;
  11604. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  11605. /*
  11606. * If the EEPROM 'termination' field is set to automatic (0), then set
  11607. * the ADV_DVC_CFG 'termination' field to automatic also.
  11608. *
  11609. * If the termination is specified with a non-zero 'termination'
  11610. * value check that a legal value is set and set the ADV_DVC_CFG
  11611. * 'termination' field appropriately.
  11612. */
  11613. if (eep_config.termination == 0) {
  11614. asc_dvc->cfg->termination = 0; /* auto termination */
  11615. } else {
  11616. /* Enable manual control with low off / high off. */
  11617. if (eep_config.termination == 1) {
  11618. asc_dvc->cfg->termination = TERM_CTL_SEL;
  11619. /* Enable manual control with low off / high on. */
  11620. } else if (eep_config.termination == 2) {
  11621. asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H;
  11622. /* Enable manual control with low on / high on. */
  11623. } else if (eep_config.termination == 3) {
  11624. asc_dvc->cfg->termination =
  11625. TERM_CTL_SEL | TERM_CTL_H | TERM_CTL_L;
  11626. } else {
  11627. /*
  11628. * The EEPROM 'termination' field contains a bad value. Use
  11629. * automatic termination instead.
  11630. */
  11631. asc_dvc->cfg->termination = 0;
  11632. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  11633. }
  11634. }
  11635. return warn_code;
  11636. }
  11637. /*
  11638. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  11639. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  11640. * all of this is done.
  11641. *
  11642. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  11643. *
  11644. * For a non-fatal error return a warning code. If there are no warnings
  11645. * then 0 is returned.
  11646. *
  11647. * Note: Chip is stopped on entry.
  11648. */
  11649. static int __devinit AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
  11650. {
  11651. AdvPortAddr iop_base;
  11652. ushort warn_code;
  11653. ADVEEP_38C0800_CONFIG eep_config;
  11654. uchar tid, termination;
  11655. ushort sdtr_speed = 0;
  11656. iop_base = asc_dvc->iop_base;
  11657. warn_code = 0;
  11658. /*
  11659. * Read the board's EEPROM configuration.
  11660. *
  11661. * Set default values if a bad checksum is found.
  11662. */
  11663. if (AdvGet38C0800EEPConfig(iop_base, &eep_config) !=
  11664. eep_config.check_sum) {
  11665. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  11666. /*
  11667. * Set EEPROM default values.
  11668. */
  11669. memcpy(&eep_config, &Default_38C0800_EEPROM_Config,
  11670. sizeof(ADVEEP_38C0800_CONFIG));
  11671. /*
  11672. * Assume the 6 byte board serial number that was read from
  11673. * EEPROM is correct even if the EEPROM checksum failed.
  11674. */
  11675. eep_config.serial_number_word3 =
  11676. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  11677. eep_config.serial_number_word2 =
  11678. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  11679. eep_config.serial_number_word1 =
  11680. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  11681. AdvSet38C0800EEPConfig(iop_base, &eep_config);
  11682. }
  11683. /*
  11684. * Set ADV_DVC_VAR and ADV_DVC_CFG variables from the
  11685. * EEPROM configuration that was read.
  11686. *
  11687. * This is the mapping of EEPROM fields to Adv Library fields.
  11688. */
  11689. asc_dvc->wdtr_able = eep_config.wdtr_able;
  11690. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  11691. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  11692. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  11693. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  11694. asc_dvc->tagqng_able = eep_config.tagqng_able;
  11695. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  11696. asc_dvc->max_host_qng = eep_config.max_host_qng;
  11697. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  11698. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  11699. asc_dvc->start_motor = eep_config.start_motor;
  11700. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  11701. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  11702. asc_dvc->no_scam = eep_config.scam_tolerant;
  11703. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  11704. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  11705. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  11706. /*
  11707. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  11708. * are set, then set an 'sdtr_able' bit for it.
  11709. */
  11710. asc_dvc->sdtr_able = 0;
  11711. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  11712. if (tid == 0) {
  11713. sdtr_speed = asc_dvc->sdtr_speed1;
  11714. } else if (tid == 4) {
  11715. sdtr_speed = asc_dvc->sdtr_speed2;
  11716. } else if (tid == 8) {
  11717. sdtr_speed = asc_dvc->sdtr_speed3;
  11718. } else if (tid == 12) {
  11719. sdtr_speed = asc_dvc->sdtr_speed4;
  11720. }
  11721. if (sdtr_speed & ADV_MAX_TID) {
  11722. asc_dvc->sdtr_able |= (1 << tid);
  11723. }
  11724. sdtr_speed >>= 4;
  11725. }
  11726. /*
  11727. * Set the host maximum queuing (max. 253, min. 16) and the per device
  11728. * maximum queuing (max. 63, min. 4).
  11729. */
  11730. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  11731. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11732. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  11733. /* If the value is zero, assume it is uninitialized. */
  11734. if (eep_config.max_host_qng == 0) {
  11735. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11736. } else {
  11737. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  11738. }
  11739. }
  11740. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  11741. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  11742. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  11743. /* If the value is zero, assume it is uninitialized. */
  11744. if (eep_config.max_dvc_qng == 0) {
  11745. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  11746. } else {
  11747. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  11748. }
  11749. }
  11750. /*
  11751. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  11752. * set 'max_dvc_qng' to 'max_host_qng'.
  11753. */
  11754. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  11755. eep_config.max_dvc_qng = eep_config.max_host_qng;
  11756. }
  11757. /*
  11758. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  11759. * values based on possibly adjusted EEPROM values.
  11760. */
  11761. asc_dvc->max_host_qng = eep_config.max_host_qng;
  11762. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  11763. /*
  11764. * If the EEPROM 'termination' field is set to automatic (0), then set
  11765. * the ADV_DVC_CFG 'termination' field to automatic also.
  11766. *
  11767. * If the termination is specified with a non-zero 'termination'
  11768. * value check that a legal value is set and set the ADV_DVC_CFG
  11769. * 'termination' field appropriately.
  11770. */
  11771. if (eep_config.termination_se == 0) {
  11772. termination = 0; /* auto termination for SE */
  11773. } else {
  11774. /* Enable manual control with low off / high off. */
  11775. if (eep_config.termination_se == 1) {
  11776. termination = 0;
  11777. /* Enable manual control with low off / high on. */
  11778. } else if (eep_config.termination_se == 2) {
  11779. termination = TERM_SE_HI;
  11780. /* Enable manual control with low on / high on. */
  11781. } else if (eep_config.termination_se == 3) {
  11782. termination = TERM_SE;
  11783. } else {
  11784. /*
  11785. * The EEPROM 'termination_se' field contains a bad value.
  11786. * Use automatic termination instead.
  11787. */
  11788. termination = 0;
  11789. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  11790. }
  11791. }
  11792. if (eep_config.termination_lvd == 0) {
  11793. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  11794. } else {
  11795. /* Enable manual control with low off / high off. */
  11796. if (eep_config.termination_lvd == 1) {
  11797. asc_dvc->cfg->termination = termination;
  11798. /* Enable manual control with low off / high on. */
  11799. } else if (eep_config.termination_lvd == 2) {
  11800. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  11801. /* Enable manual control with low on / high on. */
  11802. } else if (eep_config.termination_lvd == 3) {
  11803. asc_dvc->cfg->termination = termination | TERM_LVD;
  11804. } else {
  11805. /*
  11806. * The EEPROM 'termination_lvd' field contains a bad value.
  11807. * Use automatic termination instead.
  11808. */
  11809. asc_dvc->cfg->termination = termination;
  11810. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  11811. }
  11812. }
  11813. return warn_code;
  11814. }
  11815. /*
  11816. * Read the board's EEPROM configuration. Set fields in ASC_DVC_VAR and
  11817. * ASC_DVC_CFG based on the EEPROM settings. The chip is stopped while
  11818. * all of this is done.
  11819. *
  11820. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  11821. *
  11822. * For a non-fatal error return a warning code. If there are no warnings
  11823. * then 0 is returned.
  11824. *
  11825. * Note: Chip is stopped on entry.
  11826. */
  11827. static int __devinit AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
  11828. {
  11829. AdvPortAddr iop_base;
  11830. ushort warn_code;
  11831. ADVEEP_38C1600_CONFIG eep_config;
  11832. uchar tid, termination;
  11833. ushort sdtr_speed = 0;
  11834. iop_base = asc_dvc->iop_base;
  11835. warn_code = 0;
  11836. /*
  11837. * Read the board's EEPROM configuration.
  11838. *
  11839. * Set default values if a bad checksum is found.
  11840. */
  11841. if (AdvGet38C1600EEPConfig(iop_base, &eep_config) !=
  11842. eep_config.check_sum) {
  11843. struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
  11844. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  11845. /*
  11846. * Set EEPROM default values.
  11847. */
  11848. memcpy(&eep_config, &Default_38C1600_EEPROM_Config,
  11849. sizeof(ADVEEP_38C1600_CONFIG));
  11850. if (PCI_FUNC(pdev->devfn) != 0) {
  11851. u8 ints;
  11852. /*
  11853. * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60
  11854. * and old Mac system booting problem. The Expansion
  11855. * ROM must be disabled in Function 1 for these systems
  11856. */
  11857. eep_config.cfg_lsw &= ~ADV_EEPROM_BIOS_ENABLE;
  11858. /*
  11859. * Clear the INTAB (bit 11) if the GPIO 0 input
  11860. * indicates the Function 1 interrupt line is wired
  11861. * to INTB.
  11862. *
  11863. * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input:
  11864. * 1 - Function 1 interrupt line wired to INT A.
  11865. * 0 - Function 1 interrupt line wired to INT B.
  11866. *
  11867. * Note: Function 0 is always wired to INTA.
  11868. * Put all 5 GPIO bits in input mode and then read
  11869. * their input values.
  11870. */
  11871. AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, 0);
  11872. ints = AdvReadByteRegister(iop_base, IOPB_GPIO_DATA);
  11873. if ((ints & 0x01) == 0)
  11874. eep_config.cfg_lsw &= ~ADV_EEPROM_INTAB;
  11875. }
  11876. /*
  11877. * Assume the 6 byte board serial number that was read from
  11878. * EEPROM is correct even if the EEPROM checksum failed.
  11879. */
  11880. eep_config.serial_number_word3 =
  11881. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  11882. eep_config.serial_number_word2 =
  11883. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  11884. eep_config.serial_number_word1 =
  11885. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  11886. AdvSet38C1600EEPConfig(iop_base, &eep_config);
  11887. }
  11888. /*
  11889. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  11890. * EEPROM configuration that was read.
  11891. *
  11892. * This is the mapping of EEPROM fields to Adv Library fields.
  11893. */
  11894. asc_dvc->wdtr_able = eep_config.wdtr_able;
  11895. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  11896. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  11897. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  11898. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  11899. asc_dvc->ppr_able = 0;
  11900. asc_dvc->tagqng_able = eep_config.tagqng_able;
  11901. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  11902. asc_dvc->max_host_qng = eep_config.max_host_qng;
  11903. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  11904. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ASC_MAX_TID);
  11905. asc_dvc->start_motor = eep_config.start_motor;
  11906. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  11907. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  11908. asc_dvc->no_scam = eep_config.scam_tolerant;
  11909. /*
  11910. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  11911. * are set, then set an 'sdtr_able' bit for it.
  11912. */
  11913. asc_dvc->sdtr_able = 0;
  11914. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  11915. if (tid == 0) {
  11916. sdtr_speed = asc_dvc->sdtr_speed1;
  11917. } else if (tid == 4) {
  11918. sdtr_speed = asc_dvc->sdtr_speed2;
  11919. } else if (tid == 8) {
  11920. sdtr_speed = asc_dvc->sdtr_speed3;
  11921. } else if (tid == 12) {
  11922. sdtr_speed = asc_dvc->sdtr_speed4;
  11923. }
  11924. if (sdtr_speed & ASC_MAX_TID) {
  11925. asc_dvc->sdtr_able |= (1 << tid);
  11926. }
  11927. sdtr_speed >>= 4;
  11928. }
  11929. /*
  11930. * Set the host maximum queuing (max. 253, min. 16) and the per device
  11931. * maximum queuing (max. 63, min. 4).
  11932. */
  11933. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  11934. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11935. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  11936. /* If the value is zero, assume it is uninitialized. */
  11937. if (eep_config.max_host_qng == 0) {
  11938. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  11939. } else {
  11940. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  11941. }
  11942. }
  11943. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  11944. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  11945. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  11946. /* If the value is zero, assume it is uninitialized. */
  11947. if (eep_config.max_dvc_qng == 0) {
  11948. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  11949. } else {
  11950. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  11951. }
  11952. }
  11953. /*
  11954. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  11955. * set 'max_dvc_qng' to 'max_host_qng'.
  11956. */
  11957. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  11958. eep_config.max_dvc_qng = eep_config.max_host_qng;
  11959. }
  11960. /*
  11961. * Set ASC_DVC_VAR 'max_host_qng' and ASC_DVC_VAR 'max_dvc_qng'
  11962. * values based on possibly adjusted EEPROM values.
  11963. */
  11964. asc_dvc->max_host_qng = eep_config.max_host_qng;
  11965. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  11966. /*
  11967. * If the EEPROM 'termination' field is set to automatic (0), then set
  11968. * the ASC_DVC_CFG 'termination' field to automatic also.
  11969. *
  11970. * If the termination is specified with a non-zero 'termination'
  11971. * value check that a legal value is set and set the ASC_DVC_CFG
  11972. * 'termination' field appropriately.
  11973. */
  11974. if (eep_config.termination_se == 0) {
  11975. termination = 0; /* auto termination for SE */
  11976. } else {
  11977. /* Enable manual control with low off / high off. */
  11978. if (eep_config.termination_se == 1) {
  11979. termination = 0;
  11980. /* Enable manual control with low off / high on. */
  11981. } else if (eep_config.termination_se == 2) {
  11982. termination = TERM_SE_HI;
  11983. /* Enable manual control with low on / high on. */
  11984. } else if (eep_config.termination_se == 3) {
  11985. termination = TERM_SE;
  11986. } else {
  11987. /*
  11988. * The EEPROM 'termination_se' field contains a bad value.
  11989. * Use automatic termination instead.
  11990. */
  11991. termination = 0;
  11992. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  11993. }
  11994. }
  11995. if (eep_config.termination_lvd == 0) {
  11996. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  11997. } else {
  11998. /* Enable manual control with low off / high off. */
  11999. if (eep_config.termination_lvd == 1) {
  12000. asc_dvc->cfg->termination = termination;
  12001. /* Enable manual control with low off / high on. */
  12002. } else if (eep_config.termination_lvd == 2) {
  12003. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  12004. /* Enable manual control with low on / high on. */
  12005. } else if (eep_config.termination_lvd == 3) {
  12006. asc_dvc->cfg->termination = termination | TERM_LVD;
  12007. } else {
  12008. /*
  12009. * The EEPROM 'termination_lvd' field contains a bad value.
  12010. * Use automatic termination instead.
  12011. */
  12012. asc_dvc->cfg->termination = termination;
  12013. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12014. }
  12015. }
  12016. return warn_code;
  12017. }
  12018. /*
  12019. * Initialize the ADV_DVC_VAR structure.
  12020. *
  12021. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  12022. *
  12023. * For a non-fatal error return a warning code. If there are no warnings
  12024. * then 0 is returned.
  12025. */
  12026. static int __devinit
  12027. AdvInitGetConfig(struct pci_dev *pdev, struct Scsi_Host *shost)
  12028. {
  12029. struct asc_board *board = shost_priv(shost);
  12030. ADV_DVC_VAR *asc_dvc = &board->dvc_var.adv_dvc_var;
  12031. unsigned short warn_code = 0;
  12032. AdvPortAddr iop_base = asc_dvc->iop_base;
  12033. u16 cmd;
  12034. int status;
  12035. asc_dvc->err_code = 0;
  12036. /*
  12037. * Save the state of the PCI Configuration Command Register
  12038. * "Parity Error Response Control" Bit. If the bit is clear (0),
  12039. * in AdvInitAsc3550/38C0800Driver() tell the microcode to ignore
  12040. * DMA parity errors.
  12041. */
  12042. asc_dvc->cfg->control_flag = 0;
  12043. pci_read_config_word(pdev, PCI_COMMAND, &cmd);
  12044. if ((cmd & PCI_COMMAND_PARITY) == 0)
  12045. asc_dvc->cfg->control_flag |= CONTROL_FLAG_IGNORE_PERR;
  12046. asc_dvc->cfg->chip_version =
  12047. AdvGetChipVersion(iop_base, asc_dvc->bus_type);
  12048. ASC_DBG(1, "iopb_chip_id_1: 0x%x 0x%x\n",
  12049. (ushort)AdvReadByteRegister(iop_base, IOPB_CHIP_ID_1),
  12050. (ushort)ADV_CHIP_ID_BYTE);
  12051. ASC_DBG(1, "iopw_chip_id_0: 0x%x 0x%x\n",
  12052. (ushort)AdvReadWordRegister(iop_base, IOPW_CHIP_ID_0),
  12053. (ushort)ADV_CHIP_ID_WORD);
  12054. /*
  12055. * Reset the chip to start and allow register writes.
  12056. */
  12057. if (AdvFindSignature(iop_base) == 0) {
  12058. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  12059. return ADV_ERROR;
  12060. } else {
  12061. /*
  12062. * The caller must set 'chip_type' to a valid setting.
  12063. */
  12064. if (asc_dvc->chip_type != ADV_CHIP_ASC3550 &&
  12065. asc_dvc->chip_type != ADV_CHIP_ASC38C0800 &&
  12066. asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
  12067. asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
  12068. return ADV_ERROR;
  12069. }
  12070. /*
  12071. * Reset Chip.
  12072. */
  12073. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  12074. ADV_CTRL_REG_CMD_RESET);
  12075. mdelay(100);
  12076. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  12077. ADV_CTRL_REG_CMD_WR_IO_REG);
  12078. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  12079. status = AdvInitFrom38C1600EEP(asc_dvc);
  12080. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  12081. status = AdvInitFrom38C0800EEP(asc_dvc);
  12082. } else {
  12083. status = AdvInitFrom3550EEP(asc_dvc);
  12084. }
  12085. warn_code |= status;
  12086. }
  12087. if (warn_code != 0)
  12088. shost_printk(KERN_WARNING, shost, "warning: 0x%x\n", warn_code);
  12089. if (asc_dvc->err_code)
  12090. shost_printk(KERN_ERR, shost, "error code 0x%x\n",
  12091. asc_dvc->err_code);
  12092. return asc_dvc->err_code;
  12093. }
  12094. #endif
  12095. static struct scsi_host_template advansys_template = {
  12096. .proc_name = DRV_NAME,
  12097. #ifdef CONFIG_PROC_FS
  12098. .proc_info = advansys_proc_info,
  12099. #endif
  12100. .name = DRV_NAME,
  12101. .info = advansys_info,
  12102. .queuecommand = advansys_queuecommand,
  12103. .eh_bus_reset_handler = advansys_reset,
  12104. .bios_param = advansys_biosparam,
  12105. .slave_configure = advansys_slave_configure,
  12106. /*
  12107. * Because the driver may control an ISA adapter 'unchecked_isa_dma'
  12108. * must be set. The flag will be cleared in advansys_board_found
  12109. * for non-ISA adapters.
  12110. */
  12111. .unchecked_isa_dma = 1,
  12112. /*
  12113. * All adapters controlled by this driver are capable of large
  12114. * scatter-gather lists. According to the mid-level SCSI documentation
  12115. * this obviates any performance gain provided by setting
  12116. * 'use_clustering'. But empirically while CPU utilization is increased
  12117. * by enabling clustering, I/O throughput increases as well.
  12118. */
  12119. .use_clustering = ENABLE_CLUSTERING,
  12120. };
  12121. static int __devinit advansys_wide_init_chip(struct Scsi_Host *shost)
  12122. {
  12123. struct asc_board *board = shost_priv(shost);
  12124. struct adv_dvc_var *adv_dvc = &board->dvc_var.adv_dvc_var;
  12125. int req_cnt = 0;
  12126. adv_req_t *reqp = NULL;
  12127. int sg_cnt = 0;
  12128. adv_sgblk_t *sgp;
  12129. int warn_code, err_code;
  12130. /*
  12131. * Allocate buffer carrier structures. The total size
  12132. * is about 4 KB, so allocate all at once.
  12133. */
  12134. adv_dvc->carrier_buf = kmalloc(ADV_CARRIER_BUFSIZE, GFP_KERNEL);
  12135. ASC_DBG(1, "carrier_buf 0x%p\n", adv_dvc->carrier_buf);
  12136. if (!adv_dvc->carrier_buf)
  12137. goto kmalloc_failed;
  12138. /*
  12139. * Allocate up to 'max_host_qng' request structures for the Wide
  12140. * board. The total size is about 16 KB, so allocate all at once.
  12141. * If the allocation fails decrement and try again.
  12142. */
  12143. for (req_cnt = adv_dvc->max_host_qng; req_cnt > 0; req_cnt--) {
  12144. reqp = kmalloc(sizeof(adv_req_t) * req_cnt, GFP_KERNEL);
  12145. ASC_DBG(1, "reqp 0x%p, req_cnt %d, bytes %lu\n", reqp, req_cnt,
  12146. (ulong)sizeof(adv_req_t) * req_cnt);
  12147. if (reqp)
  12148. break;
  12149. }
  12150. if (!reqp)
  12151. goto kmalloc_failed;
  12152. adv_dvc->orig_reqp = reqp;
  12153. /*
  12154. * Allocate up to ADV_TOT_SG_BLOCK request structures for
  12155. * the Wide board. Each structure is about 136 bytes.
  12156. */
  12157. board->adv_sgblkp = NULL;
  12158. for (sg_cnt = 0; sg_cnt < ADV_TOT_SG_BLOCK; sg_cnt++) {
  12159. sgp = kmalloc(sizeof(adv_sgblk_t), GFP_KERNEL);
  12160. if (!sgp)
  12161. break;
  12162. sgp->next_sgblkp = board->adv_sgblkp;
  12163. board->adv_sgblkp = sgp;
  12164. }
  12165. ASC_DBG(1, "sg_cnt %d * %u = %u bytes\n", sg_cnt, sizeof(adv_sgblk_t),
  12166. (unsigned)(sizeof(adv_sgblk_t) * sg_cnt));
  12167. if (!board->adv_sgblkp)
  12168. goto kmalloc_failed;
  12169. /*
  12170. * Point 'adv_reqp' to the request structures and
  12171. * link them together.
  12172. */
  12173. req_cnt--;
  12174. reqp[req_cnt].next_reqp = NULL;
  12175. for (; req_cnt > 0; req_cnt--) {
  12176. reqp[req_cnt - 1].next_reqp = &reqp[req_cnt];
  12177. }
  12178. board->adv_reqp = &reqp[0];
  12179. if (adv_dvc->chip_type == ADV_CHIP_ASC3550) {
  12180. ASC_DBG(2, "AdvInitAsc3550Driver()\n");
  12181. warn_code = AdvInitAsc3550Driver(adv_dvc);
  12182. } else if (adv_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  12183. ASC_DBG(2, "AdvInitAsc38C0800Driver()\n");
  12184. warn_code = AdvInitAsc38C0800Driver(adv_dvc);
  12185. } else {
  12186. ASC_DBG(2, "AdvInitAsc38C1600Driver()\n");
  12187. warn_code = AdvInitAsc38C1600Driver(adv_dvc);
  12188. }
  12189. err_code = adv_dvc->err_code;
  12190. if (warn_code || err_code) {
  12191. shost_printk(KERN_WARNING, shost, "error: warn 0x%x, error "
  12192. "0x%x\n", warn_code, err_code);
  12193. }
  12194. goto exit;
  12195. kmalloc_failed:
  12196. shost_printk(KERN_ERR, shost, "error: kmalloc() failed\n");
  12197. err_code = ADV_ERROR;
  12198. exit:
  12199. return err_code;
  12200. }
  12201. static void advansys_wide_free_mem(struct asc_board *board)
  12202. {
  12203. struct adv_dvc_var *adv_dvc = &board->dvc_var.adv_dvc_var;
  12204. kfree(adv_dvc->carrier_buf);
  12205. adv_dvc->carrier_buf = NULL;
  12206. kfree(adv_dvc->orig_reqp);
  12207. adv_dvc->orig_reqp = board->adv_reqp = NULL;
  12208. while (board->adv_sgblkp) {
  12209. adv_sgblk_t *sgp = board->adv_sgblkp;
  12210. board->adv_sgblkp = sgp->next_sgblkp;
  12211. kfree(sgp);
  12212. }
  12213. }
  12214. static int __devinit advansys_board_found(struct Scsi_Host *shost,
  12215. unsigned int iop, int bus_type)
  12216. {
  12217. struct pci_dev *pdev;
  12218. struct asc_board *boardp = shost_priv(shost);
  12219. ASC_DVC_VAR *asc_dvc_varp = NULL;
  12220. ADV_DVC_VAR *adv_dvc_varp = NULL;
  12221. int share_irq, warn_code, ret;
  12222. pdev = (bus_type == ASC_IS_PCI) ? to_pci_dev(boardp->dev) : NULL;
  12223. if (ASC_NARROW_BOARD(boardp)) {
  12224. ASC_DBG(1, "narrow board\n");
  12225. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  12226. asc_dvc_varp->bus_type = bus_type;
  12227. asc_dvc_varp->drv_ptr = boardp;
  12228. asc_dvc_varp->cfg = &boardp->dvc_cfg.asc_dvc_cfg;
  12229. asc_dvc_varp->cfg->overrun_buf = &overrun_buf[0];
  12230. asc_dvc_varp->iop_base = iop;
  12231. } else {
  12232. #ifdef CONFIG_PCI
  12233. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  12234. adv_dvc_varp->drv_ptr = boardp;
  12235. adv_dvc_varp->cfg = &boardp->dvc_cfg.adv_dvc_cfg;
  12236. if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW) {
  12237. ASC_DBG(1, "wide board ASC-3550\n");
  12238. adv_dvc_varp->chip_type = ADV_CHIP_ASC3550;
  12239. } else if (pdev->device == PCI_DEVICE_ID_38C0800_REV1) {
  12240. ASC_DBG(1, "wide board ASC-38C0800\n");
  12241. adv_dvc_varp->chip_type = ADV_CHIP_ASC38C0800;
  12242. } else {
  12243. ASC_DBG(1, "wide board ASC-38C1600\n");
  12244. adv_dvc_varp->chip_type = ADV_CHIP_ASC38C1600;
  12245. }
  12246. boardp->asc_n_io_port = pci_resource_len(pdev, 1);
  12247. boardp->ioremap_addr = ioremap(pci_resource_start(pdev, 1),
  12248. boardp->asc_n_io_port);
  12249. if (!boardp->ioremap_addr) {
  12250. shost_printk(KERN_ERR, shost, "ioremap(%x, %d) "
  12251. "returned NULL\n",
  12252. pci_resource_start(pdev, 1),
  12253. boardp->asc_n_io_port);
  12254. ret = -ENODEV;
  12255. goto err_shost;
  12256. }
  12257. adv_dvc_varp->iop_base = (AdvPortAddr)boardp->ioremap_addr;
  12258. ASC_DBG(1, "iop_base: 0x%p\n", adv_dvc_varp->iop_base);
  12259. /*
  12260. * Even though it isn't used to access wide boards, other
  12261. * than for the debug line below, save I/O Port address so
  12262. * that it can be reported.
  12263. */
  12264. boardp->ioport = iop;
  12265. ASC_DBG(1, "iopb_chip_id_1 0x%x, iopw_chip_id_0 0x%x\n",
  12266. (ushort)inp(iop + 1), (ushort)inpw(iop));
  12267. #endif /* CONFIG_PCI */
  12268. }
  12269. #ifdef CONFIG_PROC_FS
  12270. /*
  12271. * Allocate buffer for printing information from
  12272. * /proc/scsi/advansys/[0...].
  12273. */
  12274. boardp->prtbuf = kmalloc(ASC_PRTBUF_SIZE, GFP_KERNEL);
  12275. if (!boardp->prtbuf) {
  12276. shost_printk(KERN_ERR, shost, "kmalloc(%d) returned NULL\n",
  12277. ASC_PRTBUF_SIZE);
  12278. ret = -ENOMEM;
  12279. goto err_unmap;
  12280. }
  12281. #endif /* CONFIG_PROC_FS */
  12282. if (ASC_NARROW_BOARD(boardp)) {
  12283. /*
  12284. * Set the board bus type and PCI IRQ before
  12285. * calling AscInitGetConfig().
  12286. */
  12287. switch (asc_dvc_varp->bus_type) {
  12288. #ifdef CONFIG_ISA
  12289. case ASC_IS_ISA:
  12290. shost->unchecked_isa_dma = TRUE;
  12291. share_irq = 0;
  12292. break;
  12293. case ASC_IS_VL:
  12294. shost->unchecked_isa_dma = FALSE;
  12295. share_irq = 0;
  12296. break;
  12297. case ASC_IS_EISA:
  12298. shost->unchecked_isa_dma = FALSE;
  12299. share_irq = IRQF_SHARED;
  12300. break;
  12301. #endif /* CONFIG_ISA */
  12302. #ifdef CONFIG_PCI
  12303. case ASC_IS_PCI:
  12304. shost->unchecked_isa_dma = FALSE;
  12305. share_irq = IRQF_SHARED;
  12306. break;
  12307. #endif /* CONFIG_PCI */
  12308. default:
  12309. shost_printk(KERN_ERR, shost, "unknown adapter type: "
  12310. "%d\n", asc_dvc_varp->bus_type);
  12311. shost->unchecked_isa_dma = TRUE;
  12312. share_irq = 0;
  12313. break;
  12314. }
  12315. /*
  12316. * NOTE: AscInitGetConfig() may change the board's
  12317. * bus_type value. The bus_type value should no
  12318. * longer be used. If the bus_type field must be
  12319. * referenced only use the bit-wise AND operator "&".
  12320. */
  12321. ASC_DBG(2, "AscInitGetConfig()\n");
  12322. ret = AscInitGetConfig(shost) ? -ENODEV : 0;
  12323. } else {
  12324. #ifdef CONFIG_PCI
  12325. /*
  12326. * For Wide boards set PCI information before calling
  12327. * AdvInitGetConfig().
  12328. */
  12329. shost->unchecked_isa_dma = FALSE;
  12330. share_irq = IRQF_SHARED;
  12331. ASC_DBG(2, "AdvInitGetConfig()\n");
  12332. ret = AdvInitGetConfig(pdev, shost) ? -ENODEV : 0;
  12333. #endif /* CONFIG_PCI */
  12334. }
  12335. if (ret)
  12336. goto err_free_proc;
  12337. /*
  12338. * Save the EEPROM configuration so that it can be displayed
  12339. * from /proc/scsi/advansys/[0...].
  12340. */
  12341. if (ASC_NARROW_BOARD(boardp)) {
  12342. ASCEEP_CONFIG *ep;
  12343. /*
  12344. * Set the adapter's target id bit in the 'init_tidmask' field.
  12345. */
  12346. boardp->init_tidmask |=
  12347. ADV_TID_TO_TIDMASK(asc_dvc_varp->cfg->chip_scsi_id);
  12348. /*
  12349. * Save EEPROM settings for the board.
  12350. */
  12351. ep = &boardp->eep_config.asc_eep;
  12352. ep->init_sdtr = asc_dvc_varp->cfg->sdtr_enable;
  12353. ep->disc_enable = asc_dvc_varp->cfg->disc_enable;
  12354. ep->use_cmd_qng = asc_dvc_varp->cfg->cmd_qng_enabled;
  12355. ASC_EEP_SET_DMA_SPD(ep, asc_dvc_varp->cfg->isa_dma_speed);
  12356. ep->start_motor = asc_dvc_varp->start_motor;
  12357. ep->cntl = asc_dvc_varp->dvc_cntl;
  12358. ep->no_scam = asc_dvc_varp->no_scam;
  12359. ep->max_total_qng = asc_dvc_varp->max_total_qng;
  12360. ASC_EEP_SET_CHIP_ID(ep, asc_dvc_varp->cfg->chip_scsi_id);
  12361. /* 'max_tag_qng' is set to the same value for every device. */
  12362. ep->max_tag_qng = asc_dvc_varp->cfg->max_tag_qng[0];
  12363. ep->adapter_info[0] = asc_dvc_varp->cfg->adapter_info[0];
  12364. ep->adapter_info[1] = asc_dvc_varp->cfg->adapter_info[1];
  12365. ep->adapter_info[2] = asc_dvc_varp->cfg->adapter_info[2];
  12366. ep->adapter_info[3] = asc_dvc_varp->cfg->adapter_info[3];
  12367. ep->adapter_info[4] = asc_dvc_varp->cfg->adapter_info[4];
  12368. ep->adapter_info[5] = asc_dvc_varp->cfg->adapter_info[5];
  12369. /*
  12370. * Modify board configuration.
  12371. */
  12372. ASC_DBG(2, "AscInitSetConfig()\n");
  12373. ret = AscInitSetConfig(pdev, shost) ? -ENODEV : 0;
  12374. if (ret)
  12375. goto err_free_proc;
  12376. } else {
  12377. ADVEEP_3550_CONFIG *ep_3550;
  12378. ADVEEP_38C0800_CONFIG *ep_38C0800;
  12379. ADVEEP_38C1600_CONFIG *ep_38C1600;
  12380. /*
  12381. * Save Wide EEP Configuration Information.
  12382. */
  12383. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  12384. ep_3550 = &boardp->eep_config.adv_3550_eep;
  12385. ep_3550->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
  12386. ep_3550->max_host_qng = adv_dvc_varp->max_host_qng;
  12387. ep_3550->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  12388. ep_3550->termination = adv_dvc_varp->cfg->termination;
  12389. ep_3550->disc_enable = adv_dvc_varp->cfg->disc_enable;
  12390. ep_3550->bios_ctrl = adv_dvc_varp->bios_ctrl;
  12391. ep_3550->wdtr_able = adv_dvc_varp->wdtr_able;
  12392. ep_3550->sdtr_able = adv_dvc_varp->sdtr_able;
  12393. ep_3550->ultra_able = adv_dvc_varp->ultra_able;
  12394. ep_3550->tagqng_able = adv_dvc_varp->tagqng_able;
  12395. ep_3550->start_motor = adv_dvc_varp->start_motor;
  12396. ep_3550->scsi_reset_delay =
  12397. adv_dvc_varp->scsi_reset_wait;
  12398. ep_3550->serial_number_word1 =
  12399. adv_dvc_varp->cfg->serial1;
  12400. ep_3550->serial_number_word2 =
  12401. adv_dvc_varp->cfg->serial2;
  12402. ep_3550->serial_number_word3 =
  12403. adv_dvc_varp->cfg->serial3;
  12404. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  12405. ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
  12406. ep_38C0800->adapter_scsi_id =
  12407. adv_dvc_varp->chip_scsi_id;
  12408. ep_38C0800->max_host_qng = adv_dvc_varp->max_host_qng;
  12409. ep_38C0800->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  12410. ep_38C0800->termination_lvd =
  12411. adv_dvc_varp->cfg->termination;
  12412. ep_38C0800->disc_enable =
  12413. adv_dvc_varp->cfg->disc_enable;
  12414. ep_38C0800->bios_ctrl = adv_dvc_varp->bios_ctrl;
  12415. ep_38C0800->wdtr_able = adv_dvc_varp->wdtr_able;
  12416. ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
  12417. ep_38C0800->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
  12418. ep_38C0800->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
  12419. ep_38C0800->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
  12420. ep_38C0800->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
  12421. ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
  12422. ep_38C0800->start_motor = adv_dvc_varp->start_motor;
  12423. ep_38C0800->scsi_reset_delay =
  12424. adv_dvc_varp->scsi_reset_wait;
  12425. ep_38C0800->serial_number_word1 =
  12426. adv_dvc_varp->cfg->serial1;
  12427. ep_38C0800->serial_number_word2 =
  12428. adv_dvc_varp->cfg->serial2;
  12429. ep_38C0800->serial_number_word3 =
  12430. adv_dvc_varp->cfg->serial3;
  12431. } else {
  12432. ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
  12433. ep_38C1600->adapter_scsi_id =
  12434. adv_dvc_varp->chip_scsi_id;
  12435. ep_38C1600->max_host_qng = adv_dvc_varp->max_host_qng;
  12436. ep_38C1600->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  12437. ep_38C1600->termination_lvd =
  12438. adv_dvc_varp->cfg->termination;
  12439. ep_38C1600->disc_enable =
  12440. adv_dvc_varp->cfg->disc_enable;
  12441. ep_38C1600->bios_ctrl = adv_dvc_varp->bios_ctrl;
  12442. ep_38C1600->wdtr_able = adv_dvc_varp->wdtr_able;
  12443. ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
  12444. ep_38C1600->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
  12445. ep_38C1600->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
  12446. ep_38C1600->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
  12447. ep_38C1600->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
  12448. ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
  12449. ep_38C1600->start_motor = adv_dvc_varp->start_motor;
  12450. ep_38C1600->scsi_reset_delay =
  12451. adv_dvc_varp->scsi_reset_wait;
  12452. ep_38C1600->serial_number_word1 =
  12453. adv_dvc_varp->cfg->serial1;
  12454. ep_38C1600->serial_number_word2 =
  12455. adv_dvc_varp->cfg->serial2;
  12456. ep_38C1600->serial_number_word3 =
  12457. adv_dvc_varp->cfg->serial3;
  12458. }
  12459. /*
  12460. * Set the adapter's target id bit in the 'init_tidmask' field.
  12461. */
  12462. boardp->init_tidmask |=
  12463. ADV_TID_TO_TIDMASK(adv_dvc_varp->chip_scsi_id);
  12464. }
  12465. /*
  12466. * Channels are numbered beginning with 0. For AdvanSys one host
  12467. * structure supports one channel. Multi-channel boards have a
  12468. * separate host structure for each channel.
  12469. */
  12470. shost->max_channel = 0;
  12471. if (ASC_NARROW_BOARD(boardp)) {
  12472. shost->max_id = ASC_MAX_TID + 1;
  12473. shost->max_lun = ASC_MAX_LUN + 1;
  12474. shost->max_cmd_len = ASC_MAX_CDB_LEN;
  12475. shost->io_port = asc_dvc_varp->iop_base;
  12476. boardp->asc_n_io_port = ASC_IOADR_GAP;
  12477. shost->this_id = asc_dvc_varp->cfg->chip_scsi_id;
  12478. /* Set maximum number of queues the adapter can handle. */
  12479. shost->can_queue = asc_dvc_varp->max_total_qng;
  12480. } else {
  12481. shost->max_id = ADV_MAX_TID + 1;
  12482. shost->max_lun = ADV_MAX_LUN + 1;
  12483. shost->max_cmd_len = ADV_MAX_CDB_LEN;
  12484. /*
  12485. * Save the I/O Port address and length even though
  12486. * I/O ports are not used to access Wide boards.
  12487. * Instead the Wide boards are accessed with
  12488. * PCI Memory Mapped I/O.
  12489. */
  12490. shost->io_port = iop;
  12491. shost->this_id = adv_dvc_varp->chip_scsi_id;
  12492. /* Set maximum number of queues the adapter can handle. */
  12493. shost->can_queue = adv_dvc_varp->max_host_qng;
  12494. }
  12495. /*
  12496. * Following v1.3.89, 'cmd_per_lun' is no longer needed
  12497. * and should be set to zero.
  12498. *
  12499. * But because of a bug introduced in v1.3.89 if the driver is
  12500. * compiled as a module and 'cmd_per_lun' is zero, the Mid-Level
  12501. * SCSI function 'allocate_device' will panic. To allow the driver
  12502. * to work as a module in these kernels set 'cmd_per_lun' to 1.
  12503. *
  12504. * Note: This is wrong. cmd_per_lun should be set to the depth
  12505. * you want on untagged devices always.
  12506. #ifdef MODULE
  12507. */
  12508. shost->cmd_per_lun = 1;
  12509. /* #else
  12510. shost->cmd_per_lun = 0;
  12511. #endif */
  12512. /*
  12513. * Set the maximum number of scatter-gather elements the
  12514. * adapter can handle.
  12515. */
  12516. if (ASC_NARROW_BOARD(boardp)) {
  12517. /*
  12518. * Allow two commands with 'sg_tablesize' scatter-gather
  12519. * elements to be executed simultaneously. This value is
  12520. * the theoretical hardware limit. It may be decreased
  12521. * below.
  12522. */
  12523. shost->sg_tablesize =
  12524. (((asc_dvc_varp->max_total_qng - 2) / 2) *
  12525. ASC_SG_LIST_PER_Q) + 1;
  12526. } else {
  12527. shost->sg_tablesize = ADV_MAX_SG_LIST;
  12528. }
  12529. /*
  12530. * The value of 'sg_tablesize' can not exceed the SCSI
  12531. * mid-level driver definition of SG_ALL. SG_ALL also
  12532. * must not be exceeded, because it is used to define the
  12533. * size of the scatter-gather table in 'struct asc_sg_head'.
  12534. */
  12535. if (shost->sg_tablesize > SG_ALL) {
  12536. shost->sg_tablesize = SG_ALL;
  12537. }
  12538. ASC_DBG(1, "sg_tablesize: %d\n", shost->sg_tablesize);
  12539. /* BIOS start address. */
  12540. if (ASC_NARROW_BOARD(boardp)) {
  12541. shost->base = AscGetChipBiosAddress(asc_dvc_varp->iop_base,
  12542. asc_dvc_varp->bus_type);
  12543. } else {
  12544. /*
  12545. * Fill-in BIOS board variables. The Wide BIOS saves
  12546. * information in LRAM that is used by the driver.
  12547. */
  12548. AdvReadWordLram(adv_dvc_varp->iop_base,
  12549. BIOS_SIGNATURE, boardp->bios_signature);
  12550. AdvReadWordLram(adv_dvc_varp->iop_base,
  12551. BIOS_VERSION, boardp->bios_version);
  12552. AdvReadWordLram(adv_dvc_varp->iop_base,
  12553. BIOS_CODESEG, boardp->bios_codeseg);
  12554. AdvReadWordLram(adv_dvc_varp->iop_base,
  12555. BIOS_CODELEN, boardp->bios_codelen);
  12556. ASC_DBG(1, "bios_signature 0x%x, bios_version 0x%x\n",
  12557. boardp->bios_signature, boardp->bios_version);
  12558. ASC_DBG(1, "bios_codeseg 0x%x, bios_codelen 0x%x\n",
  12559. boardp->bios_codeseg, boardp->bios_codelen);
  12560. /*
  12561. * If the BIOS saved a valid signature, then fill in
  12562. * the BIOS code segment base address.
  12563. */
  12564. if (boardp->bios_signature == 0x55AA) {
  12565. /*
  12566. * Convert x86 realmode code segment to a linear
  12567. * address by shifting left 4.
  12568. */
  12569. shost->base = ((ulong)boardp->bios_codeseg << 4);
  12570. } else {
  12571. shost->base = 0;
  12572. }
  12573. }
  12574. /*
  12575. * Register Board Resources - I/O Port, DMA, IRQ
  12576. */
  12577. /* Register DMA Channel for Narrow boards. */
  12578. shost->dma_channel = NO_ISA_DMA; /* Default to no ISA DMA. */
  12579. #ifdef CONFIG_ISA
  12580. if (ASC_NARROW_BOARD(boardp)) {
  12581. /* Register DMA channel for ISA bus. */
  12582. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  12583. shost->dma_channel = asc_dvc_varp->cfg->isa_dma_channel;
  12584. ret = request_dma(shost->dma_channel, DRV_NAME);
  12585. if (ret) {
  12586. shost_printk(KERN_ERR, shost, "request_dma() "
  12587. "%d failed %d\n",
  12588. shost->dma_channel, ret);
  12589. goto err_free_proc;
  12590. }
  12591. AscEnableIsaDma(shost->dma_channel);
  12592. }
  12593. }
  12594. #endif /* CONFIG_ISA */
  12595. /* Register IRQ Number. */
  12596. ASC_DBG(2, "request_irq(%d, %p)\n", boardp->irq, shost);
  12597. ret = request_irq(boardp->irq, advansys_interrupt, share_irq,
  12598. DRV_NAME, shost);
  12599. if (ret) {
  12600. if (ret == -EBUSY) {
  12601. shost_printk(KERN_ERR, shost, "request_irq(): IRQ 0x%x "
  12602. "already in use\n", boardp->irq);
  12603. } else if (ret == -EINVAL) {
  12604. shost_printk(KERN_ERR, shost, "request_irq(): IRQ 0x%x "
  12605. "not valid\n", boardp->irq);
  12606. } else {
  12607. shost_printk(KERN_ERR, shost, "request_irq(): IRQ 0x%x "
  12608. "failed with %d\n", boardp->irq, ret);
  12609. }
  12610. goto err_free_dma;
  12611. }
  12612. /*
  12613. * Initialize board RISC chip and enable interrupts.
  12614. */
  12615. if (ASC_NARROW_BOARD(boardp)) {
  12616. ASC_DBG(2, "AscInitAsc1000Driver()\n");
  12617. warn_code = AscInitAsc1000Driver(asc_dvc_varp);
  12618. if (warn_code || asc_dvc_varp->err_code) {
  12619. shost_printk(KERN_ERR, shost, "error: init_state 0x%x, "
  12620. "warn 0x%x, error 0x%x\n",
  12621. asc_dvc_varp->init_state, warn_code,
  12622. asc_dvc_varp->err_code);
  12623. if (asc_dvc_varp->err_code)
  12624. ret = -ENODEV;
  12625. }
  12626. } else {
  12627. if (advansys_wide_init_chip(shost))
  12628. ret = -ENODEV;
  12629. }
  12630. if (ret)
  12631. goto err_free_wide_mem;
  12632. ASC_DBG_PRT_SCSI_HOST(2, shost);
  12633. ret = scsi_add_host(shost, boardp->dev);
  12634. if (ret)
  12635. goto err_free_wide_mem;
  12636. scsi_scan_host(shost);
  12637. return 0;
  12638. err_free_wide_mem:
  12639. advansys_wide_free_mem(boardp);
  12640. free_irq(boardp->irq, shost);
  12641. err_free_dma:
  12642. if (shost->dma_channel != NO_ISA_DMA)
  12643. free_dma(shost->dma_channel);
  12644. err_free_proc:
  12645. kfree(boardp->prtbuf);
  12646. err_unmap:
  12647. if (boardp->ioremap_addr)
  12648. iounmap(boardp->ioremap_addr);
  12649. err_shost:
  12650. return ret;
  12651. }
  12652. /*
  12653. * advansys_release()
  12654. *
  12655. * Release resources allocated for a single AdvanSys adapter.
  12656. */
  12657. static int advansys_release(struct Scsi_Host *shost)
  12658. {
  12659. struct asc_board *boardp = shost_priv(shost);
  12660. ASC_DBG(1, "begin\n");
  12661. scsi_remove_host(shost);
  12662. free_irq(boardp->irq, shost);
  12663. if (shost->dma_channel != NO_ISA_DMA) {
  12664. ASC_DBG(1, "free_dma()\n");
  12665. free_dma(shost->dma_channel);
  12666. }
  12667. if (!ASC_NARROW_BOARD(boardp)) {
  12668. iounmap(boardp->ioremap_addr);
  12669. advansys_wide_free_mem(boardp);
  12670. }
  12671. kfree(boardp->prtbuf);
  12672. scsi_host_put(shost);
  12673. ASC_DBG(1, "end\n");
  12674. return 0;
  12675. }
  12676. #define ASC_IOADR_TABLE_MAX_IX 11
  12677. static PortAddr _asc_def_iop_base[ASC_IOADR_TABLE_MAX_IX] __devinitdata = {
  12678. 0x100, 0x0110, 0x120, 0x0130, 0x140, 0x0150, 0x0190,
  12679. 0x0210, 0x0230, 0x0250, 0x0330
  12680. };
  12681. /*
  12682. * The ISA IRQ number is found in bits 2 and 3 of the CfgLsw. It decodes as:
  12683. * 00: 10
  12684. * 01: 11
  12685. * 10: 12
  12686. * 11: 15
  12687. */
  12688. static unsigned int __devinit advansys_isa_irq_no(PortAddr iop_base)
  12689. {
  12690. unsigned short cfg_lsw = AscGetChipCfgLsw(iop_base);
  12691. unsigned int chip_irq = ((cfg_lsw >> 2) & 0x03) + 10;
  12692. if (chip_irq == 13)
  12693. chip_irq = 15;
  12694. return chip_irq;
  12695. }
  12696. static int __devinit advansys_isa_probe(struct device *dev, unsigned int id)
  12697. {
  12698. int err = -ENODEV;
  12699. PortAddr iop_base = _asc_def_iop_base[id];
  12700. struct Scsi_Host *shost;
  12701. struct asc_board *board;
  12702. if (!request_region(iop_base, ASC_IOADR_GAP, DRV_NAME)) {
  12703. ASC_DBG(1, "I/O port 0x%x busy\n", iop_base);
  12704. return -ENODEV;
  12705. }
  12706. ASC_DBG(1, "probing I/O port 0x%x\n", iop_base);
  12707. if (!AscFindSignature(iop_base))
  12708. goto release_region;
  12709. if (!(AscGetChipVersion(iop_base, ASC_IS_ISA) & ASC_CHIP_VER_ISA_BIT))
  12710. goto release_region;
  12711. err = -ENOMEM;
  12712. shost = scsi_host_alloc(&advansys_template, sizeof(*board));
  12713. if (!shost)
  12714. goto release_region;
  12715. board = shost_priv(shost);
  12716. board->irq = advansys_isa_irq_no(iop_base);
  12717. board->dev = dev;
  12718. err = advansys_board_found(shost, iop_base, ASC_IS_ISA);
  12719. if (err)
  12720. goto free_host;
  12721. dev_set_drvdata(dev, shost);
  12722. return 0;
  12723. free_host:
  12724. scsi_host_put(shost);
  12725. release_region:
  12726. release_region(iop_base, ASC_IOADR_GAP);
  12727. return err;
  12728. }
  12729. static int __devexit advansys_isa_remove(struct device *dev, unsigned int id)
  12730. {
  12731. int ioport = _asc_def_iop_base[id];
  12732. advansys_release(dev_get_drvdata(dev));
  12733. release_region(ioport, ASC_IOADR_GAP);
  12734. return 0;
  12735. }
  12736. static struct isa_driver advansys_isa_driver = {
  12737. .probe = advansys_isa_probe,
  12738. .remove = __devexit_p(advansys_isa_remove),
  12739. .driver = {
  12740. .owner = THIS_MODULE,
  12741. .name = DRV_NAME,
  12742. },
  12743. };
  12744. /*
  12745. * The VLB IRQ number is found in bits 2 to 4 of the CfgLsw. It decodes as:
  12746. * 000: invalid
  12747. * 001: 10
  12748. * 010: 11
  12749. * 011: 12
  12750. * 100: invalid
  12751. * 101: 14
  12752. * 110: 15
  12753. * 111: invalid
  12754. */
  12755. static unsigned int __devinit advansys_vlb_irq_no(PortAddr iop_base)
  12756. {
  12757. unsigned short cfg_lsw = AscGetChipCfgLsw(iop_base);
  12758. unsigned int chip_irq = ((cfg_lsw >> 2) & 0x07) + 9;
  12759. if ((chip_irq < 10) || (chip_irq == 13) || (chip_irq > 15))
  12760. return 0;
  12761. return chip_irq;
  12762. }
  12763. static int __devinit advansys_vlb_probe(struct device *dev, unsigned int id)
  12764. {
  12765. int err = -ENODEV;
  12766. PortAddr iop_base = _asc_def_iop_base[id];
  12767. struct Scsi_Host *shost;
  12768. struct asc_board *board;
  12769. if (!request_region(iop_base, ASC_IOADR_GAP, DRV_NAME)) {
  12770. ASC_DBG(1, "I/O port 0x%x busy\n", iop_base);
  12771. return -ENODEV;
  12772. }
  12773. ASC_DBG(1, "probing I/O port 0x%x\n", iop_base);
  12774. if (!AscFindSignature(iop_base))
  12775. goto release_region;
  12776. /*
  12777. * I don't think this condition can actually happen, but the old
  12778. * driver did it, and the chances of finding a VLB setup in 2007
  12779. * to do testing with is slight to none.
  12780. */
  12781. if (AscGetChipVersion(iop_base, ASC_IS_VL) > ASC_CHIP_MAX_VER_VL)
  12782. goto release_region;
  12783. err = -ENOMEM;
  12784. shost = scsi_host_alloc(&advansys_template, sizeof(*board));
  12785. if (!shost)
  12786. goto release_region;
  12787. board = shost_priv(shost);
  12788. board->irq = advansys_vlb_irq_no(iop_base);
  12789. board->dev = dev;
  12790. err = advansys_board_found(shost, iop_base, ASC_IS_VL);
  12791. if (err)
  12792. goto free_host;
  12793. dev_set_drvdata(dev, shost);
  12794. return 0;
  12795. free_host:
  12796. scsi_host_put(shost);
  12797. release_region:
  12798. release_region(iop_base, ASC_IOADR_GAP);
  12799. return -ENODEV;
  12800. }
  12801. static struct isa_driver advansys_vlb_driver = {
  12802. .probe = advansys_vlb_probe,
  12803. .remove = __devexit_p(advansys_isa_remove),
  12804. .driver = {
  12805. .owner = THIS_MODULE,
  12806. .name = "advansys_vlb",
  12807. },
  12808. };
  12809. static struct eisa_device_id advansys_eisa_table[] __devinitdata = {
  12810. { "ABP7401" },
  12811. { "ABP7501" },
  12812. { "" }
  12813. };
  12814. MODULE_DEVICE_TABLE(eisa, advansys_eisa_table);
  12815. /*
  12816. * EISA is a little more tricky than PCI; each EISA device may have two
  12817. * channels, and this driver is written to make each channel its own Scsi_Host
  12818. */
  12819. struct eisa_scsi_data {
  12820. struct Scsi_Host *host[2];
  12821. };
  12822. /*
  12823. * The EISA IRQ number is found in bits 8 to 10 of the CfgLsw. It decodes as:
  12824. * 000: 10
  12825. * 001: 11
  12826. * 010: 12
  12827. * 011: invalid
  12828. * 100: 14
  12829. * 101: 15
  12830. * 110: invalid
  12831. * 111: invalid
  12832. */
  12833. static unsigned int __devinit advansys_eisa_irq_no(struct eisa_device *edev)
  12834. {
  12835. unsigned short cfg_lsw = inw(edev->base_addr + 0xc86);
  12836. unsigned int chip_irq = ((cfg_lsw >> 8) & 0x07) + 10;
  12837. if ((chip_irq == 13) || (chip_irq > 15))
  12838. return 0;
  12839. return chip_irq;
  12840. }
  12841. static int __devinit advansys_eisa_probe(struct device *dev)
  12842. {
  12843. int i, ioport, irq = 0;
  12844. int err;
  12845. struct eisa_device *edev = to_eisa_device(dev);
  12846. struct eisa_scsi_data *data;
  12847. err = -ENOMEM;
  12848. data = kzalloc(sizeof(*data), GFP_KERNEL);
  12849. if (!data)
  12850. goto fail;
  12851. ioport = edev->base_addr + 0xc30;
  12852. err = -ENODEV;
  12853. for (i = 0; i < 2; i++, ioport += 0x20) {
  12854. struct asc_board *board;
  12855. struct Scsi_Host *shost;
  12856. if (!request_region(ioport, ASC_IOADR_GAP, DRV_NAME)) {
  12857. printk(KERN_WARNING "Region %x-%x busy\n", ioport,
  12858. ioport + ASC_IOADR_GAP - 1);
  12859. continue;
  12860. }
  12861. if (!AscFindSignature(ioport)) {
  12862. release_region(ioport, ASC_IOADR_GAP);
  12863. continue;
  12864. }
  12865. /*
  12866. * I don't know why we need to do this for EISA chips, but
  12867. * not for any others. It looks to be equivalent to
  12868. * AscGetChipCfgMsw, but I may have overlooked something,
  12869. * so I'm not converting it until I get an EISA board to
  12870. * test with.
  12871. */
  12872. inw(ioport + 4);
  12873. if (!irq)
  12874. irq = advansys_eisa_irq_no(edev);
  12875. err = -ENOMEM;
  12876. shost = scsi_host_alloc(&advansys_template, sizeof(*board));
  12877. if (!shost)
  12878. goto release_region;
  12879. board = shost_priv(shost);
  12880. board->irq = irq;
  12881. board->dev = dev;
  12882. err = advansys_board_found(shost, ioport, ASC_IS_EISA);
  12883. if (!err) {
  12884. data->host[i] = shost;
  12885. continue;
  12886. }
  12887. scsi_host_put(shost);
  12888. release_region:
  12889. release_region(ioport, ASC_IOADR_GAP);
  12890. break;
  12891. }
  12892. if (err)
  12893. goto free_data;
  12894. dev_set_drvdata(dev, data);
  12895. return 0;
  12896. free_data:
  12897. kfree(data->host[0]);
  12898. kfree(data->host[1]);
  12899. kfree(data);
  12900. fail:
  12901. return err;
  12902. }
  12903. static __devexit int advansys_eisa_remove(struct device *dev)
  12904. {
  12905. int i;
  12906. struct eisa_scsi_data *data = dev_get_drvdata(dev);
  12907. for (i = 0; i < 2; i++) {
  12908. int ioport;
  12909. struct Scsi_Host *shost = data->host[i];
  12910. if (!shost)
  12911. continue;
  12912. ioport = shost->io_port;
  12913. advansys_release(shost);
  12914. release_region(ioport, ASC_IOADR_GAP);
  12915. }
  12916. kfree(data);
  12917. return 0;
  12918. }
  12919. static struct eisa_driver advansys_eisa_driver = {
  12920. .id_table = advansys_eisa_table,
  12921. .driver = {
  12922. .name = DRV_NAME,
  12923. .probe = advansys_eisa_probe,
  12924. .remove = __devexit_p(advansys_eisa_remove),
  12925. }
  12926. };
  12927. /* PCI Devices supported by this driver */
  12928. static struct pci_device_id advansys_pci_tbl[] __devinitdata = {
  12929. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_1200A,
  12930. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  12931. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940,
  12932. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  12933. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940U,
  12934. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  12935. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940UW,
  12936. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  12937. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C0800_REV1,
  12938. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  12939. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C1600_REV1,
  12940. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  12941. {}
  12942. };
  12943. MODULE_DEVICE_TABLE(pci, advansys_pci_tbl);
  12944. static void __devinit advansys_set_latency(struct pci_dev *pdev)
  12945. {
  12946. if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
  12947. (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
  12948. pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0);
  12949. } else {
  12950. u8 latency;
  12951. pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency);
  12952. if (latency < 0x20)
  12953. pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x20);
  12954. }
  12955. }
  12956. static int __devinit
  12957. advansys_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  12958. {
  12959. int err, ioport;
  12960. struct Scsi_Host *shost;
  12961. struct asc_board *board;
  12962. err = pci_enable_device(pdev);
  12963. if (err)
  12964. goto fail;
  12965. err = pci_request_regions(pdev, DRV_NAME);
  12966. if (err)
  12967. goto disable_device;
  12968. pci_set_master(pdev);
  12969. advansys_set_latency(pdev);
  12970. err = -ENODEV;
  12971. if (pci_resource_len(pdev, 0) == 0)
  12972. goto release_region;
  12973. ioport = pci_resource_start(pdev, 0);
  12974. err = -ENOMEM;
  12975. shost = scsi_host_alloc(&advansys_template, sizeof(*board));
  12976. if (!shost)
  12977. goto release_region;
  12978. board = shost_priv(shost);
  12979. board->irq = pdev->irq;
  12980. board->dev = &pdev->dev;
  12981. if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW ||
  12982. pdev->device == PCI_DEVICE_ID_38C0800_REV1 ||
  12983. pdev->device == PCI_DEVICE_ID_38C1600_REV1) {
  12984. board->flags |= ASC_IS_WIDE_BOARD;
  12985. }
  12986. err = advansys_board_found(shost, ioport, ASC_IS_PCI);
  12987. if (err)
  12988. goto free_host;
  12989. pci_set_drvdata(pdev, shost);
  12990. return 0;
  12991. free_host:
  12992. scsi_host_put(shost);
  12993. release_region:
  12994. pci_release_regions(pdev);
  12995. disable_device:
  12996. pci_disable_device(pdev);
  12997. fail:
  12998. return err;
  12999. }
  13000. static void __devexit advansys_pci_remove(struct pci_dev *pdev)
  13001. {
  13002. advansys_release(pci_get_drvdata(pdev));
  13003. pci_release_regions(pdev);
  13004. pci_disable_device(pdev);
  13005. }
  13006. static struct pci_driver advansys_pci_driver = {
  13007. .name = DRV_NAME,
  13008. .id_table = advansys_pci_tbl,
  13009. .probe = advansys_pci_probe,
  13010. .remove = __devexit_p(advansys_pci_remove),
  13011. };
  13012. static int __init advansys_init(void)
  13013. {
  13014. int error;
  13015. error = isa_register_driver(&advansys_isa_driver,
  13016. ASC_IOADR_TABLE_MAX_IX);
  13017. if (error)
  13018. goto fail;
  13019. error = isa_register_driver(&advansys_vlb_driver,
  13020. ASC_IOADR_TABLE_MAX_IX);
  13021. if (error)
  13022. goto unregister_isa;
  13023. error = eisa_driver_register(&advansys_eisa_driver);
  13024. if (error)
  13025. goto unregister_vlb;
  13026. error = pci_register_driver(&advansys_pci_driver);
  13027. if (error)
  13028. goto unregister_eisa;
  13029. return 0;
  13030. unregister_eisa:
  13031. eisa_driver_unregister(&advansys_eisa_driver);
  13032. unregister_vlb:
  13033. isa_unregister_driver(&advansys_vlb_driver);
  13034. unregister_isa:
  13035. isa_unregister_driver(&advansys_isa_driver);
  13036. fail:
  13037. return error;
  13038. }
  13039. static void __exit advansys_exit(void)
  13040. {
  13041. pci_unregister_driver(&advansys_pci_driver);
  13042. eisa_driver_unregister(&advansys_eisa_driver);
  13043. isa_unregister_driver(&advansys_vlb_driver);
  13044. isa_unregister_driver(&advansys_isa_driver);
  13045. }
  13046. module_init(advansys_init);
  13047. module_exit(advansys_exit);
  13048. MODULE_LICENSE("GPL");