advansys.c 499 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761
  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. Kill boardp->id
  64. * 9. Add module_param to override ISA/VLB ioport array
  65. */
  66. #warning this driver is still not properly converted to the DMA API
  67. /* Enable driver /proc statistics. */
  68. #define ADVANSYS_STATS
  69. /* Enable driver tracing. */
  70. /* #define ADVANSYS_DEBUG */
  71. #define ASC_LIB_VERSION_MAJOR 1
  72. #define ASC_LIB_VERSION_MINOR 24
  73. #define ASC_LIB_SERIAL_NUMBER 123
  74. /*
  75. * Portable Data Types
  76. *
  77. * Any instance where a 32-bit long or pointer type is assumed
  78. * for precision or HW defined structures, the following define
  79. * types must be used. In Linux the char, short, and int types
  80. * are all consistent at 8, 16, and 32 bits respectively. Pointers
  81. * and long types are 64 bits on Alpha and UltraSPARC.
  82. */
  83. #define ASC_PADDR __u32 /* Physical/Bus address data type. */
  84. #define ASC_VADDR __u32 /* Virtual address data type. */
  85. #define ASC_DCNT __u32 /* Unsigned Data count type. */
  86. #define ASC_SDCNT __s32 /* Signed Data count type. */
  87. /*
  88. * These macros are used to convert a virtual address to a
  89. * 32-bit value. This currently can be used on Linux Alpha
  90. * which uses 64-bit virtual address but a 32-bit bus address.
  91. * This is likely to break in the future, but doing this now
  92. * will give us time to change the HW and FW to handle 64-bit
  93. * addresses.
  94. */
  95. #define ASC_VADDR_TO_U32 virt_to_bus
  96. #define ASC_U32_TO_VADDR bus_to_virt
  97. typedef unsigned char uchar;
  98. #ifndef TRUE
  99. #define TRUE (1)
  100. #endif
  101. #ifndef FALSE
  102. #define FALSE (0)
  103. #endif
  104. #define ERR (-1)
  105. #define UW_ERR (uint)(0xFFFF)
  106. #define isodd_word(val) ((((uint)val) & (uint)0x0001) != 0)
  107. #define PCI_VENDOR_ID_ASP 0x10cd
  108. #define PCI_DEVICE_ID_ASP_1200A 0x1100
  109. #define PCI_DEVICE_ID_ASP_ABP940 0x1200
  110. #define PCI_DEVICE_ID_ASP_ABP940U 0x1300
  111. #define PCI_DEVICE_ID_ASP_ABP940UW 0x2300
  112. #define PCI_DEVICE_ID_38C0800_REV1 0x2500
  113. #define PCI_DEVICE_ID_38C1600_REV1 0x2700
  114. /*
  115. * Enable CC_VERY_LONG_SG_LIST to support up to 64K element SG lists.
  116. * The SRB structure will have to be changed and the ASC_SRB2SCSIQ()
  117. * macro re-defined to be able to obtain a ASC_SCSI_Q pointer from the
  118. * SRB structure.
  119. */
  120. #define CC_VERY_LONG_SG_LIST 0
  121. #define ASC_SRB2SCSIQ(srb_ptr) (srb_ptr)
  122. #define PortAddr unsigned short /* port address size */
  123. #define inp(port) inb(port)
  124. #define outp(port, byte) outb((byte), (port))
  125. #define inpw(port) inw(port)
  126. #define outpw(port, word) outw((word), (port))
  127. #define ASC_MAX_SG_QUEUE 7
  128. #define ASC_MAX_SG_LIST 255
  129. #define ASC_CS_TYPE unsigned short
  130. #define ASC_IS_ISA (0x0001)
  131. #define ASC_IS_ISAPNP (0x0081)
  132. #define ASC_IS_EISA (0x0002)
  133. #define ASC_IS_PCI (0x0004)
  134. #define ASC_IS_PCI_ULTRA (0x0104)
  135. #define ASC_IS_PCMCIA (0x0008)
  136. #define ASC_IS_MCA (0x0020)
  137. #define ASC_IS_VL (0x0040)
  138. #define ASC_IS_WIDESCSI_16 (0x0100)
  139. #define ASC_IS_WIDESCSI_32 (0x0200)
  140. #define ASC_IS_BIG_ENDIAN (0x8000)
  141. #define ASC_CHIP_MIN_VER_VL (0x01)
  142. #define ASC_CHIP_MAX_VER_VL (0x07)
  143. #define ASC_CHIP_MIN_VER_PCI (0x09)
  144. #define ASC_CHIP_MAX_VER_PCI (0x0F)
  145. #define ASC_CHIP_VER_PCI_BIT (0x08)
  146. #define ASC_CHIP_MIN_VER_ISA (0x11)
  147. #define ASC_CHIP_MIN_VER_ISA_PNP (0x21)
  148. #define ASC_CHIP_MAX_VER_ISA (0x27)
  149. #define ASC_CHIP_VER_ISA_BIT (0x30)
  150. #define ASC_CHIP_VER_ISAPNP_BIT (0x20)
  151. #define ASC_CHIP_VER_ASYN_BUG (0x21)
  152. #define ASC_CHIP_VER_PCI 0x08
  153. #define ASC_CHIP_VER_PCI_ULTRA_3150 (ASC_CHIP_VER_PCI | 0x02)
  154. #define ASC_CHIP_VER_PCI_ULTRA_3050 (ASC_CHIP_VER_PCI | 0x03)
  155. #define ASC_CHIP_MIN_VER_EISA (0x41)
  156. #define ASC_CHIP_MAX_VER_EISA (0x47)
  157. #define ASC_CHIP_VER_EISA_BIT (0x40)
  158. #define ASC_CHIP_LATEST_VER_EISA ((ASC_CHIP_MIN_VER_EISA - 1) + 3)
  159. #define ASC_MAX_VL_DMA_COUNT (0x07FFFFFFL)
  160. #define ASC_MAX_PCI_DMA_COUNT (0xFFFFFFFFL)
  161. #define ASC_MAX_ISA_DMA_COUNT (0x00FFFFFFL)
  162. #define ASC_SCSI_ID_BITS 3
  163. #define ASC_SCSI_TIX_TYPE uchar
  164. #define ASC_ALL_DEVICE_BIT_SET 0xFF
  165. #define ASC_SCSI_BIT_ID_TYPE uchar
  166. #define ASC_MAX_TID 7
  167. #define ASC_MAX_LUN 7
  168. #define ASC_SCSI_WIDTH_BIT_SET 0xFF
  169. #define ASC_MAX_SENSE_LEN 32
  170. #define ASC_MIN_SENSE_LEN 14
  171. #define ASC_SCSI_RESET_HOLD_TIME_US 60
  172. /*
  173. * Narrow boards only support 12-byte commands, while wide boards
  174. * extend to 16-byte commands.
  175. */
  176. #define ASC_MAX_CDB_LEN 12
  177. #define ADV_MAX_CDB_LEN 16
  178. #define MS_SDTR_LEN 0x03
  179. #define MS_WDTR_LEN 0x02
  180. #define ASC_SG_LIST_PER_Q 7
  181. #define QS_FREE 0x00
  182. #define QS_READY 0x01
  183. #define QS_DISC1 0x02
  184. #define QS_DISC2 0x04
  185. #define QS_BUSY 0x08
  186. #define QS_ABORTED 0x40
  187. #define QS_DONE 0x80
  188. #define QC_NO_CALLBACK 0x01
  189. #define QC_SG_SWAP_QUEUE 0x02
  190. #define QC_SG_HEAD 0x04
  191. #define QC_DATA_IN 0x08
  192. #define QC_DATA_OUT 0x10
  193. #define QC_URGENT 0x20
  194. #define QC_MSG_OUT 0x40
  195. #define QC_REQ_SENSE 0x80
  196. #define QCSG_SG_XFER_LIST 0x02
  197. #define QCSG_SG_XFER_MORE 0x04
  198. #define QCSG_SG_XFER_END 0x08
  199. #define QD_IN_PROGRESS 0x00
  200. #define QD_NO_ERROR 0x01
  201. #define QD_ABORTED_BY_HOST 0x02
  202. #define QD_WITH_ERROR 0x04
  203. #define QD_INVALID_REQUEST 0x80
  204. #define QD_INVALID_HOST_NUM 0x81
  205. #define QD_INVALID_DEVICE 0x82
  206. #define QD_ERR_INTERNAL 0xFF
  207. #define QHSTA_NO_ERROR 0x00
  208. #define QHSTA_M_SEL_TIMEOUT 0x11
  209. #define QHSTA_M_DATA_OVER_RUN 0x12
  210. #define QHSTA_M_DATA_UNDER_RUN 0x12
  211. #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
  212. #define QHSTA_M_BAD_BUS_PHASE_SEQ 0x14
  213. #define QHSTA_D_QDONE_SG_LIST_CORRUPTED 0x21
  214. #define QHSTA_D_ASC_DVC_ERROR_CODE_SET 0x22
  215. #define QHSTA_D_HOST_ABORT_FAILED 0x23
  216. #define QHSTA_D_EXE_SCSI_Q_FAILED 0x24
  217. #define QHSTA_D_EXE_SCSI_Q_BUSY_TIMEOUT 0x25
  218. #define QHSTA_D_ASPI_NO_BUF_POOL 0x26
  219. #define QHSTA_M_WTM_TIMEOUT 0x41
  220. #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
  221. #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
  222. #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
  223. #define QHSTA_M_TARGET_STATUS_BUSY 0x45
  224. #define QHSTA_M_BAD_TAG_CODE 0x46
  225. #define QHSTA_M_BAD_QUEUE_FULL_OR_BUSY 0x47
  226. #define QHSTA_M_HUNG_REQ_SCSI_BUS_RESET 0x48
  227. #define QHSTA_D_LRAM_CMP_ERROR 0x81
  228. #define QHSTA_M_MICRO_CODE_ERROR_HALT 0xA1
  229. #define ASC_FLAG_SCSIQ_REQ 0x01
  230. #define ASC_FLAG_BIOS_SCSIQ_REQ 0x02
  231. #define ASC_FLAG_BIOS_ASYNC_IO 0x04
  232. #define ASC_FLAG_SRB_LINEAR_ADDR 0x08
  233. #define ASC_FLAG_WIN16 0x10
  234. #define ASC_FLAG_WIN32 0x20
  235. #define ASC_FLAG_ISA_OVER_16MB 0x40
  236. #define ASC_FLAG_DOS_VM_CALLBACK 0x80
  237. #define ASC_TAG_FLAG_EXTRA_BYTES 0x10
  238. #define ASC_TAG_FLAG_DISABLE_DISCONNECT 0x04
  239. #define ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX 0x08
  240. #define ASC_TAG_FLAG_DISABLE_CHK_COND_INT_HOST 0x40
  241. #define ASC_SCSIQ_CPY_BEG 4
  242. #define ASC_SCSIQ_SGHD_CPY_BEG 2
  243. #define ASC_SCSIQ_B_FWD 0
  244. #define ASC_SCSIQ_B_BWD 1
  245. #define ASC_SCSIQ_B_STATUS 2
  246. #define ASC_SCSIQ_B_QNO 3
  247. #define ASC_SCSIQ_B_CNTL 4
  248. #define ASC_SCSIQ_B_SG_QUEUE_CNT 5
  249. #define ASC_SCSIQ_D_DATA_ADDR 8
  250. #define ASC_SCSIQ_D_DATA_CNT 12
  251. #define ASC_SCSIQ_B_SENSE_LEN 20
  252. #define ASC_SCSIQ_DONE_INFO_BEG 22
  253. #define ASC_SCSIQ_D_SRBPTR 22
  254. #define ASC_SCSIQ_B_TARGET_IX 26
  255. #define ASC_SCSIQ_B_CDB_LEN 28
  256. #define ASC_SCSIQ_B_TAG_CODE 29
  257. #define ASC_SCSIQ_W_VM_ID 30
  258. #define ASC_SCSIQ_DONE_STATUS 32
  259. #define ASC_SCSIQ_HOST_STATUS 33
  260. #define ASC_SCSIQ_SCSI_STATUS 34
  261. #define ASC_SCSIQ_CDB_BEG 36
  262. #define ASC_SCSIQ_DW_REMAIN_XFER_ADDR 56
  263. #define ASC_SCSIQ_DW_REMAIN_XFER_CNT 60
  264. #define ASC_SCSIQ_B_FIRST_SG_WK_QP 48
  265. #define ASC_SCSIQ_B_SG_WK_QP 49
  266. #define ASC_SCSIQ_B_SG_WK_IX 50
  267. #define ASC_SCSIQ_W_ALT_DC1 52
  268. #define ASC_SCSIQ_B_LIST_CNT 6
  269. #define ASC_SCSIQ_B_CUR_LIST_CNT 7
  270. #define ASC_SGQ_B_SG_CNTL 4
  271. #define ASC_SGQ_B_SG_HEAD_QP 5
  272. #define ASC_SGQ_B_SG_LIST_CNT 6
  273. #define ASC_SGQ_B_SG_CUR_LIST_CNT 7
  274. #define ASC_SGQ_LIST_BEG 8
  275. #define ASC_DEF_SCSI1_QNG 4
  276. #define ASC_MAX_SCSI1_QNG 4
  277. #define ASC_DEF_SCSI2_QNG 16
  278. #define ASC_MAX_SCSI2_QNG 32
  279. #define ASC_TAG_CODE_MASK 0x23
  280. #define ASC_STOP_REQ_RISC_STOP 0x01
  281. #define ASC_STOP_ACK_RISC_STOP 0x03
  282. #define ASC_STOP_CLEAN_UP_BUSY_Q 0x10
  283. #define ASC_STOP_CLEAN_UP_DISC_Q 0x20
  284. #define ASC_STOP_HOST_REQ_RISC_HALT 0x40
  285. #define ASC_TIDLUN_TO_IX(tid, lun) (ASC_SCSI_TIX_TYPE)((tid) + ((lun)<<ASC_SCSI_ID_BITS))
  286. #define ASC_TID_TO_TARGET_ID(tid) (ASC_SCSI_BIT_ID_TYPE)(0x01 << (tid))
  287. #define ASC_TIX_TO_TARGET_ID(tix) (0x01 << ((tix) & ASC_MAX_TID))
  288. #define ASC_TIX_TO_TID(tix) ((tix) & ASC_MAX_TID)
  289. #define ASC_TID_TO_TIX(tid) ((tid) & ASC_MAX_TID)
  290. #define ASC_TIX_TO_LUN(tix) (((tix) >> ASC_SCSI_ID_BITS) & ASC_MAX_LUN)
  291. #define ASC_QNO_TO_QADDR(q_no) ((ASC_QADR_BEG)+((int)(q_no) << 6))
  292. typedef struct asc_scsiq_1 {
  293. uchar status;
  294. uchar q_no;
  295. uchar cntl;
  296. uchar sg_queue_cnt;
  297. uchar target_id;
  298. uchar target_lun;
  299. ASC_PADDR data_addr;
  300. ASC_DCNT data_cnt;
  301. ASC_PADDR sense_addr;
  302. uchar sense_len;
  303. uchar extra_bytes;
  304. } ASC_SCSIQ_1;
  305. typedef struct asc_scsiq_2 {
  306. ASC_VADDR srb_ptr;
  307. uchar target_ix;
  308. uchar flag;
  309. uchar cdb_len;
  310. uchar tag_code;
  311. ushort vm_id;
  312. } ASC_SCSIQ_2;
  313. typedef struct asc_scsiq_3 {
  314. uchar done_stat;
  315. uchar host_stat;
  316. uchar scsi_stat;
  317. uchar scsi_msg;
  318. } ASC_SCSIQ_3;
  319. typedef struct asc_scsiq_4 {
  320. uchar cdb[ASC_MAX_CDB_LEN];
  321. uchar y_first_sg_list_qp;
  322. uchar y_working_sg_qp;
  323. uchar y_working_sg_ix;
  324. uchar y_res;
  325. ushort x_req_count;
  326. ushort x_reconnect_rtn;
  327. ASC_PADDR x_saved_data_addr;
  328. ASC_DCNT x_saved_data_cnt;
  329. } ASC_SCSIQ_4;
  330. typedef struct asc_q_done_info {
  331. ASC_SCSIQ_2 d2;
  332. ASC_SCSIQ_3 d3;
  333. uchar q_status;
  334. uchar q_no;
  335. uchar cntl;
  336. uchar sense_len;
  337. uchar extra_bytes;
  338. uchar res;
  339. ASC_DCNT remain_bytes;
  340. } ASC_QDONE_INFO;
  341. typedef struct asc_sg_list {
  342. ASC_PADDR addr;
  343. ASC_DCNT bytes;
  344. } ASC_SG_LIST;
  345. typedef struct asc_sg_head {
  346. ushort entry_cnt;
  347. ushort queue_cnt;
  348. ushort entry_to_copy;
  349. ushort res;
  350. ASC_SG_LIST sg_list[0];
  351. } ASC_SG_HEAD;
  352. typedef struct asc_scsi_q {
  353. ASC_SCSIQ_1 q1;
  354. ASC_SCSIQ_2 q2;
  355. uchar *cdbptr;
  356. ASC_SG_HEAD *sg_head;
  357. ushort remain_sg_entry_cnt;
  358. ushort next_sg_index;
  359. } ASC_SCSI_Q;
  360. typedef struct asc_scsi_req_q {
  361. ASC_SCSIQ_1 r1;
  362. ASC_SCSIQ_2 r2;
  363. uchar *cdbptr;
  364. ASC_SG_HEAD *sg_head;
  365. uchar *sense_ptr;
  366. ASC_SCSIQ_3 r3;
  367. uchar cdb[ASC_MAX_CDB_LEN];
  368. uchar sense[ASC_MIN_SENSE_LEN];
  369. } ASC_SCSI_REQ_Q;
  370. typedef struct asc_scsi_bios_req_q {
  371. ASC_SCSIQ_1 r1;
  372. ASC_SCSIQ_2 r2;
  373. uchar *cdbptr;
  374. ASC_SG_HEAD *sg_head;
  375. uchar *sense_ptr;
  376. ASC_SCSIQ_3 r3;
  377. uchar cdb[ASC_MAX_CDB_LEN];
  378. uchar sense[ASC_MIN_SENSE_LEN];
  379. } ASC_SCSI_BIOS_REQ_Q;
  380. typedef struct asc_risc_q {
  381. uchar fwd;
  382. uchar bwd;
  383. ASC_SCSIQ_1 i1;
  384. ASC_SCSIQ_2 i2;
  385. ASC_SCSIQ_3 i3;
  386. ASC_SCSIQ_4 i4;
  387. } ASC_RISC_Q;
  388. typedef struct asc_sg_list_q {
  389. uchar seq_no;
  390. uchar q_no;
  391. uchar cntl;
  392. uchar sg_head_qp;
  393. uchar sg_list_cnt;
  394. uchar sg_cur_list_cnt;
  395. } ASC_SG_LIST_Q;
  396. typedef struct asc_risc_sg_list_q {
  397. uchar fwd;
  398. uchar bwd;
  399. ASC_SG_LIST_Q sg;
  400. ASC_SG_LIST sg_list[7];
  401. } ASC_RISC_SG_LIST_Q;
  402. #define ASCQ_ERR_Q_STATUS 0x0D
  403. #define ASCQ_ERR_CUR_QNG 0x17
  404. #define ASCQ_ERR_SG_Q_LINKS 0x18
  405. #define ASCQ_ERR_ISR_RE_ENTRY 0x1A
  406. #define ASCQ_ERR_CRITICAL_RE_ENTRY 0x1B
  407. #define ASCQ_ERR_ISR_ON_CRITICAL 0x1C
  408. /*
  409. * Warning code values are set in ASC_DVC_VAR 'warn_code'.
  410. */
  411. #define ASC_WARN_NO_ERROR 0x0000
  412. #define ASC_WARN_IO_PORT_ROTATE 0x0001
  413. #define ASC_WARN_EEPROM_CHKSUM 0x0002
  414. #define ASC_WARN_IRQ_MODIFIED 0x0004
  415. #define ASC_WARN_AUTO_CONFIG 0x0008
  416. #define ASC_WARN_CMD_QNG_CONFLICT 0x0010
  417. #define ASC_WARN_EEPROM_RECOVER 0x0020
  418. #define ASC_WARN_CFG_MSW_RECOVER 0x0040
  419. /*
  420. * Error code values are set in ASC_DVC_VAR 'err_code'.
  421. */
  422. #define ASC_IERR_WRITE_EEPROM 0x0001
  423. #define ASC_IERR_MCODE_CHKSUM 0x0002
  424. #define ASC_IERR_SET_PC_ADDR 0x0004
  425. #define ASC_IERR_START_STOP_CHIP 0x0008
  426. #define ASC_IERR_IRQ_NO 0x0010
  427. #define ASC_IERR_SET_IRQ_NO 0x0020
  428. #define ASC_IERR_CHIP_VERSION 0x0040
  429. #define ASC_IERR_SET_SCSI_ID 0x0080
  430. #define ASC_IERR_GET_PHY_ADDR 0x0100
  431. #define ASC_IERR_BAD_SIGNATURE 0x0200
  432. #define ASC_IERR_NO_BUS_TYPE 0x0400
  433. #define ASC_IERR_SCAM 0x0800
  434. #define ASC_IERR_SET_SDTR 0x1000
  435. #define ASC_IERR_RW_LRAM 0x8000
  436. #define ASC_MAX_IRQ_NO 15
  437. #define ASC_MIN_IRQ_NO 10
  438. #define ASC_DEF_MAX_TOTAL_QNG (0xF0)
  439. #define ASC_MIN_TAG_Q_PER_DVC (0x04)
  440. #define ASC_MIN_FREE_Q (0x02)
  441. #define ASC_MIN_TOTAL_QNG ((ASC_MAX_SG_QUEUE)+(ASC_MIN_FREE_Q))
  442. #define ASC_MAX_TOTAL_QNG 240
  443. #define ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG 16
  444. #define ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG 8
  445. #define ASC_MAX_PCI_INRAM_TOTAL_QNG 20
  446. #define ASC_MAX_INRAM_TAG_QNG 16
  447. #define ASC_IOADR_GAP 0x10
  448. #define ASC_MAX_SYN_XFER_NO 16
  449. #define ASC_SYN_MAX_OFFSET 0x0F
  450. #define ASC_DEF_SDTR_OFFSET 0x0F
  451. #define ASC_SDTR_ULTRA_PCI_10MB_INDEX 0x02
  452. #define SYN_XFER_NS_0 25
  453. #define SYN_XFER_NS_1 30
  454. #define SYN_XFER_NS_2 35
  455. #define SYN_XFER_NS_3 40
  456. #define SYN_XFER_NS_4 50
  457. #define SYN_XFER_NS_5 60
  458. #define SYN_XFER_NS_6 70
  459. #define SYN_XFER_NS_7 85
  460. #define SYN_ULTRA_XFER_NS_0 12
  461. #define SYN_ULTRA_XFER_NS_1 19
  462. #define SYN_ULTRA_XFER_NS_2 25
  463. #define SYN_ULTRA_XFER_NS_3 32
  464. #define SYN_ULTRA_XFER_NS_4 38
  465. #define SYN_ULTRA_XFER_NS_5 44
  466. #define SYN_ULTRA_XFER_NS_6 50
  467. #define SYN_ULTRA_XFER_NS_7 57
  468. #define SYN_ULTRA_XFER_NS_8 63
  469. #define SYN_ULTRA_XFER_NS_9 69
  470. #define SYN_ULTRA_XFER_NS_10 75
  471. #define SYN_ULTRA_XFER_NS_11 82
  472. #define SYN_ULTRA_XFER_NS_12 88
  473. #define SYN_ULTRA_XFER_NS_13 94
  474. #define SYN_ULTRA_XFER_NS_14 100
  475. #define SYN_ULTRA_XFER_NS_15 107
  476. typedef struct ext_msg {
  477. uchar msg_type;
  478. uchar msg_len;
  479. uchar msg_req;
  480. union {
  481. struct {
  482. uchar sdtr_xfer_period;
  483. uchar sdtr_req_ack_offset;
  484. } sdtr;
  485. struct {
  486. uchar wdtr_width;
  487. } wdtr;
  488. struct {
  489. uchar mdp_b3;
  490. uchar mdp_b2;
  491. uchar mdp_b1;
  492. uchar mdp_b0;
  493. } mdp;
  494. } u_ext_msg;
  495. uchar res;
  496. } EXT_MSG;
  497. #define xfer_period u_ext_msg.sdtr.sdtr_xfer_period
  498. #define req_ack_offset u_ext_msg.sdtr.sdtr_req_ack_offset
  499. #define wdtr_width u_ext_msg.wdtr.wdtr_width
  500. #define mdp_b3 u_ext_msg.mdp_b3
  501. #define mdp_b2 u_ext_msg.mdp_b2
  502. #define mdp_b1 u_ext_msg.mdp_b1
  503. #define mdp_b0 u_ext_msg.mdp_b0
  504. typedef struct asc_dvc_cfg {
  505. ASC_SCSI_BIT_ID_TYPE can_tagged_qng;
  506. ASC_SCSI_BIT_ID_TYPE cmd_qng_enabled;
  507. ASC_SCSI_BIT_ID_TYPE disc_enable;
  508. ASC_SCSI_BIT_ID_TYPE sdtr_enable;
  509. uchar chip_scsi_id;
  510. uchar isa_dma_speed;
  511. uchar isa_dma_channel;
  512. uchar chip_version;
  513. ushort lib_serial_no;
  514. ushort lib_version;
  515. ushort mcode_date;
  516. ushort mcode_version;
  517. uchar max_tag_qng[ASC_MAX_TID + 1];
  518. uchar *overrun_buf;
  519. uchar sdtr_period_offset[ASC_MAX_TID + 1];
  520. uchar adapter_info[6];
  521. } ASC_DVC_CFG;
  522. #define ASC_DEF_DVC_CNTL 0xFFFF
  523. #define ASC_DEF_CHIP_SCSI_ID 7
  524. #define ASC_DEF_ISA_DMA_SPEED 4
  525. #define ASC_INIT_STATE_BEG_GET_CFG 0x0001
  526. #define ASC_INIT_STATE_END_GET_CFG 0x0002
  527. #define ASC_INIT_STATE_BEG_SET_CFG 0x0004
  528. #define ASC_INIT_STATE_END_SET_CFG 0x0008
  529. #define ASC_INIT_STATE_BEG_LOAD_MC 0x0010
  530. #define ASC_INIT_STATE_END_LOAD_MC 0x0020
  531. #define ASC_INIT_STATE_BEG_INQUIRY 0x0040
  532. #define ASC_INIT_STATE_END_INQUIRY 0x0080
  533. #define ASC_INIT_RESET_SCSI_DONE 0x0100
  534. #define ASC_INIT_STATE_WITHOUT_EEP 0x8000
  535. #define ASC_BUG_FIX_IF_NOT_DWB 0x0001
  536. #define ASC_BUG_FIX_ASYN_USE_SYN 0x0002
  537. #define ASYN_SDTR_DATA_FIX_PCI_REV_AB 0x41
  538. #define ASC_MIN_TAGGED_CMD 7
  539. #define ASC_MAX_SCSI_RESET_WAIT 30
  540. struct asc_dvc_var; /* Forward Declaration. */
  541. typedef struct asc_dvc_var {
  542. PortAddr iop_base;
  543. ushort err_code;
  544. ushort dvc_cntl;
  545. ushort bug_fix_cntl;
  546. ushort bus_type;
  547. ASC_SCSI_BIT_ID_TYPE init_sdtr;
  548. ASC_SCSI_BIT_ID_TYPE sdtr_done;
  549. ASC_SCSI_BIT_ID_TYPE use_tagged_qng;
  550. ASC_SCSI_BIT_ID_TYPE unit_not_ready;
  551. ASC_SCSI_BIT_ID_TYPE queue_full_or_busy;
  552. ASC_SCSI_BIT_ID_TYPE start_motor;
  553. uchar scsi_reset_wait;
  554. uchar chip_no;
  555. char is_in_int;
  556. uchar max_total_qng;
  557. uchar cur_total_qng;
  558. uchar in_critical_cnt;
  559. uchar irq_no;
  560. uchar last_q_shortage;
  561. ushort init_state;
  562. uchar cur_dvc_qng[ASC_MAX_TID + 1];
  563. uchar max_dvc_qng[ASC_MAX_TID + 1];
  564. ASC_SCSI_Q *scsiq_busy_head[ASC_MAX_TID + 1];
  565. ASC_SCSI_Q *scsiq_busy_tail[ASC_MAX_TID + 1];
  566. uchar sdtr_period_tbl[ASC_MAX_SYN_XFER_NO];
  567. ASC_DVC_CFG *cfg;
  568. ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer_always;
  569. char redo_scam;
  570. ushort res2;
  571. uchar dos_int13_table[ASC_MAX_TID + 1];
  572. ASC_DCNT max_dma_count;
  573. ASC_SCSI_BIT_ID_TYPE no_scam;
  574. ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer;
  575. uchar max_sdtr_index;
  576. uchar host_init_sdtr_index;
  577. struct asc_board *drv_ptr;
  578. ASC_DCNT uc_break;
  579. } ASC_DVC_VAR;
  580. typedef struct asc_dvc_inq_info {
  581. uchar type[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
  582. } ASC_DVC_INQ_INFO;
  583. typedef struct asc_cap_info {
  584. ASC_DCNT lba;
  585. ASC_DCNT blk_size;
  586. } ASC_CAP_INFO;
  587. typedef struct asc_cap_info_array {
  588. ASC_CAP_INFO cap_info[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
  589. } ASC_CAP_INFO_ARRAY;
  590. #define ASC_MCNTL_NO_SEL_TIMEOUT (ushort)0x0001
  591. #define ASC_MCNTL_NULL_TARGET (ushort)0x0002
  592. #define ASC_CNTL_INITIATOR (ushort)0x0001
  593. #define ASC_CNTL_BIOS_GT_1GB (ushort)0x0002
  594. #define ASC_CNTL_BIOS_GT_2_DISK (ushort)0x0004
  595. #define ASC_CNTL_BIOS_REMOVABLE (ushort)0x0008
  596. #define ASC_CNTL_NO_SCAM (ushort)0x0010
  597. #define ASC_CNTL_INT_MULTI_Q (ushort)0x0080
  598. #define ASC_CNTL_NO_LUN_SUPPORT (ushort)0x0040
  599. #define ASC_CNTL_NO_VERIFY_COPY (ushort)0x0100
  600. #define ASC_CNTL_RESET_SCSI (ushort)0x0200
  601. #define ASC_CNTL_INIT_INQUIRY (ushort)0x0400
  602. #define ASC_CNTL_INIT_VERBOSE (ushort)0x0800
  603. #define ASC_CNTL_SCSI_PARITY (ushort)0x1000
  604. #define ASC_CNTL_BURST_MODE (ushort)0x2000
  605. #define ASC_CNTL_SDTR_ENABLE_ULTRA (ushort)0x4000
  606. #define ASC_EEP_DVC_CFG_BEG_VL 2
  607. #define ASC_EEP_MAX_DVC_ADDR_VL 15
  608. #define ASC_EEP_DVC_CFG_BEG 32
  609. #define ASC_EEP_MAX_DVC_ADDR 45
  610. #define ASC_EEP_MAX_RETRY 20
  611. /*
  612. * These macros keep the chip SCSI id and ISA DMA speed
  613. * bitfields in board order. C bitfields aren't portable
  614. * between big and little-endian platforms so they are
  615. * not used.
  616. */
  617. #define ASC_EEP_GET_CHIP_ID(cfg) ((cfg)->id_speed & 0x0f)
  618. #define ASC_EEP_GET_DMA_SPD(cfg) (((cfg)->id_speed & 0xf0) >> 4)
  619. #define ASC_EEP_SET_CHIP_ID(cfg, sid) \
  620. ((cfg)->id_speed = ((cfg)->id_speed & 0xf0) | ((sid) & ASC_MAX_TID))
  621. #define ASC_EEP_SET_DMA_SPD(cfg, spd) \
  622. ((cfg)->id_speed = ((cfg)->id_speed & 0x0f) | ((spd) & 0x0f) << 4)
  623. typedef struct asceep_config {
  624. ushort cfg_lsw;
  625. ushort cfg_msw;
  626. uchar init_sdtr;
  627. uchar disc_enable;
  628. uchar use_cmd_qng;
  629. uchar start_motor;
  630. uchar max_total_qng;
  631. uchar max_tag_qng;
  632. uchar bios_scan;
  633. uchar power_up_wait;
  634. uchar no_scam;
  635. uchar id_speed; /* low order 4 bits is chip scsi id */
  636. /* high order 4 bits is isa dma speed */
  637. uchar dos_int13_table[ASC_MAX_TID + 1];
  638. uchar adapter_info[6];
  639. ushort cntl;
  640. ushort chksum;
  641. } ASCEEP_CONFIG;
  642. #define ASC_EEP_CMD_READ 0x80
  643. #define ASC_EEP_CMD_WRITE 0x40
  644. #define ASC_EEP_CMD_WRITE_ABLE 0x30
  645. #define ASC_EEP_CMD_WRITE_DISABLE 0x00
  646. #define ASC_OVERRUN_BSIZE 0x00000048UL
  647. #define ASCV_MSGOUT_BEG 0x0000
  648. #define ASCV_MSGOUT_SDTR_PERIOD (ASCV_MSGOUT_BEG+3)
  649. #define ASCV_MSGOUT_SDTR_OFFSET (ASCV_MSGOUT_BEG+4)
  650. #define ASCV_BREAK_SAVED_CODE (ushort)0x0006
  651. #define ASCV_MSGIN_BEG (ASCV_MSGOUT_BEG+8)
  652. #define ASCV_MSGIN_SDTR_PERIOD (ASCV_MSGIN_BEG+3)
  653. #define ASCV_MSGIN_SDTR_OFFSET (ASCV_MSGIN_BEG+4)
  654. #define ASCV_SDTR_DATA_BEG (ASCV_MSGIN_BEG+8)
  655. #define ASCV_SDTR_DONE_BEG (ASCV_SDTR_DATA_BEG+8)
  656. #define ASCV_MAX_DVC_QNG_BEG (ushort)0x0020
  657. #define ASCV_BREAK_ADDR (ushort)0x0028
  658. #define ASCV_BREAK_NOTIFY_COUNT (ushort)0x002A
  659. #define ASCV_BREAK_CONTROL (ushort)0x002C
  660. #define ASCV_BREAK_HIT_COUNT (ushort)0x002E
  661. #define ASCV_ASCDVC_ERR_CODE_W (ushort)0x0030
  662. #define ASCV_MCODE_CHKSUM_W (ushort)0x0032
  663. #define ASCV_MCODE_SIZE_W (ushort)0x0034
  664. #define ASCV_STOP_CODE_B (ushort)0x0036
  665. #define ASCV_DVC_ERR_CODE_B (ushort)0x0037
  666. #define ASCV_OVERRUN_PADDR_D (ushort)0x0038
  667. #define ASCV_OVERRUN_BSIZE_D (ushort)0x003C
  668. #define ASCV_HALTCODE_W (ushort)0x0040
  669. #define ASCV_CHKSUM_W (ushort)0x0042
  670. #define ASCV_MC_DATE_W (ushort)0x0044
  671. #define ASCV_MC_VER_W (ushort)0x0046
  672. #define ASCV_NEXTRDY_B (ushort)0x0048
  673. #define ASCV_DONENEXT_B (ushort)0x0049
  674. #define ASCV_USE_TAGGED_QNG_B (ushort)0x004A
  675. #define ASCV_SCSIBUSY_B (ushort)0x004B
  676. #define ASCV_Q_DONE_IN_PROGRESS_B (ushort)0x004C
  677. #define ASCV_CURCDB_B (ushort)0x004D
  678. #define ASCV_RCLUN_B (ushort)0x004E
  679. #define ASCV_BUSY_QHEAD_B (ushort)0x004F
  680. #define ASCV_DISC1_QHEAD_B (ushort)0x0050
  681. #define ASCV_DISC_ENABLE_B (ushort)0x0052
  682. #define ASCV_CAN_TAGGED_QNG_B (ushort)0x0053
  683. #define ASCV_HOSTSCSI_ID_B (ushort)0x0055
  684. #define ASCV_MCODE_CNTL_B (ushort)0x0056
  685. #define ASCV_NULL_TARGET_B (ushort)0x0057
  686. #define ASCV_FREE_Q_HEAD_W (ushort)0x0058
  687. #define ASCV_DONE_Q_TAIL_W (ushort)0x005A
  688. #define ASCV_FREE_Q_HEAD_B (ushort)(ASCV_FREE_Q_HEAD_W+1)
  689. #define ASCV_DONE_Q_TAIL_B (ushort)(ASCV_DONE_Q_TAIL_W+1)
  690. #define ASCV_HOST_FLAG_B (ushort)0x005D
  691. #define ASCV_TOTAL_READY_Q_B (ushort)0x0064
  692. #define ASCV_VER_SERIAL_B (ushort)0x0065
  693. #define ASCV_HALTCODE_SAVED_W (ushort)0x0066
  694. #define ASCV_WTM_FLAG_B (ushort)0x0068
  695. #define ASCV_RISC_FLAG_B (ushort)0x006A
  696. #define ASCV_REQ_SG_LIST_QP (ushort)0x006B
  697. #define ASC_HOST_FLAG_IN_ISR 0x01
  698. #define ASC_HOST_FLAG_ACK_INT 0x02
  699. #define ASC_RISC_FLAG_GEN_INT 0x01
  700. #define ASC_RISC_FLAG_REQ_SG_LIST 0x02
  701. #define IOP_CTRL (0x0F)
  702. #define IOP_STATUS (0x0E)
  703. #define IOP_INT_ACK IOP_STATUS
  704. #define IOP_REG_IFC (0x0D)
  705. #define IOP_SYN_OFFSET (0x0B)
  706. #define IOP_EXTRA_CONTROL (0x0D)
  707. #define IOP_REG_PC (0x0C)
  708. #define IOP_RAM_ADDR (0x0A)
  709. #define IOP_RAM_DATA (0x08)
  710. #define IOP_EEP_DATA (0x06)
  711. #define IOP_EEP_CMD (0x07)
  712. #define IOP_VERSION (0x03)
  713. #define IOP_CONFIG_HIGH (0x04)
  714. #define IOP_CONFIG_LOW (0x02)
  715. #define IOP_SIG_BYTE (0x01)
  716. #define IOP_SIG_WORD (0x00)
  717. #define IOP_REG_DC1 (0x0E)
  718. #define IOP_REG_DC0 (0x0C)
  719. #define IOP_REG_SB (0x0B)
  720. #define IOP_REG_DA1 (0x0A)
  721. #define IOP_REG_DA0 (0x08)
  722. #define IOP_REG_SC (0x09)
  723. #define IOP_DMA_SPEED (0x07)
  724. #define IOP_REG_FLAG (0x07)
  725. #define IOP_FIFO_H (0x06)
  726. #define IOP_FIFO_L (0x04)
  727. #define IOP_REG_ID (0x05)
  728. #define IOP_REG_QP (0x03)
  729. #define IOP_REG_IH (0x02)
  730. #define IOP_REG_IX (0x01)
  731. #define IOP_REG_AX (0x00)
  732. #define IFC_REG_LOCK (0x00)
  733. #define IFC_REG_UNLOCK (0x09)
  734. #define IFC_WR_EN_FILTER (0x10)
  735. #define IFC_RD_NO_EEPROM (0x10)
  736. #define IFC_SLEW_RATE (0x20)
  737. #define IFC_ACT_NEG (0x40)
  738. #define IFC_INP_FILTER (0x80)
  739. #define IFC_INIT_DEFAULT (IFC_ACT_NEG | IFC_REG_UNLOCK)
  740. #define SC_SEL (uchar)(0x80)
  741. #define SC_BSY (uchar)(0x40)
  742. #define SC_ACK (uchar)(0x20)
  743. #define SC_REQ (uchar)(0x10)
  744. #define SC_ATN (uchar)(0x08)
  745. #define SC_IO (uchar)(0x04)
  746. #define SC_CD (uchar)(0x02)
  747. #define SC_MSG (uchar)(0x01)
  748. #define SEC_SCSI_CTL (uchar)(0x80)
  749. #define SEC_ACTIVE_NEGATE (uchar)(0x40)
  750. #define SEC_SLEW_RATE (uchar)(0x20)
  751. #define SEC_ENABLE_FILTER (uchar)(0x10)
  752. #define ASC_HALT_EXTMSG_IN (ushort)0x8000
  753. #define ASC_HALT_CHK_CONDITION (ushort)0x8100
  754. #define ASC_HALT_SS_QUEUE_FULL (ushort)0x8200
  755. #define ASC_HALT_DISABLE_ASYN_USE_SYN_FIX (ushort)0x8300
  756. #define ASC_HALT_ENABLE_ASYN_USE_SYN_FIX (ushort)0x8400
  757. #define ASC_HALT_SDTR_REJECTED (ushort)0x4000
  758. #define ASC_HALT_HOST_COPY_SG_LIST_TO_RISC ( ushort )0x2000
  759. #define ASC_MAX_QNO 0xF8
  760. #define ASC_DATA_SEC_BEG (ushort)0x0080
  761. #define ASC_DATA_SEC_END (ushort)0x0080
  762. #define ASC_CODE_SEC_BEG (ushort)0x0080
  763. #define ASC_CODE_SEC_END (ushort)0x0080
  764. #define ASC_QADR_BEG (0x4000)
  765. #define ASC_QADR_USED (ushort)(ASC_MAX_QNO * 64)
  766. #define ASC_QADR_END (ushort)0x7FFF
  767. #define ASC_QLAST_ADR (ushort)0x7FC0
  768. #define ASC_QBLK_SIZE 0x40
  769. #define ASC_BIOS_DATA_QBEG 0xF8
  770. #define ASC_MIN_ACTIVE_QNO 0x01
  771. #define ASC_QLINK_END 0xFF
  772. #define ASC_EEPROM_WORDS 0x10
  773. #define ASC_MAX_MGS_LEN 0x10
  774. #define ASC_BIOS_ADDR_DEF 0xDC00
  775. #define ASC_BIOS_SIZE 0x3800
  776. #define ASC_BIOS_RAM_OFF 0x3800
  777. #define ASC_BIOS_RAM_SIZE 0x800
  778. #define ASC_BIOS_MIN_ADDR 0xC000
  779. #define ASC_BIOS_MAX_ADDR 0xEC00
  780. #define ASC_BIOS_BANK_SIZE 0x0400
  781. #define ASC_MCODE_START_ADDR 0x0080
  782. #define ASC_CFG0_HOST_INT_ON 0x0020
  783. #define ASC_CFG0_BIOS_ON 0x0040
  784. #define ASC_CFG0_VERA_BURST_ON 0x0080
  785. #define ASC_CFG0_SCSI_PARITY_ON 0x0800
  786. #define ASC_CFG1_SCSI_TARGET_ON 0x0080
  787. #define ASC_CFG1_LRAM_8BITS_ON 0x0800
  788. #define ASC_CFG_MSW_CLR_MASK 0x3080
  789. #define CSW_TEST1 (ASC_CS_TYPE)0x8000
  790. #define CSW_AUTO_CONFIG (ASC_CS_TYPE)0x4000
  791. #define CSW_RESERVED1 (ASC_CS_TYPE)0x2000
  792. #define CSW_IRQ_WRITTEN (ASC_CS_TYPE)0x1000
  793. #define CSW_33MHZ_SELECTED (ASC_CS_TYPE)0x0800
  794. #define CSW_TEST2 (ASC_CS_TYPE)0x0400
  795. #define CSW_TEST3 (ASC_CS_TYPE)0x0200
  796. #define CSW_RESERVED2 (ASC_CS_TYPE)0x0100
  797. #define CSW_DMA_DONE (ASC_CS_TYPE)0x0080
  798. #define CSW_FIFO_RDY (ASC_CS_TYPE)0x0040
  799. #define CSW_EEP_READ_DONE (ASC_CS_TYPE)0x0020
  800. #define CSW_HALTED (ASC_CS_TYPE)0x0010
  801. #define CSW_SCSI_RESET_ACTIVE (ASC_CS_TYPE)0x0008
  802. #define CSW_PARITY_ERR (ASC_CS_TYPE)0x0004
  803. #define CSW_SCSI_RESET_LATCH (ASC_CS_TYPE)0x0002
  804. #define CSW_INT_PENDING (ASC_CS_TYPE)0x0001
  805. #define CIW_CLR_SCSI_RESET_INT (ASC_CS_TYPE)0x1000
  806. #define CIW_INT_ACK (ASC_CS_TYPE)0x0100
  807. #define CIW_TEST1 (ASC_CS_TYPE)0x0200
  808. #define CIW_TEST2 (ASC_CS_TYPE)0x0400
  809. #define CIW_SEL_33MHZ (ASC_CS_TYPE)0x0800
  810. #define CIW_IRQ_ACT (ASC_CS_TYPE)0x1000
  811. #define CC_CHIP_RESET (uchar)0x80
  812. #define CC_SCSI_RESET (uchar)0x40
  813. #define CC_HALT (uchar)0x20
  814. #define CC_SINGLE_STEP (uchar)0x10
  815. #define CC_DMA_ABLE (uchar)0x08
  816. #define CC_TEST (uchar)0x04
  817. #define CC_BANK_ONE (uchar)0x02
  818. #define CC_DIAG (uchar)0x01
  819. #define ASC_1000_ID0W 0x04C1
  820. #define ASC_1000_ID0W_FIX 0x00C1
  821. #define ASC_1000_ID1B 0x25
  822. #define ASC_EISA_REV_IOP_MASK (0x0C83)
  823. #define ASC_EISA_CFG_IOP_MASK (0x0C86)
  824. #define ASC_GET_EISA_SLOT(iop) (PortAddr)((iop) & 0xF000)
  825. #define INS_HALTINT (ushort)0x6281
  826. #define INS_HALT (ushort)0x6280
  827. #define INS_SINT (ushort)0x6200
  828. #define INS_RFLAG_WTM (ushort)0x7380
  829. #define ASC_MC_SAVE_CODE_WSIZE 0x500
  830. #define ASC_MC_SAVE_DATA_WSIZE 0x40
  831. typedef struct asc_mc_saved {
  832. ushort data[ASC_MC_SAVE_DATA_WSIZE];
  833. ushort code[ASC_MC_SAVE_CODE_WSIZE];
  834. } ASC_MC_SAVED;
  835. #define AscGetQDoneInProgress(port) AscReadLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B)
  836. #define AscPutQDoneInProgress(port, val) AscWriteLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B, val)
  837. #define AscGetVarFreeQHead(port) AscReadLramWord((port), ASCV_FREE_Q_HEAD_W)
  838. #define AscGetVarDoneQTail(port) AscReadLramWord((port), ASCV_DONE_Q_TAIL_W)
  839. #define AscPutVarFreeQHead(port, val) AscWriteLramWord((port), ASCV_FREE_Q_HEAD_W, val)
  840. #define AscPutVarDoneQTail(port, val) AscWriteLramWord((port), ASCV_DONE_Q_TAIL_W, val)
  841. #define AscGetRiscVarFreeQHead(port) AscReadLramByte((port), ASCV_NEXTRDY_B)
  842. #define AscGetRiscVarDoneQTail(port) AscReadLramByte((port), ASCV_DONENEXT_B)
  843. #define AscPutRiscVarFreeQHead(port, val) AscWriteLramByte((port), ASCV_NEXTRDY_B, val)
  844. #define AscPutRiscVarDoneQTail(port, val) AscWriteLramByte((port), ASCV_DONENEXT_B, val)
  845. #define AscPutMCodeSDTRDoneAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id), (data))
  846. #define AscGetMCodeSDTRDoneAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id))
  847. #define AscPutMCodeInitSDTRAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id), data)
  848. #define AscGetMCodeInitSDTRAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id))
  849. #define AscSynIndexToPeriod(index) (uchar)(asc_dvc->sdtr_period_tbl[ (index) ])
  850. #define AscGetChipSignatureByte(port) (uchar)inp((port)+IOP_SIG_BYTE)
  851. #define AscGetChipSignatureWord(port) (ushort)inpw((port)+IOP_SIG_WORD)
  852. #define AscGetChipVerNo(port) (uchar)inp((port)+IOP_VERSION)
  853. #define AscGetChipCfgLsw(port) (ushort)inpw((port)+IOP_CONFIG_LOW)
  854. #define AscGetChipCfgMsw(port) (ushort)inpw((port)+IOP_CONFIG_HIGH)
  855. #define AscSetChipCfgLsw(port, data) outpw((port)+IOP_CONFIG_LOW, data)
  856. #define AscSetChipCfgMsw(port, data) outpw((port)+IOP_CONFIG_HIGH, data)
  857. #define AscGetChipEEPCmd(port) (uchar)inp((port)+IOP_EEP_CMD)
  858. #define AscSetChipEEPCmd(port, data) outp((port)+IOP_EEP_CMD, data)
  859. #define AscGetChipEEPData(port) (ushort)inpw((port)+IOP_EEP_DATA)
  860. #define AscSetChipEEPData(port, data) outpw((port)+IOP_EEP_DATA, data)
  861. #define AscGetChipLramAddr(port) (ushort)inpw((PortAddr)((port)+IOP_RAM_ADDR))
  862. #define AscSetChipLramAddr(port, addr) outpw((PortAddr)((port)+IOP_RAM_ADDR), addr)
  863. #define AscGetChipLramData(port) (ushort)inpw((port)+IOP_RAM_DATA)
  864. #define AscSetChipLramData(port, data) outpw((port)+IOP_RAM_DATA, data)
  865. #define AscGetChipIFC(port) (uchar)inp((port)+IOP_REG_IFC)
  866. #define AscSetChipIFC(port, data) outp((port)+IOP_REG_IFC, data)
  867. #define AscGetChipStatus(port) (ASC_CS_TYPE)inpw((port)+IOP_STATUS)
  868. #define AscSetChipStatus(port, cs_val) outpw((port)+IOP_STATUS, cs_val)
  869. #define AscGetChipControl(port) (uchar)inp((port)+IOP_CTRL)
  870. #define AscSetChipControl(port, cc_val) outp((port)+IOP_CTRL, cc_val)
  871. #define AscGetChipSyn(port) (uchar)inp((port)+IOP_SYN_OFFSET)
  872. #define AscSetChipSyn(port, data) outp((port)+IOP_SYN_OFFSET, data)
  873. #define AscSetPCAddr(port, data) outpw((port)+IOP_REG_PC, data)
  874. #define AscGetPCAddr(port) (ushort)inpw((port)+IOP_REG_PC)
  875. #define AscIsIntPending(port) (AscGetChipStatus(port) & (CSW_INT_PENDING | CSW_SCSI_RESET_LATCH))
  876. #define AscGetChipScsiID(port) ((AscGetChipCfgLsw(port) >> 8) & ASC_MAX_TID)
  877. #define AscGetExtraControl(port) (uchar)inp((port)+IOP_EXTRA_CONTROL)
  878. #define AscSetExtraControl(port, data) outp((port)+IOP_EXTRA_CONTROL, data)
  879. #define AscReadChipAX(port) (ushort)inpw((port)+IOP_REG_AX)
  880. #define AscWriteChipAX(port, data) outpw((port)+IOP_REG_AX, data)
  881. #define AscReadChipIX(port) (uchar)inp((port)+IOP_REG_IX)
  882. #define AscWriteChipIX(port, data) outp((port)+IOP_REG_IX, data)
  883. #define AscReadChipIH(port) (ushort)inpw((port)+IOP_REG_IH)
  884. #define AscWriteChipIH(port, data) outpw((port)+IOP_REG_IH, data)
  885. #define AscReadChipQP(port) (uchar)inp((port)+IOP_REG_QP)
  886. #define AscWriteChipQP(port, data) outp((port)+IOP_REG_QP, data)
  887. #define AscReadChipFIFO_L(port) (ushort)inpw((port)+IOP_REG_FIFO_L)
  888. #define AscWriteChipFIFO_L(port, data) outpw((port)+IOP_REG_FIFO_L, data)
  889. #define AscReadChipFIFO_H(port) (ushort)inpw((port)+IOP_REG_FIFO_H)
  890. #define AscWriteChipFIFO_H(port, data) outpw((port)+IOP_REG_FIFO_H, data)
  891. #define AscReadChipDmaSpeed(port) (uchar)inp((port)+IOP_DMA_SPEED)
  892. #define AscWriteChipDmaSpeed(port, data) outp((port)+IOP_DMA_SPEED, data)
  893. #define AscReadChipDA0(port) (ushort)inpw((port)+IOP_REG_DA0)
  894. #define AscWriteChipDA0(port) outpw((port)+IOP_REG_DA0, data)
  895. #define AscReadChipDA1(port) (ushort)inpw((port)+IOP_REG_DA1)
  896. #define AscWriteChipDA1(port) outpw((port)+IOP_REG_DA1, data)
  897. #define AscReadChipDC0(port) (ushort)inpw((port)+IOP_REG_DC0)
  898. #define AscWriteChipDC0(port) outpw((port)+IOP_REG_DC0, data)
  899. #define AscReadChipDC1(port) (ushort)inpw((port)+IOP_REG_DC1)
  900. #define AscWriteChipDC1(port) outpw((port)+IOP_REG_DC1, data)
  901. #define AscReadChipDvcID(port) (uchar)inp((port)+IOP_REG_ID)
  902. #define AscWriteChipDvcID(port, data) outp((port)+IOP_REG_ID, data)
  903. #define ADV_LIB_VERSION_MAJOR 5
  904. #define ADV_LIB_VERSION_MINOR 14
  905. /*
  906. * Define Adv Library required special types.
  907. */
  908. /*
  909. * Portable Data Types
  910. *
  911. * Any instance where a 32-bit long or pointer type is assumed
  912. * for precision or HW defined structures, the following define
  913. * types must be used. In Linux the char, short, and int types
  914. * are all consistent at 8, 16, and 32 bits respectively. Pointers
  915. * and long types are 64 bits on Alpha and UltraSPARC.
  916. */
  917. #define ADV_PADDR __u32 /* Physical address data type. */
  918. #define ADV_VADDR __u32 /* Virtual address data type. */
  919. #define ADV_DCNT __u32 /* Unsigned Data count type. */
  920. #define ADV_SDCNT __s32 /* Signed Data count type. */
  921. /*
  922. * These macros are used to convert a virtual address to a
  923. * 32-bit value. This currently can be used on Linux Alpha
  924. * which uses 64-bit virtual address but a 32-bit bus address.
  925. * This is likely to break in the future, but doing this now
  926. * will give us time to change the HW and FW to handle 64-bit
  927. * addresses.
  928. */
  929. #define ADV_VADDR_TO_U32 virt_to_bus
  930. #define ADV_U32_TO_VADDR bus_to_virt
  931. #define AdvPortAddr void __iomem * /* Virtual memory address size */
  932. /*
  933. * Define Adv Library required memory access macros.
  934. */
  935. #define ADV_MEM_READB(addr) readb(addr)
  936. #define ADV_MEM_READW(addr) readw(addr)
  937. #define ADV_MEM_WRITEB(addr, byte) writeb(byte, addr)
  938. #define ADV_MEM_WRITEW(addr, word) writew(word, addr)
  939. #define ADV_MEM_WRITEDW(addr, dword) writel(dword, addr)
  940. #define ADV_CARRIER_COUNT (ASC_DEF_MAX_HOST_QNG + 15)
  941. /*
  942. * Define total number of simultaneous maximum element scatter-gather
  943. * request blocks per wide adapter. ASC_DEF_MAX_HOST_QNG (253) is the
  944. * maximum number of outstanding commands per wide host adapter. Each
  945. * command uses one or more ADV_SG_BLOCK each with 15 scatter-gather
  946. * elements. Allow each command to have at least one ADV_SG_BLOCK structure.
  947. * This allows about 15 commands to have the maximum 17 ADV_SG_BLOCK
  948. * structures or 255 scatter-gather elements.
  949. *
  950. */
  951. #define ADV_TOT_SG_BLOCK ASC_DEF_MAX_HOST_QNG
  952. /*
  953. * Define Adv Library required maximum number of scatter-gather
  954. * elements per request.
  955. */
  956. #define ADV_MAX_SG_LIST 255
  957. /* Number of SG blocks needed. */
  958. #define ADV_NUM_SG_BLOCK \
  959. ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK)
  960. /* Total contiguous memory needed for SG blocks. */
  961. #define ADV_SG_TOTAL_MEM_SIZE \
  962. (sizeof(ADV_SG_BLOCK) * ADV_NUM_SG_BLOCK)
  963. #define ADV_PAGE_SIZE PAGE_SIZE
  964. #define ADV_NUM_PAGE_CROSSING \
  965. ((ADV_SG_TOTAL_MEM_SIZE + (ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
  966. #define ADV_EEP_DVC_CFG_BEGIN (0x00)
  967. #define ADV_EEP_DVC_CFG_END (0x15)
  968. #define ADV_EEP_DVC_CTL_BEGIN (0x16) /* location of OEM name */
  969. #define ADV_EEP_MAX_WORD_ADDR (0x1E)
  970. #define ADV_EEP_DELAY_MS 100
  971. #define ADV_EEPROM_BIG_ENDIAN 0x8000 /* EEPROM Bit 15 */
  972. #define ADV_EEPROM_BIOS_ENABLE 0x4000 /* EEPROM Bit 14 */
  973. /*
  974. * For the ASC3550 Bit 13 is Termination Polarity control bit.
  975. * For later ICs Bit 13 controls whether the CIS (Card Information
  976. * Service Section) is loaded from EEPROM.
  977. */
  978. #define ADV_EEPROM_TERM_POL 0x2000 /* EEPROM Bit 13 */
  979. #define ADV_EEPROM_CIS_LD 0x2000 /* EEPROM Bit 13 */
  980. /*
  981. * ASC38C1600 Bit 11
  982. *
  983. * If EEPROM Bit 11 is 0 for Function 0, then Function 0 will specify
  984. * INT A in the PCI Configuration Space Int Pin field. If it is 1, then
  985. * Function 0 will specify INT B.
  986. *
  987. * If EEPROM Bit 11 is 0 for Function 1, then Function 1 will specify
  988. * INT B in the PCI Configuration Space Int Pin field. If it is 1, then
  989. * Function 1 will specify INT A.
  990. */
  991. #define ADV_EEPROM_INTAB 0x0800 /* EEPROM Bit 11 */
  992. typedef struct adveep_3550_config {
  993. /* Word Offset, Description */
  994. ushort cfg_lsw; /* 00 power up initialization */
  995. /* bit 13 set - Term Polarity Control */
  996. /* bit 14 set - BIOS Enable */
  997. /* bit 15 set - Big Endian Mode */
  998. ushort cfg_msw; /* 01 unused */
  999. ushort disc_enable; /* 02 disconnect enable */
  1000. ushort wdtr_able; /* 03 Wide DTR able */
  1001. ushort sdtr_able; /* 04 Synchronous DTR able */
  1002. ushort start_motor; /* 05 send start up motor */
  1003. ushort tagqng_able; /* 06 tag queuing able */
  1004. ushort bios_scan; /* 07 BIOS device control */
  1005. ushort scam_tolerant; /* 08 no scam */
  1006. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1007. uchar bios_boot_delay; /* power up wait */
  1008. uchar scsi_reset_delay; /* 10 reset delay */
  1009. uchar bios_id_lun; /* first boot device scsi id & lun */
  1010. /* high nibble is lun */
  1011. /* low nibble is scsi id */
  1012. uchar termination; /* 11 0 - automatic */
  1013. /* 1 - low off / high off */
  1014. /* 2 - low off / high on */
  1015. /* 3 - low on / high on */
  1016. /* There is no low on / high off */
  1017. uchar reserved1; /* reserved byte (not used) */
  1018. ushort bios_ctrl; /* 12 BIOS control bits */
  1019. /* bit 0 BIOS don't act as initiator. */
  1020. /* bit 1 BIOS > 1 GB support */
  1021. /* bit 2 BIOS > 2 Disk Support */
  1022. /* bit 3 BIOS don't support removables */
  1023. /* bit 4 BIOS support bootable CD */
  1024. /* bit 5 BIOS scan enabled */
  1025. /* bit 6 BIOS support multiple LUNs */
  1026. /* bit 7 BIOS display of message */
  1027. /* bit 8 SCAM disabled */
  1028. /* bit 9 Reset SCSI bus during init. */
  1029. /* bit 10 */
  1030. /* bit 11 No verbose initialization. */
  1031. /* bit 12 SCSI parity enabled */
  1032. /* bit 13 */
  1033. /* bit 14 */
  1034. /* bit 15 */
  1035. ushort ultra_able; /* 13 ULTRA speed able */
  1036. ushort reserved2; /* 14 reserved */
  1037. uchar max_host_qng; /* 15 maximum host queuing */
  1038. uchar max_dvc_qng; /* maximum per device queuing */
  1039. ushort dvc_cntl; /* 16 control bit for driver */
  1040. ushort bug_fix; /* 17 control bit for bug fix */
  1041. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1042. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1043. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1044. ushort check_sum; /* 21 EEP check sum */
  1045. uchar oem_name[16]; /* 22 OEM name */
  1046. ushort dvc_err_code; /* 30 last device driver error code */
  1047. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1048. ushort adv_err_addr; /* 32 last uc error address */
  1049. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1050. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1051. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1052. ushort num_of_err; /* 36 number of error */
  1053. } ADVEEP_3550_CONFIG;
  1054. typedef struct adveep_38C0800_config {
  1055. /* Word Offset, Description */
  1056. ushort cfg_lsw; /* 00 power up initialization */
  1057. /* bit 13 set - Load CIS */
  1058. /* bit 14 set - BIOS Enable */
  1059. /* bit 15 set - Big Endian Mode */
  1060. ushort cfg_msw; /* 01 unused */
  1061. ushort disc_enable; /* 02 disconnect enable */
  1062. ushort wdtr_able; /* 03 Wide DTR able */
  1063. ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
  1064. ushort start_motor; /* 05 send start up motor */
  1065. ushort tagqng_able; /* 06 tag queuing able */
  1066. ushort bios_scan; /* 07 BIOS device control */
  1067. ushort scam_tolerant; /* 08 no scam */
  1068. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1069. uchar bios_boot_delay; /* power up wait */
  1070. uchar scsi_reset_delay; /* 10 reset delay */
  1071. uchar bios_id_lun; /* first boot device scsi id & lun */
  1072. /* high nibble is lun */
  1073. /* low nibble is scsi id */
  1074. uchar termination_se; /* 11 0 - automatic */
  1075. /* 1 - low off / high off */
  1076. /* 2 - low off / high on */
  1077. /* 3 - low on / high on */
  1078. /* There is no low on / high off */
  1079. uchar termination_lvd; /* 11 0 - automatic */
  1080. /* 1 - low off / high off */
  1081. /* 2 - low off / high on */
  1082. /* 3 - low on / high on */
  1083. /* There is no low on / high off */
  1084. ushort bios_ctrl; /* 12 BIOS control bits */
  1085. /* bit 0 BIOS don't act as initiator. */
  1086. /* bit 1 BIOS > 1 GB support */
  1087. /* bit 2 BIOS > 2 Disk Support */
  1088. /* bit 3 BIOS don't support removables */
  1089. /* bit 4 BIOS support bootable CD */
  1090. /* bit 5 BIOS scan enabled */
  1091. /* bit 6 BIOS support multiple LUNs */
  1092. /* bit 7 BIOS display of message */
  1093. /* bit 8 SCAM disabled */
  1094. /* bit 9 Reset SCSI bus during init. */
  1095. /* bit 10 */
  1096. /* bit 11 No verbose initialization. */
  1097. /* bit 12 SCSI parity enabled */
  1098. /* bit 13 */
  1099. /* bit 14 */
  1100. /* bit 15 */
  1101. ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
  1102. ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
  1103. uchar max_host_qng; /* 15 maximum host queueing */
  1104. uchar max_dvc_qng; /* maximum per device queuing */
  1105. ushort dvc_cntl; /* 16 control bit for driver */
  1106. ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
  1107. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1108. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1109. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1110. ushort check_sum; /* 21 EEP check sum */
  1111. uchar oem_name[16]; /* 22 OEM name */
  1112. ushort dvc_err_code; /* 30 last device driver error code */
  1113. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1114. ushort adv_err_addr; /* 32 last uc error address */
  1115. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1116. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1117. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1118. ushort reserved36; /* 36 reserved */
  1119. ushort reserved37; /* 37 reserved */
  1120. ushort reserved38; /* 38 reserved */
  1121. ushort reserved39; /* 39 reserved */
  1122. ushort reserved40; /* 40 reserved */
  1123. ushort reserved41; /* 41 reserved */
  1124. ushort reserved42; /* 42 reserved */
  1125. ushort reserved43; /* 43 reserved */
  1126. ushort reserved44; /* 44 reserved */
  1127. ushort reserved45; /* 45 reserved */
  1128. ushort reserved46; /* 46 reserved */
  1129. ushort reserved47; /* 47 reserved */
  1130. ushort reserved48; /* 48 reserved */
  1131. ushort reserved49; /* 49 reserved */
  1132. ushort reserved50; /* 50 reserved */
  1133. ushort reserved51; /* 51 reserved */
  1134. ushort reserved52; /* 52 reserved */
  1135. ushort reserved53; /* 53 reserved */
  1136. ushort reserved54; /* 54 reserved */
  1137. ushort reserved55; /* 55 reserved */
  1138. ushort cisptr_lsw; /* 56 CIS PTR LSW */
  1139. ushort cisprt_msw; /* 57 CIS PTR MSW */
  1140. ushort subsysvid; /* 58 SubSystem Vendor ID */
  1141. ushort subsysid; /* 59 SubSystem ID */
  1142. ushort reserved60; /* 60 reserved */
  1143. ushort reserved61; /* 61 reserved */
  1144. ushort reserved62; /* 62 reserved */
  1145. ushort reserved63; /* 63 reserved */
  1146. } ADVEEP_38C0800_CONFIG;
  1147. typedef struct adveep_38C1600_config {
  1148. /* Word Offset, Description */
  1149. ushort cfg_lsw; /* 00 power up initialization */
  1150. /* bit 11 set - Func. 0 INTB, Func. 1 INTA */
  1151. /* clear - Func. 0 INTA, Func. 1 INTB */
  1152. /* bit 13 set - Load CIS */
  1153. /* bit 14 set - BIOS Enable */
  1154. /* bit 15 set - Big Endian Mode */
  1155. ushort cfg_msw; /* 01 unused */
  1156. ushort disc_enable; /* 02 disconnect enable */
  1157. ushort wdtr_able; /* 03 Wide DTR able */
  1158. ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
  1159. ushort start_motor; /* 05 send start up motor */
  1160. ushort tagqng_able; /* 06 tag queuing able */
  1161. ushort bios_scan; /* 07 BIOS device control */
  1162. ushort scam_tolerant; /* 08 no scam */
  1163. uchar adapter_scsi_id; /* 09 Host Adapter ID */
  1164. uchar bios_boot_delay; /* power up wait */
  1165. uchar scsi_reset_delay; /* 10 reset delay */
  1166. uchar bios_id_lun; /* first boot device scsi id & lun */
  1167. /* high nibble is lun */
  1168. /* low nibble is scsi id */
  1169. uchar termination_se; /* 11 0 - automatic */
  1170. /* 1 - low off / high off */
  1171. /* 2 - low off / high on */
  1172. /* 3 - low on / high on */
  1173. /* There is no low on / high off */
  1174. uchar termination_lvd; /* 11 0 - automatic */
  1175. /* 1 - low off / high off */
  1176. /* 2 - low off / high on */
  1177. /* 3 - low on / high on */
  1178. /* There is no low on / high off */
  1179. ushort bios_ctrl; /* 12 BIOS control bits */
  1180. /* bit 0 BIOS don't act as initiator. */
  1181. /* bit 1 BIOS > 1 GB support */
  1182. /* bit 2 BIOS > 2 Disk Support */
  1183. /* bit 3 BIOS don't support removables */
  1184. /* bit 4 BIOS support bootable CD */
  1185. /* bit 5 BIOS scan enabled */
  1186. /* bit 6 BIOS support multiple LUNs */
  1187. /* bit 7 BIOS display of message */
  1188. /* bit 8 SCAM disabled */
  1189. /* bit 9 Reset SCSI bus during init. */
  1190. /* bit 10 Basic Integrity Checking disabled */
  1191. /* bit 11 No verbose initialization. */
  1192. /* bit 12 SCSI parity enabled */
  1193. /* bit 13 AIPP (Asyn. Info. Ph. Prot.) dis. */
  1194. /* bit 14 */
  1195. /* bit 15 */
  1196. ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
  1197. ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
  1198. uchar max_host_qng; /* 15 maximum host queueing */
  1199. uchar max_dvc_qng; /* maximum per device queuing */
  1200. ushort dvc_cntl; /* 16 control bit for driver */
  1201. ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
  1202. ushort serial_number_word1; /* 18 Board serial number word 1 */
  1203. ushort serial_number_word2; /* 19 Board serial number word 2 */
  1204. ushort serial_number_word3; /* 20 Board serial number word 3 */
  1205. ushort check_sum; /* 21 EEP check sum */
  1206. uchar oem_name[16]; /* 22 OEM name */
  1207. ushort dvc_err_code; /* 30 last device driver error code */
  1208. ushort adv_err_code; /* 31 last uc and Adv Lib error code */
  1209. ushort adv_err_addr; /* 32 last uc error address */
  1210. ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
  1211. ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
  1212. ushort saved_adv_err_addr; /* 35 saved last uc error address */
  1213. ushort reserved36; /* 36 reserved */
  1214. ushort reserved37; /* 37 reserved */
  1215. ushort reserved38; /* 38 reserved */
  1216. ushort reserved39; /* 39 reserved */
  1217. ushort reserved40; /* 40 reserved */
  1218. ushort reserved41; /* 41 reserved */
  1219. ushort reserved42; /* 42 reserved */
  1220. ushort reserved43; /* 43 reserved */
  1221. ushort reserved44; /* 44 reserved */
  1222. ushort reserved45; /* 45 reserved */
  1223. ushort reserved46; /* 46 reserved */
  1224. ushort reserved47; /* 47 reserved */
  1225. ushort reserved48; /* 48 reserved */
  1226. ushort reserved49; /* 49 reserved */
  1227. ushort reserved50; /* 50 reserved */
  1228. ushort reserved51; /* 51 reserved */
  1229. ushort reserved52; /* 52 reserved */
  1230. ushort reserved53; /* 53 reserved */
  1231. ushort reserved54; /* 54 reserved */
  1232. ushort reserved55; /* 55 reserved */
  1233. ushort cisptr_lsw; /* 56 CIS PTR LSW */
  1234. ushort cisprt_msw; /* 57 CIS PTR MSW */
  1235. ushort subsysvid; /* 58 SubSystem Vendor ID */
  1236. ushort subsysid; /* 59 SubSystem ID */
  1237. ushort reserved60; /* 60 reserved */
  1238. ushort reserved61; /* 61 reserved */
  1239. ushort reserved62; /* 62 reserved */
  1240. ushort reserved63; /* 63 reserved */
  1241. } ADVEEP_38C1600_CONFIG;
  1242. /*
  1243. * EEPROM Commands
  1244. */
  1245. #define ASC_EEP_CMD_DONE 0x0200
  1246. /* bios_ctrl */
  1247. #define BIOS_CTRL_BIOS 0x0001
  1248. #define BIOS_CTRL_EXTENDED_XLAT 0x0002
  1249. #define BIOS_CTRL_GT_2_DISK 0x0004
  1250. #define BIOS_CTRL_BIOS_REMOVABLE 0x0008
  1251. #define BIOS_CTRL_BOOTABLE_CD 0x0010
  1252. #define BIOS_CTRL_MULTIPLE_LUN 0x0040
  1253. #define BIOS_CTRL_DISPLAY_MSG 0x0080
  1254. #define BIOS_CTRL_NO_SCAM 0x0100
  1255. #define BIOS_CTRL_RESET_SCSI_BUS 0x0200
  1256. #define BIOS_CTRL_INIT_VERBOSE 0x0800
  1257. #define BIOS_CTRL_SCSI_PARITY 0x1000
  1258. #define BIOS_CTRL_AIPP_DIS 0x2000
  1259. #define ADV_3550_MEMSIZE 0x2000 /* 8 KB Internal Memory */
  1260. #define ADV_38C0800_MEMSIZE 0x4000 /* 16 KB Internal Memory */
  1261. /*
  1262. * XXX - Since ASC38C1600 Rev.3 has a local RAM failure issue, there is
  1263. * a special 16K Adv Library and Microcode version. After the issue is
  1264. * resolved, should restore 32K support.
  1265. *
  1266. * #define ADV_38C1600_MEMSIZE 0x8000L * 32 KB Internal Memory *
  1267. */
  1268. #define ADV_38C1600_MEMSIZE 0x4000 /* 16 KB Internal Memory */
  1269. /*
  1270. * Byte I/O register address from base of 'iop_base'.
  1271. */
  1272. #define IOPB_INTR_STATUS_REG 0x00
  1273. #define IOPB_CHIP_ID_1 0x01
  1274. #define IOPB_INTR_ENABLES 0x02
  1275. #define IOPB_CHIP_TYPE_REV 0x03
  1276. #define IOPB_RES_ADDR_4 0x04
  1277. #define IOPB_RES_ADDR_5 0x05
  1278. #define IOPB_RAM_DATA 0x06
  1279. #define IOPB_RES_ADDR_7 0x07
  1280. #define IOPB_FLAG_REG 0x08
  1281. #define IOPB_RES_ADDR_9 0x09
  1282. #define IOPB_RISC_CSR 0x0A
  1283. #define IOPB_RES_ADDR_B 0x0B
  1284. #define IOPB_RES_ADDR_C 0x0C
  1285. #define IOPB_RES_ADDR_D 0x0D
  1286. #define IOPB_SOFT_OVER_WR 0x0E
  1287. #define IOPB_RES_ADDR_F 0x0F
  1288. #define IOPB_MEM_CFG 0x10
  1289. #define IOPB_RES_ADDR_11 0x11
  1290. #define IOPB_GPIO_DATA 0x12
  1291. #define IOPB_RES_ADDR_13 0x13
  1292. #define IOPB_FLASH_PAGE 0x14
  1293. #define IOPB_RES_ADDR_15 0x15
  1294. #define IOPB_GPIO_CNTL 0x16
  1295. #define IOPB_RES_ADDR_17 0x17
  1296. #define IOPB_FLASH_DATA 0x18
  1297. #define IOPB_RES_ADDR_19 0x19
  1298. #define IOPB_RES_ADDR_1A 0x1A
  1299. #define IOPB_RES_ADDR_1B 0x1B
  1300. #define IOPB_RES_ADDR_1C 0x1C
  1301. #define IOPB_RES_ADDR_1D 0x1D
  1302. #define IOPB_RES_ADDR_1E 0x1E
  1303. #define IOPB_RES_ADDR_1F 0x1F
  1304. #define IOPB_DMA_CFG0 0x20
  1305. #define IOPB_DMA_CFG1 0x21
  1306. #define IOPB_TICKLE 0x22
  1307. #define IOPB_DMA_REG_WR 0x23
  1308. #define IOPB_SDMA_STATUS 0x24
  1309. #define IOPB_SCSI_BYTE_CNT 0x25
  1310. #define IOPB_HOST_BYTE_CNT 0x26
  1311. #define IOPB_BYTE_LEFT_TO_XFER 0x27
  1312. #define IOPB_BYTE_TO_XFER_0 0x28
  1313. #define IOPB_BYTE_TO_XFER_1 0x29
  1314. #define IOPB_BYTE_TO_XFER_2 0x2A
  1315. #define IOPB_BYTE_TO_XFER_3 0x2B
  1316. #define IOPB_ACC_GRP 0x2C
  1317. #define IOPB_RES_ADDR_2D 0x2D
  1318. #define IOPB_DEV_ID 0x2E
  1319. #define IOPB_RES_ADDR_2F 0x2F
  1320. #define IOPB_SCSI_DATA 0x30
  1321. #define IOPB_RES_ADDR_31 0x31
  1322. #define IOPB_RES_ADDR_32 0x32
  1323. #define IOPB_SCSI_DATA_HSHK 0x33
  1324. #define IOPB_SCSI_CTRL 0x34
  1325. #define IOPB_RES_ADDR_35 0x35
  1326. #define IOPB_RES_ADDR_36 0x36
  1327. #define IOPB_RES_ADDR_37 0x37
  1328. #define IOPB_RAM_BIST 0x38
  1329. #define IOPB_PLL_TEST 0x39
  1330. #define IOPB_PCI_INT_CFG 0x3A
  1331. #define IOPB_RES_ADDR_3B 0x3B
  1332. #define IOPB_RFIFO_CNT 0x3C
  1333. #define IOPB_RES_ADDR_3D 0x3D
  1334. #define IOPB_RES_ADDR_3E 0x3E
  1335. #define IOPB_RES_ADDR_3F 0x3F
  1336. /*
  1337. * Word I/O register address from base of 'iop_base'.
  1338. */
  1339. #define IOPW_CHIP_ID_0 0x00 /* CID0 */
  1340. #define IOPW_CTRL_REG 0x02 /* CC */
  1341. #define IOPW_RAM_ADDR 0x04 /* LA */
  1342. #define IOPW_RAM_DATA 0x06 /* LD */
  1343. #define IOPW_RES_ADDR_08 0x08
  1344. #define IOPW_RISC_CSR 0x0A /* CSR */
  1345. #define IOPW_SCSI_CFG0 0x0C /* CFG0 */
  1346. #define IOPW_SCSI_CFG1 0x0E /* CFG1 */
  1347. #define IOPW_RES_ADDR_10 0x10
  1348. #define IOPW_SEL_MASK 0x12 /* SM */
  1349. #define IOPW_RES_ADDR_14 0x14
  1350. #define IOPW_FLASH_ADDR 0x16 /* FA */
  1351. #define IOPW_RES_ADDR_18 0x18
  1352. #define IOPW_EE_CMD 0x1A /* EC */
  1353. #define IOPW_EE_DATA 0x1C /* ED */
  1354. #define IOPW_SFIFO_CNT 0x1E /* SFC */
  1355. #define IOPW_RES_ADDR_20 0x20
  1356. #define IOPW_Q_BASE 0x22 /* QB */
  1357. #define IOPW_QP 0x24 /* QP */
  1358. #define IOPW_IX 0x26 /* IX */
  1359. #define IOPW_SP 0x28 /* SP */
  1360. #define IOPW_PC 0x2A /* PC */
  1361. #define IOPW_RES_ADDR_2C 0x2C
  1362. #define IOPW_RES_ADDR_2E 0x2E
  1363. #define IOPW_SCSI_DATA 0x30 /* SD */
  1364. #define IOPW_SCSI_DATA_HSHK 0x32 /* SDH */
  1365. #define IOPW_SCSI_CTRL 0x34 /* SC */
  1366. #define IOPW_HSHK_CFG 0x36 /* HCFG */
  1367. #define IOPW_SXFR_STATUS 0x36 /* SXS */
  1368. #define IOPW_SXFR_CNTL 0x38 /* SXL */
  1369. #define IOPW_SXFR_CNTH 0x3A /* SXH */
  1370. #define IOPW_RES_ADDR_3C 0x3C
  1371. #define IOPW_RFIFO_DATA 0x3E /* RFD */
  1372. /*
  1373. * Doubleword I/O register address from base of 'iop_base'.
  1374. */
  1375. #define IOPDW_RES_ADDR_0 0x00
  1376. #define IOPDW_RAM_DATA 0x04
  1377. #define IOPDW_RES_ADDR_8 0x08
  1378. #define IOPDW_RES_ADDR_C 0x0C
  1379. #define IOPDW_RES_ADDR_10 0x10
  1380. #define IOPDW_COMMA 0x14
  1381. #define IOPDW_COMMB 0x18
  1382. #define IOPDW_RES_ADDR_1C 0x1C
  1383. #define IOPDW_SDMA_ADDR0 0x20
  1384. #define IOPDW_SDMA_ADDR1 0x24
  1385. #define IOPDW_SDMA_COUNT 0x28
  1386. #define IOPDW_SDMA_ERROR 0x2C
  1387. #define IOPDW_RDMA_ADDR0 0x30
  1388. #define IOPDW_RDMA_ADDR1 0x34
  1389. #define IOPDW_RDMA_COUNT 0x38
  1390. #define IOPDW_RDMA_ERROR 0x3C
  1391. #define ADV_CHIP_ID_BYTE 0x25
  1392. #define ADV_CHIP_ID_WORD 0x04C1
  1393. #define ADV_INTR_ENABLE_HOST_INTR 0x01
  1394. #define ADV_INTR_ENABLE_SEL_INTR 0x02
  1395. #define ADV_INTR_ENABLE_DPR_INTR 0x04
  1396. #define ADV_INTR_ENABLE_RTA_INTR 0x08
  1397. #define ADV_INTR_ENABLE_RMA_INTR 0x10
  1398. #define ADV_INTR_ENABLE_RST_INTR 0x20
  1399. #define ADV_INTR_ENABLE_DPE_INTR 0x40
  1400. #define ADV_INTR_ENABLE_GLOBAL_INTR 0x80
  1401. #define ADV_INTR_STATUS_INTRA 0x01
  1402. #define ADV_INTR_STATUS_INTRB 0x02
  1403. #define ADV_INTR_STATUS_INTRC 0x04
  1404. #define ADV_RISC_CSR_STOP (0x0000)
  1405. #define ADV_RISC_TEST_COND (0x2000)
  1406. #define ADV_RISC_CSR_RUN (0x4000)
  1407. #define ADV_RISC_CSR_SINGLE_STEP (0x8000)
  1408. #define ADV_CTRL_REG_HOST_INTR 0x0100
  1409. #define ADV_CTRL_REG_SEL_INTR 0x0200
  1410. #define ADV_CTRL_REG_DPR_INTR 0x0400
  1411. #define ADV_CTRL_REG_RTA_INTR 0x0800
  1412. #define ADV_CTRL_REG_RMA_INTR 0x1000
  1413. #define ADV_CTRL_REG_RES_BIT14 0x2000
  1414. #define ADV_CTRL_REG_DPE_INTR 0x4000
  1415. #define ADV_CTRL_REG_POWER_DONE 0x8000
  1416. #define ADV_CTRL_REG_ANY_INTR 0xFF00
  1417. #define ADV_CTRL_REG_CMD_RESET 0x00C6
  1418. #define ADV_CTRL_REG_CMD_WR_IO_REG 0x00C5
  1419. #define ADV_CTRL_REG_CMD_RD_IO_REG 0x00C4
  1420. #define ADV_CTRL_REG_CMD_WR_PCI_CFG_SPACE 0x00C3
  1421. #define ADV_CTRL_REG_CMD_RD_PCI_CFG_SPACE 0x00C2
  1422. #define ADV_TICKLE_NOP 0x00
  1423. #define ADV_TICKLE_A 0x01
  1424. #define ADV_TICKLE_B 0x02
  1425. #define ADV_TICKLE_C 0x03
  1426. #define AdvIsIntPending(port) \
  1427. (AdvReadWordRegister(port, IOPW_CTRL_REG) & ADV_CTRL_REG_HOST_INTR)
  1428. /*
  1429. * SCSI_CFG0 Register bit definitions
  1430. */
  1431. #define TIMER_MODEAB 0xC000 /* Watchdog, Second, and Select. Timer Ctrl. */
  1432. #define PARITY_EN 0x2000 /* Enable SCSI Parity Error detection */
  1433. #define EVEN_PARITY 0x1000 /* Select Even Parity */
  1434. #define WD_LONG 0x0800 /* Watchdog Interval, 1: 57 min, 0: 13 sec */
  1435. #define QUEUE_128 0x0400 /* Queue Size, 1: 128 byte, 0: 64 byte */
  1436. #define PRIM_MODE 0x0100 /* Primitive SCSI mode */
  1437. #define SCAM_EN 0x0080 /* Enable SCAM selection */
  1438. #define SEL_TMO_LONG 0x0040 /* Sel/Resel Timeout, 1: 400 ms, 0: 1.6 ms */
  1439. #define CFRM_ID 0x0020 /* SCAM id sel. confirm., 1: fast, 0: 6.4 ms */
  1440. #define OUR_ID_EN 0x0010 /* Enable OUR_ID bits */
  1441. #define OUR_ID 0x000F /* SCSI ID */
  1442. /*
  1443. * SCSI_CFG1 Register bit definitions
  1444. */
  1445. #define BIG_ENDIAN 0x8000 /* Enable Big Endian Mode MIO:15, EEP:15 */
  1446. #define TERM_POL 0x2000 /* Terminator Polarity Ctrl. MIO:13, EEP:13 */
  1447. #define SLEW_RATE 0x1000 /* SCSI output buffer slew rate */
  1448. #define FILTER_SEL 0x0C00 /* Filter Period Selection */
  1449. #define FLTR_DISABLE 0x0000 /* Input Filtering Disabled */
  1450. #define FLTR_11_TO_20NS 0x0800 /* Input Filtering 11ns to 20ns */
  1451. #define FLTR_21_TO_39NS 0x0C00 /* Input Filtering 21ns to 39ns */
  1452. #define ACTIVE_DBL 0x0200 /* Disable Active Negation */
  1453. #define DIFF_MODE 0x0100 /* SCSI differential Mode (Read-Only) */
  1454. #define DIFF_SENSE 0x0080 /* 1: No SE cables, 0: SE cable (Read-Only) */
  1455. #define TERM_CTL_SEL 0x0040 /* Enable TERM_CTL_H and TERM_CTL_L */
  1456. #define TERM_CTL 0x0030 /* External SCSI Termination Bits */
  1457. #define TERM_CTL_H 0x0020 /* Enable External SCSI Upper Termination */
  1458. #define TERM_CTL_L 0x0010 /* Enable External SCSI Lower Termination */
  1459. #define CABLE_DETECT 0x000F /* External SCSI Cable Connection Status */
  1460. /*
  1461. * Addendum for ASC-38C0800 Chip
  1462. *
  1463. * The ASC-38C1600 Chip uses the same definitions except that the
  1464. * bus mode override bits [12:10] have been moved to byte register
  1465. * offset 0xE (IOPB_SOFT_OVER_WR) bits [12:10]. The [12:10] bits in
  1466. * SCSI_CFG1 are read-only and always available. Bit 14 (DIS_TERM_DRV)
  1467. * is not needed. The [12:10] bits in IOPB_SOFT_OVER_WR are write-only.
  1468. * Also each ASC-38C1600 function or channel uses only cable bits [5:4]
  1469. * and [1:0]. Bits [14], [7:6], [3:2] are unused.
  1470. */
  1471. #define DIS_TERM_DRV 0x4000 /* 1: Read c_det[3:0], 0: cannot read */
  1472. #define HVD_LVD_SE 0x1C00 /* Device Detect Bits */
  1473. #define HVD 0x1000 /* HVD Device Detect */
  1474. #define LVD 0x0800 /* LVD Device Detect */
  1475. #define SE 0x0400 /* SE Device Detect */
  1476. #define TERM_LVD 0x00C0 /* LVD Termination Bits */
  1477. #define TERM_LVD_HI 0x0080 /* Enable LVD Upper Termination */
  1478. #define TERM_LVD_LO 0x0040 /* Enable LVD Lower Termination */
  1479. #define TERM_SE 0x0030 /* SE Termination Bits */
  1480. #define TERM_SE_HI 0x0020 /* Enable SE Upper Termination */
  1481. #define TERM_SE_LO 0x0010 /* Enable SE Lower Termination */
  1482. #define C_DET_LVD 0x000C /* LVD Cable Detect Bits */
  1483. #define C_DET3 0x0008 /* Cable Detect for LVD External Wide */
  1484. #define C_DET2 0x0004 /* Cable Detect for LVD Internal Wide */
  1485. #define C_DET_SE 0x0003 /* SE Cable Detect Bits */
  1486. #define C_DET1 0x0002 /* Cable Detect for SE Internal Wide */
  1487. #define C_DET0 0x0001 /* Cable Detect for SE Internal Narrow */
  1488. #define CABLE_ILLEGAL_A 0x7
  1489. /* x 0 0 0 | on on | Illegal (all 3 connectors are used) */
  1490. #define CABLE_ILLEGAL_B 0xB
  1491. /* 0 x 0 0 | on on | Illegal (all 3 connectors are used) */
  1492. /*
  1493. * MEM_CFG Register bit definitions
  1494. */
  1495. #define BIOS_EN 0x40 /* BIOS Enable MIO:14,EEP:14 */
  1496. #define FAST_EE_CLK 0x20 /* Diagnostic Bit */
  1497. #define RAM_SZ 0x1C /* Specify size of RAM to RISC */
  1498. #define RAM_SZ_2KB 0x00 /* 2 KB */
  1499. #define RAM_SZ_4KB 0x04 /* 4 KB */
  1500. #define RAM_SZ_8KB 0x08 /* 8 KB */
  1501. #define RAM_SZ_16KB 0x0C /* 16 KB */
  1502. #define RAM_SZ_32KB 0x10 /* 32 KB */
  1503. #define RAM_SZ_64KB 0x14 /* 64 KB */
  1504. /*
  1505. * DMA_CFG0 Register bit definitions
  1506. *
  1507. * This register is only accessible to the host.
  1508. */
  1509. #define BC_THRESH_ENB 0x80 /* PCI DMA Start Conditions */
  1510. #define FIFO_THRESH 0x70 /* PCI DMA FIFO Threshold */
  1511. #define FIFO_THRESH_16B 0x00 /* 16 bytes */
  1512. #define FIFO_THRESH_32B 0x20 /* 32 bytes */
  1513. #define FIFO_THRESH_48B 0x30 /* 48 bytes */
  1514. #define FIFO_THRESH_64B 0x40 /* 64 bytes */
  1515. #define FIFO_THRESH_80B 0x50 /* 80 bytes (default) */
  1516. #define FIFO_THRESH_96B 0x60 /* 96 bytes */
  1517. #define FIFO_THRESH_112B 0x70 /* 112 bytes */
  1518. #define START_CTL 0x0C /* DMA start conditions */
  1519. #define START_CTL_TH 0x00 /* Wait threshold level (default) */
  1520. #define START_CTL_ID 0x04 /* Wait SDMA/SBUS idle */
  1521. #define START_CTL_THID 0x08 /* Wait threshold and SDMA/SBUS idle */
  1522. #define START_CTL_EMFU 0x0C /* Wait SDMA FIFO empty/full */
  1523. #define READ_CMD 0x03 /* Memory Read Method */
  1524. #define READ_CMD_MR 0x00 /* Memory Read */
  1525. #define READ_CMD_MRL 0x02 /* Memory Read Long */
  1526. #define READ_CMD_MRM 0x03 /* Memory Read Multiple (default) */
  1527. /*
  1528. * ASC-38C0800 RAM BIST Register bit definitions
  1529. */
  1530. #define RAM_TEST_MODE 0x80
  1531. #define PRE_TEST_MODE 0x40
  1532. #define NORMAL_MODE 0x00
  1533. #define RAM_TEST_DONE 0x10
  1534. #define RAM_TEST_STATUS 0x0F
  1535. #define RAM_TEST_HOST_ERROR 0x08
  1536. #define RAM_TEST_INTRAM_ERROR 0x04
  1537. #define RAM_TEST_RISC_ERROR 0x02
  1538. #define RAM_TEST_SCSI_ERROR 0x01
  1539. #define RAM_TEST_SUCCESS 0x00
  1540. #define PRE_TEST_VALUE 0x05
  1541. #define NORMAL_VALUE 0x00
  1542. /*
  1543. * ASC38C1600 Definitions
  1544. *
  1545. * IOPB_PCI_INT_CFG Bit Field Definitions
  1546. */
  1547. #define INTAB_LD 0x80 /* Value loaded from EEPROM Bit 11. */
  1548. /*
  1549. * Bit 1 can be set to change the interrupt for the Function to operate in
  1550. * Totem Pole mode. By default Bit 1 is 0 and the interrupt operates in
  1551. * Open Drain mode. Both functions of the ASC38C1600 must be set to the same
  1552. * mode, otherwise the operating mode is undefined.
  1553. */
  1554. #define TOTEMPOLE 0x02
  1555. /*
  1556. * Bit 0 can be used to change the Int Pin for the Function. The value is
  1557. * 0 by default for both Functions with Function 0 using INT A and Function
  1558. * B using INT B. For Function 0 if set, INT B is used. For Function 1 if set,
  1559. * INT A is used.
  1560. *
  1561. * EEPROM Word 0 Bit 11 for each Function may change the initial Int Pin
  1562. * value specified in the PCI Configuration Space.
  1563. */
  1564. #define INTAB 0x01
  1565. /*
  1566. * Adv Library Status Definitions
  1567. */
  1568. #define ADV_TRUE 1
  1569. #define ADV_FALSE 0
  1570. #define ADV_SUCCESS 1
  1571. #define ADV_BUSY 0
  1572. #define ADV_ERROR (-1)
  1573. /*
  1574. * ADV_DVC_VAR 'warn_code' values
  1575. */
  1576. #define ASC_WARN_BUSRESET_ERROR 0x0001 /* SCSI Bus Reset error */
  1577. #define ASC_WARN_EEPROM_CHKSUM 0x0002 /* EEP check sum error */
  1578. #define ASC_WARN_EEPROM_TERMINATION 0x0004 /* EEP termination bad field */
  1579. #define ASC_WARN_ERROR 0xFFFF /* ADV_ERROR return */
  1580. #define ADV_MAX_TID 15 /* max. target identifier */
  1581. #define ADV_MAX_LUN 7 /* max. logical unit number */
  1582. /*
  1583. * Error code values are set in ADV_DVC_VAR 'err_code'.
  1584. */
  1585. #define ASC_IERR_WRITE_EEPROM 0x0001 /* write EEPROM error */
  1586. #define ASC_IERR_MCODE_CHKSUM 0x0002 /* micro code check sum error */
  1587. #define ASC_IERR_NO_CARRIER 0x0004 /* No more carrier memory. */
  1588. #define ASC_IERR_START_STOP_CHIP 0x0008 /* start/stop chip failed */
  1589. #define ASC_IERR_CHIP_VERSION 0x0040 /* wrong chip version */
  1590. #define ASC_IERR_SET_SCSI_ID 0x0080 /* set SCSI ID failed */
  1591. #define ASC_IERR_HVD_DEVICE 0x0100 /* HVD attached to LVD connector. */
  1592. #define ASC_IERR_BAD_SIGNATURE 0x0200 /* signature not found */
  1593. #define ASC_IERR_ILLEGAL_CONNECTION 0x0400 /* Illegal cable connection */
  1594. #define ASC_IERR_SINGLE_END_DEVICE 0x0800 /* Single-end used w/differential */
  1595. #define ASC_IERR_REVERSED_CABLE 0x1000 /* Narrow flat cable reversed */
  1596. #define ASC_IERR_BIST_PRE_TEST 0x2000 /* BIST pre-test error */
  1597. #define ASC_IERR_BIST_RAM_TEST 0x4000 /* BIST RAM test error */
  1598. #define ASC_IERR_BAD_CHIPTYPE 0x8000 /* Invalid 'chip_type' setting. */
  1599. /*
  1600. * Fixed locations of microcode operating variables.
  1601. */
  1602. #define ASC_MC_CODE_BEGIN_ADDR 0x0028 /* microcode start address */
  1603. #define ASC_MC_CODE_END_ADDR 0x002A /* microcode end address */
  1604. #define ASC_MC_CODE_CHK_SUM 0x002C /* microcode code checksum */
  1605. #define ASC_MC_VERSION_DATE 0x0038 /* microcode version */
  1606. #define ASC_MC_VERSION_NUM 0x003A /* microcode number */
  1607. #define ASC_MC_BIOSMEM 0x0040 /* BIOS RISC Memory Start */
  1608. #define ASC_MC_BIOSLEN 0x0050 /* BIOS RISC Memory Length */
  1609. #define ASC_MC_BIOS_SIGNATURE 0x0058 /* BIOS Signature 0x55AA */
  1610. #define ASC_MC_BIOS_VERSION 0x005A /* BIOS Version (2 bytes) */
  1611. #define ASC_MC_SDTR_SPEED1 0x0090 /* SDTR Speed for TID 0-3 */
  1612. #define ASC_MC_SDTR_SPEED2 0x0092 /* SDTR Speed for TID 4-7 */
  1613. #define ASC_MC_SDTR_SPEED3 0x0094 /* SDTR Speed for TID 8-11 */
  1614. #define ASC_MC_SDTR_SPEED4 0x0096 /* SDTR Speed for TID 12-15 */
  1615. #define ASC_MC_CHIP_TYPE 0x009A
  1616. #define ASC_MC_INTRB_CODE 0x009B
  1617. #define ASC_MC_WDTR_ABLE 0x009C
  1618. #define ASC_MC_SDTR_ABLE 0x009E
  1619. #define ASC_MC_TAGQNG_ABLE 0x00A0
  1620. #define ASC_MC_DISC_ENABLE 0x00A2
  1621. #define ASC_MC_IDLE_CMD_STATUS 0x00A4
  1622. #define ASC_MC_IDLE_CMD 0x00A6
  1623. #define ASC_MC_IDLE_CMD_PARAMETER 0x00A8
  1624. #define ASC_MC_DEFAULT_SCSI_CFG0 0x00AC
  1625. #define ASC_MC_DEFAULT_SCSI_CFG1 0x00AE
  1626. #define ASC_MC_DEFAULT_MEM_CFG 0x00B0
  1627. #define ASC_MC_DEFAULT_SEL_MASK 0x00B2
  1628. #define ASC_MC_SDTR_DONE 0x00B6
  1629. #define ASC_MC_NUMBER_OF_QUEUED_CMD 0x00C0
  1630. #define ASC_MC_NUMBER_OF_MAX_CMD 0x00D0
  1631. #define ASC_MC_DEVICE_HSHK_CFG_TABLE 0x0100
  1632. #define ASC_MC_CONTROL_FLAG 0x0122 /* Microcode control flag. */
  1633. #define ASC_MC_WDTR_DONE 0x0124
  1634. #define ASC_MC_CAM_MODE_MASK 0x015E /* CAM mode TID bitmask. */
  1635. #define ASC_MC_ICQ 0x0160
  1636. #define ASC_MC_IRQ 0x0164
  1637. #define ASC_MC_PPR_ABLE 0x017A
  1638. /*
  1639. * BIOS LRAM variable absolute offsets.
  1640. */
  1641. #define BIOS_CODESEG 0x54
  1642. #define BIOS_CODELEN 0x56
  1643. #define BIOS_SIGNATURE 0x58
  1644. #define BIOS_VERSION 0x5A
  1645. /*
  1646. * Microcode Control Flags
  1647. *
  1648. * Flags set by the Adv Library in RISC variable 'control_flag' (0x122)
  1649. * and handled by the microcode.
  1650. */
  1651. #define CONTROL_FLAG_IGNORE_PERR 0x0001 /* Ignore DMA Parity Errors */
  1652. #define CONTROL_FLAG_ENABLE_AIPP 0x0002 /* Enabled AIPP checking. */
  1653. /*
  1654. * ASC_MC_DEVICE_HSHK_CFG_TABLE microcode table or HSHK_CFG register format
  1655. */
  1656. #define HSHK_CFG_WIDE_XFR 0x8000
  1657. #define HSHK_CFG_RATE 0x0F00
  1658. #define HSHK_CFG_OFFSET 0x001F
  1659. #define ASC_DEF_MAX_HOST_QNG 0xFD /* Max. number of host commands (253) */
  1660. #define ASC_DEF_MIN_HOST_QNG 0x10 /* Min. number of host commands (16) */
  1661. #define ASC_DEF_MAX_DVC_QNG 0x3F /* Max. number commands per device (63) */
  1662. #define ASC_DEF_MIN_DVC_QNG 0x04 /* Min. number commands per device (4) */
  1663. #define ASC_QC_DATA_CHECK 0x01 /* Require ASC_QC_DATA_OUT set or clear. */
  1664. #define ASC_QC_DATA_OUT 0x02 /* Data out DMA transfer. */
  1665. #define ASC_QC_START_MOTOR 0x04 /* Send auto-start motor before request. */
  1666. #define ASC_QC_NO_OVERRUN 0x08 /* Don't report overrun. */
  1667. #define ASC_QC_FREEZE_TIDQ 0x10 /* Freeze TID queue after request. XXX TBD */
  1668. #define ASC_QSC_NO_DISC 0x01 /* Don't allow disconnect for request. */
  1669. #define ASC_QSC_NO_TAGMSG 0x02 /* Don't allow tag queuing for request. */
  1670. #define ASC_QSC_NO_SYNC 0x04 /* Don't use Synch. transfer on request. */
  1671. #define ASC_QSC_NO_WIDE 0x08 /* Don't use Wide transfer on request. */
  1672. #define ASC_QSC_REDO_DTR 0x10 /* Renegotiate WDTR/SDTR before request. */
  1673. /*
  1674. * Note: If a Tag Message is to be sent and neither ASC_QSC_HEAD_TAG or
  1675. * ASC_QSC_ORDERED_TAG is set, then a Simple Tag Message (0x20) is used.
  1676. */
  1677. #define ASC_QSC_HEAD_TAG 0x40 /* Use Head Tag Message (0x21). */
  1678. #define ASC_QSC_ORDERED_TAG 0x80 /* Use Ordered Tag Message (0x22). */
  1679. /*
  1680. * All fields here are accessed by the board microcode and need to be
  1681. * little-endian.
  1682. */
  1683. typedef struct adv_carr_t {
  1684. ADV_VADDR carr_va; /* Carrier Virtual Address */
  1685. ADV_PADDR carr_pa; /* Carrier Physical Address */
  1686. ADV_VADDR areq_vpa; /* ASC_SCSI_REQ_Q Virtual or Physical Address */
  1687. /*
  1688. * next_vpa [31:4] Carrier Virtual or Physical Next Pointer
  1689. *
  1690. * next_vpa [3:1] Reserved Bits
  1691. * next_vpa [0] Done Flag set in Response Queue.
  1692. */
  1693. ADV_VADDR next_vpa;
  1694. } ADV_CARR_T;
  1695. /*
  1696. * Mask used to eliminate low 4 bits of carrier 'next_vpa' field.
  1697. */
  1698. #define ASC_NEXT_VPA_MASK 0xFFFFFFF0
  1699. #define ASC_RQ_DONE 0x00000001
  1700. #define ASC_RQ_GOOD 0x00000002
  1701. #define ASC_CQ_STOPPER 0x00000000
  1702. #define ASC_GET_CARRP(carrp) ((carrp) & ASC_NEXT_VPA_MASK)
  1703. #define ADV_CARRIER_NUM_PAGE_CROSSING \
  1704. (((ADV_CARRIER_COUNT * sizeof(ADV_CARR_T)) + \
  1705. (ADV_PAGE_SIZE - 1))/ADV_PAGE_SIZE)
  1706. #define ADV_CARRIER_BUFSIZE \
  1707. ((ADV_CARRIER_COUNT + ADV_CARRIER_NUM_PAGE_CROSSING) * sizeof(ADV_CARR_T))
  1708. /*
  1709. * ASC_SCSI_REQ_Q 'a_flag' definitions
  1710. *
  1711. * The Adv Library should limit use to the lower nibble (4 bits) of
  1712. * a_flag. Drivers are free to use the upper nibble (4 bits) of a_flag.
  1713. */
  1714. #define ADV_POLL_REQUEST 0x01 /* poll for request completion */
  1715. #define ADV_SCSIQ_DONE 0x02 /* request done */
  1716. #define ADV_DONT_RETRY 0x08 /* don't do retry */
  1717. #define ADV_CHIP_ASC3550 0x01 /* Ultra-Wide IC */
  1718. #define ADV_CHIP_ASC38C0800 0x02 /* Ultra2-Wide/LVD IC */
  1719. #define ADV_CHIP_ASC38C1600 0x03 /* Ultra3-Wide/LVD2 IC */
  1720. /*
  1721. * Adapter temporary configuration structure
  1722. *
  1723. * This structure can be discarded after initialization. Don't add
  1724. * fields here needed after initialization.
  1725. *
  1726. * Field naming convention:
  1727. *
  1728. * *_enable indicates the field enables or disables a feature. The
  1729. * value of the field is never reset.
  1730. */
  1731. typedef struct adv_dvc_cfg {
  1732. ushort disc_enable; /* enable disconnection */
  1733. uchar chip_version; /* chip version */
  1734. uchar termination; /* Term. Ctrl. bits 6-5 of SCSI_CFG1 register */
  1735. ushort lib_version; /* Adv Library version number */
  1736. ushort control_flag; /* Microcode Control Flag */
  1737. ushort mcode_date; /* Microcode date */
  1738. ushort mcode_version; /* Microcode version */
  1739. ushort serial1; /* EEPROM serial number word 1 */
  1740. ushort serial2; /* EEPROM serial number word 2 */
  1741. ushort serial3; /* EEPROM serial number word 3 */
  1742. } ADV_DVC_CFG;
  1743. struct adv_dvc_var;
  1744. struct adv_scsi_req_q;
  1745. /*
  1746. * Adapter operation variable structure.
  1747. *
  1748. * One structure is required per host adapter.
  1749. *
  1750. * Field naming convention:
  1751. *
  1752. * *_able indicates both whether a feature should be enabled or disabled
  1753. * and whether a device isi capable of the feature. At initialization
  1754. * this field may be set, but later if a device is found to be incapable
  1755. * of the feature, the field is cleared.
  1756. */
  1757. typedef struct adv_dvc_var {
  1758. AdvPortAddr iop_base; /* I/O port address */
  1759. ushort err_code; /* fatal error code */
  1760. ushort bios_ctrl; /* BIOS control word, EEPROM word 12 */
  1761. ushort wdtr_able; /* try WDTR for a device */
  1762. ushort sdtr_able; /* try SDTR for a device */
  1763. ushort ultra_able; /* try SDTR Ultra speed for a device */
  1764. ushort sdtr_speed1; /* EEPROM SDTR Speed for TID 0-3 */
  1765. ushort sdtr_speed2; /* EEPROM SDTR Speed for TID 4-7 */
  1766. ushort sdtr_speed3; /* EEPROM SDTR Speed for TID 8-11 */
  1767. ushort sdtr_speed4; /* EEPROM SDTR Speed for TID 12-15 */
  1768. ushort tagqng_able; /* try tagged queuing with a device */
  1769. ushort ppr_able; /* PPR message capable per TID bitmask. */
  1770. uchar max_dvc_qng; /* maximum number of tagged commands per device */
  1771. ushort start_motor; /* start motor command allowed */
  1772. uchar scsi_reset_wait; /* delay in seconds after scsi bus reset */
  1773. uchar chip_no; /* should be assigned by caller */
  1774. uchar max_host_qng; /* maximum number of Q'ed command allowed */
  1775. uchar irq_no; /* IRQ number */
  1776. ushort no_scam; /* scam_tolerant of EEPROM */
  1777. struct asc_board *drv_ptr; /* driver pointer to private structure */
  1778. uchar chip_scsi_id; /* chip SCSI target ID */
  1779. uchar chip_type;
  1780. uchar bist_err_code;
  1781. ADV_CARR_T *carrier_buf;
  1782. ADV_CARR_T *carr_freelist; /* Carrier free list. */
  1783. ADV_CARR_T *icq_sp; /* Initiator command queue stopper pointer. */
  1784. ADV_CARR_T *irq_sp; /* Initiator response queue stopper pointer. */
  1785. ushort carr_pending_cnt; /* Count of pending carriers. */
  1786. /*
  1787. * Note: The following fields will not be used after initialization. The
  1788. * driver may discard the buffer after initialization is done.
  1789. */
  1790. ADV_DVC_CFG *cfg; /* temporary configuration structure */
  1791. } ADV_DVC_VAR;
  1792. #define NO_OF_SG_PER_BLOCK 15
  1793. typedef struct asc_sg_block {
  1794. uchar reserved1;
  1795. uchar reserved2;
  1796. uchar reserved3;
  1797. uchar sg_cnt; /* Valid entries in block. */
  1798. ADV_PADDR sg_ptr; /* Pointer to next sg block. */
  1799. struct {
  1800. ADV_PADDR sg_addr; /* SG element address. */
  1801. ADV_DCNT sg_count; /* SG element count. */
  1802. } sg_list[NO_OF_SG_PER_BLOCK];
  1803. } ADV_SG_BLOCK;
  1804. /*
  1805. * ADV_SCSI_REQ_Q - microcode request structure
  1806. *
  1807. * All fields in this structure up to byte 60 are used by the microcode.
  1808. * The microcode makes assumptions about the size and ordering of fields
  1809. * in this structure. Do not change the structure definition here without
  1810. * coordinating the change with the microcode.
  1811. *
  1812. * All fields accessed by microcode must be maintained in little_endian
  1813. * order.
  1814. */
  1815. typedef struct adv_scsi_req_q {
  1816. uchar cntl; /* Ucode flags and state (ASC_MC_QC_*). */
  1817. uchar target_cmd;
  1818. uchar target_id; /* Device target identifier. */
  1819. uchar target_lun; /* Device target logical unit number. */
  1820. ADV_PADDR data_addr; /* Data buffer physical address. */
  1821. ADV_DCNT data_cnt; /* Data count. Ucode sets to residual. */
  1822. ADV_PADDR sense_addr;
  1823. ADV_PADDR carr_pa;
  1824. uchar mflag;
  1825. uchar sense_len;
  1826. uchar cdb_len; /* SCSI CDB length. Must <= 16 bytes. */
  1827. uchar scsi_cntl;
  1828. uchar done_status; /* Completion status. */
  1829. uchar scsi_status; /* SCSI status byte. */
  1830. uchar host_status; /* Ucode host status. */
  1831. uchar sg_working_ix;
  1832. uchar cdb[12]; /* SCSI CDB bytes 0-11. */
  1833. ADV_PADDR sg_real_addr; /* SG list physical address. */
  1834. ADV_PADDR scsiq_rptr;
  1835. uchar cdb16[4]; /* SCSI CDB bytes 12-15. */
  1836. ADV_VADDR scsiq_ptr;
  1837. ADV_VADDR carr_va;
  1838. /*
  1839. * End of microcode structure - 60 bytes. The rest of the structure
  1840. * is used by the Adv Library and ignored by the microcode.
  1841. */
  1842. ADV_VADDR srb_ptr;
  1843. ADV_SG_BLOCK *sg_list_ptr; /* SG list virtual address. */
  1844. char *vdata_addr; /* Data buffer virtual address. */
  1845. uchar a_flag;
  1846. uchar pad[2]; /* Pad out to a word boundary. */
  1847. } ADV_SCSI_REQ_Q;
  1848. /*
  1849. * Microcode idle loop commands
  1850. */
  1851. #define IDLE_CMD_COMPLETED 0
  1852. #define IDLE_CMD_STOP_CHIP 0x0001
  1853. #define IDLE_CMD_STOP_CHIP_SEND_INT 0x0002
  1854. #define IDLE_CMD_SEND_INT 0x0004
  1855. #define IDLE_CMD_ABORT 0x0008
  1856. #define IDLE_CMD_DEVICE_RESET 0x0010
  1857. #define IDLE_CMD_SCSI_RESET_START 0x0020 /* Assert SCSI Bus Reset */
  1858. #define IDLE_CMD_SCSI_RESET_END 0x0040 /* Deassert SCSI Bus Reset */
  1859. #define IDLE_CMD_SCSIREQ 0x0080
  1860. #define IDLE_CMD_STATUS_SUCCESS 0x0001
  1861. #define IDLE_CMD_STATUS_FAILURE 0x0002
  1862. /*
  1863. * AdvSendIdleCmd() flag definitions.
  1864. */
  1865. #define ADV_NOWAIT 0x01
  1866. /*
  1867. * Wait loop time out values.
  1868. */
  1869. #define SCSI_WAIT_100_MSEC 100UL /* 100 milliseconds */
  1870. #define SCSI_US_PER_MSEC 1000 /* microseconds per millisecond */
  1871. #define SCSI_MAX_RETRY 10 /* retry count */
  1872. #define ADV_ASYNC_RDMA_FAILURE 0x01 /* Fatal RDMA failure. */
  1873. #define ADV_ASYNC_SCSI_BUS_RESET_DET 0x02 /* Detected SCSI Bus Reset. */
  1874. #define ADV_ASYNC_CARRIER_READY_FAILURE 0x03 /* Carrier Ready failure. */
  1875. #define ADV_RDMA_IN_CARR_AND_Q_INVALID 0x04 /* RDMAed-in data invalid. */
  1876. #define ADV_HOST_SCSI_BUS_RESET 0x80 /* Host Initiated SCSI Bus Reset. */
  1877. /* Read byte from a register. */
  1878. #define AdvReadByteRegister(iop_base, reg_off) \
  1879. (ADV_MEM_READB((iop_base) + (reg_off)))
  1880. /* Write byte to a register. */
  1881. #define AdvWriteByteRegister(iop_base, reg_off, byte) \
  1882. (ADV_MEM_WRITEB((iop_base) + (reg_off), (byte)))
  1883. /* Read word (2 bytes) from a register. */
  1884. #define AdvReadWordRegister(iop_base, reg_off) \
  1885. (ADV_MEM_READW((iop_base) + (reg_off)))
  1886. /* Write word (2 bytes) to a register. */
  1887. #define AdvWriteWordRegister(iop_base, reg_off, word) \
  1888. (ADV_MEM_WRITEW((iop_base) + (reg_off), (word)))
  1889. /* Write dword (4 bytes) to a register. */
  1890. #define AdvWriteDWordRegister(iop_base, reg_off, dword) \
  1891. (ADV_MEM_WRITEDW((iop_base) + (reg_off), (dword)))
  1892. /* Read byte from LRAM. */
  1893. #define AdvReadByteLram(iop_base, addr, byte) \
  1894. do { \
  1895. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
  1896. (byte) = ADV_MEM_READB((iop_base) + IOPB_RAM_DATA); \
  1897. } while (0)
  1898. /* Write byte to LRAM. */
  1899. #define AdvWriteByteLram(iop_base, addr, byte) \
  1900. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  1901. ADV_MEM_WRITEB((iop_base) + IOPB_RAM_DATA, (byte)))
  1902. /* Read word (2 bytes) from LRAM. */
  1903. #define AdvReadWordLram(iop_base, addr, word) \
  1904. do { \
  1905. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
  1906. (word) = (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA)); \
  1907. } while (0)
  1908. /* Write word (2 bytes) to LRAM. */
  1909. #define AdvWriteWordLram(iop_base, addr, word) \
  1910. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  1911. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
  1912. /* Write little-endian double word (4 bytes) to LRAM */
  1913. /* Because of unspecified C language ordering don't use auto-increment. */
  1914. #define AdvWriteDWordLramNoSwap(iop_base, addr, dword) \
  1915. ((ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
  1916. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
  1917. cpu_to_le16((ushort) ((dword) & 0xFFFF)))), \
  1918. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr) + 2), \
  1919. ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
  1920. cpu_to_le16((ushort) ((dword >> 16) & 0xFFFF)))))
  1921. /* Read word (2 bytes) from LRAM assuming that the address is already set. */
  1922. #define AdvReadWordAutoIncLram(iop_base) \
  1923. (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA))
  1924. /* Write word (2 bytes) to LRAM assuming that the address is already set. */
  1925. #define AdvWriteWordAutoIncLram(iop_base, word) \
  1926. (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
  1927. /*
  1928. * Define macro to check for Condor signature.
  1929. *
  1930. * Evaluate to ADV_TRUE if a Condor chip is found the specified port
  1931. * address 'iop_base'. Otherwise evalue to ADV_FALSE.
  1932. */
  1933. #define AdvFindSignature(iop_base) \
  1934. (((AdvReadByteRegister((iop_base), IOPB_CHIP_ID_1) == \
  1935. ADV_CHIP_ID_BYTE) && \
  1936. (AdvReadWordRegister((iop_base), IOPW_CHIP_ID_0) == \
  1937. ADV_CHIP_ID_WORD)) ? ADV_TRUE : ADV_FALSE)
  1938. /*
  1939. * Define macro to Return the version number of the chip at 'iop_base'.
  1940. *
  1941. * The second parameter 'bus_type' is currently unused.
  1942. */
  1943. #define AdvGetChipVersion(iop_base, bus_type) \
  1944. AdvReadByteRegister((iop_base), IOPB_CHIP_TYPE_REV)
  1945. /*
  1946. * Abort an SRB in the chip's RISC Memory. The 'srb_ptr' argument must
  1947. * match the ASC_SCSI_REQ_Q 'srb_ptr' field.
  1948. *
  1949. * If the request has not yet been sent to the device it will simply be
  1950. * aborted from RISC memory. If the request is disconnected it will be
  1951. * aborted on reselection by sending an Abort Message to the target ID.
  1952. *
  1953. * Return value:
  1954. * ADV_TRUE(1) - Queue was successfully aborted.
  1955. * ADV_FALSE(0) - Queue was not found on the active queue list.
  1956. */
  1957. #define AdvAbortQueue(asc_dvc, scsiq) \
  1958. AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_ABORT, \
  1959. (ADV_DCNT) (scsiq))
  1960. /*
  1961. * Send a Bus Device Reset Message to the specified target ID.
  1962. *
  1963. * All outstanding commands will be purged if sending the
  1964. * Bus Device Reset Message is successful.
  1965. *
  1966. * Return Value:
  1967. * ADV_TRUE(1) - All requests on the target are purged.
  1968. * ADV_FALSE(0) - Couldn't issue Bus Device Reset Message; Requests
  1969. * are not purged.
  1970. */
  1971. #define AdvResetDevice(asc_dvc, target_id) \
  1972. AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_DEVICE_RESET, \
  1973. (ADV_DCNT) (target_id))
  1974. /*
  1975. * SCSI Wide Type definition.
  1976. */
  1977. #define ADV_SCSI_BIT_ID_TYPE ushort
  1978. /*
  1979. * AdvInitScsiTarget() 'cntl_flag' options.
  1980. */
  1981. #define ADV_SCAN_LUN 0x01
  1982. #define ADV_CAPINFO_NOLUN 0x02
  1983. /*
  1984. * Convert target id to target id bit mask.
  1985. */
  1986. #define ADV_TID_TO_TIDMASK(tid) (0x01 << ((tid) & ADV_MAX_TID))
  1987. /*
  1988. * ASC_SCSI_REQ_Q 'done_status' and 'host_status' return values.
  1989. */
  1990. #define QD_NO_STATUS 0x00 /* Request not completed yet. */
  1991. #define QD_NO_ERROR 0x01
  1992. #define QD_ABORTED_BY_HOST 0x02
  1993. #define QD_WITH_ERROR 0x04
  1994. #define QHSTA_NO_ERROR 0x00
  1995. #define QHSTA_M_SEL_TIMEOUT 0x11
  1996. #define QHSTA_M_DATA_OVER_RUN 0x12
  1997. #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
  1998. #define QHSTA_M_QUEUE_ABORTED 0x15
  1999. #define QHSTA_M_SXFR_SDMA_ERR 0x16 /* SXFR_STATUS SCSI DMA Error */
  2000. #define QHSTA_M_SXFR_SXFR_PERR 0x17 /* SXFR_STATUS SCSI Bus Parity Error */
  2001. #define QHSTA_M_RDMA_PERR 0x18 /* RISC PCI DMA parity error */
  2002. #define QHSTA_M_SXFR_OFF_UFLW 0x19 /* SXFR_STATUS Offset Underflow */
  2003. #define QHSTA_M_SXFR_OFF_OFLW 0x20 /* SXFR_STATUS Offset Overflow */
  2004. #define QHSTA_M_SXFR_WD_TMO 0x21 /* SXFR_STATUS Watchdog Timeout */
  2005. #define QHSTA_M_SXFR_DESELECTED 0x22 /* SXFR_STATUS Deselected */
  2006. /* Note: QHSTA_M_SXFR_XFR_OFLW is identical to QHSTA_M_DATA_OVER_RUN. */
  2007. #define QHSTA_M_SXFR_XFR_OFLW 0x12 /* SXFR_STATUS Transfer Overflow */
  2008. #define QHSTA_M_SXFR_XFR_PH_ERR 0x24 /* SXFR_STATUS Transfer Phase Error */
  2009. #define QHSTA_M_SXFR_UNKNOWN_ERROR 0x25 /* SXFR_STATUS Unknown Error */
  2010. #define QHSTA_M_SCSI_BUS_RESET 0x30 /* Request aborted from SBR */
  2011. #define QHSTA_M_SCSI_BUS_RESET_UNSOL 0x31 /* Request aborted from unsol. SBR */
  2012. #define QHSTA_M_BUS_DEVICE_RESET 0x32 /* Request aborted from BDR */
  2013. #define QHSTA_M_DIRECTION_ERR 0x35 /* Data Phase mismatch */
  2014. #define QHSTA_M_DIRECTION_ERR_HUNG 0x36 /* Data Phase mismatch and bus hang */
  2015. #define QHSTA_M_WTM_TIMEOUT 0x41
  2016. #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
  2017. #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
  2018. #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
  2019. #define QHSTA_M_INVALID_DEVICE 0x45 /* Bad target ID */
  2020. #define QHSTA_M_FROZEN_TIDQ 0x46 /* TID Queue frozen. */
  2021. #define QHSTA_M_SGBACKUP_ERROR 0x47 /* Scatter-Gather backup error */
  2022. /*
  2023. * DvcGetPhyAddr() flag arguments
  2024. */
  2025. #define ADV_IS_SCSIQ_FLAG 0x01 /* 'addr' is ASC_SCSI_REQ_Q pointer */
  2026. #define ADV_ASCGETSGLIST_VADDR 0x02 /* 'addr' is AscGetSGList() virtual addr */
  2027. #define ADV_IS_SENSE_FLAG 0x04 /* 'addr' is sense virtual pointer */
  2028. #define ADV_IS_DATA_FLAG 0x08 /* 'addr' is data virtual pointer */
  2029. #define ADV_IS_SGLIST_FLAG 0x10 /* 'addr' is sglist virtual pointer */
  2030. #define ADV_IS_CARRIER_FLAG 0x20 /* 'addr' is ADV_CARR_T pointer */
  2031. /* Return the address that is aligned at the next doubleword >= to 'addr'. */
  2032. #define ADV_8BALIGN(addr) (((ulong) (addr) + 0x7) & ~0x7)
  2033. #define ADV_16BALIGN(addr) (((ulong) (addr) + 0xF) & ~0xF)
  2034. #define ADV_32BALIGN(addr) (((ulong) (addr) + 0x1F) & ~0x1F)
  2035. /*
  2036. * Total contiguous memory needed for driver SG blocks.
  2037. *
  2038. * ADV_MAX_SG_LIST must be defined by a driver. It is the maximum
  2039. * number of scatter-gather elements the driver supports in a
  2040. * single request.
  2041. */
  2042. #define ADV_SG_LIST_MAX_BYTE_SIZE \
  2043. (sizeof(ADV_SG_BLOCK) * \
  2044. ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK))
  2045. /* Reference Scsi_Host hostdata */
  2046. #define ASC_BOARDP(host) ((asc_board_t *) &((host)->hostdata))
  2047. /* asc_board_t flags */
  2048. #define ASC_IS_WIDE_BOARD 0x04 /* AdvanSys Wide Board */
  2049. #define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0)
  2050. #define ASC_WIDE_BOARD(boardp) ((boardp)->flags & ASC_IS_WIDE_BOARD)
  2051. #define NO_ISA_DMA 0xff /* No ISA DMA Channel Used */
  2052. #define ASC_INFO_SIZE 128 /* advansys_info() line size */
  2053. #ifdef CONFIG_PROC_FS
  2054. /* /proc/scsi/advansys/[0...] related definitions */
  2055. #define ASC_PRTBUF_SIZE 2048
  2056. #define ASC_PRTLINE_SIZE 160
  2057. #define ASC_PRT_NEXT() \
  2058. if (cp) { \
  2059. totlen += len; \
  2060. leftlen -= len; \
  2061. if (leftlen == 0) { \
  2062. return totlen; \
  2063. } \
  2064. cp += len; \
  2065. }
  2066. #endif /* CONFIG_PROC_FS */
  2067. /* Asc Library return codes */
  2068. #define ASC_TRUE 1
  2069. #define ASC_FALSE 0
  2070. #define ASC_NOERROR 1
  2071. #define ASC_BUSY 0
  2072. #define ASC_ERROR (-1)
  2073. /* struct scsi_cmnd function return codes */
  2074. #define STATUS_BYTE(byte) (byte)
  2075. #define MSG_BYTE(byte) ((byte) << 8)
  2076. #define HOST_BYTE(byte) ((byte) << 16)
  2077. #define DRIVER_BYTE(byte) ((byte) << 24)
  2078. #ifndef ADVANSYS_STATS
  2079. #define ASC_STATS(shost, counter)
  2080. #define ASC_STATS_ADD(shost, counter, count)
  2081. #else /* ADVANSYS_STATS */
  2082. #define ASC_STATS(shost, counter) \
  2083. (ASC_BOARDP(shost)->asc_stats.counter++)
  2084. #define ASC_STATS_ADD(shost, counter, count) \
  2085. (ASC_BOARDP(shost)->asc_stats.counter += (count))
  2086. #endif /* ADVANSYS_STATS */
  2087. #define ASC_CEILING(val, unit) (((val) + ((unit) - 1))/(unit))
  2088. /* If the result wraps when calculating tenths, return 0. */
  2089. #define ASC_TENTHS(num, den) \
  2090. (((10 * ((num)/(den))) > (((num) * 10)/(den))) ? \
  2091. 0 : ((((num) * 10)/(den)) - (10 * ((num)/(den)))))
  2092. /*
  2093. * Display a message to the console.
  2094. */
  2095. #define ASC_PRINT(s) \
  2096. { \
  2097. printk("advansys: "); \
  2098. printk(s); \
  2099. }
  2100. #define ASC_PRINT1(s, a1) \
  2101. { \
  2102. printk("advansys: "); \
  2103. printk((s), (a1)); \
  2104. }
  2105. #define ASC_PRINT2(s, a1, a2) \
  2106. { \
  2107. printk("advansys: "); \
  2108. printk((s), (a1), (a2)); \
  2109. }
  2110. #define ASC_PRINT3(s, a1, a2, a3) \
  2111. { \
  2112. printk("advansys: "); \
  2113. printk((s), (a1), (a2), (a3)); \
  2114. }
  2115. #define ASC_PRINT4(s, a1, a2, a3, a4) \
  2116. { \
  2117. printk("advansys: "); \
  2118. printk((s), (a1), (a2), (a3), (a4)); \
  2119. }
  2120. #ifndef ADVANSYS_DEBUG
  2121. #define ASC_DBG(lvl, s)
  2122. #define ASC_DBG1(lvl, s, a1)
  2123. #define ASC_DBG2(lvl, s, a1, a2)
  2124. #define ASC_DBG3(lvl, s, a1, a2, a3)
  2125. #define ASC_DBG4(lvl, s, a1, a2, a3, a4)
  2126. #define ASC_DBG_PRT_SCSI_HOST(lvl, s)
  2127. #define ASC_DBG_PRT_SCSI_CMND(lvl, s)
  2128. #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp)
  2129. #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
  2130. #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone)
  2131. #define ADV_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
  2132. #define ASC_DBG_PRT_HEX(lvl, name, start, length)
  2133. #define ASC_DBG_PRT_CDB(lvl, cdb, len)
  2134. #define ASC_DBG_PRT_SENSE(lvl, sense, len)
  2135. #define ASC_DBG_PRT_INQUIRY(lvl, inq, len)
  2136. #else /* ADVANSYS_DEBUG */
  2137. /*
  2138. * Debugging Message Levels:
  2139. * 0: Errors Only
  2140. * 1: High-Level Tracing
  2141. * 2-N: Verbose Tracing
  2142. */
  2143. #define ASC_DBG(lvl, s) \
  2144. { \
  2145. if (asc_dbglvl >= (lvl)) { \
  2146. printk(s); \
  2147. } \
  2148. }
  2149. #define ASC_DBG1(lvl, s, a1) \
  2150. { \
  2151. if (asc_dbglvl >= (lvl)) { \
  2152. printk((s), (a1)); \
  2153. } \
  2154. }
  2155. #define ASC_DBG2(lvl, s, a1, a2) \
  2156. { \
  2157. if (asc_dbglvl >= (lvl)) { \
  2158. printk((s), (a1), (a2)); \
  2159. } \
  2160. }
  2161. #define ASC_DBG3(lvl, s, a1, a2, a3) \
  2162. { \
  2163. if (asc_dbglvl >= (lvl)) { \
  2164. printk((s), (a1), (a2), (a3)); \
  2165. } \
  2166. }
  2167. #define ASC_DBG4(lvl, s, a1, a2, a3, a4) \
  2168. { \
  2169. if (asc_dbglvl >= (lvl)) { \
  2170. printk((s), (a1), (a2), (a3), (a4)); \
  2171. } \
  2172. }
  2173. #define ASC_DBG_PRT_SCSI_HOST(lvl, s) \
  2174. { \
  2175. if (asc_dbglvl >= (lvl)) { \
  2176. asc_prt_scsi_host(s); \
  2177. } \
  2178. }
  2179. #define ASC_DBG_PRT_SCSI_CMND(lvl, s) \
  2180. { \
  2181. if (asc_dbglvl >= (lvl)) { \
  2182. asc_prt_scsi_cmnd(s); \
  2183. } \
  2184. }
  2185. #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp) \
  2186. { \
  2187. if (asc_dbglvl >= (lvl)) { \
  2188. asc_prt_asc_scsi_q(scsiqp); \
  2189. } \
  2190. }
  2191. #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone) \
  2192. { \
  2193. if (asc_dbglvl >= (lvl)) { \
  2194. asc_prt_asc_qdone_info(qdone); \
  2195. } \
  2196. }
  2197. #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp) \
  2198. { \
  2199. if (asc_dbglvl >= (lvl)) { \
  2200. asc_prt_adv_scsi_req_q(scsiqp); \
  2201. } \
  2202. }
  2203. #define ASC_DBG_PRT_HEX(lvl, name, start, length) \
  2204. { \
  2205. if (asc_dbglvl >= (lvl)) { \
  2206. asc_prt_hex((name), (start), (length)); \
  2207. } \
  2208. }
  2209. #define ASC_DBG_PRT_CDB(lvl, cdb, len) \
  2210. ASC_DBG_PRT_HEX((lvl), "CDB", (uchar *) (cdb), (len));
  2211. #define ASC_DBG_PRT_SENSE(lvl, sense, len) \
  2212. ASC_DBG_PRT_HEX((lvl), "SENSE", (uchar *) (sense), (len));
  2213. #define ASC_DBG_PRT_INQUIRY(lvl, inq, len) \
  2214. ASC_DBG_PRT_HEX((lvl), "INQUIRY", (uchar *) (inq), (len));
  2215. #endif /* ADVANSYS_DEBUG */
  2216. #ifdef ADVANSYS_STATS
  2217. /* Per board statistics structure */
  2218. struct asc_stats {
  2219. /* Driver Entrypoint Statistics */
  2220. ADV_DCNT queuecommand; /* # calls to advansys_queuecommand() */
  2221. ADV_DCNT reset; /* # calls to advansys_eh_bus_reset() */
  2222. ADV_DCNT biosparam; /* # calls to advansys_biosparam() */
  2223. ADV_DCNT interrupt; /* # advansys_interrupt() calls */
  2224. ADV_DCNT callback; /* # calls to asc/adv_isr_callback() */
  2225. ADV_DCNT done; /* # calls to request's scsi_done function */
  2226. ADV_DCNT build_error; /* # asc/adv_build_req() ASC_ERROR returns. */
  2227. ADV_DCNT adv_build_noreq; /* # adv_build_req() adv_req_t alloc. fail. */
  2228. ADV_DCNT adv_build_nosg; /* # adv_build_req() adv_sgblk_t alloc. fail. */
  2229. /* AscExeScsiQueue()/AdvExeScsiQueue() Statistics */
  2230. ADV_DCNT exe_noerror; /* # ASC_NOERROR returns. */
  2231. ADV_DCNT exe_busy; /* # ASC_BUSY returns. */
  2232. ADV_DCNT exe_error; /* # ASC_ERROR returns. */
  2233. ADV_DCNT exe_unknown; /* # unknown returns. */
  2234. /* Data Transfer Statistics */
  2235. ADV_DCNT cont_cnt; /* # non-scatter-gather I/O requests received */
  2236. ADV_DCNT cont_xfer; /* # contiguous transfer 512-bytes */
  2237. ADV_DCNT sg_cnt; /* # scatter-gather I/O requests received */
  2238. ADV_DCNT sg_elem; /* # scatter-gather elements */
  2239. ADV_DCNT sg_xfer; /* # scatter-gather transfer 512-bytes */
  2240. };
  2241. #endif /* ADVANSYS_STATS */
  2242. /*
  2243. * Adv Library Request Structures
  2244. *
  2245. * The following two structures are used to process Wide Board requests.
  2246. *
  2247. * The ADV_SCSI_REQ_Q structure in adv_req_t is passed to the Adv Library
  2248. * and microcode with the ADV_SCSI_REQ_Q field 'srb_ptr' pointing to the
  2249. * adv_req_t. The adv_req_t structure 'cmndp' field in turn points to the
  2250. * Mid-Level SCSI request structure.
  2251. *
  2252. * Zero or more ADV_SG_BLOCK are used with each ADV_SCSI_REQ_Q. Each
  2253. * ADV_SG_BLOCK structure holds 15 scatter-gather elements. Under Linux
  2254. * up to 255 scatter-gather elements may be used per request or
  2255. * ADV_SCSI_REQ_Q.
  2256. *
  2257. * Both structures must be 32 byte aligned.
  2258. */
  2259. typedef struct adv_sgblk {
  2260. ADV_SG_BLOCK sg_block; /* Sgblock structure. */
  2261. uchar align[32]; /* Sgblock structure padding. */
  2262. struct adv_sgblk *next_sgblkp; /* Next scatter-gather structure. */
  2263. } adv_sgblk_t;
  2264. typedef struct adv_req {
  2265. ADV_SCSI_REQ_Q scsi_req_q; /* Adv Library request structure. */
  2266. uchar align[32]; /* Request structure padding. */
  2267. struct scsi_cmnd *cmndp; /* Mid-Level SCSI command pointer. */
  2268. adv_sgblk_t *sgblkp; /* Adv Library scatter-gather pointer. */
  2269. struct adv_req *next_reqp; /* Next Request Structure. */
  2270. } adv_req_t;
  2271. /*
  2272. * Structure allocated for each board.
  2273. *
  2274. * This structure is allocated by scsi_host_alloc() at the end
  2275. * of the 'Scsi_Host' structure starting at the 'hostdata'
  2276. * field. It is guaranteed to be allocated from DMA-able memory.
  2277. */
  2278. typedef struct asc_board {
  2279. struct device *dev;
  2280. int id; /* Board Id */
  2281. uint flags; /* Board flags */
  2282. union {
  2283. ASC_DVC_VAR asc_dvc_var; /* Narrow board */
  2284. ADV_DVC_VAR adv_dvc_var; /* Wide board */
  2285. } dvc_var;
  2286. union {
  2287. ASC_DVC_CFG asc_dvc_cfg; /* Narrow board */
  2288. ADV_DVC_CFG adv_dvc_cfg; /* Wide board */
  2289. } dvc_cfg;
  2290. ushort asc_n_io_port; /* Number I/O ports. */
  2291. ADV_SCSI_BIT_ID_TYPE init_tidmask; /* Target init./valid mask */
  2292. ushort reqcnt[ADV_MAX_TID + 1]; /* Starvation request count */
  2293. ADV_SCSI_BIT_ID_TYPE queue_full; /* Queue full mask */
  2294. ushort queue_full_cnt[ADV_MAX_TID + 1]; /* Queue full count */
  2295. union {
  2296. ASCEEP_CONFIG asc_eep; /* Narrow EEPROM config. */
  2297. ADVEEP_3550_CONFIG adv_3550_eep; /* 3550 EEPROM config. */
  2298. ADVEEP_38C0800_CONFIG adv_38C0800_eep; /* 38C0800 EEPROM config. */
  2299. ADVEEP_38C1600_CONFIG adv_38C1600_eep; /* 38C1600 EEPROM config. */
  2300. } eep_config;
  2301. ulong last_reset; /* Saved last reset time */
  2302. spinlock_t lock; /* Board spinlock */
  2303. /* /proc/scsi/advansys/[0...] */
  2304. char *prtbuf; /* /proc print buffer */
  2305. #ifdef ADVANSYS_STATS
  2306. struct asc_stats asc_stats; /* Board statistics */
  2307. #endif /* ADVANSYS_STATS */
  2308. /*
  2309. * The following fields are used only for Narrow Boards.
  2310. */
  2311. uchar sdtr_data[ASC_MAX_TID + 1]; /* SDTR information */
  2312. /*
  2313. * The following fields are used only for Wide Boards.
  2314. */
  2315. void __iomem *ioremap_addr; /* I/O Memory remap address. */
  2316. ushort ioport; /* I/O Port address. */
  2317. ADV_CARR_T *carrp; /* ADV_CARR_T memory block. */
  2318. adv_req_t *orig_reqp; /* adv_req_t memory block. */
  2319. adv_req_t *adv_reqp; /* Request structures. */
  2320. adv_sgblk_t *adv_sgblkp; /* Scatter-gather structures. */
  2321. ushort bios_signature; /* BIOS Signature. */
  2322. ushort bios_version; /* BIOS Version. */
  2323. ushort bios_codeseg; /* BIOS Code Segment. */
  2324. ushort bios_codelen; /* BIOS Code Segment Length. */
  2325. } asc_board_t;
  2326. #define adv_dvc_to_board(adv_dvc) container_of(adv_dvc, struct asc_board, \
  2327. dvc_var.adv_dvc_var)
  2328. #define adv_dvc_to_pdev(adv_dvc) to_pci_dev(adv_dvc_to_board(adv_dvc)->dev)
  2329. /* Number of boards detected in system. */
  2330. static int asc_board_count;
  2331. /* Overrun buffer used by all narrow boards. */
  2332. static uchar overrun_buf[ASC_OVERRUN_BSIZE] = { 0 };
  2333. #ifdef ADVANSYS_DEBUG
  2334. static int asc_dbglvl = 3;
  2335. /*
  2336. * asc_prt_scsi_host()
  2337. */
  2338. static void asc_prt_scsi_host(struct Scsi_Host *s)
  2339. {
  2340. asc_board_t *boardp;
  2341. boardp = ASC_BOARDP(s);
  2342. printk("Scsi_Host at addr 0x%lx\n", (ulong)s);
  2343. printk(" host_busy %u, host_no %d, last_reset %d,\n",
  2344. s->host_busy, s->host_no, (unsigned)s->last_reset);
  2345. printk(" base 0x%lx, io_port 0x%lx, irq 0x%x,\n",
  2346. (ulong)s->base, (ulong)s->io_port, s->irq);
  2347. printk(" dma_channel %d, this_id %d, can_queue %d,\n",
  2348. s->dma_channel, s->this_id, s->can_queue);
  2349. printk(" cmd_per_lun %d, sg_tablesize %d, unchecked_isa_dma %d\n",
  2350. s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma);
  2351. if (ASC_NARROW_BOARD(boardp)) {
  2352. asc_prt_asc_dvc_var(&ASC_BOARDP(s)->dvc_var.asc_dvc_var);
  2353. asc_prt_asc_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.asc_dvc_cfg);
  2354. } else {
  2355. asc_prt_adv_dvc_var(&ASC_BOARDP(s)->dvc_var.adv_dvc_var);
  2356. asc_prt_adv_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.adv_dvc_cfg);
  2357. }
  2358. }
  2359. /*
  2360. * asc_prt_scsi_cmnd()
  2361. */
  2362. static void asc_prt_scsi_cmnd(struct scsi_cmnd *s)
  2363. {
  2364. printk("struct scsi_cmnd at addr 0x%lx\n", (ulong)s);
  2365. printk(" host 0x%lx, device 0x%lx, target %u, lun %u, channel %u,\n",
  2366. (ulong)s->device->host, (ulong)s->device, s->device->id,
  2367. s->device->lun, s->device->channel);
  2368. asc_prt_hex(" CDB", s->cmnd, s->cmd_len);
  2369. printk("sc_data_direction %u, resid %d\n",
  2370. s->sc_data_direction, s->resid);
  2371. printk(" use_sg %u, sglist_len %u\n", s->use_sg, s->sglist_len);
  2372. printk(" serial_number 0x%x, retries %d, allowed %d\n",
  2373. (unsigned)s->serial_number, s->retries, s->allowed);
  2374. printk(" timeout_per_command %d\n", s->timeout_per_command);
  2375. printk(" scsi_done 0x%p, done 0x%p, host_scribble 0x%p, result 0x%x\n",
  2376. s->scsi_done, s->done, s->host_scribble, s->result);
  2377. printk(" tag %u, pid %u\n", (unsigned)s->tag, (unsigned)s->pid);
  2378. }
  2379. /*
  2380. * asc_prt_asc_dvc_var()
  2381. */
  2382. static void asc_prt_asc_dvc_var(ASC_DVC_VAR *h)
  2383. {
  2384. printk("ASC_DVC_VAR at addr 0x%lx\n", (ulong)h);
  2385. printk(" iop_base 0x%x, err_code 0x%x, dvc_cntl 0x%x, bug_fix_cntl "
  2386. "%d,\n", h->iop_base, h->err_code, h->dvc_cntl, h->bug_fix_cntl);
  2387. printk(" bus_type %d, init_sdtr 0x%x,\n", h->bus_type,
  2388. (unsigned)h->init_sdtr);
  2389. printk(" sdtr_done 0x%x, use_tagged_qng 0x%x, unit_not_ready 0x%x, "
  2390. "chip_no 0x%x,\n", (unsigned)h->sdtr_done,
  2391. (unsigned)h->use_tagged_qng, (unsigned)h->unit_not_ready,
  2392. (unsigned)h->chip_no);
  2393. printk(" queue_full_or_busy 0x%x, start_motor 0x%x, scsi_reset_wait "
  2394. "%u,\n", (unsigned)h->queue_full_or_busy,
  2395. (unsigned)h->start_motor, (unsigned)h->scsi_reset_wait);
  2396. printk(" is_in_int %u, max_total_qng %u, cur_total_qng %u, "
  2397. "in_critical_cnt %u,\n", (unsigned)h->is_in_int,
  2398. (unsigned)h->max_total_qng, (unsigned)h->cur_total_qng,
  2399. (unsigned)h->in_critical_cnt);
  2400. printk(" last_q_shortage %u, init_state 0x%x, no_scam 0x%x, "
  2401. "pci_fix_asyn_xfer 0x%x,\n", (unsigned)h->last_q_shortage,
  2402. (unsigned)h->init_state, (unsigned)h->no_scam,
  2403. (unsigned)h->pci_fix_asyn_xfer);
  2404. printk(" cfg 0x%lx, irq_no 0x%x\n", (ulong)h->cfg, (unsigned)h->irq_no);
  2405. }
  2406. /*
  2407. * asc_prt_asc_dvc_cfg()
  2408. */
  2409. static void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *h)
  2410. {
  2411. printk("ASC_DVC_CFG at addr 0x%lx\n", (ulong)h);
  2412. printk(" can_tagged_qng 0x%x, cmd_qng_enabled 0x%x,\n",
  2413. h->can_tagged_qng, h->cmd_qng_enabled);
  2414. printk(" disc_enable 0x%x, sdtr_enable 0x%x,\n",
  2415. h->disc_enable, h->sdtr_enable);
  2416. printk
  2417. (" chip_scsi_id %d, isa_dma_speed %d, isa_dma_channel %d, chip_version %d,\n",
  2418. h->chip_scsi_id, h->isa_dma_speed, h->isa_dma_channel,
  2419. h->chip_version);
  2420. printk
  2421. (" pci_device_id %d, lib_serial_no %u, lib_version %u, mcode_date 0x%x,\n",
  2422. to_pci_dev(h->dev)->device, h->lib_serial_no, h->lib_version,
  2423. h->mcode_date);
  2424. printk(" mcode_version %d, overrun_buf 0x%lx\n",
  2425. h->mcode_version, (ulong)h->overrun_buf);
  2426. }
  2427. /*
  2428. * asc_prt_asc_scsi_q()
  2429. */
  2430. static void asc_prt_asc_scsi_q(ASC_SCSI_Q *q)
  2431. {
  2432. ASC_SG_HEAD *sgp;
  2433. int i;
  2434. printk("ASC_SCSI_Q at addr 0x%lx\n", (ulong)q);
  2435. printk
  2436. (" target_ix 0x%x, target_lun %u, srb_ptr 0x%lx, tag_code 0x%x,\n",
  2437. q->q2.target_ix, q->q1.target_lun, (ulong)q->q2.srb_ptr,
  2438. q->q2.tag_code);
  2439. printk
  2440. (" data_addr 0x%lx, data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  2441. (ulong)le32_to_cpu(q->q1.data_addr),
  2442. (ulong)le32_to_cpu(q->q1.data_cnt),
  2443. (ulong)le32_to_cpu(q->q1.sense_addr), q->q1.sense_len);
  2444. printk(" cdbptr 0x%lx, cdb_len %u, sg_head 0x%lx, sg_queue_cnt %u\n",
  2445. (ulong)q->cdbptr, q->q2.cdb_len,
  2446. (ulong)q->sg_head, q->q1.sg_queue_cnt);
  2447. if (q->sg_head) {
  2448. sgp = q->sg_head;
  2449. printk("ASC_SG_HEAD at addr 0x%lx\n", (ulong)sgp);
  2450. printk(" entry_cnt %u, queue_cnt %u\n", sgp->entry_cnt,
  2451. sgp->queue_cnt);
  2452. for (i = 0; i < sgp->entry_cnt; i++) {
  2453. printk(" [%u]: addr 0x%lx, bytes %lu\n",
  2454. i, (ulong)le32_to_cpu(sgp->sg_list[i].addr),
  2455. (ulong)le32_to_cpu(sgp->sg_list[i].bytes));
  2456. }
  2457. }
  2458. }
  2459. /*
  2460. * asc_prt_asc_qdone_info()
  2461. */
  2462. static void asc_prt_asc_qdone_info(ASC_QDONE_INFO *q)
  2463. {
  2464. printk("ASC_QDONE_INFO at addr 0x%lx\n", (ulong)q);
  2465. printk(" srb_ptr 0x%lx, target_ix %u, cdb_len %u, tag_code %u,\n",
  2466. (ulong)q->d2.srb_ptr, q->d2.target_ix, q->d2.cdb_len,
  2467. q->d2.tag_code);
  2468. printk
  2469. (" done_stat 0x%x, host_stat 0x%x, scsi_stat 0x%x, scsi_msg 0x%x\n",
  2470. q->d3.done_stat, q->d3.host_stat, q->d3.scsi_stat, q->d3.scsi_msg);
  2471. }
  2472. /*
  2473. * asc_prt_adv_dvc_var()
  2474. *
  2475. * Display an ADV_DVC_VAR structure.
  2476. */
  2477. static void asc_prt_adv_dvc_var(ADV_DVC_VAR *h)
  2478. {
  2479. printk(" ADV_DVC_VAR at addr 0x%lx\n", (ulong)h);
  2480. printk(" iop_base 0x%lx, err_code 0x%x, ultra_able 0x%x\n",
  2481. (ulong)h->iop_base, h->err_code, (unsigned)h->ultra_able);
  2482. printk(" isr_callback 0x%lx, sdtr_able 0x%x, wdtr_able 0x%x\n",
  2483. (ulong)h->isr_callback, (unsigned)h->sdtr_able,
  2484. (unsigned)h->wdtr_able);
  2485. printk(" start_motor 0x%x, scsi_reset_wait 0x%x, irq_no 0x%x,\n",
  2486. (unsigned)h->start_motor,
  2487. (unsigned)h->scsi_reset_wait, (unsigned)h->irq_no);
  2488. printk(" max_host_qng %u, max_dvc_qng %u, carr_freelist 0x%lxn\n",
  2489. (unsigned)h->max_host_qng, (unsigned)h->max_dvc_qng,
  2490. (ulong)h->carr_freelist);
  2491. printk(" icq_sp 0x%lx, irq_sp 0x%lx\n",
  2492. (ulong)h->icq_sp, (ulong)h->irq_sp);
  2493. printk(" no_scam 0x%x, tagqng_able 0x%x\n",
  2494. (unsigned)h->no_scam, (unsigned)h->tagqng_able);
  2495. printk(" chip_scsi_id 0x%x, cfg 0x%lx\n",
  2496. (unsigned)h->chip_scsi_id, (ulong)h->cfg);
  2497. }
  2498. /*
  2499. * asc_prt_adv_dvc_cfg()
  2500. *
  2501. * Display an ADV_DVC_CFG structure.
  2502. */
  2503. static void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *h)
  2504. {
  2505. printk(" ADV_DVC_CFG at addr 0x%lx\n", (ulong)h);
  2506. printk(" disc_enable 0x%x, termination 0x%x\n",
  2507. h->disc_enable, h->termination);
  2508. printk(" chip_version 0x%x, mcode_date 0x%x\n",
  2509. h->chip_version, h->mcode_date);
  2510. printk(" mcode_version 0x%x, pci_device_id 0x%x, lib_version %u\n",
  2511. h->mcode_version, to_pci_dev(h->dev)->device, h->lib_version);
  2512. printk(" control_flag 0x%x\n", h->control_flag);
  2513. }
  2514. /*
  2515. * asc_prt_adv_scsi_req_q()
  2516. *
  2517. * Display an ADV_SCSI_REQ_Q structure.
  2518. */
  2519. static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
  2520. {
  2521. int sg_blk_cnt;
  2522. struct asc_sg_block *sg_ptr;
  2523. printk("ADV_SCSI_REQ_Q at addr 0x%lx\n", (ulong)q);
  2524. printk(" target_id %u, target_lun %u, srb_ptr 0x%lx, a_flag 0x%x\n",
  2525. q->target_id, q->target_lun, (ulong)q->srb_ptr, q->a_flag);
  2526. printk(" cntl 0x%x, data_addr 0x%lx, vdata_addr 0x%lx\n",
  2527. q->cntl, (ulong)le32_to_cpu(q->data_addr), (ulong)q->vdata_addr);
  2528. printk(" data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
  2529. (ulong)le32_to_cpu(q->data_cnt),
  2530. (ulong)le32_to_cpu(q->sense_addr), q->sense_len);
  2531. printk
  2532. (" cdb_len %u, done_status 0x%x, host_status 0x%x, scsi_status 0x%x\n",
  2533. q->cdb_len, q->done_status, q->host_status, q->scsi_status);
  2534. printk(" sg_working_ix 0x%x, target_cmd %u\n",
  2535. q->sg_working_ix, q->target_cmd);
  2536. printk(" scsiq_rptr 0x%lx, sg_real_addr 0x%lx, sg_list_ptr 0x%lx\n",
  2537. (ulong)le32_to_cpu(q->scsiq_rptr),
  2538. (ulong)le32_to_cpu(q->sg_real_addr), (ulong)q->sg_list_ptr);
  2539. /* Display the request's ADV_SG_BLOCK structures. */
  2540. if (q->sg_list_ptr != NULL) {
  2541. sg_blk_cnt = 0;
  2542. while (1) {
  2543. /*
  2544. * 'sg_ptr' is a physical address. Convert it to a virtual
  2545. * address by indexing 'sg_blk_cnt' into the virtual address
  2546. * array 'sg_list_ptr'.
  2547. *
  2548. * XXX - Assumes all SG physical blocks are virtually contiguous.
  2549. */
  2550. sg_ptr =
  2551. &(((ADV_SG_BLOCK *)(q->sg_list_ptr))[sg_blk_cnt]);
  2552. asc_prt_adv_sgblock(sg_blk_cnt, sg_ptr);
  2553. if (sg_ptr->sg_ptr == 0) {
  2554. break;
  2555. }
  2556. sg_blk_cnt++;
  2557. }
  2558. }
  2559. }
  2560. /*
  2561. * asc_prt_adv_sgblock()
  2562. *
  2563. * Display an ADV_SG_BLOCK structure.
  2564. */
  2565. static void asc_prt_adv_sgblock(int sgblockno, ADV_SG_BLOCK *b)
  2566. {
  2567. int i;
  2568. printk(" ASC_SG_BLOCK at addr 0x%lx (sgblockno %d)\n",
  2569. (ulong)b, sgblockno);
  2570. printk(" sg_cnt %u, sg_ptr 0x%lx\n",
  2571. b->sg_cnt, (ulong)le32_to_cpu(b->sg_ptr));
  2572. BUG_ON(b->sg_cnt > NO_OF_SG_PER_BLOCK);
  2573. if (b->sg_ptr != 0)
  2574. BUG_ON(b->sg_cnt != NO_OF_SG_PER_BLOCK);
  2575. for (i = 0; i < b->sg_cnt; i++) {
  2576. printk(" [%u]: sg_addr 0x%lx, sg_count 0x%lx\n",
  2577. i, (ulong)b->sg_list[i].sg_addr,
  2578. (ulong)b->sg_list[i].sg_count);
  2579. }
  2580. }
  2581. /*
  2582. * asc_prt_hex()
  2583. *
  2584. * Print hexadecimal output in 4 byte groupings 32 bytes
  2585. * or 8 double-words per line.
  2586. */
  2587. static void asc_prt_hex(char *f, uchar *s, int l)
  2588. {
  2589. int i;
  2590. int j;
  2591. int k;
  2592. int m;
  2593. printk("%s: (%d bytes)\n", f, l);
  2594. for (i = 0; i < l; i += 32) {
  2595. /* Display a maximum of 8 double-words per line. */
  2596. if ((k = (l - i) / 4) >= 8) {
  2597. k = 8;
  2598. m = 0;
  2599. } else {
  2600. m = (l - i) % 4;
  2601. }
  2602. for (j = 0; j < k; j++) {
  2603. printk(" %2.2X%2.2X%2.2X%2.2X",
  2604. (unsigned)s[i + (j * 4)],
  2605. (unsigned)s[i + (j * 4) + 1],
  2606. (unsigned)s[i + (j * 4) + 2],
  2607. (unsigned)s[i + (j * 4) + 3]);
  2608. }
  2609. switch (m) {
  2610. case 0:
  2611. default:
  2612. break;
  2613. case 1:
  2614. printk(" %2.2X", (unsigned)s[i + (j * 4)]);
  2615. break;
  2616. case 2:
  2617. printk(" %2.2X%2.2X",
  2618. (unsigned)s[i + (j * 4)],
  2619. (unsigned)s[i + (j * 4) + 1]);
  2620. break;
  2621. case 3:
  2622. printk(" %2.2X%2.2X%2.2X",
  2623. (unsigned)s[i + (j * 4) + 1],
  2624. (unsigned)s[i + (j * 4) + 2],
  2625. (unsigned)s[i + (j * 4) + 3]);
  2626. break;
  2627. }
  2628. printk("\n");
  2629. }
  2630. }
  2631. #endif /* ADVANSYS_DEBUG */
  2632. /*
  2633. * advansys_info()
  2634. *
  2635. * Return suitable for printing on the console with the argument
  2636. * adapter's configuration information.
  2637. *
  2638. * Note: The information line should not exceed ASC_INFO_SIZE bytes,
  2639. * otherwise the static 'info' array will be overrun.
  2640. */
  2641. static const char *advansys_info(struct Scsi_Host *shost)
  2642. {
  2643. static char info[ASC_INFO_SIZE];
  2644. asc_board_t *boardp;
  2645. ASC_DVC_VAR *asc_dvc_varp;
  2646. ADV_DVC_VAR *adv_dvc_varp;
  2647. char *busname;
  2648. char *widename = NULL;
  2649. boardp = ASC_BOARDP(shost);
  2650. if (ASC_NARROW_BOARD(boardp)) {
  2651. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  2652. ASC_DBG(1, "advansys_info: begin\n");
  2653. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  2654. if ((asc_dvc_varp->bus_type & ASC_IS_ISAPNP) ==
  2655. ASC_IS_ISAPNP) {
  2656. busname = "ISA PnP";
  2657. } else {
  2658. busname = "ISA";
  2659. }
  2660. sprintf(info,
  2661. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X, DMA 0x%X",
  2662. ASC_VERSION, busname,
  2663. (ulong)shost->io_port,
  2664. (ulong)shost->io_port + ASC_IOADR_GAP - 1,
  2665. shost->irq, shost->dma_channel);
  2666. } else {
  2667. if (asc_dvc_varp->bus_type & ASC_IS_VL) {
  2668. busname = "VL";
  2669. } else if (asc_dvc_varp->bus_type & ASC_IS_EISA) {
  2670. busname = "EISA";
  2671. } else if (asc_dvc_varp->bus_type & ASC_IS_PCI) {
  2672. if ((asc_dvc_varp->bus_type & ASC_IS_PCI_ULTRA)
  2673. == ASC_IS_PCI_ULTRA) {
  2674. busname = "PCI Ultra";
  2675. } else {
  2676. busname = "PCI";
  2677. }
  2678. } else {
  2679. busname = "?";
  2680. ASC_PRINT2("advansys_info: board %d: unknown "
  2681. "bus type %d\n", boardp->id,
  2682. asc_dvc_varp->bus_type);
  2683. }
  2684. sprintf(info,
  2685. "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X",
  2686. ASC_VERSION, busname, (ulong)shost->io_port,
  2687. (ulong)shost->io_port + ASC_IOADR_GAP - 1,
  2688. shost->irq);
  2689. }
  2690. } else {
  2691. /*
  2692. * Wide Adapter Information
  2693. *
  2694. * Memory-mapped I/O is used instead of I/O space to access
  2695. * the adapter, but display the I/O Port range. The Memory
  2696. * I/O address is displayed through the driver /proc file.
  2697. */
  2698. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  2699. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  2700. widename = "Ultra-Wide";
  2701. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  2702. widename = "Ultra2-Wide";
  2703. } else {
  2704. widename = "Ultra3-Wide";
  2705. }
  2706. sprintf(info,
  2707. "AdvanSys SCSI %s: PCI %s: PCIMEM 0x%lX-0x%lX, IRQ 0x%X",
  2708. ASC_VERSION, widename, (ulong)adv_dvc_varp->iop_base,
  2709. (ulong)adv_dvc_varp->iop_base + boardp->asc_n_io_port - 1, shost->irq);
  2710. }
  2711. BUG_ON(strlen(info) >= ASC_INFO_SIZE);
  2712. ASC_DBG(1, "advansys_info: end\n");
  2713. return info;
  2714. }
  2715. #ifdef CONFIG_PROC_FS
  2716. /*
  2717. * asc_prt_line()
  2718. *
  2719. * If 'cp' is NULL print to the console, otherwise print to a buffer.
  2720. *
  2721. * Return 0 if printing to the console, otherwise return the number of
  2722. * bytes written to the buffer.
  2723. *
  2724. * Note: If any single line is greater than ASC_PRTLINE_SIZE bytes the stack
  2725. * will be corrupted. 's[]' is defined to be ASC_PRTLINE_SIZE bytes.
  2726. */
  2727. static int asc_prt_line(char *buf, int buflen, char *fmt, ...)
  2728. {
  2729. va_list args;
  2730. int ret;
  2731. char s[ASC_PRTLINE_SIZE];
  2732. va_start(args, fmt);
  2733. ret = vsprintf(s, fmt, args);
  2734. BUG_ON(ret >= ASC_PRTLINE_SIZE);
  2735. if (buf == NULL) {
  2736. (void)printk(s);
  2737. ret = 0;
  2738. } else {
  2739. ret = min(buflen, ret);
  2740. memcpy(buf, s, ret);
  2741. }
  2742. va_end(args);
  2743. return ret;
  2744. }
  2745. /*
  2746. * asc_prt_board_devices()
  2747. *
  2748. * Print driver information for devices attached to the board.
  2749. *
  2750. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  2751. * cf. asc_prt_line().
  2752. *
  2753. * Return the number of characters copied into 'cp'. No more than
  2754. * 'cplen' characters will be copied to 'cp'.
  2755. */
  2756. static int asc_prt_board_devices(struct Scsi_Host *shost, char *cp, int cplen)
  2757. {
  2758. asc_board_t *boardp;
  2759. int leftlen;
  2760. int totlen;
  2761. int len;
  2762. int chip_scsi_id;
  2763. int i;
  2764. boardp = ASC_BOARDP(shost);
  2765. leftlen = cplen;
  2766. totlen = len = 0;
  2767. len = asc_prt_line(cp, leftlen,
  2768. "\nDevice Information for AdvanSys SCSI Host %d:\n",
  2769. shost->host_no);
  2770. ASC_PRT_NEXT();
  2771. if (ASC_NARROW_BOARD(boardp)) {
  2772. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  2773. } else {
  2774. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  2775. }
  2776. len = asc_prt_line(cp, leftlen, "Target IDs Detected:");
  2777. ASC_PRT_NEXT();
  2778. for (i = 0; i <= ADV_MAX_TID; i++) {
  2779. if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) {
  2780. len = asc_prt_line(cp, leftlen, " %X,", i);
  2781. ASC_PRT_NEXT();
  2782. }
  2783. }
  2784. len = asc_prt_line(cp, leftlen, " (%X=Host Adapter)\n", chip_scsi_id);
  2785. ASC_PRT_NEXT();
  2786. return totlen;
  2787. }
  2788. /*
  2789. * Display Wide Board BIOS Information.
  2790. */
  2791. static int asc_prt_adv_bios(struct Scsi_Host *shost, char *cp, int cplen)
  2792. {
  2793. asc_board_t *boardp;
  2794. int leftlen;
  2795. int totlen;
  2796. int len;
  2797. ushort major, minor, letter;
  2798. boardp = ASC_BOARDP(shost);
  2799. leftlen = cplen;
  2800. totlen = len = 0;
  2801. len = asc_prt_line(cp, leftlen, "\nROM BIOS Version: ");
  2802. ASC_PRT_NEXT();
  2803. /*
  2804. * If the BIOS saved a valid signature, then fill in
  2805. * the BIOS code segment base address.
  2806. */
  2807. if (boardp->bios_signature != 0x55AA) {
  2808. len = asc_prt_line(cp, leftlen, "Disabled or Pre-3.1\n");
  2809. ASC_PRT_NEXT();
  2810. len = asc_prt_line(cp, leftlen,
  2811. "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n");
  2812. ASC_PRT_NEXT();
  2813. len = asc_prt_line(cp, leftlen,
  2814. "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
  2815. ASC_PRT_NEXT();
  2816. } else {
  2817. major = (boardp->bios_version >> 12) & 0xF;
  2818. minor = (boardp->bios_version >> 8) & 0xF;
  2819. letter = (boardp->bios_version & 0xFF);
  2820. len = asc_prt_line(cp, leftlen, "%d.%d%c\n",
  2821. major, minor,
  2822. letter >= 26 ? '?' : letter + 'A');
  2823. ASC_PRT_NEXT();
  2824. /*
  2825. * Current available ROM BIOS release is 3.1I for UW
  2826. * and 3.2I for U2W. This code doesn't differentiate
  2827. * UW and U2W boards.
  2828. */
  2829. if (major < 3 || (major <= 3 && minor < 1) ||
  2830. (major <= 3 && minor <= 1 && letter < ('I' - 'A'))) {
  2831. len = asc_prt_line(cp, leftlen,
  2832. "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n");
  2833. ASC_PRT_NEXT();
  2834. len = asc_prt_line(cp, leftlen,
  2835. "ftp://ftp.connectcom.net/pub\n");
  2836. ASC_PRT_NEXT();
  2837. }
  2838. }
  2839. return totlen;
  2840. }
  2841. /*
  2842. * Add serial number to information bar if signature AAh
  2843. * is found in at bit 15-9 (7 bits) of word 1.
  2844. *
  2845. * Serial Number consists fo 12 alpha-numeric digits.
  2846. *
  2847. * 1 - Product type (A,B,C,D..) Word0: 15-13 (3 bits)
  2848. * 2 - MFG Location (A,B,C,D..) Word0: 12-10 (3 bits)
  2849. * 3-4 - Product ID (0-99) Word0: 9-0 (10 bits)
  2850. * 5 - Product revision (A-J) Word0: " "
  2851. *
  2852. * Signature Word1: 15-9 (7 bits)
  2853. * 6 - Year (0-9) Word1: 8-6 (3 bits) & Word2: 15 (1 bit)
  2854. * 7-8 - Week of the year (1-52) Word1: 5-0 (6 bits)
  2855. *
  2856. * 9-12 - Serial Number (A001-Z999) Word2: 14-0 (15 bits)
  2857. *
  2858. * Note 1: Only production cards will have a serial number.
  2859. *
  2860. * Note 2: Signature is most significant 7 bits (0xFE).
  2861. *
  2862. * Returns ASC_TRUE if serial number found, otherwise returns ASC_FALSE.
  2863. */
  2864. static int asc_get_eeprom_string(ushort *serialnum, uchar *cp)
  2865. {
  2866. ushort w, num;
  2867. if ((serialnum[1] & 0xFE00) != ((ushort)0xAA << 8)) {
  2868. return ASC_FALSE;
  2869. } else {
  2870. /*
  2871. * First word - 6 digits.
  2872. */
  2873. w = serialnum[0];
  2874. /* Product type - 1st digit. */
  2875. if ((*cp = 'A' + ((w & 0xE000) >> 13)) == 'H') {
  2876. /* Product type is P=Prototype */
  2877. *cp += 0x8;
  2878. }
  2879. cp++;
  2880. /* Manufacturing location - 2nd digit. */
  2881. *cp++ = 'A' + ((w & 0x1C00) >> 10);
  2882. /* Product ID - 3rd, 4th digits. */
  2883. num = w & 0x3FF;
  2884. *cp++ = '0' + (num / 100);
  2885. num %= 100;
  2886. *cp++ = '0' + (num / 10);
  2887. /* Product revision - 5th digit. */
  2888. *cp++ = 'A' + (num % 10);
  2889. /*
  2890. * Second word
  2891. */
  2892. w = serialnum[1];
  2893. /*
  2894. * Year - 6th digit.
  2895. *
  2896. * If bit 15 of third word is set, then the
  2897. * last digit of the year is greater than 7.
  2898. */
  2899. if (serialnum[2] & 0x8000) {
  2900. *cp++ = '8' + ((w & 0x1C0) >> 6);
  2901. } else {
  2902. *cp++ = '0' + ((w & 0x1C0) >> 6);
  2903. }
  2904. /* Week of year - 7th, 8th digits. */
  2905. num = w & 0x003F;
  2906. *cp++ = '0' + num / 10;
  2907. num %= 10;
  2908. *cp++ = '0' + num;
  2909. /*
  2910. * Third word
  2911. */
  2912. w = serialnum[2] & 0x7FFF;
  2913. /* Serial number - 9th digit. */
  2914. *cp++ = 'A' + (w / 1000);
  2915. /* 10th, 11th, 12th digits. */
  2916. num = w % 1000;
  2917. *cp++ = '0' + num / 100;
  2918. num %= 100;
  2919. *cp++ = '0' + num / 10;
  2920. num %= 10;
  2921. *cp++ = '0' + num;
  2922. *cp = '\0'; /* Null Terminate the string. */
  2923. return ASC_TRUE;
  2924. }
  2925. }
  2926. /*
  2927. * asc_prt_asc_board_eeprom()
  2928. *
  2929. * Print board EEPROM configuration.
  2930. *
  2931. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  2932. * cf. asc_prt_line().
  2933. *
  2934. * Return the number of characters copied into 'cp'. No more than
  2935. * 'cplen' characters will be copied to 'cp'.
  2936. */
  2937. static int asc_prt_asc_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
  2938. {
  2939. asc_board_t *boardp;
  2940. ASC_DVC_VAR *asc_dvc_varp;
  2941. int leftlen;
  2942. int totlen;
  2943. int len;
  2944. ASCEEP_CONFIG *ep;
  2945. int i;
  2946. #ifdef CONFIG_ISA
  2947. int isa_dma_speed[] = { 10, 8, 7, 6, 5, 4, 3, 2 };
  2948. #endif /* CONFIG_ISA */
  2949. uchar serialstr[13];
  2950. boardp = ASC_BOARDP(shost);
  2951. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  2952. ep = &boardp->eep_config.asc_eep;
  2953. leftlen = cplen;
  2954. totlen = len = 0;
  2955. len = asc_prt_line(cp, leftlen,
  2956. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
  2957. shost->host_no);
  2958. ASC_PRT_NEXT();
  2959. if (asc_get_eeprom_string((ushort *)&ep->adapter_info[0], serialstr)
  2960. == ASC_TRUE) {
  2961. len =
  2962. asc_prt_line(cp, leftlen, " Serial Number: %s\n",
  2963. serialstr);
  2964. ASC_PRT_NEXT();
  2965. } else {
  2966. if (ep->adapter_info[5] == 0xBB) {
  2967. len = asc_prt_line(cp, leftlen,
  2968. " Default Settings Used for EEPROM-less Adapter.\n");
  2969. ASC_PRT_NEXT();
  2970. } else {
  2971. len = asc_prt_line(cp, leftlen,
  2972. " Serial Number Signature Not Present.\n");
  2973. ASC_PRT_NEXT();
  2974. }
  2975. }
  2976. len = asc_prt_line(cp, leftlen,
  2977. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  2978. ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng,
  2979. ep->max_tag_qng);
  2980. ASC_PRT_NEXT();
  2981. len = asc_prt_line(cp, leftlen,
  2982. " cntl 0x%x, no_scam 0x%x\n", ep->cntl, ep->no_scam);
  2983. ASC_PRT_NEXT();
  2984. len = asc_prt_line(cp, leftlen, " Target ID: ");
  2985. ASC_PRT_NEXT();
  2986. for (i = 0; i <= ASC_MAX_TID; i++) {
  2987. len = asc_prt_line(cp, leftlen, " %d", i);
  2988. ASC_PRT_NEXT();
  2989. }
  2990. len = asc_prt_line(cp, leftlen, "\n");
  2991. ASC_PRT_NEXT();
  2992. len = asc_prt_line(cp, leftlen, " Disconnects: ");
  2993. ASC_PRT_NEXT();
  2994. for (i = 0; i <= ASC_MAX_TID; i++) {
  2995. len = asc_prt_line(cp, leftlen, " %c",
  2996. (ep->
  2997. disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  2998. 'N');
  2999. ASC_PRT_NEXT();
  3000. }
  3001. len = asc_prt_line(cp, leftlen, "\n");
  3002. ASC_PRT_NEXT();
  3003. len = asc_prt_line(cp, leftlen, " Command Queuing: ");
  3004. ASC_PRT_NEXT();
  3005. for (i = 0; i <= ASC_MAX_TID; i++) {
  3006. len = asc_prt_line(cp, leftlen, " %c",
  3007. (ep->
  3008. use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3009. 'N');
  3010. ASC_PRT_NEXT();
  3011. }
  3012. len = asc_prt_line(cp, leftlen, "\n");
  3013. ASC_PRT_NEXT();
  3014. len = asc_prt_line(cp, leftlen, " Start Motor: ");
  3015. ASC_PRT_NEXT();
  3016. for (i = 0; i <= ASC_MAX_TID; i++) {
  3017. len = asc_prt_line(cp, leftlen, " %c",
  3018. (ep->
  3019. start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3020. 'N');
  3021. ASC_PRT_NEXT();
  3022. }
  3023. len = asc_prt_line(cp, leftlen, "\n");
  3024. ASC_PRT_NEXT();
  3025. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  3026. ASC_PRT_NEXT();
  3027. for (i = 0; i <= ASC_MAX_TID; i++) {
  3028. len = asc_prt_line(cp, leftlen, " %c",
  3029. (ep->
  3030. init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3031. 'N');
  3032. ASC_PRT_NEXT();
  3033. }
  3034. len = asc_prt_line(cp, leftlen, "\n");
  3035. ASC_PRT_NEXT();
  3036. #ifdef CONFIG_ISA
  3037. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  3038. len = asc_prt_line(cp, leftlen,
  3039. " Host ISA DMA speed: %d MB/S\n",
  3040. isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]);
  3041. ASC_PRT_NEXT();
  3042. }
  3043. #endif /* CONFIG_ISA */
  3044. return totlen;
  3045. }
  3046. /*
  3047. * asc_prt_adv_board_eeprom()
  3048. *
  3049. * Print board EEPROM configuration.
  3050. *
  3051. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3052. * cf. asc_prt_line().
  3053. *
  3054. * Return the number of characters copied into 'cp'. No more than
  3055. * 'cplen' characters will be copied to 'cp'.
  3056. */
  3057. static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
  3058. {
  3059. asc_board_t *boardp;
  3060. ADV_DVC_VAR *adv_dvc_varp;
  3061. int leftlen;
  3062. int totlen;
  3063. int len;
  3064. int i;
  3065. char *termstr;
  3066. uchar serialstr[13];
  3067. ADVEEP_3550_CONFIG *ep_3550 = NULL;
  3068. ADVEEP_38C0800_CONFIG *ep_38C0800 = NULL;
  3069. ADVEEP_38C1600_CONFIG *ep_38C1600 = NULL;
  3070. ushort word;
  3071. ushort *wordp;
  3072. ushort sdtr_speed = 0;
  3073. boardp = ASC_BOARDP(shost);
  3074. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  3075. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3076. ep_3550 = &boardp->eep_config.adv_3550_eep;
  3077. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3078. ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
  3079. } else {
  3080. ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
  3081. }
  3082. leftlen = cplen;
  3083. totlen = len = 0;
  3084. len = asc_prt_line(cp, leftlen,
  3085. "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
  3086. shost->host_no);
  3087. ASC_PRT_NEXT();
  3088. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3089. wordp = &ep_3550->serial_number_word1;
  3090. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3091. wordp = &ep_38C0800->serial_number_word1;
  3092. } else {
  3093. wordp = &ep_38C1600->serial_number_word1;
  3094. }
  3095. if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) {
  3096. len =
  3097. asc_prt_line(cp, leftlen, " Serial Number: %s\n",
  3098. serialstr);
  3099. ASC_PRT_NEXT();
  3100. } else {
  3101. len = asc_prt_line(cp, leftlen,
  3102. " Serial Number Signature Not Present.\n");
  3103. ASC_PRT_NEXT();
  3104. }
  3105. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3106. len = asc_prt_line(cp, leftlen,
  3107. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  3108. ep_3550->adapter_scsi_id,
  3109. ep_3550->max_host_qng, ep_3550->max_dvc_qng);
  3110. ASC_PRT_NEXT();
  3111. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3112. len = asc_prt_line(cp, leftlen,
  3113. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  3114. ep_38C0800->adapter_scsi_id,
  3115. ep_38C0800->max_host_qng,
  3116. ep_38C0800->max_dvc_qng);
  3117. ASC_PRT_NEXT();
  3118. } else {
  3119. len = asc_prt_line(cp, leftlen,
  3120. " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
  3121. ep_38C1600->adapter_scsi_id,
  3122. ep_38C1600->max_host_qng,
  3123. ep_38C1600->max_dvc_qng);
  3124. ASC_PRT_NEXT();
  3125. }
  3126. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3127. word = ep_3550->termination;
  3128. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3129. word = ep_38C0800->termination_lvd;
  3130. } else {
  3131. word = ep_38C1600->termination_lvd;
  3132. }
  3133. switch (word) {
  3134. case 1:
  3135. termstr = "Low Off/High Off";
  3136. break;
  3137. case 2:
  3138. termstr = "Low Off/High On";
  3139. break;
  3140. case 3:
  3141. termstr = "Low On/High On";
  3142. break;
  3143. default:
  3144. case 0:
  3145. termstr = "Automatic";
  3146. break;
  3147. }
  3148. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3149. len = asc_prt_line(cp, leftlen,
  3150. " termination: %u (%s), bios_ctrl: 0x%x\n",
  3151. ep_3550->termination, termstr,
  3152. ep_3550->bios_ctrl);
  3153. ASC_PRT_NEXT();
  3154. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3155. len = asc_prt_line(cp, leftlen,
  3156. " termination: %u (%s), bios_ctrl: 0x%x\n",
  3157. ep_38C0800->termination_lvd, termstr,
  3158. ep_38C0800->bios_ctrl);
  3159. ASC_PRT_NEXT();
  3160. } else {
  3161. len = asc_prt_line(cp, leftlen,
  3162. " termination: %u (%s), bios_ctrl: 0x%x\n",
  3163. ep_38C1600->termination_lvd, termstr,
  3164. ep_38C1600->bios_ctrl);
  3165. ASC_PRT_NEXT();
  3166. }
  3167. len = asc_prt_line(cp, leftlen, " Target ID: ");
  3168. ASC_PRT_NEXT();
  3169. for (i = 0; i <= ADV_MAX_TID; i++) {
  3170. len = asc_prt_line(cp, leftlen, " %X", i);
  3171. ASC_PRT_NEXT();
  3172. }
  3173. len = asc_prt_line(cp, leftlen, "\n");
  3174. ASC_PRT_NEXT();
  3175. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3176. word = ep_3550->disc_enable;
  3177. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3178. word = ep_38C0800->disc_enable;
  3179. } else {
  3180. word = ep_38C1600->disc_enable;
  3181. }
  3182. len = asc_prt_line(cp, leftlen, " Disconnects: ");
  3183. ASC_PRT_NEXT();
  3184. for (i = 0; i <= ADV_MAX_TID; i++) {
  3185. len = asc_prt_line(cp, leftlen, " %c",
  3186. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3187. ASC_PRT_NEXT();
  3188. }
  3189. len = asc_prt_line(cp, leftlen, "\n");
  3190. ASC_PRT_NEXT();
  3191. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3192. word = ep_3550->tagqng_able;
  3193. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3194. word = ep_38C0800->tagqng_able;
  3195. } else {
  3196. word = ep_38C1600->tagqng_able;
  3197. }
  3198. len = asc_prt_line(cp, leftlen, " Command Queuing: ");
  3199. ASC_PRT_NEXT();
  3200. for (i = 0; i <= ADV_MAX_TID; i++) {
  3201. len = asc_prt_line(cp, leftlen, " %c",
  3202. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3203. ASC_PRT_NEXT();
  3204. }
  3205. len = asc_prt_line(cp, leftlen, "\n");
  3206. ASC_PRT_NEXT();
  3207. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3208. word = ep_3550->start_motor;
  3209. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3210. word = ep_38C0800->start_motor;
  3211. } else {
  3212. word = ep_38C1600->start_motor;
  3213. }
  3214. len = asc_prt_line(cp, leftlen, " Start Motor: ");
  3215. ASC_PRT_NEXT();
  3216. for (i = 0; i <= ADV_MAX_TID; i++) {
  3217. len = asc_prt_line(cp, leftlen, " %c",
  3218. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3219. ASC_PRT_NEXT();
  3220. }
  3221. len = asc_prt_line(cp, leftlen, "\n");
  3222. ASC_PRT_NEXT();
  3223. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3224. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  3225. ASC_PRT_NEXT();
  3226. for (i = 0; i <= ADV_MAX_TID; i++) {
  3227. len = asc_prt_line(cp, leftlen, " %c",
  3228. (ep_3550->
  3229. sdtr_able & ADV_TID_TO_TIDMASK(i)) ?
  3230. 'Y' : 'N');
  3231. ASC_PRT_NEXT();
  3232. }
  3233. len = asc_prt_line(cp, leftlen, "\n");
  3234. ASC_PRT_NEXT();
  3235. }
  3236. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3237. len = asc_prt_line(cp, leftlen, " Ultra Transfer: ");
  3238. ASC_PRT_NEXT();
  3239. for (i = 0; i <= ADV_MAX_TID; i++) {
  3240. len = asc_prt_line(cp, leftlen, " %c",
  3241. (ep_3550->
  3242. ultra_able & ADV_TID_TO_TIDMASK(i))
  3243. ? 'Y' : 'N');
  3244. ASC_PRT_NEXT();
  3245. }
  3246. len = asc_prt_line(cp, leftlen, "\n");
  3247. ASC_PRT_NEXT();
  3248. }
  3249. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  3250. word = ep_3550->wdtr_able;
  3251. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  3252. word = ep_38C0800->wdtr_able;
  3253. } else {
  3254. word = ep_38C1600->wdtr_able;
  3255. }
  3256. len = asc_prt_line(cp, leftlen, " Wide Transfer: ");
  3257. ASC_PRT_NEXT();
  3258. for (i = 0; i <= ADV_MAX_TID; i++) {
  3259. len = asc_prt_line(cp, leftlen, " %c",
  3260. (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
  3261. ASC_PRT_NEXT();
  3262. }
  3263. len = asc_prt_line(cp, leftlen, "\n");
  3264. ASC_PRT_NEXT();
  3265. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 ||
  3266. adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) {
  3267. len = asc_prt_line(cp, leftlen,
  3268. " Synchronous Transfer Speed (Mhz):\n ");
  3269. ASC_PRT_NEXT();
  3270. for (i = 0; i <= ADV_MAX_TID; i++) {
  3271. char *speed_str;
  3272. if (i == 0) {
  3273. sdtr_speed = adv_dvc_varp->sdtr_speed1;
  3274. } else if (i == 4) {
  3275. sdtr_speed = adv_dvc_varp->sdtr_speed2;
  3276. } else if (i == 8) {
  3277. sdtr_speed = adv_dvc_varp->sdtr_speed3;
  3278. } else if (i == 12) {
  3279. sdtr_speed = adv_dvc_varp->sdtr_speed4;
  3280. }
  3281. switch (sdtr_speed & ADV_MAX_TID) {
  3282. case 0:
  3283. speed_str = "Off";
  3284. break;
  3285. case 1:
  3286. speed_str = " 5";
  3287. break;
  3288. case 2:
  3289. speed_str = " 10";
  3290. break;
  3291. case 3:
  3292. speed_str = " 20";
  3293. break;
  3294. case 4:
  3295. speed_str = " 40";
  3296. break;
  3297. case 5:
  3298. speed_str = " 80";
  3299. break;
  3300. default:
  3301. speed_str = "Unk";
  3302. break;
  3303. }
  3304. len = asc_prt_line(cp, leftlen, "%X:%s ", i, speed_str);
  3305. ASC_PRT_NEXT();
  3306. if (i == 7) {
  3307. len = asc_prt_line(cp, leftlen, "\n ");
  3308. ASC_PRT_NEXT();
  3309. }
  3310. sdtr_speed >>= 4;
  3311. }
  3312. len = asc_prt_line(cp, leftlen, "\n");
  3313. ASC_PRT_NEXT();
  3314. }
  3315. return totlen;
  3316. }
  3317. /*
  3318. * asc_prt_driver_conf()
  3319. *
  3320. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3321. * cf. asc_prt_line().
  3322. *
  3323. * Return the number of characters copied into 'cp'. No more than
  3324. * 'cplen' characters will be copied to 'cp'.
  3325. */
  3326. static int asc_prt_driver_conf(struct Scsi_Host *shost, char *cp, int cplen)
  3327. {
  3328. asc_board_t *boardp;
  3329. int leftlen;
  3330. int totlen;
  3331. int len;
  3332. int chip_scsi_id;
  3333. boardp = ASC_BOARDP(shost);
  3334. leftlen = cplen;
  3335. totlen = len = 0;
  3336. len = asc_prt_line(cp, leftlen,
  3337. "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n",
  3338. shost->host_no);
  3339. ASC_PRT_NEXT();
  3340. len = asc_prt_line(cp, leftlen,
  3341. " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n",
  3342. shost->host_busy, shost->last_reset, shost->max_id,
  3343. shost->max_lun, shost->max_channel);
  3344. ASC_PRT_NEXT();
  3345. len = asc_prt_line(cp, leftlen,
  3346. " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n",
  3347. shost->unique_id, shost->can_queue, shost->this_id,
  3348. shost->sg_tablesize, shost->cmd_per_lun);
  3349. ASC_PRT_NEXT();
  3350. len = asc_prt_line(cp, leftlen,
  3351. " unchecked_isa_dma %d, use_clustering %d\n",
  3352. shost->unchecked_isa_dma, shost->use_clustering);
  3353. ASC_PRT_NEXT();
  3354. len = asc_prt_line(cp, leftlen,
  3355. " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n",
  3356. boardp->flags, boardp->last_reset, jiffies,
  3357. boardp->asc_n_io_port);
  3358. ASC_PRT_NEXT();
  3359. len = asc_prt_line(cp, leftlen, " io_port 0x%x\n", shost->io_port);
  3360. ASC_PRT_NEXT();
  3361. if (ASC_NARROW_BOARD(boardp)) {
  3362. chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
  3363. } else {
  3364. chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
  3365. }
  3366. return totlen;
  3367. }
  3368. /*
  3369. * asc_prt_asc_board_info()
  3370. *
  3371. * Print dynamic board configuration information.
  3372. *
  3373. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3374. * cf. asc_prt_line().
  3375. *
  3376. * Return the number of characters copied into 'cp'. No more than
  3377. * 'cplen' characters will be copied to 'cp'.
  3378. */
  3379. static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen)
  3380. {
  3381. asc_board_t *boardp;
  3382. int chip_scsi_id;
  3383. int leftlen;
  3384. int totlen;
  3385. int len;
  3386. ASC_DVC_VAR *v;
  3387. ASC_DVC_CFG *c;
  3388. int i;
  3389. int renegotiate = 0;
  3390. boardp = ASC_BOARDP(shost);
  3391. v = &boardp->dvc_var.asc_dvc_var;
  3392. c = &boardp->dvc_cfg.asc_dvc_cfg;
  3393. chip_scsi_id = c->chip_scsi_id;
  3394. leftlen = cplen;
  3395. totlen = len = 0;
  3396. len = asc_prt_line(cp, leftlen,
  3397. "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  3398. shost->host_no);
  3399. ASC_PRT_NEXT();
  3400. len = asc_prt_line(cp, leftlen,
  3401. " chip_version %u, lib_version 0x%x, lib_serial_no %u, mcode_date 0x%x\n",
  3402. c->chip_version, c->lib_version, c->lib_serial_no,
  3403. c->mcode_date);
  3404. ASC_PRT_NEXT();
  3405. len = asc_prt_line(cp, leftlen,
  3406. " mcode_version 0x%x, err_code %u\n",
  3407. c->mcode_version, v->err_code);
  3408. ASC_PRT_NEXT();
  3409. /* Current number of commands waiting for the host. */
  3410. len = asc_prt_line(cp, leftlen,
  3411. " Total Command Pending: %d\n", v->cur_total_qng);
  3412. ASC_PRT_NEXT();
  3413. len = asc_prt_line(cp, leftlen, " Command Queuing:");
  3414. ASC_PRT_NEXT();
  3415. for (i = 0; i <= ASC_MAX_TID; i++) {
  3416. if ((chip_scsi_id == i) ||
  3417. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3418. continue;
  3419. }
  3420. len = asc_prt_line(cp, leftlen, " %X:%c",
  3421. i,
  3422. (v->
  3423. use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ?
  3424. 'Y' : 'N');
  3425. ASC_PRT_NEXT();
  3426. }
  3427. len = asc_prt_line(cp, leftlen, "\n");
  3428. ASC_PRT_NEXT();
  3429. /* Current number of commands waiting for a device. */
  3430. len = asc_prt_line(cp, leftlen, " Command Queue Pending:");
  3431. ASC_PRT_NEXT();
  3432. for (i = 0; i <= ASC_MAX_TID; i++) {
  3433. if ((chip_scsi_id == i) ||
  3434. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3435. continue;
  3436. }
  3437. len = asc_prt_line(cp, leftlen, " %X:%u", i, v->cur_dvc_qng[i]);
  3438. ASC_PRT_NEXT();
  3439. }
  3440. len = asc_prt_line(cp, leftlen, "\n");
  3441. ASC_PRT_NEXT();
  3442. /* Current limit on number of commands that can be sent to a device. */
  3443. len = asc_prt_line(cp, leftlen, " Command Queue Limit:");
  3444. ASC_PRT_NEXT();
  3445. for (i = 0; i <= ASC_MAX_TID; i++) {
  3446. if ((chip_scsi_id == i) ||
  3447. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3448. continue;
  3449. }
  3450. len = asc_prt_line(cp, leftlen, " %X:%u", i, v->max_dvc_qng[i]);
  3451. ASC_PRT_NEXT();
  3452. }
  3453. len = asc_prt_line(cp, leftlen, "\n");
  3454. ASC_PRT_NEXT();
  3455. /* Indicate whether the device has returned queue full status. */
  3456. len = asc_prt_line(cp, leftlen, " Command Queue Full:");
  3457. ASC_PRT_NEXT();
  3458. for (i = 0; i <= ASC_MAX_TID; i++) {
  3459. if ((chip_scsi_id == i) ||
  3460. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3461. continue;
  3462. }
  3463. if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) {
  3464. len = asc_prt_line(cp, leftlen, " %X:Y-%d",
  3465. i, boardp->queue_full_cnt[i]);
  3466. } else {
  3467. len = asc_prt_line(cp, leftlen, " %X:N", i);
  3468. }
  3469. ASC_PRT_NEXT();
  3470. }
  3471. len = asc_prt_line(cp, leftlen, "\n");
  3472. ASC_PRT_NEXT();
  3473. len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
  3474. ASC_PRT_NEXT();
  3475. for (i = 0; i <= ASC_MAX_TID; i++) {
  3476. if ((chip_scsi_id == i) ||
  3477. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3478. continue;
  3479. }
  3480. len = asc_prt_line(cp, leftlen, " %X:%c",
  3481. i,
  3482. (v->
  3483. sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3484. 'N');
  3485. ASC_PRT_NEXT();
  3486. }
  3487. len = asc_prt_line(cp, leftlen, "\n");
  3488. ASC_PRT_NEXT();
  3489. for (i = 0; i <= ASC_MAX_TID; i++) {
  3490. uchar syn_period_ix;
  3491. if ((chip_scsi_id == i) ||
  3492. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  3493. ((v->init_sdtr & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3494. continue;
  3495. }
  3496. len = asc_prt_line(cp, leftlen, " %X:", i);
  3497. ASC_PRT_NEXT();
  3498. if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0) {
  3499. len = asc_prt_line(cp, leftlen, " Asynchronous");
  3500. ASC_PRT_NEXT();
  3501. } else {
  3502. syn_period_ix =
  3503. (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index -
  3504. 1);
  3505. len = asc_prt_line(cp, leftlen,
  3506. " Transfer Period Factor: %d (%d.%d Mhz),",
  3507. v->sdtr_period_tbl[syn_period_ix],
  3508. 250 /
  3509. v->sdtr_period_tbl[syn_period_ix],
  3510. ASC_TENTHS(250,
  3511. v->
  3512. sdtr_period_tbl
  3513. [syn_period_ix]));
  3514. ASC_PRT_NEXT();
  3515. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  3516. boardp->
  3517. sdtr_data[i] & ASC_SYN_MAX_OFFSET);
  3518. ASC_PRT_NEXT();
  3519. }
  3520. if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  3521. len = asc_prt_line(cp, leftlen, "*\n");
  3522. renegotiate = 1;
  3523. } else {
  3524. len = asc_prt_line(cp, leftlen, "\n");
  3525. }
  3526. ASC_PRT_NEXT();
  3527. }
  3528. if (renegotiate) {
  3529. len = asc_prt_line(cp, leftlen,
  3530. " * = Re-negotiation pending before next command.\n");
  3531. ASC_PRT_NEXT();
  3532. }
  3533. return totlen;
  3534. }
  3535. /*
  3536. * asc_prt_adv_board_info()
  3537. *
  3538. * Print dynamic board configuration information.
  3539. *
  3540. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3541. * cf. asc_prt_line().
  3542. *
  3543. * Return the number of characters copied into 'cp'. No more than
  3544. * 'cplen' characters will be copied to 'cp'.
  3545. */
  3546. static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
  3547. {
  3548. asc_board_t *boardp;
  3549. int leftlen;
  3550. int totlen;
  3551. int len;
  3552. int i;
  3553. ADV_DVC_VAR *v;
  3554. ADV_DVC_CFG *c;
  3555. AdvPortAddr iop_base;
  3556. ushort chip_scsi_id;
  3557. ushort lramword;
  3558. uchar lrambyte;
  3559. ushort tagqng_able;
  3560. ushort sdtr_able, wdtr_able;
  3561. ushort wdtr_done, sdtr_done;
  3562. ushort period = 0;
  3563. int renegotiate = 0;
  3564. boardp = ASC_BOARDP(shost);
  3565. v = &boardp->dvc_var.adv_dvc_var;
  3566. c = &boardp->dvc_cfg.adv_dvc_cfg;
  3567. iop_base = v->iop_base;
  3568. chip_scsi_id = v->chip_scsi_id;
  3569. leftlen = cplen;
  3570. totlen = len = 0;
  3571. len = asc_prt_line(cp, leftlen,
  3572. "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
  3573. shost->host_no);
  3574. ASC_PRT_NEXT();
  3575. len = asc_prt_line(cp, leftlen,
  3576. " iop_base 0x%lx, cable_detect: %X, err_code %u\n",
  3577. v->iop_base,
  3578. AdvReadWordRegister(iop_base,
  3579. IOPW_SCSI_CFG1) & CABLE_DETECT,
  3580. v->err_code);
  3581. ASC_PRT_NEXT();
  3582. len = asc_prt_line(cp, leftlen,
  3583. " chip_version %u, lib_version 0x%x, mcode_date 0x%x, mcode_version 0x%x\n",
  3584. c->chip_version, c->lib_version, c->mcode_date,
  3585. c->mcode_version);
  3586. ASC_PRT_NEXT();
  3587. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  3588. len = asc_prt_line(cp, leftlen, " Queuing Enabled:");
  3589. ASC_PRT_NEXT();
  3590. for (i = 0; i <= ADV_MAX_TID; i++) {
  3591. if ((chip_scsi_id == i) ||
  3592. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3593. continue;
  3594. }
  3595. len = asc_prt_line(cp, leftlen, " %X:%c",
  3596. i,
  3597. (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3598. 'N');
  3599. ASC_PRT_NEXT();
  3600. }
  3601. len = asc_prt_line(cp, leftlen, "\n");
  3602. ASC_PRT_NEXT();
  3603. len = asc_prt_line(cp, leftlen, " Queue Limit:");
  3604. ASC_PRT_NEXT();
  3605. for (i = 0; i <= ADV_MAX_TID; i++) {
  3606. if ((chip_scsi_id == i) ||
  3607. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3608. continue;
  3609. }
  3610. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i,
  3611. lrambyte);
  3612. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  3613. ASC_PRT_NEXT();
  3614. }
  3615. len = asc_prt_line(cp, leftlen, "\n");
  3616. ASC_PRT_NEXT();
  3617. len = asc_prt_line(cp, leftlen, " Command Pending:");
  3618. ASC_PRT_NEXT();
  3619. for (i = 0; i <= ADV_MAX_TID; i++) {
  3620. if ((chip_scsi_id == i) ||
  3621. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3622. continue;
  3623. }
  3624. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i,
  3625. lrambyte);
  3626. len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
  3627. ASC_PRT_NEXT();
  3628. }
  3629. len = asc_prt_line(cp, leftlen, "\n");
  3630. ASC_PRT_NEXT();
  3631. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  3632. len = asc_prt_line(cp, leftlen, " Wide Enabled:");
  3633. ASC_PRT_NEXT();
  3634. for (i = 0; i <= ADV_MAX_TID; i++) {
  3635. if ((chip_scsi_id == i) ||
  3636. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3637. continue;
  3638. }
  3639. len = asc_prt_line(cp, leftlen, " %X:%c",
  3640. i,
  3641. (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3642. 'N');
  3643. ASC_PRT_NEXT();
  3644. }
  3645. len = asc_prt_line(cp, leftlen, "\n");
  3646. ASC_PRT_NEXT();
  3647. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done);
  3648. len = asc_prt_line(cp, leftlen, " Transfer Bit Width:");
  3649. ASC_PRT_NEXT();
  3650. for (i = 0; i <= ADV_MAX_TID; i++) {
  3651. if ((chip_scsi_id == i) ||
  3652. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3653. continue;
  3654. }
  3655. AdvReadWordLram(iop_base,
  3656. ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  3657. lramword);
  3658. len = asc_prt_line(cp, leftlen, " %X:%d",
  3659. i, (lramword & 0x8000) ? 16 : 8);
  3660. ASC_PRT_NEXT();
  3661. if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) &&
  3662. (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  3663. len = asc_prt_line(cp, leftlen, "*");
  3664. ASC_PRT_NEXT();
  3665. renegotiate = 1;
  3666. }
  3667. }
  3668. len = asc_prt_line(cp, leftlen, "\n");
  3669. ASC_PRT_NEXT();
  3670. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  3671. len = asc_prt_line(cp, leftlen, " Synchronous Enabled:");
  3672. ASC_PRT_NEXT();
  3673. for (i = 0; i <= ADV_MAX_TID; i++) {
  3674. if ((chip_scsi_id == i) ||
  3675. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3676. continue;
  3677. }
  3678. len = asc_prt_line(cp, leftlen, " %X:%c",
  3679. i,
  3680. (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
  3681. 'N');
  3682. ASC_PRT_NEXT();
  3683. }
  3684. len = asc_prt_line(cp, leftlen, "\n");
  3685. ASC_PRT_NEXT();
  3686. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done);
  3687. for (i = 0; i <= ADV_MAX_TID; i++) {
  3688. AdvReadWordLram(iop_base,
  3689. ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
  3690. lramword);
  3691. lramword &= ~0x8000;
  3692. if ((chip_scsi_id == i) ||
  3693. ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
  3694. ((sdtr_able & ADV_TID_TO_TIDMASK(i)) == 0)) {
  3695. continue;
  3696. }
  3697. len = asc_prt_line(cp, leftlen, " %X:", i);
  3698. ASC_PRT_NEXT();
  3699. if ((lramword & 0x1F) == 0) { /* Check for REQ/ACK Offset 0. */
  3700. len = asc_prt_line(cp, leftlen, " Asynchronous");
  3701. ASC_PRT_NEXT();
  3702. } else {
  3703. len =
  3704. asc_prt_line(cp, leftlen,
  3705. " Transfer Period Factor: ");
  3706. ASC_PRT_NEXT();
  3707. if ((lramword & 0x1F00) == 0x1100) { /* 80 Mhz */
  3708. len =
  3709. asc_prt_line(cp, leftlen, "9 (80.0 Mhz),");
  3710. ASC_PRT_NEXT();
  3711. } else if ((lramword & 0x1F00) == 0x1000) { /* 40 Mhz */
  3712. len =
  3713. asc_prt_line(cp, leftlen, "10 (40.0 Mhz),");
  3714. ASC_PRT_NEXT();
  3715. } else { /* 20 Mhz or below. */
  3716. period = (((lramword >> 8) * 25) + 50) / 4;
  3717. if (period == 0) { /* Should never happen. */
  3718. len =
  3719. asc_prt_line(cp, leftlen,
  3720. "%d (? Mhz), ");
  3721. ASC_PRT_NEXT();
  3722. } else {
  3723. len = asc_prt_line(cp, leftlen,
  3724. "%d (%d.%d Mhz),",
  3725. period, 250 / period,
  3726. ASC_TENTHS(250,
  3727. period));
  3728. ASC_PRT_NEXT();
  3729. }
  3730. }
  3731. len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
  3732. lramword & 0x1F);
  3733. ASC_PRT_NEXT();
  3734. }
  3735. if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
  3736. len = asc_prt_line(cp, leftlen, "*\n");
  3737. renegotiate = 1;
  3738. } else {
  3739. len = asc_prt_line(cp, leftlen, "\n");
  3740. }
  3741. ASC_PRT_NEXT();
  3742. }
  3743. if (renegotiate) {
  3744. len = asc_prt_line(cp, leftlen,
  3745. " * = Re-negotiation pending before next command.\n");
  3746. ASC_PRT_NEXT();
  3747. }
  3748. return totlen;
  3749. }
  3750. /*
  3751. * asc_proc_copy()
  3752. *
  3753. * Copy proc information to a read buffer taking into account the current
  3754. * read offset in the file and the remaining space in the read buffer.
  3755. */
  3756. static int
  3757. asc_proc_copy(off_t advoffset, off_t offset, char *curbuf, int leftlen,
  3758. char *cp, int cplen)
  3759. {
  3760. int cnt = 0;
  3761. ASC_DBG3(2, "asc_proc_copy: offset %d, advoffset %d, cplen %d\n",
  3762. (unsigned)offset, (unsigned)advoffset, cplen);
  3763. if (offset <= advoffset) {
  3764. /* Read offset below current offset, copy everything. */
  3765. cnt = min(cplen, leftlen);
  3766. ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  3767. (ulong)curbuf, (ulong)cp, cnt);
  3768. memcpy(curbuf, cp, cnt);
  3769. } else if (offset < advoffset + cplen) {
  3770. /* Read offset within current range, partial copy. */
  3771. cnt = (advoffset + cplen) - offset;
  3772. cp = (cp + cplen) - cnt;
  3773. cnt = min(cnt, leftlen);
  3774. ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
  3775. (ulong)curbuf, (ulong)cp, cnt);
  3776. memcpy(curbuf, cp, cnt);
  3777. }
  3778. return cnt;
  3779. }
  3780. #ifdef ADVANSYS_STATS
  3781. /*
  3782. * asc_prt_board_stats()
  3783. *
  3784. * Note: no single line should be greater than ASC_PRTLINE_SIZE,
  3785. * cf. asc_prt_line().
  3786. *
  3787. * Return the number of characters copied into 'cp'. No more than
  3788. * 'cplen' characters will be copied to 'cp'.
  3789. */
  3790. static int asc_prt_board_stats(struct Scsi_Host *shost, char *cp, int cplen)
  3791. {
  3792. int leftlen;
  3793. int totlen;
  3794. int len;
  3795. struct asc_stats *s;
  3796. asc_board_t *boardp;
  3797. leftlen = cplen;
  3798. totlen = len = 0;
  3799. boardp = ASC_BOARDP(shost);
  3800. s = &boardp->asc_stats;
  3801. len = asc_prt_line(cp, leftlen,
  3802. "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n",
  3803. shost->host_no);
  3804. ASC_PRT_NEXT();
  3805. len = asc_prt_line(cp, leftlen,
  3806. " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n",
  3807. s->queuecommand, s->reset, s->biosparam,
  3808. s->interrupt);
  3809. ASC_PRT_NEXT();
  3810. len = asc_prt_line(cp, leftlen,
  3811. " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n",
  3812. s->callback, s->done, s->build_error,
  3813. s->adv_build_noreq, s->adv_build_nosg);
  3814. ASC_PRT_NEXT();
  3815. len = asc_prt_line(cp, leftlen,
  3816. " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n",
  3817. s->exe_noerror, s->exe_busy, s->exe_error,
  3818. s->exe_unknown);
  3819. ASC_PRT_NEXT();
  3820. /*
  3821. * Display data transfer statistics.
  3822. */
  3823. if (s->cont_cnt > 0) {
  3824. len = asc_prt_line(cp, leftlen, " cont_cnt %lu, ", s->cont_cnt);
  3825. ASC_PRT_NEXT();
  3826. len = asc_prt_line(cp, leftlen, "cont_xfer %lu.%01lu kb ",
  3827. s->cont_xfer / 2,
  3828. ASC_TENTHS(s->cont_xfer, 2));
  3829. ASC_PRT_NEXT();
  3830. /* Contiguous transfer average size */
  3831. len = asc_prt_line(cp, leftlen, "avg_xfer %lu.%01lu kb\n",
  3832. (s->cont_xfer / 2) / s->cont_cnt,
  3833. ASC_TENTHS((s->cont_xfer / 2), s->cont_cnt));
  3834. ASC_PRT_NEXT();
  3835. }
  3836. if (s->sg_cnt > 0) {
  3837. len = asc_prt_line(cp, leftlen, " sg_cnt %lu, sg_elem %lu, ",
  3838. s->sg_cnt, s->sg_elem);
  3839. ASC_PRT_NEXT();
  3840. len = asc_prt_line(cp, leftlen, "sg_xfer %lu.%01lu kb\n",
  3841. s->sg_xfer / 2, ASC_TENTHS(s->sg_xfer, 2));
  3842. ASC_PRT_NEXT();
  3843. /* Scatter gather transfer statistics */
  3844. len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ",
  3845. s->sg_elem / s->sg_cnt,
  3846. ASC_TENTHS(s->sg_elem, s->sg_cnt));
  3847. ASC_PRT_NEXT();
  3848. len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ",
  3849. (s->sg_xfer / 2) / s->sg_elem,
  3850. ASC_TENTHS((s->sg_xfer / 2), s->sg_elem));
  3851. ASC_PRT_NEXT();
  3852. len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n",
  3853. (s->sg_xfer / 2) / s->sg_cnt,
  3854. ASC_TENTHS((s->sg_xfer / 2), s->sg_cnt));
  3855. ASC_PRT_NEXT();
  3856. }
  3857. /*
  3858. * Display request queuing statistics.
  3859. */
  3860. len = asc_prt_line(cp, leftlen,
  3861. " Active and Waiting Request Queues (Time Unit: %d HZ):\n",
  3862. HZ);
  3863. ASC_PRT_NEXT();
  3864. return totlen;
  3865. }
  3866. #endif /* ADVANSYS_STATS */
  3867. /*
  3868. * advansys_proc_info() - /proc/scsi/advansys/{0,1,2,3,...}
  3869. *
  3870. * *buffer: I/O buffer
  3871. * **start: if inout == FALSE pointer into buffer where user read should start
  3872. * offset: current offset into a /proc/scsi/advansys/[0...] file
  3873. * length: length of buffer
  3874. * hostno: Scsi_Host host_no
  3875. * inout: TRUE - user is writing; FALSE - user is reading
  3876. *
  3877. * Return the number of bytes read from or written to a
  3878. * /proc/scsi/advansys/[0...] file.
  3879. *
  3880. * Note: This function uses the per board buffer 'prtbuf' which is
  3881. * allocated when the board is initialized in advansys_detect(). The
  3882. * buffer is ASC_PRTBUF_SIZE bytes. The function asc_proc_copy() is
  3883. * used to write to the buffer. The way asc_proc_copy() is written
  3884. * if 'prtbuf' is too small it will not be overwritten. Instead the
  3885. * user just won't get all the available statistics.
  3886. */
  3887. static int
  3888. advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
  3889. off_t offset, int length, int inout)
  3890. {
  3891. asc_board_t *boardp;
  3892. char *cp;
  3893. int cplen;
  3894. int cnt;
  3895. int totcnt;
  3896. int leftlen;
  3897. char *curbuf;
  3898. off_t advoffset;
  3899. ASC_DBG(1, "advansys_proc_info: begin\n");
  3900. /*
  3901. * User write not supported.
  3902. */
  3903. if (inout == TRUE) {
  3904. return (-ENOSYS);
  3905. }
  3906. /*
  3907. * User read of /proc/scsi/advansys/[0...] file.
  3908. */
  3909. boardp = ASC_BOARDP(shost);
  3910. /* Copy read data starting at the beginning of the buffer. */
  3911. *start = buffer;
  3912. curbuf = buffer;
  3913. advoffset = 0;
  3914. totcnt = 0;
  3915. leftlen = length;
  3916. /*
  3917. * Get board configuration information.
  3918. *
  3919. * advansys_info() returns the board string from its own static buffer.
  3920. */
  3921. cp = (char *)advansys_info(shost);
  3922. strcat(cp, "\n");
  3923. cplen = strlen(cp);
  3924. /* Copy board information. */
  3925. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3926. totcnt += cnt;
  3927. leftlen -= cnt;
  3928. if (leftlen == 0) {
  3929. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3930. return totcnt;
  3931. }
  3932. advoffset += cplen;
  3933. curbuf += cnt;
  3934. /*
  3935. * Display Wide Board BIOS Information.
  3936. */
  3937. if (ASC_WIDE_BOARD(boardp)) {
  3938. cp = boardp->prtbuf;
  3939. cplen = asc_prt_adv_bios(shost, cp, ASC_PRTBUF_SIZE);
  3940. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3941. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
  3942. cplen);
  3943. totcnt += cnt;
  3944. leftlen -= cnt;
  3945. if (leftlen == 0) {
  3946. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3947. return totcnt;
  3948. }
  3949. advoffset += cplen;
  3950. curbuf += cnt;
  3951. }
  3952. /*
  3953. * Display driver information for each device attached to the board.
  3954. */
  3955. cp = boardp->prtbuf;
  3956. cplen = asc_prt_board_devices(shost, cp, ASC_PRTBUF_SIZE);
  3957. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3958. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3959. totcnt += cnt;
  3960. leftlen -= cnt;
  3961. if (leftlen == 0) {
  3962. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3963. return totcnt;
  3964. }
  3965. advoffset += cplen;
  3966. curbuf += cnt;
  3967. /*
  3968. * Display EEPROM configuration for the board.
  3969. */
  3970. cp = boardp->prtbuf;
  3971. if (ASC_NARROW_BOARD(boardp)) {
  3972. cplen = asc_prt_asc_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
  3973. } else {
  3974. cplen = asc_prt_adv_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
  3975. }
  3976. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3977. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3978. totcnt += cnt;
  3979. leftlen -= cnt;
  3980. if (leftlen == 0) {
  3981. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3982. return totcnt;
  3983. }
  3984. advoffset += cplen;
  3985. curbuf += cnt;
  3986. /*
  3987. * Display driver configuration and information for the board.
  3988. */
  3989. cp = boardp->prtbuf;
  3990. cplen = asc_prt_driver_conf(shost, cp, ASC_PRTBUF_SIZE);
  3991. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  3992. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  3993. totcnt += cnt;
  3994. leftlen -= cnt;
  3995. if (leftlen == 0) {
  3996. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  3997. return totcnt;
  3998. }
  3999. advoffset += cplen;
  4000. curbuf += cnt;
  4001. #ifdef ADVANSYS_STATS
  4002. /*
  4003. * Display driver statistics for the board.
  4004. */
  4005. cp = boardp->prtbuf;
  4006. cplen = asc_prt_board_stats(shost, cp, ASC_PRTBUF_SIZE);
  4007. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  4008. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  4009. totcnt += cnt;
  4010. leftlen -= cnt;
  4011. if (leftlen == 0) {
  4012. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  4013. return totcnt;
  4014. }
  4015. advoffset += cplen;
  4016. curbuf += cnt;
  4017. #endif /* ADVANSYS_STATS */
  4018. /*
  4019. * Display Asc Library dynamic configuration information
  4020. * for the board.
  4021. */
  4022. cp = boardp->prtbuf;
  4023. if (ASC_NARROW_BOARD(boardp)) {
  4024. cplen = asc_prt_asc_board_info(shost, cp, ASC_PRTBUF_SIZE);
  4025. } else {
  4026. cplen = asc_prt_adv_board_info(shost, cp, ASC_PRTBUF_SIZE);
  4027. }
  4028. BUG_ON(cplen >= ASC_PRTBUF_SIZE);
  4029. cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
  4030. totcnt += cnt;
  4031. leftlen -= cnt;
  4032. if (leftlen == 0) {
  4033. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  4034. return totcnt;
  4035. }
  4036. advoffset += cplen;
  4037. curbuf += cnt;
  4038. ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
  4039. return totcnt;
  4040. }
  4041. #endif /* CONFIG_PROC_FS */
  4042. static void asc_scsi_done(struct scsi_cmnd *scp)
  4043. {
  4044. struct asc_board *boardp = ASC_BOARDP(scp->device->host);
  4045. if (scp->use_sg)
  4046. dma_unmap_sg(boardp->dev,
  4047. (struct scatterlist *)scp->request_buffer,
  4048. scp->use_sg, scp->sc_data_direction);
  4049. else if (scp->request_bufflen)
  4050. dma_unmap_single(boardp->dev, scp->SCp.dma_handle,
  4051. scp->request_bufflen, scp->sc_data_direction);
  4052. ASC_STATS(scp->device->host, done);
  4053. scp->scsi_done(scp);
  4054. }
  4055. static void AscSetBank(PortAddr iop_base, uchar bank)
  4056. {
  4057. uchar val;
  4058. val = AscGetChipControl(iop_base) &
  4059. (~
  4060. (CC_SINGLE_STEP | CC_TEST | CC_DIAG | CC_SCSI_RESET |
  4061. CC_CHIP_RESET));
  4062. if (bank == 1) {
  4063. val |= CC_BANK_ONE;
  4064. } else if (bank == 2) {
  4065. val |= CC_DIAG | CC_BANK_ONE;
  4066. } else {
  4067. val &= ~CC_BANK_ONE;
  4068. }
  4069. AscSetChipControl(iop_base, val);
  4070. return;
  4071. }
  4072. static void AscSetChipIH(PortAddr iop_base, ushort ins_code)
  4073. {
  4074. AscSetBank(iop_base, 1);
  4075. AscWriteChipIH(iop_base, ins_code);
  4076. AscSetBank(iop_base, 0);
  4077. return;
  4078. }
  4079. static int AscStartChip(PortAddr iop_base)
  4080. {
  4081. AscSetChipControl(iop_base, 0);
  4082. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  4083. return (0);
  4084. }
  4085. return (1);
  4086. }
  4087. static int AscStopChip(PortAddr iop_base)
  4088. {
  4089. uchar cc_val;
  4090. cc_val =
  4091. AscGetChipControl(iop_base) &
  4092. (~(CC_SINGLE_STEP | CC_TEST | CC_DIAG));
  4093. AscSetChipControl(iop_base, (uchar)(cc_val | CC_HALT));
  4094. AscSetChipIH(iop_base, INS_HALT);
  4095. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  4096. if ((AscGetChipStatus(iop_base) & CSW_HALTED) == 0) {
  4097. return (0);
  4098. }
  4099. return (1);
  4100. }
  4101. static int AscIsChipHalted(PortAddr iop_base)
  4102. {
  4103. if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
  4104. if ((AscGetChipControl(iop_base) & CC_HALT) != 0) {
  4105. return (1);
  4106. }
  4107. }
  4108. return (0);
  4109. }
  4110. static int AscResetChipAndScsiBus(ASC_DVC_VAR *asc_dvc)
  4111. {
  4112. PortAddr iop_base;
  4113. int i = 10;
  4114. iop_base = asc_dvc->iop_base;
  4115. while ((AscGetChipStatus(iop_base) & CSW_SCSI_RESET_ACTIVE)
  4116. && (i-- > 0)) {
  4117. mdelay(100);
  4118. }
  4119. AscStopChip(iop_base);
  4120. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_SCSI_RESET | CC_HALT);
  4121. udelay(60);
  4122. AscSetChipIH(iop_base, INS_RFLAG_WTM);
  4123. AscSetChipIH(iop_base, INS_HALT);
  4124. AscSetChipControl(iop_base, CC_CHIP_RESET | CC_HALT);
  4125. AscSetChipControl(iop_base, CC_HALT);
  4126. mdelay(200);
  4127. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  4128. AscSetChipStatus(iop_base, 0);
  4129. return (AscIsChipHalted(iop_base));
  4130. }
  4131. static int AscFindSignature(PortAddr iop_base)
  4132. {
  4133. ushort sig_word;
  4134. ASC_DBG2(1, "AscFindSignature: AscGetChipSignatureByte(0x%x) 0x%x\n",
  4135. iop_base, AscGetChipSignatureByte(iop_base));
  4136. if (AscGetChipSignatureByte(iop_base) == (uchar)ASC_1000_ID1B) {
  4137. ASC_DBG2(1,
  4138. "AscFindSignature: AscGetChipSignatureWord(0x%x) 0x%x\n",
  4139. iop_base, AscGetChipSignatureWord(iop_base));
  4140. sig_word = AscGetChipSignatureWord(iop_base);
  4141. if ((sig_word == (ushort)ASC_1000_ID0W) ||
  4142. (sig_word == (ushort)ASC_1000_ID0W_FIX)) {
  4143. return (1);
  4144. }
  4145. }
  4146. return (0);
  4147. }
  4148. static void AscEnableInterrupt(PortAddr iop_base)
  4149. {
  4150. ushort cfg;
  4151. cfg = AscGetChipCfgLsw(iop_base);
  4152. AscSetChipCfgLsw(iop_base, cfg | ASC_CFG0_HOST_INT_ON);
  4153. return;
  4154. }
  4155. static void AscDisableInterrupt(PortAddr iop_base)
  4156. {
  4157. ushort cfg;
  4158. cfg = AscGetChipCfgLsw(iop_base);
  4159. AscSetChipCfgLsw(iop_base, cfg & (~ASC_CFG0_HOST_INT_ON));
  4160. return;
  4161. }
  4162. static uchar AscReadLramByte(PortAddr iop_base, ushort addr)
  4163. {
  4164. unsigned char byte_data;
  4165. unsigned short word_data;
  4166. if (isodd_word(addr)) {
  4167. AscSetChipLramAddr(iop_base, addr - 1);
  4168. word_data = AscGetChipLramData(iop_base);
  4169. byte_data = (word_data >> 8) & 0xFF;
  4170. } else {
  4171. AscSetChipLramAddr(iop_base, addr);
  4172. word_data = AscGetChipLramData(iop_base);
  4173. byte_data = word_data & 0xFF;
  4174. }
  4175. return byte_data;
  4176. }
  4177. static ushort AscReadLramWord(PortAddr iop_base, ushort addr)
  4178. {
  4179. ushort word_data;
  4180. AscSetChipLramAddr(iop_base, addr);
  4181. word_data = AscGetChipLramData(iop_base);
  4182. return (word_data);
  4183. }
  4184. #if CC_VERY_LONG_SG_LIST
  4185. static ASC_DCNT AscReadLramDWord(PortAddr iop_base, ushort addr)
  4186. {
  4187. ushort val_low, val_high;
  4188. ASC_DCNT dword_data;
  4189. AscSetChipLramAddr(iop_base, addr);
  4190. val_low = AscGetChipLramData(iop_base);
  4191. val_high = AscGetChipLramData(iop_base);
  4192. dword_data = ((ASC_DCNT) val_high << 16) | (ASC_DCNT) val_low;
  4193. return (dword_data);
  4194. }
  4195. #endif /* CC_VERY_LONG_SG_LIST */
  4196. static void
  4197. AscMemWordSetLram(PortAddr iop_base, ushort s_addr, ushort set_wval, int words)
  4198. {
  4199. int i;
  4200. AscSetChipLramAddr(iop_base, s_addr);
  4201. for (i = 0; i < words; i++) {
  4202. AscSetChipLramData(iop_base, set_wval);
  4203. }
  4204. }
  4205. static void AscWriteLramWord(PortAddr iop_base, ushort addr, ushort word_val)
  4206. {
  4207. AscSetChipLramAddr(iop_base, addr);
  4208. AscSetChipLramData(iop_base, word_val);
  4209. return;
  4210. }
  4211. static void AscWriteLramByte(PortAddr iop_base, ushort addr, uchar byte_val)
  4212. {
  4213. ushort word_data;
  4214. if (isodd_word(addr)) {
  4215. addr--;
  4216. word_data = AscReadLramWord(iop_base, addr);
  4217. word_data &= 0x00FF;
  4218. word_data |= (((ushort)byte_val << 8) & 0xFF00);
  4219. } else {
  4220. word_data = AscReadLramWord(iop_base, addr);
  4221. word_data &= 0xFF00;
  4222. word_data |= ((ushort)byte_val & 0x00FF);
  4223. }
  4224. AscWriteLramWord(iop_base, addr, word_data);
  4225. return;
  4226. }
  4227. /*
  4228. * Copy 2 bytes to LRAM.
  4229. *
  4230. * The source data is assumed to be in little-endian order in memory
  4231. * and is maintained in little-endian order when written to LRAM.
  4232. */
  4233. static void
  4234. AscMemWordCopyPtrToLram(PortAddr iop_base,
  4235. ushort s_addr, uchar *s_buffer, int words)
  4236. {
  4237. int i;
  4238. AscSetChipLramAddr(iop_base, s_addr);
  4239. for (i = 0; i < 2 * words; i += 2) {
  4240. /*
  4241. * On a little-endian system the second argument below
  4242. * produces a little-endian ushort which is written to
  4243. * LRAM in little-endian order. On a big-endian system
  4244. * the second argument produces a big-endian ushort which
  4245. * is "transparently" byte-swapped by outpw() and written
  4246. * in little-endian order to LRAM.
  4247. */
  4248. outpw(iop_base + IOP_RAM_DATA,
  4249. ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]);
  4250. }
  4251. return;
  4252. }
  4253. /*
  4254. * Copy 4 bytes to LRAM.
  4255. *
  4256. * The source data is assumed to be in little-endian order in memory
  4257. * and is maintained in little-endian order when writen to LRAM.
  4258. */
  4259. static void
  4260. AscMemDWordCopyPtrToLram(PortAddr iop_base,
  4261. ushort s_addr, uchar *s_buffer, int dwords)
  4262. {
  4263. int i;
  4264. AscSetChipLramAddr(iop_base, s_addr);
  4265. for (i = 0; i < 4 * dwords; i += 4) {
  4266. outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]); /* LSW */
  4267. outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 3] << 8) | s_buffer[i + 2]); /* MSW */
  4268. }
  4269. return;
  4270. }
  4271. /*
  4272. * Copy 2 bytes from LRAM.
  4273. *
  4274. * The source data is assumed to be in little-endian order in LRAM
  4275. * and is maintained in little-endian order when written to memory.
  4276. */
  4277. static void
  4278. AscMemWordCopyPtrFromLram(PortAddr iop_base,
  4279. ushort s_addr, uchar *d_buffer, int words)
  4280. {
  4281. int i;
  4282. ushort word;
  4283. AscSetChipLramAddr(iop_base, s_addr);
  4284. for (i = 0; i < 2 * words; i += 2) {
  4285. word = inpw(iop_base + IOP_RAM_DATA);
  4286. d_buffer[i] = word & 0xff;
  4287. d_buffer[i + 1] = (word >> 8) & 0xff;
  4288. }
  4289. return;
  4290. }
  4291. static ASC_DCNT AscMemSumLramWord(PortAddr iop_base, ushort s_addr, int words)
  4292. {
  4293. ASC_DCNT sum;
  4294. int i;
  4295. sum = 0L;
  4296. for (i = 0; i < words; i++, s_addr += 2) {
  4297. sum += AscReadLramWord(iop_base, s_addr);
  4298. }
  4299. return (sum);
  4300. }
  4301. static ushort AscInitLram(ASC_DVC_VAR *asc_dvc)
  4302. {
  4303. uchar i;
  4304. ushort s_addr;
  4305. PortAddr iop_base;
  4306. ushort warn_code;
  4307. iop_base = asc_dvc->iop_base;
  4308. warn_code = 0;
  4309. AscMemWordSetLram(iop_base, ASC_QADR_BEG, 0,
  4310. (ushort)(((int)(asc_dvc->max_total_qng + 2 + 1) *
  4311. 64) >> 1));
  4312. i = ASC_MIN_ACTIVE_QNO;
  4313. s_addr = ASC_QADR_BEG + ASC_QBLK_SIZE;
  4314. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  4315. (uchar)(i + 1));
  4316. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  4317. (uchar)(asc_dvc->max_total_qng));
  4318. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  4319. (uchar)i);
  4320. i++;
  4321. s_addr += ASC_QBLK_SIZE;
  4322. for (; i < asc_dvc->max_total_qng; i++, s_addr += ASC_QBLK_SIZE) {
  4323. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  4324. (uchar)(i + 1));
  4325. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  4326. (uchar)(i - 1));
  4327. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  4328. (uchar)i);
  4329. }
  4330. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
  4331. (uchar)ASC_QLINK_END);
  4332. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
  4333. (uchar)(asc_dvc->max_total_qng - 1));
  4334. AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
  4335. (uchar)asc_dvc->max_total_qng);
  4336. i++;
  4337. s_addr += ASC_QBLK_SIZE;
  4338. for (; i <= (uchar)(asc_dvc->max_total_qng + 3);
  4339. i++, s_addr += ASC_QBLK_SIZE) {
  4340. AscWriteLramByte(iop_base,
  4341. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_FWD), i);
  4342. AscWriteLramByte(iop_base,
  4343. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_BWD), i);
  4344. AscWriteLramByte(iop_base,
  4345. (ushort)(s_addr + (ushort)ASC_SCSIQ_B_QNO), i);
  4346. }
  4347. return warn_code;
  4348. }
  4349. static ASC_DCNT
  4350. AscLoadMicroCode(PortAddr iop_base,
  4351. ushort s_addr, uchar *mcode_buf, ushort mcode_size)
  4352. {
  4353. ASC_DCNT chksum;
  4354. ushort mcode_word_size;
  4355. ushort mcode_chksum;
  4356. /* Write the microcode buffer starting at LRAM address 0. */
  4357. mcode_word_size = (ushort)(mcode_size >> 1);
  4358. AscMemWordSetLram(iop_base, s_addr, 0, mcode_word_size);
  4359. AscMemWordCopyPtrToLram(iop_base, s_addr, mcode_buf, mcode_word_size);
  4360. chksum = AscMemSumLramWord(iop_base, s_addr, mcode_word_size);
  4361. ASC_DBG1(1, "AscLoadMicroCode: chksum 0x%lx\n", (ulong)chksum);
  4362. mcode_chksum = (ushort)AscMemSumLramWord(iop_base,
  4363. (ushort)ASC_CODE_SEC_BEG,
  4364. (ushort)((mcode_size -
  4365. s_addr - (ushort)
  4366. ASC_CODE_SEC_BEG) /
  4367. 2));
  4368. ASC_DBG1(1, "AscLoadMicroCode: mcode_chksum 0x%lx\n",
  4369. (ulong)mcode_chksum);
  4370. AscWriteLramWord(iop_base, ASCV_MCODE_CHKSUM_W, mcode_chksum);
  4371. AscWriteLramWord(iop_base, ASCV_MCODE_SIZE_W, mcode_size);
  4372. return (chksum);
  4373. }
  4374. /* Microcode buffer is kept after initialization for error recovery. */
  4375. static uchar _asc_mcode_buf[] = {
  4376. 0x01, 0x03, 0x01, 0x19, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4377. 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F,
  4378. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4379. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4380. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4381. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x12, 0x0D, 0x05,
  4382. 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4383. 0xFF, 0x80, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  4384. 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0xFF,
  4385. 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
  4386. 0x00, 0x00, 0xE4, 0x88, 0x00, 0x00, 0x00, 0x00, 0x80, 0x73, 0x48, 0x04,
  4387. 0x36, 0x00, 0x00, 0xA2, 0xC2, 0x00, 0x80, 0x73, 0x03, 0x23, 0x36, 0x40,
  4388. 0xB6, 0x00, 0x36, 0x00, 0x05, 0xD6, 0x0C, 0xD2, 0x12, 0xDA, 0x00, 0xA2,
  4389. 0xC2, 0x00, 0x92, 0x80, 0x1E, 0x98, 0x50, 0x00, 0xF5, 0x00, 0x48, 0x98,
  4390. 0xDF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x4F, 0x00, 0xF5, 0x00,
  4391. 0x48, 0x98, 0xEF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x80, 0x62,
  4392. 0x92, 0x80, 0x00, 0x46, 0x15, 0xEE, 0x13, 0xEA, 0x02, 0x01, 0x09, 0xD8,
  4393. 0xCD, 0x04, 0x4D, 0x00, 0x00, 0xA3, 0xD6, 0x00, 0xA6, 0x97, 0x7F, 0x23,
  4394. 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84, 0xD2, 0xC1, 0x80, 0x73, 0xCD, 0x04,
  4395. 0x4D, 0x00, 0x00, 0xA3, 0xDA, 0x01, 0xA6, 0x97, 0xC6, 0x81, 0xC2, 0x88,
  4396. 0x80, 0x73, 0x80, 0x77, 0x00, 0x01, 0x01, 0xA1, 0xFE, 0x00, 0x4F, 0x00,
  4397. 0x84, 0x97, 0x07, 0xA6, 0x08, 0x01, 0x00, 0x33, 0x03, 0x00, 0xC2, 0x88,
  4398. 0x03, 0x03, 0x01, 0xDE, 0xC2, 0x88, 0xCE, 0x00, 0x69, 0x60, 0xCE, 0x00,
  4399. 0x02, 0x03, 0x4A, 0x60, 0x00, 0xA2, 0x78, 0x01, 0x80, 0x63, 0x07, 0xA6,
  4400. 0x24, 0x01, 0x78, 0x81, 0x03, 0x03, 0x80, 0x63, 0xE2, 0x00, 0x07, 0xA6,
  4401. 0x34, 0x01, 0x00, 0x33, 0x04, 0x00, 0xC2, 0x88, 0x03, 0x07, 0x02, 0x01,
  4402. 0x04, 0xCA, 0x0D, 0x23, 0x68, 0x98, 0x4D, 0x04, 0x04, 0x85, 0x05, 0xD8,
  4403. 0x0D, 0x23, 0x68, 0x98, 0xCD, 0x04, 0x15, 0x23, 0xF8, 0x88, 0xFB, 0x23,
  4404. 0x02, 0x61, 0x82, 0x01, 0x80, 0x63, 0x02, 0x03, 0x06, 0xA3, 0x62, 0x01,
  4405. 0x00, 0x33, 0x0A, 0x00, 0xC2, 0x88, 0x4E, 0x00, 0x07, 0xA3, 0x6E, 0x01,
  4406. 0x00, 0x33, 0x0B, 0x00, 0xC2, 0x88, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33,
  4407. 0x1A, 0x00, 0xC2, 0x88, 0x50, 0x04, 0x88, 0x81, 0x06, 0xAB, 0x82, 0x01,
  4408. 0x88, 0x81, 0x4E, 0x00, 0x07, 0xA3, 0x92, 0x01, 0x50, 0x00, 0x00, 0xA3,
  4409. 0x3C, 0x01, 0x00, 0x05, 0x7C, 0x81, 0x46, 0x97, 0x02, 0x01, 0x05, 0xC6,
  4410. 0x04, 0x23, 0xA0, 0x01, 0x15, 0x23, 0xA1, 0x01, 0xBE, 0x81, 0xFD, 0x23,
  4411. 0x02, 0x61, 0x82, 0x01, 0x0A, 0xDA, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA0,
  4412. 0xB4, 0x01, 0x80, 0x63, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33, 0x1B, 0x00,
  4413. 0xC2, 0x88, 0x06, 0x23, 0x68, 0x98, 0xCD, 0x04, 0xE6, 0x84, 0x06, 0x01,
  4414. 0x00, 0xA2, 0xD4, 0x01, 0x57, 0x60, 0x00, 0xA0, 0xDA, 0x01, 0xE6, 0x84,
  4415. 0x80, 0x23, 0xA0, 0x01, 0xE6, 0x84, 0x80, 0x73, 0x4B, 0x00, 0x06, 0x61,
  4416. 0x00, 0xA2, 0x00, 0x02, 0x04, 0x01, 0x0C, 0xDE, 0x02, 0x01, 0x03, 0xCC,
  4417. 0x4F, 0x00, 0x84, 0x97, 0xFC, 0x81, 0x08, 0x23, 0x02, 0x41, 0x82, 0x01,
  4418. 0x4F, 0x00, 0x62, 0x97, 0x48, 0x04, 0x84, 0x80, 0xF0, 0x97, 0x00, 0x46,
  4419. 0x56, 0x00, 0x03, 0xC0, 0x01, 0x23, 0xE8, 0x00, 0x81, 0x73, 0x06, 0x29,
  4420. 0x03, 0x42, 0x06, 0xE2, 0x03, 0xEE, 0x6B, 0xEB, 0x11, 0x23, 0xF8, 0x88,
  4421. 0x04, 0x98, 0xF0, 0x80, 0x80, 0x73, 0x80, 0x77, 0x07, 0xA4, 0x2A, 0x02,
  4422. 0x7C, 0x95, 0x06, 0xA6, 0x34, 0x02, 0x03, 0xA6, 0x4C, 0x04, 0x46, 0x82,
  4423. 0x04, 0x01, 0x03, 0xD8, 0xB4, 0x98, 0x6A, 0x96, 0x46, 0x82, 0xFE, 0x95,
  4424. 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0xB6, 0x2D, 0x02, 0xA6, 0x6C, 0x02,
  4425. 0x07, 0xA6, 0x5A, 0x02, 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x62, 0x02,
  4426. 0xC2, 0x88, 0x7C, 0x95, 0x48, 0x82, 0x60, 0x96, 0x48, 0x82, 0x04, 0x23,
  4427. 0xA0, 0x01, 0x14, 0x23, 0xA1, 0x01, 0x3C, 0x84, 0x04, 0x01, 0x0C, 0xDC,
  4428. 0xE0, 0x23, 0x25, 0x61, 0xEF, 0x00, 0x14, 0x01, 0x4F, 0x04, 0xA8, 0x01,
  4429. 0x6F, 0x00, 0xA5, 0x01, 0x03, 0x23, 0xA4, 0x01, 0x06, 0x23, 0x9C, 0x01,
  4430. 0x24, 0x2B, 0x1C, 0x01, 0x02, 0xA6, 0xAA, 0x02, 0x07, 0xA6, 0x5A, 0x02,
  4431. 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x20, 0x04, 0x01, 0xA6, 0xB4, 0x02,
  4432. 0x00, 0xA6, 0xB4, 0x02, 0x00, 0x33, 0x12, 0x00, 0xC2, 0x88, 0x00, 0x0E,
  4433. 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0x8C, 0x02, 0x4D, 0x04, 0x04, 0x01,
  4434. 0x0B, 0xDC, 0xE7, 0x23, 0x04, 0x61, 0x84, 0x01, 0x10, 0x31, 0x12, 0x35,
  4435. 0x14, 0x01, 0xEC, 0x00, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0xEA, 0x82,
  4436. 0x18, 0x23, 0x04, 0x61, 0x18, 0xA0, 0xE2, 0x02, 0x04, 0x01, 0xA2, 0xC8,
  4437. 0x00, 0x33, 0x1F, 0x00, 0xC2, 0x88, 0x08, 0x31, 0x0A, 0x35, 0x0C, 0x39,
  4438. 0x0E, 0x3D, 0x7E, 0x98, 0xB6, 0x2D, 0x01, 0xA6, 0x14, 0x03, 0x00, 0xA6,
  4439. 0x14, 0x03, 0x07, 0xA6, 0x0C, 0x03, 0x06, 0xA6, 0x10, 0x03, 0x03, 0xA6,
  4440. 0x20, 0x04, 0x02, 0xA6, 0x6C, 0x02, 0x00, 0x33, 0x33, 0x00, 0xC2, 0x88,
  4441. 0x7C, 0x95, 0xEE, 0x82, 0x60, 0x96, 0xEE, 0x82, 0x82, 0x98, 0x80, 0x42,
  4442. 0x7E, 0x98, 0x64, 0xE4, 0x04, 0x01, 0x2D, 0xC8, 0x31, 0x05, 0x07, 0x01,
  4443. 0x00, 0xA2, 0x54, 0x03, 0x00, 0x43, 0x87, 0x01, 0x05, 0x05, 0x86, 0x98,
  4444. 0x7E, 0x98, 0x00, 0xA6, 0x16, 0x03, 0x07, 0xA6, 0x4C, 0x03, 0x03, 0xA6,
  4445. 0x3C, 0x04, 0x06, 0xA6, 0x50, 0x03, 0x01, 0xA6, 0x16, 0x03, 0x00, 0x33,
  4446. 0x25, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x32, 0x83, 0x60, 0x96, 0x32, 0x83,
  4447. 0x04, 0x01, 0x10, 0xCE, 0x07, 0xC8, 0x05, 0x05, 0xEB, 0x04, 0x00, 0x33,
  4448. 0x00, 0x20, 0xC0, 0x20, 0x81, 0x62, 0x72, 0x83, 0x00, 0x01, 0x05, 0x05,
  4449. 0xFF, 0xA2, 0x7A, 0x03, 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x2E, 0x83,
  4450. 0x05, 0x05, 0x15, 0x01, 0x00, 0xA2, 0x9A, 0x03, 0xEC, 0x00, 0x6E, 0x00,
  4451. 0x95, 0x01, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0x01, 0xA6, 0x96, 0x03,
  4452. 0x00, 0xA6, 0x96, 0x03, 0x10, 0x84, 0x80, 0x42, 0x7E, 0x98, 0x01, 0xA6,
  4453. 0xA4, 0x03, 0x00, 0xA6, 0xBC, 0x03, 0x10, 0x84, 0xA8, 0x98, 0x80, 0x42,
  4454. 0x01, 0xA6, 0xA4, 0x03, 0x07, 0xA6, 0xB2, 0x03, 0xD4, 0x83, 0x7C, 0x95,
  4455. 0xA8, 0x83, 0x00, 0x33, 0x2F, 0x00, 0xC2, 0x88, 0xA8, 0x98, 0x80, 0x42,
  4456. 0x00, 0xA6, 0xBC, 0x03, 0x07, 0xA6, 0xCA, 0x03, 0xD4, 0x83, 0x7C, 0x95,
  4457. 0xC0, 0x83, 0x00, 0x33, 0x26, 0x00, 0xC2, 0x88, 0x38, 0x2B, 0x80, 0x32,
  4458. 0x80, 0x36, 0x04, 0x23, 0xA0, 0x01, 0x12, 0x23, 0xA1, 0x01, 0x10, 0x84,
  4459. 0x07, 0xF0, 0x06, 0xA4, 0xF4, 0x03, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23,
  4460. 0x83, 0x03, 0x80, 0x63, 0x03, 0xA6, 0x0E, 0x04, 0x07, 0xA6, 0x06, 0x04,
  4461. 0x06, 0xA6, 0x0A, 0x04, 0x00, 0x33, 0x17, 0x00, 0xC2, 0x88, 0x7C, 0x95,
  4462. 0xF4, 0x83, 0x60, 0x96, 0xF4, 0x83, 0x20, 0x84, 0x07, 0xF0, 0x06, 0xA4,
  4463. 0x20, 0x04, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23, 0x83, 0x03, 0x80, 0x63,
  4464. 0xB6, 0x2D, 0x03, 0xA6, 0x3C, 0x04, 0x07, 0xA6, 0x34, 0x04, 0x06, 0xA6,
  4465. 0x38, 0x04, 0x00, 0x33, 0x30, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x20, 0x84,
  4466. 0x60, 0x96, 0x20, 0x84, 0x1D, 0x01, 0x06, 0xCC, 0x00, 0x33, 0x00, 0x84,
  4467. 0xC0, 0x20, 0x00, 0x23, 0xEA, 0x00, 0x81, 0x62, 0xA2, 0x0D, 0x80, 0x63,
  4468. 0x07, 0xA6, 0x5A, 0x04, 0x00, 0x33, 0x18, 0x00, 0xC2, 0x88, 0x03, 0x03,
  4469. 0x80, 0x63, 0xA3, 0x01, 0x07, 0xA4, 0x64, 0x04, 0x23, 0x01, 0x00, 0xA2,
  4470. 0x86, 0x04, 0x0A, 0xA0, 0x76, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1D, 0x00,
  4471. 0xC2, 0x88, 0x0B, 0xA0, 0x82, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1E, 0x00,
  4472. 0xC2, 0x88, 0x42, 0x23, 0xF8, 0x88, 0x00, 0x23, 0x22, 0xA3, 0xE6, 0x04,
  4473. 0x08, 0x23, 0x22, 0xA3, 0xA2, 0x04, 0x28, 0x23, 0x22, 0xA3, 0xAE, 0x04,
  4474. 0x02, 0x23, 0x22, 0xA3, 0xC4, 0x04, 0x42, 0x23, 0xF8, 0x88, 0x4A, 0x00,
  4475. 0x06, 0x61, 0x00, 0xA0, 0xAE, 0x04, 0x45, 0x23, 0xF8, 0x88, 0x04, 0x98,
  4476. 0x00, 0xA2, 0xC0, 0x04, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x82, 0xC0, 0x20,
  4477. 0x81, 0x62, 0xE8, 0x81, 0x47, 0x23, 0xF8, 0x88, 0x04, 0x01, 0x0B, 0xDE,
  4478. 0x04, 0x98, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x81, 0xC0, 0x20, 0x81, 0x62,
  4479. 0x14, 0x01, 0x00, 0xA0, 0x00, 0x02, 0x43, 0x23, 0xF8, 0x88, 0x04, 0x23,
  4480. 0xA0, 0x01, 0x44, 0x23, 0xA1, 0x01, 0x80, 0x73, 0x4D, 0x00, 0x03, 0xA3,
  4481. 0xF4, 0x04, 0x00, 0x33, 0x27, 0x00, 0xC2, 0x88, 0x04, 0x01, 0x04, 0xDC,
  4482. 0x02, 0x23, 0xA2, 0x01, 0x04, 0x23, 0xA0, 0x01, 0x04, 0x98, 0x26, 0x95,
  4483. 0x4B, 0x00, 0xF6, 0x00, 0x4F, 0x04, 0x4F, 0x00, 0x00, 0xA3, 0x22, 0x05,
  4484. 0x00, 0x05, 0x76, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x1C, 0x05, 0x0A, 0x85,
  4485. 0x46, 0x97, 0xCD, 0x04, 0x24, 0x85, 0x48, 0x04, 0x84, 0x80, 0x02, 0x01,
  4486. 0x03, 0xDA, 0x80, 0x23, 0x82, 0x01, 0x34, 0x85, 0x02, 0x23, 0xA0, 0x01,
  4487. 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x40, 0x05, 0x1D, 0x01, 0x04, 0xD6,
  4488. 0xFF, 0x23, 0x86, 0x41, 0x4B, 0x60, 0xCB, 0x00, 0xFF, 0x23, 0x80, 0x01,
  4489. 0x49, 0x00, 0x81, 0x01, 0x04, 0x01, 0x02, 0xC8, 0x30, 0x01, 0x80, 0x01,
  4490. 0xF7, 0x04, 0x03, 0x01, 0x49, 0x04, 0x80, 0x01, 0xC9, 0x00, 0x00, 0x05,
  4491. 0x00, 0x01, 0xFF, 0xA0, 0x60, 0x05, 0x77, 0x04, 0x01, 0x23, 0xEA, 0x00,
  4492. 0x5D, 0x00, 0xFE, 0xC7, 0x00, 0x62, 0x00, 0x23, 0xEA, 0x00, 0x00, 0x63,
  4493. 0x07, 0xA4, 0xF8, 0x05, 0x03, 0x03, 0x02, 0xA0, 0x8E, 0x05, 0xF4, 0x85,
  4494. 0x00, 0x33, 0x2D, 0x00, 0xC2, 0x88, 0x04, 0xA0, 0xB8, 0x05, 0x80, 0x63,
  4495. 0x00, 0x23, 0xDF, 0x00, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0xA4, 0x05,
  4496. 0x1D, 0x01, 0x06, 0xD6, 0x02, 0x23, 0x02, 0x41, 0x82, 0x01, 0x50, 0x00,
  4497. 0x62, 0x97, 0x04, 0x85, 0x04, 0x23, 0x02, 0x41, 0x82, 0x01, 0x04, 0x85,
  4498. 0x08, 0xA0, 0xBE, 0x05, 0xF4, 0x85, 0x03, 0xA0, 0xC4, 0x05, 0xF4, 0x85,
  4499. 0x01, 0xA0, 0xCE, 0x05, 0x88, 0x00, 0x80, 0x63, 0xCC, 0x86, 0x07, 0xA0,
  4500. 0xEE, 0x05, 0x5F, 0x00, 0x00, 0x2B, 0xDF, 0x08, 0x00, 0xA2, 0xE6, 0x05,
  4501. 0x80, 0x67, 0x80, 0x63, 0x01, 0xA2, 0x7A, 0x06, 0x7C, 0x85, 0x06, 0x23,
  4502. 0x68, 0x98, 0x48, 0x23, 0xF8, 0x88, 0x07, 0x23, 0x80, 0x00, 0x06, 0x87,
  4503. 0x80, 0x63, 0x7C, 0x85, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63, 0x4A, 0x00,
  4504. 0x06, 0x61, 0x00, 0xA2, 0x36, 0x06, 0x1D, 0x01, 0x16, 0xD4, 0xC0, 0x23,
  4505. 0x07, 0x41, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x1C, 0x06, 0x00, 0x33,
  4506. 0x37, 0x00, 0xC2, 0x88, 0x1D, 0x01, 0x01, 0xD6, 0x20, 0x23, 0x63, 0x60,
  4507. 0x83, 0x03, 0x80, 0x63, 0x02, 0x23, 0xDF, 0x00, 0x07, 0xA6, 0x7C, 0x05,
  4508. 0xEF, 0x04, 0x6F, 0x00, 0x00, 0x63, 0x4B, 0x00, 0x06, 0x41, 0xCB, 0x00,
  4509. 0x52, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x4E, 0x06, 0x1D, 0x01, 0x03, 0xCA,
  4510. 0xC0, 0x23, 0x07, 0x41, 0x00, 0x63, 0x1D, 0x01, 0x04, 0xCC, 0x00, 0x33,
  4511. 0x00, 0x83, 0xC0, 0x20, 0x81, 0x62, 0x80, 0x23, 0x07, 0x41, 0x00, 0x63,
  4512. 0x80, 0x67, 0x08, 0x23, 0x83, 0x03, 0x80, 0x63, 0x00, 0x63, 0x01, 0x23,
  4513. 0xDF, 0x00, 0x06, 0xA6, 0x84, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67,
  4514. 0x80, 0x63, 0x00, 0x33, 0x00, 0x40, 0xC0, 0x20, 0x81, 0x62, 0x00, 0x63,
  4515. 0x00, 0x00, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x94, 0x06,
  4516. 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x00, 0x01, 0xA0, 0x14, 0x07, 0x00, 0x2B,
  4517. 0x40, 0x0E, 0x80, 0x63, 0x01, 0x00, 0x06, 0xA6, 0xAA, 0x06, 0x07, 0xA6,
  4518. 0x7C, 0x05, 0x40, 0x0E, 0x80, 0x63, 0x00, 0x43, 0x00, 0xA0, 0xA2, 0x06,
  4519. 0x06, 0xA6, 0xBC, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67, 0x40, 0x0E,
  4520. 0x80, 0x63, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63,
  4521. 0x07, 0xA6, 0xD6, 0x06, 0x00, 0x33, 0x2A, 0x00, 0xC2, 0x88, 0x03, 0x03,
  4522. 0x80, 0x63, 0x89, 0x00, 0x0A, 0x2B, 0x07, 0xA6, 0xE8, 0x06, 0x00, 0x33,
  4523. 0x29, 0x00, 0xC2, 0x88, 0x00, 0x43, 0x00, 0xA2, 0xF4, 0x06, 0xC0, 0x0E,
  4524. 0x80, 0x63, 0xDE, 0x86, 0xC0, 0x0E, 0x00, 0x33, 0x00, 0x80, 0xC0, 0x20,
  4525. 0x81, 0x62, 0x04, 0x01, 0x02, 0xDA, 0x80, 0x63, 0x7C, 0x85, 0x80, 0x7B,
  4526. 0x80, 0x63, 0x06, 0xA6, 0x8C, 0x06, 0x00, 0x33, 0x2C, 0x00, 0xC2, 0x88,
  4527. 0x0C, 0xA2, 0x2E, 0x07, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6,
  4528. 0x2C, 0x07, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x33, 0x3D, 0x00, 0xC2, 0x88,
  4529. 0x00, 0x00, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0x0C, 0xA0, 0x44, 0x07,
  4530. 0x07, 0xA6, 0x7C, 0x05, 0xBF, 0x23, 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84,
  4531. 0x00, 0x63, 0xF0, 0x04, 0x01, 0x01, 0xF1, 0x00, 0x00, 0x01, 0xF2, 0x00,
  4532. 0x01, 0x05, 0x80, 0x01, 0x72, 0x04, 0x71, 0x00, 0x81, 0x01, 0x70, 0x04,
  4533. 0x80, 0x05, 0x81, 0x05, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04,
  4534. 0x01, 0x01, 0xF1, 0x00, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04, 0x71, 0x00,
  4535. 0x81, 0x01, 0x72, 0x00, 0x80, 0x01, 0x71, 0x04, 0x70, 0x00, 0x80, 0x01,
  4536. 0x70, 0x04, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x00, 0x01,
  4537. 0xF1, 0x00, 0x70, 0x00, 0x80, 0x01, 0x70, 0x04, 0x71, 0x00, 0x80, 0x01,
  4538. 0x72, 0x00, 0x81, 0x01, 0x71, 0x04, 0x70, 0x00, 0x81, 0x01, 0x70, 0x04,
  4539. 0x00, 0x63, 0x00, 0x23, 0xB3, 0x01, 0x83, 0x05, 0xA3, 0x01, 0xA2, 0x01,
  4540. 0xA1, 0x01, 0x01, 0x23, 0xA0, 0x01, 0x00, 0x01, 0xC8, 0x00, 0x03, 0xA1,
  4541. 0xC4, 0x07, 0x00, 0x33, 0x07, 0x00, 0xC2, 0x88, 0x80, 0x05, 0x81, 0x05,
  4542. 0x04, 0x01, 0x11, 0xC8, 0x48, 0x00, 0xB0, 0x01, 0xB1, 0x01, 0x08, 0x23,
  4543. 0xB2, 0x01, 0x05, 0x01, 0x48, 0x04, 0x00, 0x43, 0x00, 0xA2, 0xE4, 0x07,
  4544. 0x00, 0x05, 0xDA, 0x87, 0x00, 0x01, 0xC8, 0x00, 0xFF, 0x23, 0x80, 0x01,
  4545. 0x05, 0x05, 0x00, 0x63, 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04,
  4546. 0x00, 0x02, 0x80, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04, 0x00, 0x63,
  4547. 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04, 0x00, 0x02, 0x00, 0xA0,
  4548. 0x14, 0x08, 0x16, 0x88, 0x00, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04,
  4549. 0x00, 0x63, 0xF3, 0x04, 0x00, 0x23, 0xF4, 0x00, 0x74, 0x00, 0x80, 0x43,
  4550. 0xF4, 0x00, 0xCF, 0x40, 0x00, 0xA2, 0x44, 0x08, 0x74, 0x04, 0x02, 0x01,
  4551. 0xF7, 0xC9, 0xF6, 0xD9, 0x00, 0x01, 0x01, 0xA1, 0x24, 0x08, 0x04, 0x98,
  4552. 0x26, 0x95, 0x24, 0x88, 0x73, 0x04, 0x00, 0x63, 0xF3, 0x04, 0x75, 0x04,
  4553. 0x5A, 0x88, 0x02, 0x01, 0x04, 0xD8, 0x46, 0x97, 0x04, 0x98, 0x26, 0x95,
  4554. 0x4A, 0x88, 0x75, 0x00, 0x00, 0xA3, 0x64, 0x08, 0x00, 0x05, 0x4E, 0x88,
  4555. 0x73, 0x04, 0x00, 0x63, 0x80, 0x7B, 0x80, 0x63, 0x06, 0xA6, 0x76, 0x08,
  4556. 0x00, 0x33, 0x3E, 0x00, 0xC2, 0x88, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63,
  4557. 0x00, 0x63, 0x38, 0x2B, 0x9C, 0x88, 0x38, 0x2B, 0x92, 0x88, 0x32, 0x09,
  4558. 0x31, 0x05, 0x92, 0x98, 0x05, 0x05, 0xB2, 0x09, 0x00, 0x63, 0x00, 0x32,
  4559. 0x00, 0x36, 0x00, 0x3A, 0x00, 0x3E, 0x00, 0x63, 0x80, 0x32, 0x80, 0x36,
  4560. 0x80, 0x3A, 0x80, 0x3E, 0xB4, 0x3D, 0x00, 0x63, 0x38, 0x2B, 0x40, 0x32,
  4561. 0x40, 0x36, 0x40, 0x3A, 0x40, 0x3E, 0x00, 0x63, 0x5A, 0x20, 0xC9, 0x40,
  4562. 0x00, 0xA0, 0xB4, 0x08, 0x5D, 0x00, 0xFE, 0xC3, 0x00, 0x63, 0x80, 0x73,
  4563. 0xE6, 0x20, 0x02, 0x23, 0xE8, 0x00, 0x82, 0x73, 0xFF, 0xFD, 0x80, 0x73,
  4564. 0x13, 0x23, 0xF8, 0x88, 0x66, 0x20, 0xC0, 0x20, 0x04, 0x23, 0xA0, 0x01,
  4565. 0xA1, 0x23, 0xA1, 0x01, 0x81, 0x62, 0xE2, 0x88, 0x80, 0x73, 0x80, 0x77,
  4566. 0x68, 0x00, 0x00, 0xA2, 0x80, 0x00, 0x03, 0xC2, 0xF1, 0xC7, 0x41, 0x23,
  4567. 0xF8, 0x88, 0x11, 0x23, 0xA1, 0x01, 0x04, 0x23, 0xA0, 0x01, 0xE6, 0x84,
  4568. };
  4569. static unsigned short _asc_mcode_size = sizeof(_asc_mcode_buf);
  4570. static ADV_DCNT _asc_mcode_chksum = 0x012C453FUL;
  4571. /* Microcode buffer is kept after initialization for error recovery. */
  4572. static unsigned char _adv_asc3550_buf[] = {
  4573. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0x16, 0x18, 0xe4, 0x00, 0xfc,
  4574. 0x01, 0x00, 0x48, 0xe4, 0xbe, 0x18, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00,
  4575. 0x00, 0xfa, 0xff, 0xff, 0x28, 0x0e, 0x9e, 0xe7, 0xff, 0x00, 0x82, 0xe7,
  4576. 0x00, 0xea, 0x00, 0xf6, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0, 0x01, 0xf6,
  4577. 0x01, 0xfa, 0x08, 0x00, 0x03, 0x00, 0x04, 0x00, 0x18, 0xf4, 0x10, 0x00,
  4578. 0x00, 0xec, 0x85, 0xf0, 0xbc, 0x00, 0xd5, 0xf0, 0x8e, 0x0c, 0x38, 0x54,
  4579. 0x00, 0xe6, 0x1e, 0xf0, 0x86, 0xf0, 0xb4, 0x00, 0x98, 0x57, 0xd0, 0x01,
  4580. 0x0c, 0x1c, 0x3e, 0x1c, 0x0c, 0x00, 0xbb, 0x00, 0xaa, 0x18, 0x02, 0x80,
  4581. 0x32, 0xf0, 0x01, 0xfc, 0x88, 0x0c, 0xc6, 0x12, 0x02, 0x13, 0x18, 0x40,
  4582. 0x00, 0x57, 0x01, 0xea, 0x3c, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
  4583. 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
  4584. 0x3e, 0x01, 0xda, 0x0f, 0x22, 0x10, 0x08, 0x12, 0x02, 0x4a, 0xb9, 0x54,
  4585. 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4, 0x20, 0x00, 0x32, 0x00,
  4586. 0x3e, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
  4587. 0x70, 0x01, 0x72, 0x01, 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x62, 0x0a,
  4588. 0x92, 0x0c, 0x2c, 0x10, 0x2e, 0x10, 0x06, 0x13, 0x4c, 0x1c, 0xbb, 0x55,
  4589. 0x3c, 0x56, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0xb1, 0xf0,
  4590. 0x03, 0xf7, 0x06, 0xf7, 0x03, 0xfc, 0x0f, 0x00, 0x40, 0x00, 0xbe, 0x00,
  4591. 0x00, 0x01, 0xb0, 0x08, 0x30, 0x13, 0x64, 0x15, 0x32, 0x1c, 0x38, 0x1c,
  4592. 0x4e, 0x1c, 0x10, 0x44, 0x02, 0x48, 0x00, 0x4c, 0x04, 0xea, 0x5d, 0xf0,
  4593. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00,
  4594. 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01, 0x4e, 0x0b, 0x1e, 0x0e, 0x0c, 0x10,
  4595. 0x0a, 0x12, 0x04, 0x13, 0x40, 0x13, 0x30, 0x1c, 0x00, 0x4e, 0xbd, 0x56,
  4596. 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xa7, 0xf0,
  4597. 0xb8, 0xf0, 0x0e, 0xf7, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00,
  4598. 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00,
  4599. 0xde, 0x03, 0x56, 0x0a, 0x14, 0x0e, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10,
  4600. 0x36, 0x10, 0x0a, 0x13, 0x12, 0x13, 0x52, 0x13, 0x10, 0x15, 0x14, 0x15,
  4601. 0xac, 0x16, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44,
  4602. 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x83, 0x55,
  4603. 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0, 0x0c, 0xf0,
  4604. 0x5c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8, 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa,
  4605. 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00, 0x0a, 0x00, 0x0d, 0x00, 0x1c, 0x00,
  4606. 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01,
  4607. 0x26, 0x01, 0x79, 0x01, 0x7a, 0x01, 0xc0, 0x01, 0xc2, 0x01, 0x7c, 0x02,
  4608. 0x5a, 0x03, 0xea, 0x04, 0xe8, 0x07, 0x68, 0x08, 0x69, 0x08, 0xba, 0x08,
  4609. 0xe9, 0x09, 0x06, 0x0b, 0x3a, 0x0e, 0x00, 0x10, 0x1a, 0x10, 0xed, 0x10,
  4610. 0xf1, 0x10, 0x06, 0x12, 0x0c, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x82, 0x13,
  4611. 0x42, 0x14, 0xd6, 0x14, 0x8a, 0x15, 0xc6, 0x17, 0xd2, 0x17, 0x6b, 0x18,
  4612. 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40, 0x0e, 0x47, 0x48, 0x47,
  4613. 0x41, 0x48, 0x89, 0x48, 0x80, 0x4c, 0x00, 0x54, 0x44, 0x55, 0xe5, 0x55,
  4614. 0x14, 0x56, 0x77, 0x57, 0xbf, 0x57, 0x40, 0x5c, 0x06, 0x80, 0x08, 0x90,
  4615. 0x03, 0xa1, 0xfe, 0x9c, 0xf0, 0x29, 0x02, 0xfe, 0xb8, 0x0c, 0xff, 0x10,
  4616. 0x00, 0x00, 0xd0, 0xfe, 0xcc, 0x18, 0x00, 0xcf, 0xfe, 0x80, 0x01, 0xff,
  4617. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  4618. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x48, 0x00, 0x4f, 0xff, 0x04, 0x00,
  4619. 0x00, 0x10, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  4620. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x0f,
  4621. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  4622. 0xfe, 0x04, 0xf7, 0xcf, 0x2a, 0x67, 0x0b, 0x01, 0xfe, 0xce, 0x0e, 0xfe,
  4623. 0x04, 0xf7, 0xcf, 0x67, 0x0b, 0x3c, 0x2a, 0xfe, 0x3d, 0xf0, 0xfe, 0x02,
  4624. 0x02, 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x91, 0xf0, 0xfe, 0xf0, 0x01, 0xfe,
  4625. 0x90, 0xf0, 0xfe, 0xf0, 0x01, 0xfe, 0x8f, 0xf0, 0x9c, 0x05, 0x51, 0x3b,
  4626. 0x02, 0xfe, 0xd4, 0x0c, 0x01, 0xfe, 0x44, 0x0d, 0xfe, 0xdd, 0x12, 0xfe,
  4627. 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x05, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
  4628. 0x47, 0x18, 0xfe, 0xa6, 0x00, 0xb5, 0xfe, 0x48, 0xf0, 0xfe, 0x86, 0x02,
  4629. 0xfe, 0x49, 0xf0, 0xfe, 0xa0, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xbe, 0x02,
  4630. 0xfe, 0x46, 0xf0, 0xfe, 0x50, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x56, 0x02,
  4631. 0xfe, 0x43, 0xf0, 0xfe, 0x44, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x48, 0x02,
  4632. 0xfe, 0x45, 0xf0, 0xfe, 0x4c, 0x02, 0x17, 0x0b, 0xa0, 0x17, 0x06, 0x18,
  4633. 0x96, 0x02, 0x29, 0xfe, 0x00, 0x1c, 0xde, 0xfe, 0x02, 0x1c, 0xdd, 0xfe,
  4634. 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x20, 0x17, 0xfe, 0xe7, 0x10,
  4635. 0xfe, 0x06, 0xfc, 0xc7, 0x0a, 0x6b, 0x01, 0x9e, 0x02, 0x29, 0x14, 0x4d,
  4636. 0x37, 0x97, 0x01, 0xfe, 0x64, 0x0f, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xbd,
  4637. 0x10, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
  4638. 0x58, 0x1c, 0x17, 0x06, 0x18, 0x96, 0x2a, 0x25, 0x29, 0xfe, 0x3d, 0xf0,
  4639. 0xfe, 0x02, 0x02, 0x21, 0xfe, 0x94, 0x02, 0xfe, 0x5a, 0x1c, 0xea, 0xfe,
  4640. 0x14, 0x1c, 0x14, 0xfe, 0x30, 0x00, 0x37, 0x97, 0x01, 0xfe, 0x54, 0x0f,
  4641. 0x17, 0x06, 0x18, 0x96, 0x02, 0xd0, 0x1e, 0x20, 0x07, 0x10, 0x34, 0xfe,
  4642. 0x69, 0x10, 0x17, 0x06, 0x18, 0x96, 0xfe, 0x04, 0xec, 0x20, 0x46, 0x3d,
  4643. 0x12, 0x20, 0xfe, 0x05, 0xf6, 0xc7, 0x01, 0xfe, 0x52, 0x16, 0x09, 0x4a,
  4644. 0x4c, 0x35, 0x11, 0x2d, 0x3c, 0x8a, 0x01, 0xe6, 0x02, 0x29, 0x0a, 0x40,
  4645. 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x01, 0x6f, 0xfe, 0x18, 0x10, 0xfe, 0x41,
  4646. 0x58, 0x0a, 0x99, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x64, 0xfe, 0x0c, 0x03,
  4647. 0x01, 0xe6, 0x02, 0x29, 0x2a, 0x46, 0xfe, 0x02, 0xe8, 0x27, 0xf8, 0xfe,
  4648. 0x9e, 0x43, 0xf7, 0xfe, 0x27, 0xf0, 0xfe, 0xdc, 0x01, 0xfe, 0x07, 0x4b,
  4649. 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x40, 0x1c, 0x25, 0xd2, 0xfe, 0x26, 0xf0,
  4650. 0xfe, 0x56, 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x44, 0x03, 0xfe, 0x11, 0xf0,
  4651. 0x9c, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 0xf0, 0xfe, 0x64, 0x03, 0xeb, 0x0f,
  4652. 0xfe, 0x11, 0x00, 0x02, 0x5a, 0x2a, 0xfe, 0x48, 0x1c, 0xeb, 0x09, 0x04,
  4653. 0x1d, 0xfe, 0x18, 0x13, 0x23, 0x1e, 0x98, 0xac, 0x12, 0x98, 0x0a, 0x40,
  4654. 0x01, 0x0e, 0xac, 0x75, 0x01, 0xfe, 0xbc, 0x15, 0x11, 0xca, 0x25, 0xd2,
  4655. 0xfe, 0x01, 0xf0, 0xd2, 0xfe, 0x82, 0xf0, 0xfe, 0x92, 0x03, 0xec, 0x11,
  4656. 0xfe, 0xe4, 0x00, 0x65, 0xfe, 0xa4, 0x03, 0x25, 0x32, 0x1f, 0xfe, 0xb4,
  4657. 0x03, 0x01, 0x43, 0xfe, 0x06, 0xf0, 0xfe, 0xc4, 0x03, 0x8d, 0x81, 0xfe,
  4658. 0x0a, 0xf0, 0xfe, 0x7a, 0x06, 0x02, 0x22, 0x05, 0x6b, 0x28, 0x16, 0xfe,
  4659. 0xf6, 0x04, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02, 0xd1,
  4660. 0xeb, 0x2a, 0x67, 0x1a, 0xfe, 0x67, 0x1b, 0xf8, 0xf7, 0xfe, 0x48, 0x1c,
  4661. 0x70, 0x01, 0x6e, 0x87, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x16, 0xd3,
  4662. 0x0a, 0xca, 0x01, 0x0e, 0x74, 0x60, 0x59, 0x76, 0x27, 0x05, 0x6b, 0x28,
  4663. 0xfe, 0x10, 0x12, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 0x66, 0x02, 0x02,
  4664. 0xd1, 0xbc, 0x7d, 0xbd, 0x7f, 0x25, 0x22, 0x65, 0xfe, 0x3c, 0x04, 0x1f,
  4665. 0xfe, 0x38, 0x04, 0x68, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
  4666. 0x12, 0x2b, 0xff, 0x02, 0x00, 0x10, 0x01, 0x08, 0x1f, 0xfe, 0xe0, 0x04,
  4667. 0x2b, 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd5, 0xfe, 0x4c, 0x44, 0xfe,
  4668. 0x4c, 0x12, 0x60, 0xfe, 0x44, 0x48, 0x13, 0x2c, 0xfe, 0x4c, 0x54, 0x64,
  4669. 0xd3, 0x46, 0x76, 0x27, 0xfa, 0xef, 0xfe, 0x62, 0x13, 0x09, 0x04, 0x1d,
  4670. 0xfe, 0x2a, 0x13, 0x2f, 0x07, 0x7e, 0xa5, 0xfe, 0x20, 0x10, 0x13, 0x2c,
  4671. 0xfe, 0x4c, 0x54, 0x64, 0xd3, 0xfa, 0xef, 0x86, 0x09, 0x04, 0x1d, 0xfe,
  4672. 0x08, 0x13, 0x2f, 0x07, 0x7e, 0x6e, 0x09, 0x04, 0x1d, 0xfe, 0x1c, 0x12,
  4673. 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe,
  4674. 0x70, 0x0c, 0x02, 0x22, 0x2b, 0x11, 0xfe, 0xe6, 0x00, 0xfe, 0x1c, 0x90,
  4675. 0xf9, 0x03, 0x14, 0x92, 0x01, 0x33, 0x02, 0x29, 0xfe, 0x42, 0x5b, 0x67,
  4676. 0x1a, 0xfe, 0x46, 0x59, 0xf8, 0xf7, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4,
  4677. 0x4f, 0x09, 0x04, 0x0b, 0xfe, 0x78, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x1a,
  4678. 0xfe, 0x70, 0x12, 0x49, 0x04, 0x06, 0xfe, 0x60, 0x13, 0x05, 0xfe, 0xa2,
  4679. 0x00, 0x28, 0x16, 0xfe, 0x80, 0x05, 0xfe, 0x31, 0xe4, 0x6a, 0x49, 0x04,
  4680. 0x0b, 0xfe, 0x4a, 0x13, 0x05, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x42, 0x12,
  4681. 0x5e, 0x01, 0x08, 0x25, 0x32, 0xf1, 0x01, 0x08, 0x26, 0xfe, 0x98, 0x05,
  4682. 0x11, 0xfe, 0xe3, 0x00, 0x23, 0x49, 0xfe, 0x4a, 0xf0, 0xfe, 0x6a, 0x05,
  4683. 0xfe, 0x49, 0xf0, 0xfe, 0x64, 0x05, 0x83, 0x24, 0xfe, 0x21, 0x00, 0xa1,
  4684. 0x24, 0xfe, 0x22, 0x00, 0xa0, 0x24, 0x4c, 0xfe, 0x09, 0x48, 0x01, 0x08,
  4685. 0x26, 0xfe, 0x98, 0x05, 0xfe, 0xe2, 0x08, 0x49, 0x04, 0xc5, 0x3b, 0x01,
  4686. 0x86, 0x24, 0x06, 0x12, 0xcc, 0x37, 0xfe, 0x27, 0x01, 0x09, 0x04, 0x1d,
  4687. 0xfe, 0x22, 0x12, 0x47, 0x01, 0xa7, 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b,
  4688. 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe, 0x70, 0x0c, 0x02, 0x22, 0x05, 0xfe,
  4689. 0x9c, 0x00, 0x28, 0xfe, 0x3e, 0x12, 0x05, 0x50, 0x28, 0xfe, 0x36, 0x13,
  4690. 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x08, 0x06, 0x0a, 0x06, 0x49, 0x04, 0x19,
  4691. 0xfe, 0x02, 0x12, 0x5f, 0x01, 0xfe, 0xaa, 0x14, 0x1f, 0xfe, 0xfe, 0x05,
  4692. 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x50, 0xb4, 0x0c,
  4693. 0x50, 0x05, 0xc6, 0x28, 0xfe, 0x62, 0x12, 0x05, 0x3f, 0x28, 0xfe, 0x5a,
  4694. 0x13, 0x01, 0xfe, 0x14, 0x18, 0x01, 0xfe, 0x66, 0x18, 0xfe, 0x43, 0x48,
  4695. 0xb7, 0x19, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d,
  4696. 0x85, 0xb7, 0x69, 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x72, 0x06, 0x49, 0x04,
  4697. 0x1b, 0xdf, 0x89, 0x0a, 0x4d, 0x01, 0xfe, 0xd8, 0x14, 0x1f, 0xfe, 0x68,
  4698. 0x06, 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x3f, 0xb4,
  4699. 0x0c, 0x3f, 0x17, 0x06, 0x01, 0xa7, 0xec, 0x72, 0x70, 0x01, 0x6e, 0x87,
  4700. 0x11, 0xfe, 0xe2, 0x00, 0x01, 0x08, 0x25, 0x32, 0xfe, 0x0a, 0xf0, 0xfe,
  4701. 0xa6, 0x06, 0x8c, 0xfe, 0x5c, 0x07, 0xfe, 0x06, 0xf0, 0xfe, 0x64, 0x07,
  4702. 0x8d, 0x81, 0x02, 0x22, 0x09, 0x04, 0x0b, 0xfe, 0x2e, 0x12, 0x15, 0x1a,
  4703. 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00,
  4704. 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08, 0x15, 0x00, 0x02, 0xfe, 0x32,
  4705. 0x08, 0x61, 0x04, 0x1b, 0xfe, 0x38, 0x12, 0x09, 0x04, 0x1b, 0x6e, 0x15,
  4706. 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01,
  4707. 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x06, 0x01, 0x08, 0x15, 0x00, 0x02,
  4708. 0xd9, 0x66, 0x4c, 0xfe, 0x3a, 0x55, 0x5f, 0xfe, 0x9a, 0x81, 0x4b, 0x1d,
  4709. 0xba, 0xfe, 0x32, 0x07, 0x0a, 0x1d, 0xfe, 0x09, 0x6f, 0xaf, 0xfe, 0xca,
  4710. 0x45, 0xfe, 0x32, 0x12, 0x62, 0x2c, 0x85, 0x66, 0x7b, 0x01, 0x08, 0x25,
  4711. 0x32, 0xfe, 0x0a, 0xf0, 0xfe, 0x32, 0x07, 0x8d, 0x81, 0x8c, 0xfe, 0x5c,
  4712. 0x07, 0x02, 0x22, 0x01, 0x43, 0x02, 0xfe, 0x8a, 0x06, 0x15, 0x19, 0x02,
  4713. 0xfe, 0x8a, 0x06, 0xfe, 0x9c, 0xf7, 0xd4, 0xfe, 0x2c, 0x90, 0xfe, 0xae,
  4714. 0x90, 0x77, 0xfe, 0xca, 0x07, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x4a, 0x6a,
  4715. 0x35, 0x1e, 0x20, 0x07, 0x10, 0xfe, 0x0e, 0x12, 0x74, 0xfe, 0x80, 0x80,
  4716. 0x37, 0x20, 0x63, 0x27, 0xfe, 0x06, 0x10, 0xfe, 0x83, 0xe7, 0xc4, 0xa1,
  4717. 0xfe, 0x03, 0x40, 0x09, 0x4a, 0x4f, 0x35, 0x01, 0xa8, 0xad, 0xfe, 0x1f,
  4718. 0x40, 0x12, 0x58, 0x01, 0xa5, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
  4719. 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x83, 0xfb, 0xfe, 0x8a, 0x90, 0x0c, 0x52,
  4720. 0x18, 0x53, 0xfe, 0x0c, 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe,
  4721. 0xc2, 0x50, 0x0c, 0x39, 0x18, 0x3a, 0xfe, 0x4a, 0x10, 0x09, 0x04, 0x6a,
  4722. 0xfe, 0x2a, 0x12, 0xfe, 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x54, 0x18,
  4723. 0x55, 0x09, 0x04, 0x4f, 0x85, 0x01, 0xa8, 0xfe, 0x1f, 0x80, 0x12, 0x58,
  4724. 0xfe, 0x44, 0x90, 0xfe, 0xc6, 0x90, 0x0c, 0x56, 0x18, 0x57, 0xfb, 0xfe,
  4725. 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90,
  4726. 0x0c, 0x39, 0x18, 0x3a, 0x0c, 0x38, 0x18, 0x4e, 0x09, 0x4a, 0x19, 0x35,
  4727. 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x48, 0x08, 0xfe, 0x9e, 0xf0,
  4728. 0xfe, 0x5c, 0x08, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0xfe, 0x80,
  4729. 0x08, 0xb9, 0xfe, 0x9e, 0x08, 0x8c, 0xfe, 0x74, 0x08, 0xfe, 0x06, 0xf0,
  4730. 0xfe, 0x7a, 0x08, 0x8d, 0x81, 0x02, 0x22, 0x01, 0x43, 0xfe, 0xc9, 0x10,
  4731. 0x15, 0x19, 0xfe, 0xc9, 0x10, 0x61, 0x04, 0x06, 0xfe, 0x10, 0x12, 0x61,
  4732. 0x04, 0x0b, 0x45, 0x09, 0x04, 0x0b, 0xfe, 0x68, 0x12, 0xfe, 0x2e, 0x1c,
  4733. 0x02, 0xfe, 0x24, 0x0a, 0x61, 0x04, 0x06, 0x45, 0x61, 0x04, 0x0b, 0xfe,
  4734. 0x52, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0x1e, 0x09, 0xfe,
  4735. 0xac, 0xf0, 0xfe, 0xbe, 0x08, 0xfe, 0x8a, 0x10, 0xaa, 0xfe, 0xf3, 0x10,
  4736. 0xfe, 0xad, 0xf0, 0xfe, 0xca, 0x08, 0x02, 0xfe, 0x24, 0x0a, 0xab, 0xfe,
  4737. 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0x9d, 0xe9, 0x1c, 0xfe, 0x00, 0xfe, 0xfe,
  4738. 0x1c, 0x12, 0xb5, 0xfe, 0xd2, 0xf0, 0x9d, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
  4739. 0x16, 0x9d, 0x05, 0xcb, 0x1c, 0x06, 0x16, 0x9d, 0xb8, 0x6d, 0xb9, 0x6d,
  4740. 0xaa, 0xab, 0xfe, 0xb1, 0x10, 0x70, 0x5e, 0x2b, 0x14, 0x92, 0x01, 0x33,
  4741. 0x0f, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x5a, 0x0f, 0x7c, 0x02, 0x5a,
  4742. 0xfe, 0x74, 0x18, 0x1c, 0xfe, 0x00, 0xf8, 0x16, 0x6d, 0x67, 0x1b, 0x01,
  4743. 0xfe, 0x44, 0x0d, 0x3b, 0x01, 0xe6, 0x1e, 0x27, 0x74, 0x67, 0x1a, 0x02,
  4744. 0x6d, 0x09, 0x04, 0x0b, 0x21, 0xfe, 0x06, 0x0a, 0x09, 0x04, 0x6a, 0xfe,
  4745. 0x82, 0x12, 0x09, 0x04, 0x19, 0xfe, 0x66, 0x13, 0x1e, 0x58, 0xac, 0xfc,
  4746. 0xfe, 0x83, 0x80, 0xfe, 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91,
  4747. 0xfe, 0x86, 0x91, 0x63, 0x27, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x77,
  4748. 0xd7, 0x05, 0x54, 0x31, 0x55, 0x0c, 0x7b, 0x18, 0x7c, 0xbe, 0x54, 0xbf,
  4749. 0x55, 0x01, 0xa8, 0xad, 0x63, 0x27, 0x12, 0x58, 0xc0, 0x38, 0xc1, 0x4e,
  4750. 0x79, 0x56, 0x68, 0x57, 0xf4, 0xf5, 0xfe, 0x04, 0xfa, 0x38, 0xfe, 0x05,
  4751. 0xfa, 0x4e, 0x01, 0xa5, 0xa2, 0x23, 0x0c, 0x7b, 0x0c, 0x7c, 0x79, 0x56,
  4752. 0x68, 0x57, 0xfe, 0x12, 0x10, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x79, 0x39,
  4753. 0x68, 0x3a, 0x09, 0x04, 0xfe, 0xf7, 0x00, 0x35, 0x05, 0x52, 0x31, 0x53,
  4754. 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59,
  4755. 0x02, 0x6d, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x09, 0x04, 0xfe, 0xf7, 0x00,
  4756. 0x35, 0xfe, 0x3a, 0x55, 0xfe, 0x19, 0x81, 0x5f, 0xfe, 0x10, 0x90, 0xfe,
  4757. 0x92, 0x90, 0xfe, 0xd7, 0x10, 0x2f, 0x07, 0x9b, 0x16, 0xfe, 0xc6, 0x08,
  4758. 0x11, 0x9b, 0x09, 0x04, 0x0b, 0xfe, 0x14, 0x13, 0x05, 0x39, 0x31, 0x3a,
  4759. 0x77, 0xfe, 0xc6, 0x08, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x6d,
  4760. 0x23, 0x47, 0xfe, 0x19, 0x80, 0xde, 0x09, 0x04, 0x0b, 0xfe, 0x1a, 0x12,
  4761. 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xe9, 0xb5, 0xfe, 0xd1, 0xf0, 0xd9,
  4762. 0x14, 0x7a, 0x01, 0x33, 0x0f, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe,
  4763. 0x6c, 0x19, 0xbe, 0x39, 0xfe, 0xed, 0x19, 0xbf, 0x3a, 0xfe, 0x0c, 0x51,
  4764. 0xfe, 0x8e, 0x51, 0xe9, 0x1c, 0xfe, 0x00, 0xff, 0x34, 0xfe, 0x74, 0x10,
  4765. 0xb5, 0xfe, 0xd2, 0xf0, 0xfe, 0xb2, 0x0a, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
  4766. 0x84, 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0x08, 0x13, 0x0f, 0xfe, 0x16, 0x00,
  4767. 0x02, 0x5a, 0xfe, 0xd1, 0xf0, 0xfe, 0xc4, 0x0a, 0x14, 0x7a, 0x01, 0x33,
  4768. 0x0f, 0xfe, 0x17, 0x00, 0xfe, 0x42, 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xca,
  4769. 0x0a, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xd6, 0x0a, 0x0f, 0xfe,
  4770. 0x22, 0x00, 0x02, 0x5a, 0xfe, 0xcb, 0xf0, 0xfe, 0xe2, 0x0a, 0x0f, 0xfe,
  4771. 0x24, 0x00, 0x02, 0x5a, 0xfe, 0xd0, 0xf0, 0xfe, 0xec, 0x0a, 0x0f, 0x93,
  4772. 0xdc, 0xfe, 0xcf, 0xf0, 0xfe, 0xf6, 0x0a, 0x0f, 0x4c, 0xfe, 0x10, 0x10,
  4773. 0xfe, 0xcc, 0xf0, 0xd9, 0x61, 0x04, 0x19, 0x3b, 0x0f, 0xfe, 0x12, 0x00,
  4774. 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x0c, 0x0b, 0xfe, 0x9e, 0xf0,
  4775. 0xfe, 0x20, 0x0b, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0x22, 0xb9,
  4776. 0x22, 0x2a, 0xec, 0x65, 0xfe, 0x2c, 0x0b, 0x25, 0x32, 0x8c, 0xfe, 0x48,
  4777. 0x0b, 0x8d, 0x81, 0xb8, 0xd4, 0xb9, 0xd4, 0x02, 0x22, 0x01, 0x43, 0xfe,
  4778. 0xdb, 0x10, 0x11, 0xfe, 0xe8, 0x00, 0xaa, 0xab, 0x70, 0xbc, 0x7d, 0xbd,
  4779. 0x7f, 0xfe, 0x89, 0xf0, 0x22, 0x30, 0x2e, 0xd8, 0xbc, 0x7d, 0xbd, 0x7f,
  4780. 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd6, 0xb1, 0x45, 0x0f, 0xfe, 0x42,
  4781. 0x00, 0x02, 0x5a, 0x78, 0x06, 0xfe, 0x81, 0x49, 0x16, 0xfe, 0x38, 0x0c,
  4782. 0x09, 0x04, 0x0b, 0xfe, 0x44, 0x13, 0x0f, 0x00, 0x4b, 0x0b, 0xfe, 0x54,
  4783. 0x12, 0x4b, 0xfe, 0x28, 0x00, 0x21, 0xfe, 0xa6, 0x0c, 0x0a, 0x40, 0x01,
  4784. 0x0e, 0x07, 0x00, 0x5d, 0x3e, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01,
  4785. 0xe7, 0x01, 0xe8, 0x0a, 0x99, 0x01, 0xfe, 0x32, 0x0e, 0x59, 0x11, 0x2d,
  4786. 0x01, 0x6f, 0x02, 0x29, 0x0f, 0xfe, 0x44, 0x00, 0x4b, 0x0b, 0xdf, 0x3e,
  4787. 0x0b, 0xfe, 0xb4, 0x10, 0x01, 0x86, 0x3e, 0x0b, 0xfe, 0xaa, 0x10, 0x01,
  4788. 0x86, 0xfe, 0x19, 0x82, 0xfe, 0x34, 0x46, 0xa3, 0x3e, 0x0b, 0x0f, 0xfe,
  4789. 0x43, 0x00, 0xfe, 0x96, 0x10, 0x09, 0x4a, 0x0b, 0x35, 0x01, 0xe7, 0x01,
  4790. 0xe8, 0x59, 0x11, 0x2d, 0x01, 0x6f, 0x67, 0x0b, 0x59, 0x3c, 0x8a, 0x02,
  4791. 0xfe, 0x2a, 0x03, 0x09, 0x04, 0x0b, 0x84, 0x3e, 0x0b, 0x0f, 0x00, 0xfe,
  4792. 0x5c, 0x10, 0x61, 0x04, 0x1b, 0xfe, 0x58, 0x12, 0x09, 0x04, 0x1b, 0xfe,
  4793. 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x5c, 0x0c, 0xfe,
  4794. 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x62, 0x0c, 0x09, 0x4a, 0x1b, 0x35,
  4795. 0xfe, 0xa9, 0x10, 0x0f, 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0b, 0x5f,
  4796. 0x5c, 0x0f, 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x0f, 0xfe, 0x47, 0x00,
  4797. 0xa1, 0x0f, 0xfe, 0x41, 0x00, 0xa0, 0x0f, 0xfe, 0x24, 0x00, 0x87, 0xaa,
  4798. 0xab, 0x70, 0x05, 0x6b, 0x28, 0x21, 0xd1, 0x5f, 0xfe, 0x04, 0xe6, 0x1b,
  4799. 0xfe, 0x9d, 0x41, 0xfe, 0x1c, 0x42, 0x59, 0x01, 0xda, 0x02, 0x29, 0xea,
  4800. 0x14, 0x0b, 0x37, 0x95, 0xa9, 0x14, 0xfe, 0x31, 0x00, 0x37, 0x97, 0x01,
  4801. 0xfe, 0x54, 0x0f, 0x02, 0xd0, 0x3c, 0xfe, 0x06, 0xec, 0xc9, 0xee, 0x3e,
  4802. 0x1d, 0xfe, 0xce, 0x45, 0x34, 0x3c, 0xfe, 0x06, 0xea, 0xc9, 0xfe, 0x47,
  4803. 0x4b, 0x89, 0xfe, 0x75, 0x57, 0x05, 0x51, 0xfe, 0x98, 0x56, 0xfe, 0x38,
  4804. 0x12, 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x44, 0x48, 0x46, 0x09, 0x04, 0x1d,
  4805. 0xfe, 0x1a, 0x13, 0x0a, 0x40, 0x01, 0x0e, 0x47, 0xfe, 0x41, 0x58, 0x0a,
  4806. 0x99, 0x01, 0x0e, 0xfe, 0x49, 0x54, 0x8e, 0xfe, 0x2a, 0x0d, 0x02, 0xfe,
  4807. 0x2a, 0x03, 0x0a, 0x51, 0xfe, 0xee, 0x14, 0xee, 0x3e, 0x1d, 0xfe, 0xce,
  4808. 0x45, 0x34, 0x3c, 0xfe, 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x29, 0x1e,
  4809. 0x20, 0x07, 0x10, 0xfe, 0x9e, 0x12, 0x23, 0x12, 0x4d, 0x12, 0x94, 0x12,
  4810. 0xce, 0x1e, 0x2d, 0x47, 0x37, 0x2d, 0xb1, 0xe0, 0xfe, 0xbc, 0xf0, 0xfe,
  4811. 0xec, 0x0d, 0x13, 0x06, 0x12, 0x4d, 0x01, 0xfe, 0xe2, 0x15, 0x05, 0xfe,
  4812. 0x38, 0x01, 0x31, 0xfe, 0x3a, 0x01, 0x77, 0xfe, 0xf0, 0x0d, 0xfe, 0x02,
  4813. 0xec, 0xce, 0x62, 0x00, 0x5d, 0xfe, 0x04, 0xec, 0x20, 0x46, 0xfe, 0x05,
  4814. 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x52, 0x16, 0xfb, 0xfe, 0x48, 0xf4,
  4815. 0x0d, 0xfe, 0x18, 0x13, 0xaf, 0xfe, 0x02, 0xea, 0xce, 0x62, 0x7a, 0xfe,
  4816. 0xc5, 0x13, 0x14, 0x1b, 0x37, 0x95, 0xa9, 0x5c, 0x05, 0xfe, 0x38, 0x01,
  4817. 0x1c, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x05, 0xfe, 0x3a, 0x01,
  4818. 0x0c, 0xfe, 0x62, 0x01, 0x3d, 0x12, 0x20, 0x24, 0x06, 0x12, 0x2d, 0x11,
  4819. 0x2d, 0x8a, 0x13, 0x06, 0x03, 0x23, 0x03, 0x1e, 0x4d, 0xfe, 0xf7, 0x12,
  4820. 0x1e, 0x94, 0xac, 0x12, 0x94, 0x07, 0x7a, 0xfe, 0x71, 0x13, 0xfe, 0x24,
  4821. 0x1c, 0x14, 0x1a, 0x37, 0x95, 0xa9, 0xfe, 0xd9, 0x10, 0xb6, 0xfe, 0x03,
  4822. 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xb6, 0xfe, 0x03, 0xdc,
  4823. 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x23,
  4824. 0xfe, 0x00, 0xcc, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x75, 0x03, 0x09, 0x04,
  4825. 0x4c, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
  4826. 0xfe, 0x1e, 0x80, 0xe1, 0xfe, 0x1d, 0x80, 0xa4, 0xfe, 0x0c, 0x90, 0xfe,
  4827. 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xa3, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
  4828. 0x0b, 0xfe, 0x3c, 0x50, 0xa0, 0x01, 0xfe, 0x82, 0x16, 0x2f, 0x07, 0x2d,
  4829. 0xe0, 0x01, 0xfe, 0xbc, 0x15, 0x09, 0x04, 0x1d, 0x45, 0x01, 0xe7, 0x01,
  4830. 0xe8, 0x11, 0xfe, 0xe9, 0x00, 0x09, 0x04, 0x4c, 0xfe, 0x2c, 0x13, 0x01,
  4831. 0xfe, 0x14, 0x16, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
  4832. 0x0c, 0xfe, 0x64, 0x01, 0x18, 0xfe, 0x66, 0x01, 0x09, 0x04, 0x4f, 0xfe,
  4833. 0x12, 0x12, 0xfe, 0x03, 0x80, 0x74, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
  4834. 0x40, 0x12, 0x20, 0x63, 0x27, 0x11, 0xc8, 0x59, 0x1e, 0x20, 0xed, 0x76,
  4835. 0x20, 0x03, 0xfe, 0x08, 0x1c, 0x05, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
  4836. 0x05, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x05, 0xfe, 0xb0, 0x00, 0xfe,
  4837. 0x08, 0x58, 0x05, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
  4838. 0x24, 0x69, 0x12, 0xc9, 0x23, 0x0c, 0x50, 0x0c, 0x3f, 0x13, 0x40, 0x48,
  4839. 0x5f, 0x17, 0x1d, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x21, 0xfe, 0x08,
  4840. 0x0f, 0x3e, 0x10, 0x13, 0x42, 0x48, 0x17, 0x4c, 0xfe, 0x90, 0x4d, 0xfe,
  4841. 0x91, 0x54, 0x21, 0xfe, 0x1e, 0x0f, 0x24, 0x10, 0x12, 0x20, 0x78, 0x2c,
  4842. 0x46, 0x1e, 0x20, 0xed, 0x76, 0x20, 0x11, 0xc8, 0xf6, 0xfe, 0xd6, 0xf0,
  4843. 0xfe, 0x32, 0x0f, 0xea, 0x70, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
  4844. 0x18, 0x1c, 0x03, 0x3c, 0xfe, 0x0c, 0x14, 0xee, 0xfe, 0x07, 0xe6, 0x1d,
  4845. 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x03, 0x01, 0x86, 0x78, 0x2c, 0x46,
  4846. 0xfa, 0xef, 0xfe, 0x42, 0x13, 0x2f, 0x07, 0x2d, 0xfe, 0x34, 0x13, 0x0a,
  4847. 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x36, 0x12, 0xf0, 0xfe, 0x45, 0x48, 0x01,
  4848. 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13, 0x3d, 0x75, 0x07, 0x10,
  4849. 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x6f, 0xfe, 0x0e,
  4850. 0x10, 0x07, 0x7e, 0x45, 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x6c, 0x0f, 0x03,
  4851. 0xfe, 0x44, 0x58, 0x74, 0xfe, 0x01, 0xec, 0x97, 0xfe, 0x9e, 0x40, 0xfe,
  4852. 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1b, 0x76, 0x27, 0x01, 0xda, 0xfe,
  4853. 0xdd, 0x10, 0x2a, 0xbc, 0x7d, 0xbd, 0x7f, 0x30, 0x2e, 0xd5, 0x07, 0x1b,
  4854. 0xfe, 0x48, 0x12, 0x07, 0x0b, 0xfe, 0x56, 0x12, 0x07, 0x1a, 0xfe, 0x30,
  4855. 0x12, 0x07, 0xc2, 0x16, 0xfe, 0x3e, 0x11, 0x07, 0xfe, 0x23, 0x00, 0x16,
  4856. 0xfe, 0x4a, 0x11, 0x07, 0x06, 0x16, 0xfe, 0xa8, 0x11, 0x07, 0x19, 0xfe,
  4857. 0x12, 0x12, 0x07, 0x00, 0x16, 0x22, 0x14, 0xc2, 0x01, 0x33, 0x9f, 0x2b,
  4858. 0x01, 0x08, 0x8c, 0x43, 0x03, 0x2b, 0xfe, 0x62, 0x08, 0x0a, 0xca, 0x01,
  4859. 0xfe, 0x32, 0x0e, 0x11, 0x7e, 0x02, 0x29, 0x2b, 0x2f, 0x07, 0x9b, 0xfe,
  4860. 0xd9, 0x13, 0x79, 0x39, 0x68, 0x3a, 0x77, 0xfe, 0xfc, 0x10, 0x09, 0x04,
  4861. 0x6a, 0xfe, 0x72, 0x12, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x8e, 0xfe,
  4862. 0xc6, 0x10, 0x1e, 0x58, 0xfe, 0x26, 0x13, 0x05, 0x7b, 0x31, 0x7c, 0x77,
  4863. 0xfe, 0x82, 0x0c, 0x0c, 0x54, 0x18, 0x55, 0x23, 0x0c, 0x7b, 0x0c, 0x7c,
  4864. 0x01, 0xa8, 0x24, 0x69, 0x73, 0x12, 0x58, 0x01, 0xa5, 0xc0, 0x38, 0xc1,
  4865. 0x4e, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x38, 0xfe,
  4866. 0x05, 0xfa, 0x4e, 0xfe, 0x91, 0x10, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x40,
  4867. 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x56, 0x18, 0x57, 0x83, 0xc0, 0x38, 0xc1,
  4868. 0x4e, 0xf4, 0xf5, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x00, 0x56, 0xfe, 0xa1,
  4869. 0x56, 0x0c, 0x52, 0x18, 0x53, 0x09, 0x04, 0x6a, 0xfe, 0x1e, 0x12, 0x1e,
  4870. 0x58, 0xfe, 0x1f, 0x40, 0x05, 0x54, 0x31, 0x55, 0xfe, 0x2c, 0x50, 0xfe,
  4871. 0xae, 0x50, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x44, 0x50, 0xfe, 0xc6, 0x50,
  4872. 0x05, 0x52, 0x31, 0x53, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x05, 0x39,
  4873. 0x31, 0x3a, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x5c, 0x24, 0x06,
  4874. 0x12, 0xcd, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x1f, 0x44, 0x30, 0x2e, 0xd5,
  4875. 0x07, 0x06, 0x21, 0x44, 0x2f, 0x07, 0x9b, 0x21, 0x5b, 0x01, 0x6e, 0x1c,
  4876. 0x3d, 0x16, 0x44, 0x09, 0x04, 0x0b, 0xe2, 0x79, 0x39, 0x68, 0x3a, 0xfe,
  4877. 0x0a, 0x55, 0x34, 0xfe, 0x8b, 0x55, 0xbe, 0x39, 0xbf, 0x3a, 0xfe, 0x0c,
  4878. 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x5b, 0xfe, 0x19, 0x81, 0xaf, 0xfe, 0x19,
  4879. 0x41, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e,
  4880. 0xd8, 0x4b, 0x1a, 0xfe, 0xa6, 0x12, 0x4b, 0x0b, 0x3b, 0x02, 0x44, 0x01,
  4881. 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e, 0xd6, 0x07, 0x1a, 0x21, 0x44,
  4882. 0x01, 0x08, 0x1f, 0xa2, 0x30, 0x2e, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49,
  4883. 0x60, 0x05, 0xfe, 0x9c, 0x00, 0x28, 0x84, 0x49, 0x04, 0x19, 0x34, 0x9f,
  4884. 0xfe, 0xbb, 0x45, 0x4b, 0x00, 0x45, 0x3e, 0x06, 0x78, 0x3d, 0xfe, 0xda,
  4885. 0x14, 0x01, 0x6e, 0x87, 0xfe, 0x4b, 0x45, 0xe2, 0x2f, 0x07, 0x9a, 0xe1,
  4886. 0x05, 0xc6, 0x28, 0x84, 0x05, 0x3f, 0x28, 0x34, 0x5e, 0x02, 0x5b, 0xfe,
  4887. 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17, 0x05, 0x50, 0xb4, 0x0c,
  4888. 0x50, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe, 0xaa, 0x14, 0x02,
  4889. 0x5c, 0x01, 0x08, 0x25, 0x32, 0x1f, 0x44, 0x30, 0x2e, 0xd6, 0x07, 0x06,
  4890. 0x21, 0x44, 0x01, 0xfe, 0x8e, 0x13, 0xfe, 0x42, 0x58, 0xfe, 0x82, 0x14,
  4891. 0xfe, 0xa4, 0x14, 0x87, 0xfe, 0x4a, 0xf4, 0x0b, 0x16, 0x44, 0xfe, 0x4a,
  4892. 0xf4, 0x06, 0xfe, 0x0c, 0x12, 0x2f, 0x07, 0x9a, 0x85, 0x02, 0x5b, 0x05,
  4893. 0x3f, 0xb4, 0x0c, 0x3f, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe,
  4894. 0xd8, 0x14, 0x02, 0x5c, 0x13, 0x06, 0x65, 0xfe, 0xca, 0x12, 0x26, 0xfe,
  4895. 0xe0, 0x12, 0x72, 0xf1, 0x01, 0x08, 0x23, 0x72, 0x03, 0x8f, 0xfe, 0xdc,
  4896. 0x12, 0x25, 0xfe, 0xdc, 0x12, 0x1f, 0xfe, 0xca, 0x12, 0x5e, 0x2b, 0x01,
  4897. 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
  4898. 0x1c, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13,
  4899. 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0x3d, 0xfe, 0x30, 0x56,
  4900. 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
  4901. 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0xfe, 0x0b, 0x58,
  4902. 0x03, 0x0a, 0x50, 0x01, 0x82, 0x0a, 0x3f, 0x01, 0x82, 0x03, 0xfc, 0x1c,
  4903. 0x10, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x19, 0x48, 0xfe, 0x00,
  4904. 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c, 0x63, 0x27,
  4905. 0x0c, 0x52, 0x18, 0x53, 0xbe, 0x56, 0xbf, 0x57, 0x03, 0xfe, 0x62, 0x08,
  4906. 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x74, 0x03, 0x01,
  4907. 0xfe, 0x14, 0x18, 0xfe, 0x42, 0x48, 0x5f, 0x60, 0x89, 0x01, 0x08, 0x1f,
  4908. 0xfe, 0xa2, 0x14, 0x30, 0x2e, 0xd8, 0x01, 0x08, 0x1f, 0xfe, 0xa2, 0x14,
  4909. 0x30, 0x2e, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x05, 0xc6, 0x28, 0xfe,
  4910. 0xcc, 0x12, 0x49, 0x04, 0x1b, 0xfe, 0xc4, 0x13, 0x23, 0x62, 0x1b, 0xe2,
  4911. 0x4b, 0xc3, 0x64, 0xfe, 0xe8, 0x13, 0x3b, 0x13, 0x06, 0x17, 0xc3, 0x78,
  4912. 0xdb, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xa1, 0xff, 0x02, 0x83,
  4913. 0x55, 0x62, 0x1a, 0xa4, 0xbb, 0xfe, 0x30, 0x00, 0x8e, 0xe4, 0x17, 0x2c,
  4914. 0x13, 0x06, 0xfe, 0x56, 0x10, 0x62, 0x0b, 0xe1, 0xbb, 0xfe, 0x64, 0x00,
  4915. 0x8e, 0xe4, 0x0a, 0xfe, 0x64, 0x00, 0x17, 0x93, 0x13, 0x06, 0xfe, 0x28,
  4916. 0x10, 0x62, 0x06, 0xfe, 0x60, 0x13, 0xbb, 0xfe, 0xc8, 0x00, 0x8e, 0xe4,
  4917. 0x0a, 0xfe, 0xc8, 0x00, 0x17, 0x4d, 0x13, 0x06, 0x83, 0xbb, 0xfe, 0x90,
  4918. 0x01, 0xba, 0xfe, 0x4e, 0x14, 0x89, 0xfe, 0x12, 0x10, 0xfe, 0x43, 0xf4,
  4919. 0x94, 0xfe, 0x56, 0xf0, 0xfe, 0x60, 0x14, 0xfe, 0x04, 0xf4, 0x6c, 0xfe,
  4920. 0x43, 0xf4, 0x93, 0xfe, 0xf3, 0x10, 0xf9, 0x01, 0xfe, 0x22, 0x13, 0x1c,
  4921. 0x3d, 0xfe, 0x10, 0x13, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x69, 0xba,
  4922. 0xfe, 0x9c, 0x14, 0xb7, 0x69, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe,
  4923. 0x4d, 0xe4, 0x19, 0xba, 0xfe, 0x9c, 0x14, 0xb7, 0x19, 0x83, 0x60, 0x23,
  4924. 0xfe, 0x4d, 0xf4, 0x00, 0xdf, 0x89, 0x13, 0x06, 0xfe, 0xb4, 0x56, 0xfe,
  4925. 0xc3, 0x58, 0x03, 0x60, 0x13, 0x0b, 0x03, 0x15, 0x06, 0x01, 0x08, 0x26,
  4926. 0xe5, 0x15, 0x0b, 0x01, 0x08, 0x26, 0xe5, 0x15, 0x1a, 0x01, 0x08, 0x26,
  4927. 0xe5, 0x72, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x03, 0x15, 0x06, 0x01, 0x08,
  4928. 0x26, 0xa6, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xa6, 0x15, 0x06, 0x01, 0x08,
  4929. 0x26, 0xa6, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x26, 0xa6, 0x72, 0xfe, 0x89,
  4930. 0x4a, 0x01, 0x08, 0x03, 0x60, 0x03, 0x1e, 0xcc, 0x07, 0x06, 0xfe, 0x44,
  4931. 0x13, 0xad, 0x12, 0xcc, 0xfe, 0x49, 0xf4, 0x00, 0x3b, 0x72, 0x9f, 0x5e,
  4932. 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xf1, 0x01, 0x08, 0x2f, 0x07, 0xfe,
  4933. 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1f, 0xfe, 0x5a, 0x15, 0x23, 0x12, 0xcd,
  4934. 0x01, 0x43, 0x1e, 0xcd, 0x07, 0x06, 0x45, 0x09, 0x4a, 0x06, 0x35, 0x03,
  4935. 0x0a, 0x42, 0x01, 0x0e, 0xed, 0x88, 0x07, 0x10, 0xa4, 0x0a, 0x80, 0x01,
  4936. 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a, 0x80, 0x01, 0x0e, 0x88,
  4937. 0xfe, 0x80, 0xe7, 0x10, 0x07, 0x10, 0x84, 0xfe, 0x45, 0x58, 0x01, 0xe3,
  4938. 0x88, 0x03, 0x0a, 0x42, 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03,
  4939. 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x80, 0x80, 0xf2, 0xfe, 0x49, 0xe4, 0x10,
  4940. 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x0a, 0x51, 0x01, 0x82, 0x03, 0x17,
  4941. 0x10, 0x71, 0x66, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde,
  4942. 0xfe, 0x24, 0x1c, 0xfe, 0x1d, 0xf7, 0x1d, 0x90, 0xfe, 0xf6, 0x15, 0x01,
  4943. 0xfe, 0xfc, 0x16, 0xe0, 0x91, 0x1d, 0x66, 0xfe, 0x2c, 0x01, 0xfe, 0x2f,
  4944. 0x19, 0x03, 0xae, 0x21, 0xfe, 0xe6, 0x15, 0xfe, 0xda, 0x10, 0x17, 0x10,
  4945. 0x71, 0x05, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x19, 0xfe, 0x18, 0x58,
  4946. 0x05, 0xfe, 0x66, 0x01, 0xfe, 0x19, 0x58, 0x91, 0x19, 0xfe, 0x3c, 0x90,
  4947. 0xfe, 0x30, 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x66, 0xfe, 0x38, 0x00, 0xfe,
  4948. 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x19, 0x90, 0xfe, 0x40, 0x16, 0xfe, 0xb6,
  4949. 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x18, 0x16, 0xfe, 0x9c, 0x10, 0x17,
  4950. 0x10, 0x71, 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe,
  4951. 0x1d, 0xf7, 0x38, 0x90, 0xfe, 0x62, 0x16, 0xfe, 0x94, 0x14, 0xfe, 0x10,
  4952. 0x13, 0x91, 0x38, 0x66, 0x1b, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00,
  4953. 0x03, 0xae, 0x21, 0xfe, 0x56, 0x16, 0xfe, 0x6c, 0x10, 0x17, 0x10, 0x71,
  4954. 0xfe, 0x30, 0xbc, 0xfe, 0xb2, 0xbc, 0x91, 0xc5, 0x66, 0x1b, 0xfe, 0x0f,
  4955. 0x79, 0xfe, 0x1c, 0xf7, 0xc5, 0x90, 0xfe, 0x9a, 0x16, 0xfe, 0x5c, 0x14,
  4956. 0x34, 0x03, 0xae, 0x21, 0xfe, 0x86, 0x16, 0xfe, 0x42, 0x10, 0xfe, 0x02,
  4957. 0xf6, 0x10, 0x71, 0xfe, 0x18, 0xfe, 0x54, 0xfe, 0x19, 0xfe, 0x55, 0xfc,
  4958. 0xfe, 0x1d, 0xf7, 0x4f, 0x90, 0xfe, 0xc0, 0x16, 0xfe, 0x36, 0x14, 0xfe,
  4959. 0x1c, 0x13, 0x91, 0x4f, 0x47, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe,
  4960. 0x80, 0xe7, 0x10, 0xfe, 0x81, 0xe7, 0x10, 0x11, 0xfe, 0xdd, 0x00, 0x63,
  4961. 0x27, 0x03, 0x63, 0x27, 0xfe, 0x12, 0x45, 0x21, 0xfe, 0xb0, 0x16, 0x14,
  4962. 0x06, 0x37, 0x95, 0xa9, 0x02, 0x29, 0xfe, 0x39, 0xf0, 0xfe, 0x04, 0x17,
  4963. 0x23, 0x03, 0xfe, 0x7e, 0x18, 0x1c, 0x1a, 0x5d, 0x13, 0x0d, 0x03, 0x71,
  4964. 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x78, 0x2c,
  4965. 0x46, 0x2f, 0x07, 0x2d, 0xfe, 0x3c, 0x13, 0xfe, 0x82, 0x14, 0xfe, 0x42,
  4966. 0x13, 0x3c, 0x8a, 0x0a, 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x3e, 0x12, 0xf0,
  4967. 0xfe, 0x45, 0x48, 0x01, 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13,
  4968. 0x3d, 0x75, 0x07, 0x10, 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x01, 0x6f,
  4969. 0xfe, 0x16, 0x10, 0x07, 0x7e, 0x85, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12,
  4970. 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x24, 0x17, 0x17, 0x0b, 0x03, 0xfe, 0x9c,
  4971. 0xe7, 0x0b, 0x0f, 0xfe, 0x15, 0x00, 0x59, 0x76, 0x27, 0x01, 0xda, 0x17,
  4972. 0x06, 0x03, 0x3c, 0x8a, 0x09, 0x4a, 0x1d, 0x35, 0x11, 0x2d, 0x01, 0x6f,
  4973. 0x17, 0x06, 0x03, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x79, 0xc7, 0x68,
  4974. 0xc8, 0xfe, 0x48, 0x55, 0x34, 0xfe, 0xc9, 0x55, 0x03, 0x1e, 0x98, 0x73,
  4975. 0x12, 0x98, 0x03, 0x0a, 0x99, 0x01, 0x0e, 0xf0, 0x0a, 0x40, 0x01, 0x0e,
  4976. 0xfe, 0x49, 0x44, 0x16, 0xfe, 0xf0, 0x17, 0x73, 0x75, 0x03, 0x0a, 0x42,
  4977. 0x01, 0x0e, 0x07, 0x10, 0x45, 0x0a, 0x51, 0x01, 0x9e, 0x0a, 0x40, 0x01,
  4978. 0x0e, 0x73, 0x75, 0x03, 0xfe, 0x4e, 0xe4, 0x1a, 0x64, 0xfe, 0x24, 0x18,
  4979. 0x05, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0x5b, 0xfe, 0x4e, 0xe4, 0xc2,
  4980. 0x64, 0xfe, 0x36, 0x18, 0x05, 0xfe, 0x92, 0x00, 0xfe, 0x02, 0xe6, 0x1b,
  4981. 0xdc, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x64, 0xfe, 0x48, 0x18, 0x05,
  4982. 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x19, 0xfe, 0x08, 0x10, 0x05, 0xfe,
  4983. 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x2c, 0xfe, 0x4e, 0x45, 0xfe, 0x0c, 0x12,
  4984. 0xaf, 0xff, 0x04, 0x68, 0x54, 0xde, 0x1c, 0x69, 0x03, 0x07, 0x7a, 0xfe,
  4985. 0x5a, 0xf0, 0xfe, 0x74, 0x18, 0x24, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10,
  4986. 0x07, 0x1b, 0xfe, 0x5a, 0xf0, 0xfe, 0x82, 0x18, 0x24, 0xc3, 0xfe, 0x26,
  4987. 0x10, 0x07, 0x1a, 0x5d, 0x24, 0x2c, 0xdc, 0x07, 0x0b, 0x5d, 0x24, 0x93,
  4988. 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x5d, 0x24, 0x4d, 0x9f, 0xad, 0x03, 0x14,
  4989. 0xfe, 0x09, 0x00, 0x01, 0x33, 0xfe, 0x04, 0xfe, 0x7d, 0x05, 0x7f, 0xf9,
  4990. 0x03, 0x25, 0xfe, 0xca, 0x18, 0xfe, 0x14, 0xf0, 0x08, 0x65, 0xfe, 0xc6,
  4991. 0x18, 0x03, 0xff, 0x1a, 0x00, 0x00,
  4992. };
  4993. static unsigned short _adv_asc3550_size = sizeof(_adv_asc3550_buf); /* 0x13AD */
  4994. static ADV_DCNT _adv_asc3550_chksum = 0x04D52DDDUL; /* Expanded little-endian checksum. */
  4995. /* Microcode buffer is kept after initialization for error recovery. */
  4996. static unsigned char _adv_asc38C0800_buf[] = {
  4997. 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0xfc, 0x00, 0x16, 0x18, 0xe4,
  4998. 0x01, 0x00, 0x48, 0xe4, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0xce, 0x19,
  4999. 0x00, 0xfa, 0xff, 0xff, 0x1c, 0x0f, 0x00, 0xf6, 0x9e, 0xe7, 0xff, 0x00,
  5000. 0x82, 0xe7, 0x00, 0xea, 0x01, 0xfa, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0,
  5001. 0x01, 0xf6, 0x03, 0x00, 0x04, 0x00, 0x10, 0x00, 0x1e, 0xf0, 0x85, 0xf0,
  5002. 0x18, 0xf4, 0x08, 0x00, 0xbc, 0x00, 0x38, 0x54, 0x00, 0xec, 0xd5, 0xf0,
  5003. 0x82, 0x0d, 0x00, 0xe6, 0x86, 0xf0, 0xb1, 0xf0, 0x98, 0x57, 0x01, 0xfc,
  5004. 0xb4, 0x00, 0xd4, 0x01, 0x0c, 0x1c, 0x3e, 0x1c, 0x3c, 0x00, 0xbb, 0x00,
  5005. 0x00, 0x10, 0xba, 0x19, 0x02, 0x80, 0x32, 0xf0, 0x7c, 0x0d, 0x02, 0x13,
  5006. 0xba, 0x13, 0x18, 0x40, 0x00, 0x57, 0x01, 0xea, 0x02, 0xfc, 0x03, 0xfc,
  5007. 0x3e, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x74, 0x01, 0x76, 0x01, 0xb9, 0x54,
  5008. 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01,
  5009. 0x3e, 0x01, 0x7a, 0x01, 0xca, 0x08, 0xce, 0x10, 0x16, 0x11, 0x04, 0x12,
  5010. 0x08, 0x12, 0x02, 0x4a, 0xbb, 0x55, 0x3c, 0x56, 0x03, 0x58, 0x1b, 0x80,
  5011. 0x30, 0xe4, 0x4b, 0xe4, 0x5d, 0xf0, 0x02, 0xfa, 0x20, 0x00, 0x32, 0x00,
  5012. 0x40, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01,
  5013. 0x70, 0x01, 0x72, 0x01, 0x78, 0x01, 0x7c, 0x01, 0x62, 0x0a, 0x86, 0x0d,
  5014. 0x06, 0x13, 0x4c, 0x1c, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0,
  5015. 0x03, 0xf7, 0x0c, 0x00, 0x0f, 0x00, 0x47, 0x00, 0xbe, 0x00, 0x00, 0x01,
  5016. 0x20, 0x11, 0x5c, 0x16, 0x32, 0x1c, 0x38, 0x1c, 0x4e, 0x1c, 0x10, 0x44,
  5017. 0x00, 0x4c, 0x04, 0xea, 0x5c, 0xf0, 0xa7, 0xf0, 0x04, 0xf6, 0x03, 0xfa,
  5018. 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0xcc, 0x00, 0x20, 0x01,
  5019. 0x4e, 0x01, 0x4a, 0x0b, 0x42, 0x0c, 0x12, 0x0f, 0x0c, 0x10, 0x22, 0x11,
  5020. 0x0a, 0x12, 0x04, 0x13, 0x30, 0x1c, 0x02, 0x48, 0x00, 0x4e, 0x42, 0x54,
  5021. 0x44, 0x55, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0,
  5022. 0x59, 0xf0, 0xb8, 0xf0, 0x4b, 0xf4, 0x06, 0xf7, 0x0e, 0xf7, 0x04, 0xfc,
  5023. 0x05, 0xfc, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00, 0xa4, 0x00,
  5024. 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00, 0xe2, 0x03,
  5025. 0x08, 0x0f, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10, 0x0a, 0x13, 0x0c, 0x13,
  5026. 0x12, 0x13, 0x24, 0x14, 0x34, 0x14, 0x04, 0x16, 0x08, 0x16, 0xa4, 0x17,
  5027. 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44,
  5028. 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x3a, 0x55, 0x83, 0x55,
  5029. 0xe5, 0x55, 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0,
  5030. 0x0c, 0xf0, 0x04, 0xf8, 0x05, 0xf8, 0x07, 0x00, 0x0a, 0x00, 0x1c, 0x00,
  5031. 0x1e, 0x00, 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00,
  5032. 0x22, 0x01, 0x26, 0x01, 0x79, 0x01, 0x7e, 0x01, 0xc4, 0x01, 0xc6, 0x01,
  5033. 0x80, 0x02, 0x5e, 0x03, 0xee, 0x04, 0x9a, 0x06, 0xf8, 0x07, 0x62, 0x08,
  5034. 0x68, 0x08, 0x69, 0x08, 0xd6, 0x08, 0xe9, 0x09, 0xfa, 0x0b, 0x2e, 0x0f,
  5035. 0x12, 0x10, 0x1a, 0x10, 0xed, 0x10, 0xf1, 0x10, 0x2a, 0x11, 0x06, 0x12,
  5036. 0x0c, 0x12, 0x3e, 0x12, 0x10, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x46, 0x14,
  5037. 0x76, 0x14, 0x82, 0x14, 0x36, 0x15, 0xca, 0x15, 0x6b, 0x18, 0xbe, 0x18,
  5038. 0xca, 0x18, 0xe6, 0x19, 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40,
  5039. 0x0e, 0x47, 0xfe, 0x9c, 0xf0, 0x2b, 0x02, 0xfe, 0xac, 0x0d, 0xff, 0x10,
  5040. 0x00, 0x00, 0xd7, 0xfe, 0xe8, 0x19, 0x00, 0xd6, 0xfe, 0x84, 0x01, 0xff,
  5041. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  5042. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x5b, 0xff, 0x04, 0x00,
  5043. 0x00, 0x11, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  5044. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x11,
  5045. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  5046. 0xfe, 0x04, 0xf7, 0xd6, 0x2c, 0x99, 0x0a, 0x01, 0xfe, 0xc2, 0x0f, 0xfe,
  5047. 0x04, 0xf7, 0xd6, 0x99, 0x0a, 0x42, 0x2c, 0xfe, 0x3d, 0xf0, 0xfe, 0x06,
  5048. 0x02, 0xfe, 0x20, 0xf0, 0xa7, 0xfe, 0x91, 0xf0, 0xfe, 0xf4, 0x01, 0xfe,
  5049. 0x90, 0xf0, 0xfe, 0xf4, 0x01, 0xfe, 0x8f, 0xf0, 0xa7, 0x03, 0x5d, 0x4d,
  5050. 0x02, 0xfe, 0xc8, 0x0d, 0x01, 0xfe, 0x38, 0x0e, 0xfe, 0xdd, 0x12, 0xfe,
  5051. 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd3, 0x12,
  5052. 0x41, 0x14, 0xfe, 0xa6, 0x00, 0xc2, 0xfe, 0x48, 0xf0, 0xfe, 0x8a, 0x02,
  5053. 0xfe, 0x49, 0xf0, 0xfe, 0xa4, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc2, 0x02,
  5054. 0xfe, 0x46, 0xf0, 0xfe, 0x54, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x5a, 0x02,
  5055. 0xfe, 0x43, 0xf0, 0xfe, 0x48, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x4c, 0x02,
  5056. 0xfe, 0x45, 0xf0, 0xfe, 0x50, 0x02, 0x18, 0x0a, 0xaa, 0x18, 0x06, 0x14,
  5057. 0xa1, 0x02, 0x2b, 0xfe, 0x00, 0x1c, 0xe7, 0xfe, 0x02, 0x1c, 0xe6, 0xfe,
  5058. 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0xfe, 0x18, 0x18, 0xfe, 0xe7, 0x10,
  5059. 0xfe, 0x06, 0xfc, 0xce, 0x09, 0x70, 0x01, 0xa8, 0x02, 0x2b, 0x15, 0x59,
  5060. 0x39, 0xa2, 0x01, 0xfe, 0x58, 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xbd,
  5061. 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
  5062. 0x58, 0x1c, 0x18, 0x06, 0x14, 0xa1, 0x2c, 0x1c, 0x2b, 0xfe, 0x3d, 0xf0,
  5063. 0xfe, 0x06, 0x02, 0x23, 0xfe, 0x98, 0x02, 0xfe, 0x5a, 0x1c, 0xf8, 0xfe,
  5064. 0x14, 0x1c, 0x15, 0xfe, 0x30, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10,
  5065. 0x18, 0x06, 0x14, 0xa1, 0x02, 0xd7, 0x22, 0x20, 0x07, 0x11, 0x35, 0xfe,
  5066. 0x69, 0x10, 0x18, 0x06, 0x14, 0xa1, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0x43,
  5067. 0x13, 0x20, 0xfe, 0x05, 0xf6, 0xce, 0x01, 0xfe, 0x4a, 0x17, 0x08, 0x54,
  5068. 0x58, 0x37, 0x12, 0x2f, 0x42, 0x92, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b,
  5069. 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66, 0x01, 0x73, 0xfe, 0x18, 0x10,
  5070. 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x6b, 0xfe,
  5071. 0x10, 0x03, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b, 0x2c, 0x4f, 0xfe, 0x02,
  5072. 0xe8, 0x2a, 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe,
  5073. 0x27, 0xf0, 0xfe, 0xe0, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xa7,
  5074. 0xfe, 0x40, 0x1c, 0x1c, 0xd9, 0xfe, 0x26, 0xf0, 0xfe, 0x5a, 0x03, 0xfe,
  5075. 0xa0, 0xf0, 0xfe, 0x48, 0x03, 0xfe, 0x11, 0xf0, 0xa7, 0xfe, 0xef, 0x10,
  5076. 0xfe, 0x9f, 0xf0, 0xfe, 0x68, 0x03, 0xf9, 0x10, 0xfe, 0x11, 0x00, 0x02,
  5077. 0x65, 0x2c, 0xfe, 0x48, 0x1c, 0xf9, 0x08, 0x05, 0x1b, 0xfe, 0x18, 0x13,
  5078. 0x21, 0x22, 0xa3, 0xb7, 0x13, 0xa3, 0x09, 0x46, 0x01, 0x0e, 0xb7, 0x78,
  5079. 0x01, 0xfe, 0xb4, 0x16, 0x12, 0xd1, 0x1c, 0xd9, 0xfe, 0x01, 0xf0, 0xd9,
  5080. 0xfe, 0x82, 0xf0, 0xfe, 0x96, 0x03, 0xfa, 0x12, 0xfe, 0xe4, 0x00, 0x27,
  5081. 0xfe, 0xa8, 0x03, 0x1c, 0x34, 0x1d, 0xfe, 0xb8, 0x03, 0x01, 0x4b, 0xfe,
  5082. 0x06, 0xf0, 0xfe, 0xc8, 0x03, 0x95, 0x86, 0xfe, 0x0a, 0xf0, 0xfe, 0x8a,
  5083. 0x06, 0x02, 0x24, 0x03, 0x70, 0x28, 0x17, 0xfe, 0xfa, 0x04, 0x15, 0x6d,
  5084. 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02, 0xd8, 0xf9, 0x2c, 0x99, 0x19,
  5085. 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c,
  5086. 0x74, 0x01, 0xaf, 0x8c, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x17, 0xda,
  5087. 0x09, 0xd1, 0x01, 0x0e, 0x8d, 0x51, 0x64, 0x79, 0x2a, 0x03, 0x70, 0x28,
  5088. 0xfe, 0x10, 0x12, 0x15, 0x6d, 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02,
  5089. 0xd8, 0xc7, 0x81, 0xc8, 0x83, 0x1c, 0x24, 0x27, 0xfe, 0x40, 0x04, 0x1d,
  5090. 0xfe, 0x3c, 0x04, 0x3b, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
  5091. 0x12, 0x2d, 0xff, 0x02, 0x00, 0x10, 0x01, 0x0b, 0x1d, 0xfe, 0xe4, 0x04,
  5092. 0x2d, 0x01, 0x0b, 0x1d, 0x24, 0x33, 0x31, 0xde, 0xfe, 0x4c, 0x44, 0xfe,
  5093. 0x4c, 0x12, 0x51, 0xfe, 0x44, 0x48, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b,
  5094. 0xda, 0x4f, 0x79, 0x2a, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x62,
  5095. 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x2a, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x52,
  5096. 0x13, 0xfe, 0x20, 0x10, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b, 0xda, 0xfe,
  5097. 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x40, 0x13, 0x08, 0x05, 0x1b, 0xfe,
  5098. 0x08, 0x13, 0x32, 0x07, 0x82, 0xfe, 0x30, 0x13, 0x08, 0x05, 0x1b, 0xfe,
  5099. 0x1c, 0x12, 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00,
  5100. 0x01, 0x36, 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x2d, 0x12, 0xfe, 0xe6,
  5101. 0x00, 0xfe, 0x1c, 0x90, 0xfe, 0x40, 0x5c, 0x04, 0x15, 0x9d, 0x01, 0x36,
  5102. 0x02, 0x2b, 0xfe, 0x42, 0x5b, 0x99, 0x19, 0xfe, 0x46, 0x59, 0xfe, 0xbf,
  5103. 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4, 0x5b, 0x08,
  5104. 0x05, 0x0a, 0xfe, 0x84, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x19, 0xfe, 0x7c,
  5105. 0x12, 0x53, 0x05, 0x06, 0xfe, 0x6c, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x28,
  5106. 0x17, 0xfe, 0x90, 0x05, 0xfe, 0x31, 0xe4, 0x5a, 0x53, 0x05, 0x0a, 0xfe,
  5107. 0x56, 0x13, 0x03, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x4e, 0x12, 0x67, 0xff,
  5108. 0x02, 0x00, 0x10, 0x27, 0xfe, 0x48, 0x05, 0x1c, 0x34, 0xfe, 0x89, 0x48,
  5109. 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x56, 0x05, 0x26, 0xfe, 0xa8, 0x05,
  5110. 0x12, 0xfe, 0xe3, 0x00, 0x21, 0x53, 0xfe, 0x4a, 0xf0, 0xfe, 0x76, 0x05,
  5111. 0xfe, 0x49, 0xf0, 0xfe, 0x70, 0x05, 0x88, 0x25, 0xfe, 0x21, 0x00, 0xab,
  5112. 0x25, 0xfe, 0x22, 0x00, 0xaa, 0x25, 0x58, 0xfe, 0x09, 0x48, 0xff, 0x02,
  5113. 0x00, 0x10, 0x27, 0xfe, 0x86, 0x05, 0x26, 0xfe, 0xa8, 0x05, 0xfe, 0xe2,
  5114. 0x08, 0x53, 0x05, 0xcb, 0x4d, 0x01, 0xb0, 0x25, 0x06, 0x13, 0xd3, 0x39,
  5115. 0xfe, 0x27, 0x01, 0x08, 0x05, 0x1b, 0xfe, 0x22, 0x12, 0x41, 0x01, 0xb2,
  5116. 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00, 0x01, 0x36,
  5117. 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0xeb,
  5118. 0x03, 0x5c, 0x28, 0xfe, 0x36, 0x13, 0x41, 0x01, 0xb2, 0x26, 0xfe, 0x18,
  5119. 0x06, 0x09, 0x06, 0x53, 0x05, 0x1f, 0xfe, 0x02, 0x12, 0x50, 0x01, 0xfe,
  5120. 0x9e, 0x15, 0x1d, 0xfe, 0x0e, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12, 0xfe,
  5121. 0xe5, 0x00, 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x03, 0xcd, 0x28, 0xfe, 0x62,
  5122. 0x12, 0x03, 0x45, 0x28, 0xfe, 0x5a, 0x13, 0x01, 0xfe, 0x0c, 0x19, 0x01,
  5123. 0xfe, 0x76, 0x19, 0xfe, 0x43, 0x48, 0xc4, 0xcc, 0x0f, 0x71, 0xff, 0x02,
  5124. 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0x8b, 0xc4, 0x6e, 0x41, 0x01, 0xb2,
  5125. 0x26, 0xfe, 0x82, 0x06, 0x53, 0x05, 0x1a, 0xe9, 0x91, 0x09, 0x59, 0x01,
  5126. 0xfe, 0xcc, 0x15, 0x1d, 0xfe, 0x78, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12,
  5127. 0xfe, 0xe5, 0x00, 0x03, 0x45, 0xc1, 0x0c, 0x45, 0x18, 0x06, 0x01, 0xb2,
  5128. 0xfa, 0x76, 0x74, 0x01, 0xaf, 0x8c, 0x12, 0xfe, 0xe2, 0x00, 0x27, 0xdb,
  5129. 0x1c, 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0xb6, 0x06, 0x94, 0xfe, 0x6c, 0x07,
  5130. 0xfe, 0x06, 0xf0, 0xfe, 0x74, 0x07, 0x95, 0x86, 0x02, 0x24, 0x08, 0x05,
  5131. 0x0a, 0xfe, 0x2e, 0x12, 0x16, 0x19, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b,
  5132. 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0xfe, 0x99, 0xa4, 0x01,
  5133. 0x0b, 0x16, 0x00, 0x02, 0xfe, 0x42, 0x08, 0x68, 0x05, 0x1a, 0xfe, 0x38,
  5134. 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x30, 0x13, 0x16, 0xfe, 0x1b, 0x00, 0x01,
  5135. 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01,
  5136. 0x0b, 0x16, 0x06, 0x01, 0x0b, 0x16, 0x00, 0x02, 0xe2, 0x6c, 0x58, 0xbe,
  5137. 0x50, 0xfe, 0x9a, 0x81, 0x55, 0x1b, 0x7a, 0xfe, 0x42, 0x07, 0x09, 0x1b,
  5138. 0xfe, 0x09, 0x6f, 0xba, 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 0x69, 0x6d,
  5139. 0x8b, 0x6c, 0x7f, 0x27, 0xfe, 0x54, 0x07, 0x1c, 0x34, 0xfe, 0x0a, 0xf0,
  5140. 0xfe, 0x42, 0x07, 0x95, 0x86, 0x94, 0xfe, 0x6c, 0x07, 0x02, 0x24, 0x01,
  5141. 0x4b, 0x02, 0xdb, 0x16, 0x1f, 0x02, 0xdb, 0xfe, 0x9c, 0xf7, 0xdc, 0xfe,
  5142. 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x56, 0xfe, 0xda, 0x07, 0x0c, 0x60, 0x14,
  5143. 0x61, 0x08, 0x54, 0x5a, 0x37, 0x22, 0x20, 0x07, 0x11, 0xfe, 0x0e, 0x12,
  5144. 0x8d, 0xfe, 0x80, 0x80, 0x39, 0x20, 0x6a, 0x2a, 0xfe, 0x06, 0x10, 0xfe,
  5145. 0x83, 0xe7, 0xfe, 0x48, 0x00, 0xab, 0xfe, 0x03, 0x40, 0x08, 0x54, 0x5b,
  5146. 0x37, 0x01, 0xb3, 0xb8, 0xfe, 0x1f, 0x40, 0x13, 0x62, 0x01, 0xef, 0xfe,
  5147. 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x88,
  5148. 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90, 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x0c,
  5149. 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x0c, 0x3d,
  5150. 0x14, 0x3e, 0xfe, 0x4a, 0x10, 0x08, 0x05, 0x5a, 0xfe, 0x2a, 0x12, 0xfe,
  5151. 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x60, 0x14, 0x61, 0x08, 0x05, 0x5b,
  5152. 0x8b, 0x01, 0xb3, 0xfe, 0x1f, 0x80, 0x13, 0x62, 0xfe, 0x44, 0x90, 0xfe,
  5153. 0xc6, 0x90, 0x0c, 0x3f, 0x14, 0x40, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90,
  5154. 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90, 0x0c, 0x3d,
  5155. 0x14, 0x3e, 0x0c, 0x2e, 0x14, 0x3c, 0x21, 0x0c, 0x49, 0x0c, 0x63, 0x08,
  5156. 0x54, 0x1f, 0x37, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27, 0xdd, 0xfe, 0x9e,
  5157. 0xf0, 0xfe, 0x76, 0x08, 0xbc, 0x17, 0x34, 0x2c, 0x77, 0xe6, 0xc5, 0xfe,
  5158. 0x9a, 0x08, 0xc6, 0xfe, 0xb8, 0x08, 0x94, 0xfe, 0x8e, 0x08, 0xfe, 0x06,
  5159. 0xf0, 0xfe, 0x94, 0x08, 0x95, 0x86, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xc9,
  5160. 0x10, 0x16, 0x1f, 0xfe, 0xc9, 0x10, 0x68, 0x05, 0x06, 0xfe, 0x10, 0x12,
  5161. 0x68, 0x05, 0x0a, 0x4e, 0x08, 0x05, 0x0a, 0xfe, 0x90, 0x12, 0xfe, 0x2e,
  5162. 0x1c, 0x02, 0xfe, 0x18, 0x0b, 0x68, 0x05, 0x06, 0x4e, 0x68, 0x05, 0x0a,
  5163. 0xfe, 0x7a, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0xd2, 0x09,
  5164. 0xfe, 0xac, 0xf0, 0xfe, 0x00, 0x09, 0x02, 0xfe, 0xde, 0x09, 0xfe, 0xb7,
  5165. 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0x02, 0xf6, 0x1a, 0x50, 0xfe, 0x70, 0x18,
  5166. 0xfe, 0xf1, 0x18, 0xfe, 0x40, 0x55, 0xfe, 0xe1, 0x55, 0xfe, 0x10, 0x58,
  5167. 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x1c, 0x85, 0xfe,
  5168. 0x8c, 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0xac, 0xf0, 0xfe, 0xf0, 0x08, 0xb5,
  5169. 0xfe, 0xcb, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0x0c, 0x09, 0x02, 0xfe, 0x18,
  5170. 0x0b, 0xb6, 0xfe, 0xbf, 0x10, 0xfe, 0x2b, 0xf0, 0x85, 0xf4, 0x1e, 0xfe,
  5171. 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xc2, 0xfe, 0xd2, 0xf0, 0x85, 0xfe, 0x76,
  5172. 0x18, 0x1e, 0x19, 0x17, 0x85, 0x03, 0xd2, 0x1e, 0x06, 0x17, 0x85, 0xc5,
  5173. 0x4a, 0xc6, 0x4a, 0xb5, 0xb6, 0xfe, 0x89, 0x10, 0x74, 0x67, 0x2d, 0x15,
  5174. 0x9d, 0x01, 0x36, 0x10, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x65, 0x10,
  5175. 0x80, 0x02, 0x65, 0xfe, 0x98, 0x80, 0xfe, 0x19, 0xe4, 0x0a, 0xfe, 0x1a,
  5176. 0x12, 0x51, 0xfe, 0x19, 0x82, 0xfe, 0x6c, 0x18, 0xfe, 0x44, 0x54, 0xbe,
  5177. 0xfe, 0x19, 0x81, 0xfe, 0x74, 0x18, 0x8f, 0x90, 0x17, 0xfe, 0xce, 0x08,
  5178. 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xec, 0x03, 0x2e, 0x29, 0x3c, 0x0c, 0x3f,
  5179. 0x14, 0x40, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x6c, 0x18, 0xfe, 0xed, 0x18,
  5180. 0xfe, 0x44, 0x54, 0xfe, 0xe5, 0x54, 0x3a, 0x3f, 0x3b, 0x40, 0x03, 0x49,
  5181. 0x29, 0x63, 0x8f, 0xfe, 0xe3, 0x54, 0xfe, 0x74, 0x18, 0xfe, 0xf5, 0x18,
  5182. 0x8f, 0xfe, 0xe3, 0x54, 0x90, 0xc0, 0x56, 0xfe, 0xce, 0x08, 0x02, 0x4a,
  5183. 0xfe, 0x37, 0xf0, 0xfe, 0xda, 0x09, 0xfe, 0x8b, 0xf0, 0xfe, 0x60, 0x09,
  5184. 0x02, 0x4a, 0x08, 0x05, 0x0a, 0x23, 0xfe, 0xfa, 0x0a, 0x3a, 0x49, 0x3b,
  5185. 0x63, 0x56, 0xfe, 0x3e, 0x0a, 0x0f, 0xfe, 0xc0, 0x07, 0x41, 0x98, 0x00,
  5186. 0xad, 0xfe, 0x01, 0x59, 0xfe, 0x52, 0xf0, 0xfe, 0x0c, 0x0a, 0x8f, 0x7a,
  5187. 0xfe, 0x24, 0x0a, 0x3a, 0x49, 0x8f, 0xfe, 0xe3, 0x54, 0x57, 0x49, 0x7d,
  5188. 0x63, 0xfe, 0x14, 0x58, 0xfe, 0x95, 0x58, 0x02, 0x4a, 0x3a, 0x49, 0x3b,
  5189. 0x63, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0xbe, 0x57, 0x49, 0x57, 0x63,
  5190. 0x02, 0x4a, 0x08, 0x05, 0x5a, 0xfe, 0x82, 0x12, 0x08, 0x05, 0x1f, 0xfe,
  5191. 0x66, 0x13, 0x22, 0x62, 0xb7, 0xfe, 0x03, 0xa1, 0xfe, 0x83, 0x80, 0xfe,
  5192. 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91, 0xfe, 0x86, 0x91, 0x6a,
  5193. 0x2a, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x56, 0xe0, 0x03, 0x60, 0x29,
  5194. 0x61, 0x0c, 0x7f, 0x14, 0x80, 0x57, 0x60, 0x7d, 0x61, 0x01, 0xb3, 0xb8,
  5195. 0x6a, 0x2a, 0x13, 0x62, 0x9b, 0x2e, 0x9c, 0x3c, 0x3a, 0x3f, 0x3b, 0x40,
  5196. 0x90, 0xc0, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0x01, 0xef,
  5197. 0xfe, 0x36, 0x10, 0x21, 0x0c, 0x7f, 0x0c, 0x80, 0x3a, 0x3f, 0x3b, 0x40,
  5198. 0xe4, 0x08, 0x05, 0x1f, 0x17, 0xe0, 0x3a, 0x3d, 0x3b, 0x3e, 0x08, 0x05,
  5199. 0xfe, 0xf7, 0x00, 0x37, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x10, 0x58, 0xfe,
  5200. 0x91, 0x58, 0x57, 0x49, 0x7d, 0x63, 0x02, 0xfe, 0xf4, 0x09, 0x08, 0x05,
  5201. 0x1f, 0x17, 0xe0, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37, 0xbe, 0xfe, 0x19,
  5202. 0x81, 0x50, 0xfe, 0x10, 0x90, 0xfe, 0x92, 0x90, 0xfe, 0xd3, 0x10, 0x32,
  5203. 0x07, 0xa6, 0x17, 0xfe, 0x08, 0x09, 0x12, 0xa6, 0x08, 0x05, 0x0a, 0xfe,
  5204. 0x14, 0x13, 0x03, 0x3d, 0x29, 0x3e, 0x56, 0xfe, 0x08, 0x09, 0xfe, 0x0c,
  5205. 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x4a, 0x21, 0x41, 0xfe, 0x19, 0x80, 0xe7,
  5206. 0x08, 0x05, 0x0a, 0xfe, 0x1a, 0x12, 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41,
  5207. 0xf4, 0xc2, 0xfe, 0xd1, 0xf0, 0xe2, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe,
  5208. 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19, 0x57, 0x3d, 0xfe, 0xed,
  5209. 0x19, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xf4, 0x1e, 0xfe,
  5210. 0x00, 0xff, 0x35, 0xfe, 0x74, 0x10, 0xc2, 0xfe, 0xd2, 0xf0, 0xfe, 0xa6,
  5211. 0x0b, 0xfe, 0x76, 0x18, 0x1e, 0x19, 0x8a, 0x03, 0xd2, 0x1e, 0x06, 0xfe,
  5212. 0x08, 0x13, 0x10, 0xfe, 0x16, 0x00, 0x02, 0x65, 0xfe, 0xd1, 0xf0, 0xfe,
  5213. 0xb8, 0x0b, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe, 0x17, 0x00, 0xfe, 0x42,
  5214. 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xbe, 0x0b, 0xfe, 0x3c, 0x10, 0xfe, 0xcd,
  5215. 0xf0, 0xfe, 0xca, 0x0b, 0x10, 0xfe, 0x22, 0x00, 0x02, 0x65, 0xfe, 0xcb,
  5216. 0xf0, 0xfe, 0xd6, 0x0b, 0x10, 0xfe, 0x24, 0x00, 0x02, 0x65, 0xfe, 0xd0,
  5217. 0xf0, 0xfe, 0xe0, 0x0b, 0x10, 0x9e, 0xe5, 0xfe, 0xcf, 0xf0, 0xfe, 0xea,
  5218. 0x0b, 0x10, 0x58, 0xfe, 0x10, 0x10, 0xfe, 0xcc, 0xf0, 0xe2, 0x68, 0x05,
  5219. 0x1f, 0x4d, 0x10, 0xfe, 0x12, 0x00, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27,
  5220. 0xfe, 0x00, 0x0c, 0xfe, 0x9e, 0xf0, 0xfe, 0x14, 0x0c, 0xbc, 0x17, 0x34,
  5221. 0x2c, 0x77, 0xe6, 0xc5, 0x24, 0xc6, 0x24, 0x2c, 0xfa, 0x27, 0xfe, 0x20,
  5222. 0x0c, 0x1c, 0x34, 0x94, 0xfe, 0x3c, 0x0c, 0x95, 0x86, 0xc5, 0xdc, 0xc6,
  5223. 0xdc, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xdb, 0x10, 0x12, 0xfe, 0xe8, 0x00,
  5224. 0xb5, 0xb6, 0x74, 0xc7, 0x81, 0xc8, 0x83, 0xfe, 0x89, 0xf0, 0x24, 0x33,
  5225. 0x31, 0xe1, 0xc7, 0x81, 0xc8, 0x83, 0x27, 0xfe, 0x66, 0x0c, 0x1d, 0x24,
  5226. 0x33, 0x31, 0xdf, 0xbc, 0x4e, 0x10, 0xfe, 0x42, 0x00, 0x02, 0x65, 0x7c,
  5227. 0x06, 0xfe, 0x81, 0x49, 0x17, 0xfe, 0x2c, 0x0d, 0x08, 0x05, 0x0a, 0xfe,
  5228. 0x44, 0x13, 0x10, 0x00, 0x55, 0x0a, 0xfe, 0x54, 0x12, 0x55, 0xfe, 0x28,
  5229. 0x00, 0x23, 0xfe, 0x9a, 0x0d, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66,
  5230. 0x44, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01, 0xf5, 0x01, 0xf6, 0x09,
  5231. 0xa4, 0x01, 0xfe, 0x26, 0x0f, 0x64, 0x12, 0x2f, 0x01, 0x73, 0x02, 0x2b,
  5232. 0x10, 0xfe, 0x44, 0x00, 0x55, 0x0a, 0xe9, 0x44, 0x0a, 0xfe, 0xb4, 0x10,
  5233. 0x01, 0xb0, 0x44, 0x0a, 0xfe, 0xaa, 0x10, 0x01, 0xb0, 0xfe, 0x19, 0x82,
  5234. 0xfe, 0x34, 0x46, 0xac, 0x44, 0x0a, 0x10, 0xfe, 0x43, 0x00, 0xfe, 0x96,
  5235. 0x10, 0x08, 0x54, 0x0a, 0x37, 0x01, 0xf5, 0x01, 0xf6, 0x64, 0x12, 0x2f,
  5236. 0x01, 0x73, 0x99, 0x0a, 0x64, 0x42, 0x92, 0x02, 0xfe, 0x2e, 0x03, 0x08,
  5237. 0x05, 0x0a, 0x8a, 0x44, 0x0a, 0x10, 0x00, 0xfe, 0x5c, 0x10, 0x68, 0x05,
  5238. 0x1a, 0xfe, 0x58, 0x12, 0x08, 0x05, 0x1a, 0xfe, 0x50, 0x13, 0xfe, 0x1c,
  5239. 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x50, 0x0d, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d,
  5240. 0xf0, 0xfe, 0x56, 0x0d, 0x08, 0x54, 0x1a, 0x37, 0xfe, 0xa9, 0x10, 0x10,
  5241. 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0a, 0x50, 0xfe, 0x2e, 0x10, 0x10,
  5242. 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x10, 0x6f, 0xab, 0x10, 0xfe, 0x41,
  5243. 0x00, 0xaa, 0x10, 0xfe, 0x24, 0x00, 0x8c, 0xb5, 0xb6, 0x74, 0x03, 0x70,
  5244. 0x28, 0x23, 0xd8, 0x50, 0xfe, 0x04, 0xe6, 0x1a, 0xfe, 0x9d, 0x41, 0xfe,
  5245. 0x1c, 0x42, 0x64, 0x01, 0xe3, 0x02, 0x2b, 0xf8, 0x15, 0x0a, 0x39, 0xa0,
  5246. 0xb4, 0x15, 0xfe, 0x31, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10, 0x02,
  5247. 0xd7, 0x42, 0xfe, 0x06, 0xec, 0xd0, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45,
  5248. 0x35, 0x42, 0xfe, 0x06, 0xea, 0xd0, 0xfe, 0x47, 0x4b, 0x91, 0xfe, 0x75,
  5249. 0x57, 0x03, 0x5d, 0xfe, 0x98, 0x56, 0xfe, 0x38, 0x12, 0x09, 0x48, 0x01,
  5250. 0x0e, 0xfe, 0x44, 0x48, 0x4f, 0x08, 0x05, 0x1b, 0xfe, 0x1a, 0x13, 0x09,
  5251. 0x46, 0x01, 0x0e, 0x41, 0xfe, 0x41, 0x58, 0x09, 0xa4, 0x01, 0x0e, 0xfe,
  5252. 0x49, 0x54, 0x96, 0xfe, 0x1e, 0x0e, 0x02, 0xfe, 0x2e, 0x03, 0x09, 0x5d,
  5253. 0xfe, 0xee, 0x14, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe,
  5254. 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x2b, 0x22, 0x20, 0x07, 0x11, 0xfe,
  5255. 0x9e, 0x12, 0x21, 0x13, 0x59, 0x13, 0x9f, 0x13, 0xd5, 0x22, 0x2f, 0x41,
  5256. 0x39, 0x2f, 0xbc, 0xad, 0xfe, 0xbc, 0xf0, 0xfe, 0xe0, 0x0e, 0x0f, 0x06,
  5257. 0x13, 0x59, 0x01, 0xfe, 0xda, 0x16, 0x03, 0xfe, 0x38, 0x01, 0x29, 0xfe,
  5258. 0x3a, 0x01, 0x56, 0xfe, 0xe4, 0x0e, 0xfe, 0x02, 0xec, 0xd5, 0x69, 0x00,
  5259. 0x66, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01,
  5260. 0x01, 0xfe, 0x4a, 0x17, 0xfe, 0x08, 0x90, 0xfe, 0x48, 0xf4, 0x0d, 0xfe,
  5261. 0x18, 0x13, 0xba, 0xfe, 0x02, 0xea, 0xd5, 0x69, 0x7e, 0xfe, 0xc5, 0x13,
  5262. 0x15, 0x1a, 0x39, 0xa0, 0xb4, 0xfe, 0x2e, 0x10, 0x03, 0xfe, 0x38, 0x01,
  5263. 0x1e, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x03, 0xfe, 0x3a, 0x01,
  5264. 0x0c, 0xfe, 0x62, 0x01, 0x43, 0x13, 0x20, 0x25, 0x06, 0x13, 0x2f, 0x12,
  5265. 0x2f, 0x92, 0x0f, 0x06, 0x04, 0x21, 0x04, 0x22, 0x59, 0xfe, 0xf7, 0x12,
  5266. 0x22, 0x9f, 0xb7, 0x13, 0x9f, 0x07, 0x7e, 0xfe, 0x71, 0x13, 0xfe, 0x24,
  5267. 0x1c, 0x15, 0x19, 0x39, 0xa0, 0xb4, 0xfe, 0xd9, 0x10, 0xc3, 0xfe, 0x03,
  5268. 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xc3, 0xfe, 0x03, 0xdc,
  5269. 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x21,
  5270. 0xfe, 0x00, 0xcc, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x78, 0x04, 0x08, 0x05,
  5271. 0x58, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
  5272. 0xfe, 0x1e, 0x80, 0xed, 0xfe, 0x1d, 0x80, 0xae, 0xfe, 0x0c, 0x90, 0xfe,
  5273. 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xac, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
  5274. 0x0a, 0xfe, 0x3c, 0x50, 0xaa, 0x01, 0xfe, 0x7a, 0x17, 0x32, 0x07, 0x2f,
  5275. 0xad, 0x01, 0xfe, 0xb4, 0x16, 0x08, 0x05, 0x1b, 0x4e, 0x01, 0xf5, 0x01,
  5276. 0xf6, 0x12, 0xfe, 0xe9, 0x00, 0x08, 0x05, 0x58, 0xfe, 0x2c, 0x13, 0x01,
  5277. 0xfe, 0x0c, 0x17, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
  5278. 0x0c, 0xfe, 0x64, 0x01, 0x14, 0xfe, 0x66, 0x01, 0x08, 0x05, 0x5b, 0xfe,
  5279. 0x12, 0x12, 0xfe, 0x03, 0x80, 0x8d, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
  5280. 0x40, 0x13, 0x20, 0x6a, 0x2a, 0x12, 0xcf, 0x64, 0x22, 0x20, 0xfb, 0x79,
  5281. 0x20, 0x04, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
  5282. 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe,
  5283. 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
  5284. 0x25, 0x6e, 0x13, 0xd0, 0x21, 0x0c, 0x5c, 0x0c, 0x45, 0x0f, 0x46, 0x52,
  5285. 0x50, 0x18, 0x1b, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xfe, 0xfc,
  5286. 0x0f, 0x44, 0x11, 0x0f, 0x48, 0x52, 0x18, 0x58, 0xfe, 0x90, 0x4d, 0xfe,
  5287. 0x91, 0x54, 0x23, 0xe4, 0x25, 0x11, 0x13, 0x20, 0x7c, 0x6f, 0x4f, 0x22,
  5288. 0x20, 0xfb, 0x79, 0x20, 0x12, 0xcf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
  5289. 0xfe, 0x26, 0x10, 0xf8, 0x74, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
  5290. 0x18, 0x1c, 0x04, 0x42, 0xfe, 0x0c, 0x14, 0xfc, 0xfe, 0x07, 0xe6, 0x1b,
  5291. 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x04, 0x01, 0xb0, 0x7c, 0x6f, 0x4f,
  5292. 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42, 0x13, 0x32, 0x07, 0x2f,
  5293. 0xfe, 0x34, 0x13, 0x09, 0x48, 0x01, 0x0e, 0xbb, 0xfe, 0x36, 0x12, 0xfe,
  5294. 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe,
  5295. 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11, 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe,
  5296. 0x80, 0x5c, 0x01, 0x73, 0xfe, 0x0e, 0x10, 0x07, 0x82, 0x4e, 0xfe, 0x14,
  5297. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x60, 0x10, 0x04, 0xfe, 0x44, 0x58, 0x8d,
  5298. 0xfe, 0x01, 0xec, 0xa2, 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe,
  5299. 0x9c, 0xe7, 0x1a, 0x79, 0x2a, 0x01, 0xe3, 0xfe, 0xdd, 0x10, 0x2c, 0xc7,
  5300. 0x81, 0xc8, 0x83, 0x33, 0x31, 0xde, 0x07, 0x1a, 0xfe, 0x48, 0x12, 0x07,
  5301. 0x0a, 0xfe, 0x56, 0x12, 0x07, 0x19, 0xfe, 0x30, 0x12, 0x07, 0xc9, 0x17,
  5302. 0xfe, 0x32, 0x12, 0x07, 0xfe, 0x23, 0x00, 0x17, 0xeb, 0x07, 0x06, 0x17,
  5303. 0xfe, 0x9c, 0x12, 0x07, 0x1f, 0xfe, 0x12, 0x12, 0x07, 0x00, 0x17, 0x24,
  5304. 0x15, 0xc9, 0x01, 0x36, 0xa9, 0x2d, 0x01, 0x0b, 0x94, 0x4b, 0x04, 0x2d,
  5305. 0xdd, 0x09, 0xd1, 0x01, 0xfe, 0x26, 0x0f, 0x12, 0x82, 0x02, 0x2b, 0x2d,
  5306. 0x32, 0x07, 0xa6, 0xfe, 0xd9, 0x13, 0x3a, 0x3d, 0x3b, 0x3e, 0x56, 0xfe,
  5307. 0xf0, 0x11, 0x08, 0x05, 0x5a, 0xfe, 0x72, 0x12, 0x9b, 0x2e, 0x9c, 0x3c,
  5308. 0x90, 0xc0, 0x96, 0xfe, 0xba, 0x11, 0x22, 0x62, 0xfe, 0x26, 0x13, 0x03,
  5309. 0x7f, 0x29, 0x80, 0x56, 0xfe, 0x76, 0x0d, 0x0c, 0x60, 0x14, 0x61, 0x21,
  5310. 0x0c, 0x7f, 0x0c, 0x80, 0x01, 0xb3, 0x25, 0x6e, 0x77, 0x13, 0x62, 0x01,
  5311. 0xef, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe,
  5312. 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0xfe, 0x91, 0x10, 0x03, 0x3f,
  5313. 0x29, 0x40, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x3f, 0x14, 0x40,
  5314. 0x88, 0x9b, 0x2e, 0x9c, 0x3c, 0x90, 0xc0, 0x03, 0x5e, 0x29, 0x5f, 0xfe,
  5315. 0x00, 0x56, 0xfe, 0xa1, 0x56, 0x0c, 0x5e, 0x14, 0x5f, 0x08, 0x05, 0x5a,
  5316. 0xfe, 0x1e, 0x12, 0x22, 0x62, 0xfe, 0x1f, 0x40, 0x03, 0x60, 0x29, 0x61,
  5317. 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x03, 0x3f, 0x29, 0x40, 0xfe, 0x44,
  5318. 0x50, 0xfe, 0xc6, 0x50, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x08, 0x50, 0xfe,
  5319. 0x8a, 0x50, 0x03, 0x3d, 0x29, 0x3e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50,
  5320. 0x02, 0x89, 0x25, 0x06, 0x13, 0xd4, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1d,
  5321. 0x4c, 0x33, 0x31, 0xde, 0x07, 0x06, 0x23, 0x4c, 0x32, 0x07, 0xa6, 0x23,
  5322. 0x72, 0x01, 0xaf, 0x1e, 0x43, 0x17, 0x4c, 0x08, 0x05, 0x0a, 0xee, 0x3a,
  5323. 0x3d, 0x3b, 0x3e, 0xfe, 0x0a, 0x55, 0x35, 0xfe, 0x8b, 0x55, 0x57, 0x3d,
  5324. 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x72, 0xfe, 0x19,
  5325. 0x81, 0xba, 0xfe, 0x19, 0x41, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1c, 0x34,
  5326. 0x1d, 0xe8, 0x33, 0x31, 0xe1, 0x55, 0x19, 0xfe, 0xa6, 0x12, 0x55, 0x0a,
  5327. 0x4d, 0x02, 0x4c, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0xe8, 0x33, 0x31, 0xdf,
  5328. 0x07, 0x19, 0x23, 0x4c, 0x01, 0x0b, 0x1d, 0xe8, 0x33, 0x31, 0xfe, 0xe8,
  5329. 0x09, 0xfe, 0xc2, 0x49, 0x51, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0x8a, 0x53,
  5330. 0x05, 0x1f, 0x35, 0xa9, 0xfe, 0xbb, 0x45, 0x55, 0x00, 0x4e, 0x44, 0x06,
  5331. 0x7c, 0x43, 0xfe, 0xda, 0x14, 0x01, 0xaf, 0x8c, 0xfe, 0x4b, 0x45, 0xee,
  5332. 0x32, 0x07, 0xa5, 0xed, 0x03, 0xcd, 0x28, 0x8a, 0x03, 0x45, 0x28, 0x35,
  5333. 0x67, 0x02, 0x72, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17,
  5334. 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01,
  5335. 0xfe, 0x9e, 0x15, 0x02, 0x89, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0x4c, 0x33,
  5336. 0x31, 0xdf, 0x07, 0x06, 0x23, 0x4c, 0x01, 0xf1, 0xfe, 0x42, 0x58, 0xf1,
  5337. 0xfe, 0xa4, 0x14, 0x8c, 0xfe, 0x4a, 0xf4, 0x0a, 0x17, 0x4c, 0xfe, 0x4a,
  5338. 0xf4, 0x06, 0xea, 0x32, 0x07, 0xa5, 0x8b, 0x02, 0x72, 0x03, 0x45, 0xc1,
  5339. 0x0c, 0x45, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01, 0xfe, 0xcc, 0x15,
  5340. 0x02, 0x89, 0x0f, 0x06, 0x27, 0xfe, 0xbe, 0x13, 0x26, 0xfe, 0xd4, 0x13,
  5341. 0x76, 0xfe, 0x89, 0x48, 0x01, 0x0b, 0x21, 0x76, 0x04, 0x7b, 0xfe, 0xd0,
  5342. 0x13, 0x1c, 0xfe, 0xd0, 0x13, 0x1d, 0xfe, 0xbe, 0x13, 0x67, 0x2d, 0x01,
  5343. 0x0b, 0xfe, 0xd5, 0x10, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
  5344. 0x1e, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x04, 0x0f,
  5345. 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0xfe, 0x30, 0x56,
  5346. 0xfe, 0x00, 0x5c, 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93,
  5347. 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0xfe, 0x0b, 0x58,
  5348. 0x04, 0x09, 0x5c, 0x01, 0x87, 0x09, 0x45, 0x01, 0x87, 0x04, 0xfe, 0x03,
  5349. 0xa1, 0x1e, 0x11, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x1f, 0x52,
  5350. 0xfe, 0x00, 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c,
  5351. 0x6a, 0x2a, 0x0c, 0x5e, 0x14, 0x5f, 0x57, 0x3f, 0x7d, 0x40, 0x04, 0xdd,
  5352. 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x8d, 0x04, 0x01,
  5353. 0xfe, 0x0c, 0x19, 0xfe, 0x42, 0x48, 0x50, 0x51, 0x91, 0x01, 0x0b, 0x1d,
  5354. 0xfe, 0x96, 0x15, 0x33, 0x31, 0xe1, 0x01, 0x0b, 0x1d, 0xfe, 0x96, 0x15,
  5355. 0x33, 0x31, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0xcd, 0x28, 0xfe,
  5356. 0xcc, 0x12, 0x53, 0x05, 0x1a, 0xfe, 0xc4, 0x13, 0x21, 0x69, 0x1a, 0xee,
  5357. 0x55, 0xca, 0x6b, 0xfe, 0xdc, 0x14, 0x4d, 0x0f, 0x06, 0x18, 0xca, 0x7c,
  5358. 0x30, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xab, 0xff, 0x02, 0x83,
  5359. 0x55, 0x69, 0x19, 0xae, 0x98, 0xfe, 0x30, 0x00, 0x96, 0xf2, 0x18, 0x6d,
  5360. 0x0f, 0x06, 0xfe, 0x56, 0x10, 0x69, 0x0a, 0xed, 0x98, 0xfe, 0x64, 0x00,
  5361. 0x96, 0xf2, 0x09, 0xfe, 0x64, 0x00, 0x18, 0x9e, 0x0f, 0x06, 0xfe, 0x28,
  5362. 0x10, 0x69, 0x06, 0xfe, 0x60, 0x13, 0x98, 0xfe, 0xc8, 0x00, 0x96, 0xf2,
  5363. 0x09, 0xfe, 0xc8, 0x00, 0x18, 0x59, 0x0f, 0x06, 0x88, 0x98, 0xfe, 0x90,
  5364. 0x01, 0x7a, 0xfe, 0x42, 0x15, 0x91, 0xe4, 0xfe, 0x43, 0xf4, 0x9f, 0xfe,
  5365. 0x56, 0xf0, 0xfe, 0x54, 0x15, 0xfe, 0x04, 0xf4, 0x71, 0xfe, 0x43, 0xf4,
  5366. 0x9e, 0xfe, 0xf3, 0x10, 0xfe, 0x40, 0x5c, 0x01, 0xfe, 0x16, 0x14, 0x1e,
  5367. 0x43, 0xec, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x6e, 0x7a, 0xfe, 0x90,
  5368. 0x15, 0xc4, 0x6e, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4,
  5369. 0xcc, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0xcc, 0x88, 0x51, 0x21, 0xfe, 0x4d,
  5370. 0xf4, 0x00, 0xe9, 0x91, 0x0f, 0x06, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58,
  5371. 0x04, 0x51, 0x0f, 0x0a, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xf3, 0x16,
  5372. 0x0a, 0x01, 0x0b, 0x26, 0xf3, 0x16, 0x19, 0x01, 0x0b, 0x26, 0xf3, 0x76,
  5373. 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
  5374. 0x16, 0x19, 0x01, 0x0b, 0x26, 0xb1, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
  5375. 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x26, 0xb1, 0x76, 0xfe, 0x89, 0x4a, 0x01,
  5376. 0x0b, 0x04, 0x51, 0x04, 0x22, 0xd3, 0x07, 0x06, 0xfe, 0x48, 0x13, 0xb8,
  5377. 0x13, 0xd3, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x76, 0xa9, 0x67, 0xfe, 0x01,
  5378. 0xec, 0xfe, 0x27, 0x01, 0xfe, 0x89, 0x48, 0xff, 0x02, 0x00, 0x10, 0x27,
  5379. 0xfe, 0x2e, 0x16, 0x32, 0x07, 0xfe, 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1d,
  5380. 0xfe, 0x52, 0x16, 0x21, 0x13, 0xd4, 0x01, 0x4b, 0x22, 0xd4, 0x07, 0x06,
  5381. 0x4e, 0x08, 0x54, 0x06, 0x37, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfb, 0x8e,
  5382. 0x07, 0x11, 0xae, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0x09, 0x5d, 0x01, 0xa8,
  5383. 0x04, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0xfe, 0x80, 0xe7, 0x11, 0x07, 0x11,
  5384. 0x8a, 0xfe, 0x45, 0x58, 0x01, 0xf0, 0x8e, 0x04, 0x09, 0x48, 0x01, 0x0e,
  5385. 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfe, 0x80,
  5386. 0x80, 0xfe, 0x80, 0x4c, 0xfe, 0x49, 0xe4, 0x11, 0xae, 0x09, 0x84, 0x01,
  5387. 0x0e, 0xfe, 0x80, 0x4c, 0x09, 0x5d, 0x01, 0x87, 0x04, 0x18, 0x11, 0x75,
  5388. 0x6c, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24,
  5389. 0x1c, 0xfe, 0x1d, 0xf7, 0x1b, 0x97, 0xfe, 0xee, 0x16, 0x01, 0xfe, 0xf4,
  5390. 0x17, 0xad, 0x9a, 0x1b, 0x6c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x04,
  5391. 0xb9, 0x23, 0xfe, 0xde, 0x16, 0xfe, 0xda, 0x10, 0x18, 0x11, 0x75, 0x03,
  5392. 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x1f, 0xfe, 0x18, 0x58, 0x03, 0xfe,
  5393. 0x66, 0x01, 0xfe, 0x19, 0x58, 0x9a, 0x1f, 0xfe, 0x3c, 0x90, 0xfe, 0x30,
  5394. 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x6c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79,
  5395. 0xfe, 0x1c, 0xf7, 0x1f, 0x97, 0xfe, 0x38, 0x17, 0xfe, 0xb6, 0x14, 0x35,
  5396. 0x04, 0xb9, 0x23, 0xfe, 0x10, 0x17, 0xfe, 0x9c, 0x10, 0x18, 0x11, 0x75,
  5397. 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7,
  5398. 0x2e, 0x97, 0xfe, 0x5a, 0x17, 0xfe, 0x94, 0x14, 0xec, 0x9a, 0x2e, 0x6c,
  5399. 0x1a, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x04, 0xb9, 0x23, 0xfe,
  5400. 0x4e, 0x17, 0xfe, 0x6c, 0x10, 0x18, 0x11, 0x75, 0xfe, 0x30, 0xbc, 0xfe,
  5401. 0xb2, 0xbc, 0x9a, 0xcb, 0x6c, 0x1a, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7,
  5402. 0xcb, 0x97, 0xfe, 0x92, 0x17, 0xfe, 0x5c, 0x14, 0x35, 0x04, 0xb9, 0x23,
  5403. 0xfe, 0x7e, 0x17, 0xfe, 0x42, 0x10, 0xfe, 0x02, 0xf6, 0x11, 0x75, 0xfe,
  5404. 0x18, 0xfe, 0x60, 0xfe, 0x19, 0xfe, 0x61, 0xfe, 0x03, 0xa1, 0xfe, 0x1d,
  5405. 0xf7, 0x5b, 0x97, 0xfe, 0xb8, 0x17, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13,
  5406. 0x9a, 0x5b, 0x41, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7,
  5407. 0x11, 0xfe, 0x81, 0xe7, 0x11, 0x12, 0xfe, 0xdd, 0x00, 0x6a, 0x2a, 0x04,
  5408. 0x6a, 0x2a, 0xfe, 0x12, 0x45, 0x23, 0xfe, 0xa8, 0x17, 0x15, 0x06, 0x39,
  5409. 0xa0, 0xb4, 0x02, 0x2b, 0xfe, 0x39, 0xf0, 0xfe, 0xfc, 0x17, 0x21, 0x04,
  5410. 0xfe, 0x7e, 0x18, 0x1e, 0x19, 0x66, 0x0f, 0x0d, 0x04, 0x75, 0x03, 0xd2,
  5411. 0x1e, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x7c, 0x6f, 0x4f, 0x32,
  5412. 0x07, 0x2f, 0xfe, 0x3c, 0x13, 0xf1, 0xfe, 0x42, 0x13, 0x42, 0x92, 0x09,
  5413. 0x48, 0x01, 0x0e, 0xbb, 0xeb, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
  5414. 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11,
  5415. 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x4c, 0x01, 0x73, 0xfe, 0x16,
  5416. 0x10, 0x07, 0x82, 0x8b, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xfe, 0x14,
  5417. 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x1c, 0x18, 0x18, 0x0a, 0x04, 0xfe, 0x9c,
  5418. 0xe7, 0x0a, 0x10, 0xfe, 0x15, 0x00, 0x64, 0x79, 0x2a, 0x01, 0xe3, 0x18,
  5419. 0x06, 0x04, 0x42, 0x92, 0x08, 0x54, 0x1b, 0x37, 0x12, 0x2f, 0x01, 0x73,
  5420. 0x18, 0x06, 0x04, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x3a, 0xce, 0x3b,
  5421. 0xcf, 0xfe, 0x48, 0x55, 0x35, 0xfe, 0xc9, 0x55, 0x04, 0x22, 0xa3, 0x77,
  5422. 0x13, 0xa3, 0x04, 0x09, 0xa4, 0x01, 0x0e, 0xfe, 0x41, 0x48, 0x09, 0x46,
  5423. 0x01, 0x0e, 0xfe, 0x49, 0x44, 0x17, 0xfe, 0xe8, 0x18, 0x77, 0x78, 0x04,
  5424. 0x09, 0x48, 0x01, 0x0e, 0x07, 0x11, 0x4e, 0x09, 0x5d, 0x01, 0xa8, 0x09,
  5425. 0x46, 0x01, 0x0e, 0x77, 0x78, 0x04, 0xfe, 0x4e, 0xe4, 0x19, 0x6b, 0xfe,
  5426. 0x1c, 0x19, 0x03, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10,
  5427. 0xfe, 0x4e, 0xe4, 0xc9, 0x6b, 0xfe, 0x2e, 0x19, 0x03, 0xfe, 0x92, 0x00,
  5428. 0xfe, 0x02, 0xe6, 0x1a, 0xe5, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x6b,
  5429. 0xfe, 0x40, 0x19, 0x03, 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x1f, 0xfe,
  5430. 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x6d, 0xfe, 0x4e,
  5431. 0x45, 0xea, 0xba, 0xff, 0x04, 0x68, 0x54, 0xe7, 0x1e, 0x6e, 0xfe, 0x08,
  5432. 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c, 0xfe, 0x1a, 0xf4, 0xfe, 0x00,
  5433. 0x04, 0xea, 0xfe, 0x48, 0xf4, 0x19, 0x7a, 0xfe, 0x74, 0x19, 0x0f, 0x19,
  5434. 0x04, 0x07, 0x7e, 0xfe, 0x5a, 0xf0, 0xfe, 0x84, 0x19, 0x25, 0xfe, 0x09,
  5435. 0x00, 0xfe, 0x34, 0x10, 0x07, 0x1a, 0xfe, 0x5a, 0xf0, 0xfe, 0x92, 0x19,
  5436. 0x25, 0xca, 0xfe, 0x26, 0x10, 0x07, 0x19, 0x66, 0x25, 0x6d, 0xe5, 0x07,
  5437. 0x0a, 0x66, 0x25, 0x9e, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x66, 0x25, 0x59,
  5438. 0xa9, 0xb8, 0x04, 0x15, 0xfe, 0x09, 0x00, 0x01, 0x36, 0xfe, 0x04, 0xfe,
  5439. 0x81, 0x03, 0x83, 0xfe, 0x40, 0x5c, 0x04, 0x1c, 0xf7, 0xfe, 0x14, 0xf0,
  5440. 0x0b, 0x27, 0xfe, 0xd6, 0x19, 0x1c, 0xf7, 0x7b, 0xf7, 0xfe, 0x82, 0xf0,
  5441. 0xfe, 0xda, 0x19, 0x04, 0xff, 0xcc, 0x00, 0x00,
  5442. };
  5443. static unsigned short _adv_asc38C0800_size = sizeof(_adv_asc38C0800_buf); /* 0x14E1 */
  5444. static ADV_DCNT _adv_asc38C0800_chksum = 0x050D3FD8UL; /* Expanded little-endian checksum. */
  5445. /* Microcode buffer is kept after initialization for error recovery. */
  5446. static unsigned char _adv_asc38C1600_buf[] = {
  5447. 0x00, 0x00, 0x00, 0xf2, 0x00, 0x16, 0x00, 0xfc, 0x00, 0x10, 0x00, 0xf0,
  5448. 0x18, 0xe4, 0x01, 0x00, 0x04, 0x1e, 0x48, 0xe4, 0x03, 0xf6, 0xf7, 0x13,
  5449. 0x2e, 0x1e, 0x02, 0x00, 0x07, 0x17, 0xc0, 0x5f, 0x00, 0xfa, 0xff, 0xff,
  5450. 0x04, 0x00, 0x00, 0xf6, 0x09, 0xe7, 0x82, 0xe7, 0x85, 0xf0, 0x86, 0xf0,
  5451. 0x4e, 0x10, 0x9e, 0xe7, 0xff, 0x00, 0x55, 0xf0, 0x01, 0xf6, 0x03, 0x00,
  5452. 0x98, 0x57, 0x01, 0xe6, 0x00, 0xea, 0x00, 0xec, 0x01, 0xfa, 0x18, 0xf4,
  5453. 0x08, 0x00, 0xf0, 0x1d, 0x38, 0x54, 0x32, 0xf0, 0x10, 0x00, 0xc2, 0x0e,
  5454. 0x1e, 0xf0, 0xd5, 0xf0, 0xbc, 0x00, 0x4b, 0xe4, 0x00, 0xe6, 0xb1, 0xf0,
  5455. 0xb4, 0x00, 0x02, 0x13, 0x3e, 0x1c, 0xc8, 0x47, 0x3e, 0x00, 0xd8, 0x01,
  5456. 0x06, 0x13, 0x0c, 0x1c, 0x5e, 0x1e, 0x00, 0x57, 0xc8, 0x57, 0x01, 0xfc,
  5457. 0xbc, 0x0e, 0xa2, 0x12, 0xb9, 0x54, 0x00, 0x80, 0x62, 0x0a, 0x5a, 0x12,
  5458. 0xc8, 0x15, 0x3e, 0x1e, 0x18, 0x40, 0xbd, 0x56, 0x03, 0xe6, 0x01, 0xea,
  5459. 0x5c, 0xf0, 0x0f, 0x00, 0x20, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
  5460. 0x04, 0x13, 0xbb, 0x55, 0x3c, 0x56, 0x3e, 0x57, 0x03, 0x58, 0x4a, 0xe4,
  5461. 0x40, 0x00, 0xb6, 0x00, 0xbb, 0x00, 0xc0, 0x00, 0x00, 0x01, 0x01, 0x01,
  5462. 0x3e, 0x01, 0x58, 0x0a, 0x44, 0x10, 0x0a, 0x12, 0x4c, 0x1c, 0x4e, 0x1c,
  5463. 0x02, 0x4a, 0x30, 0xe4, 0x05, 0xe6, 0x0c, 0x00, 0x3c, 0x00, 0x80, 0x00,
  5464. 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01,
  5465. 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x7c, 0x01, 0xc6, 0x0e, 0x0c, 0x10,
  5466. 0xac, 0x12, 0xae, 0x12, 0x16, 0x1a, 0x32, 0x1c, 0x6e, 0x1e, 0x02, 0x48,
  5467. 0x3a, 0x55, 0xc9, 0x57, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x06, 0xf7,
  5468. 0x03, 0xfc, 0x06, 0x00, 0x1e, 0x00, 0xbe, 0x00, 0xe1, 0x00, 0x0c, 0x12,
  5469. 0x18, 0x1a, 0x70, 0x1a, 0x30, 0x1c, 0x38, 0x1c, 0x10, 0x44, 0x00, 0x4c,
  5470. 0xb0, 0x57, 0x40, 0x5c, 0x4d, 0xe4, 0x04, 0xea, 0x5d, 0xf0, 0xa7, 0xf0,
  5471. 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x09, 0x00, 0x19, 0x00, 0x32, 0x00,
  5472. 0x33, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0x9e, 0x00, 0xcc, 0x00,
  5473. 0x20, 0x01, 0x4e, 0x01, 0x79, 0x01, 0x3c, 0x09, 0x68, 0x0d, 0x02, 0x10,
  5474. 0x04, 0x10, 0x3a, 0x10, 0x08, 0x12, 0x0a, 0x13, 0x40, 0x16, 0x50, 0x16,
  5475. 0x00, 0x17, 0x4a, 0x19, 0x00, 0x4e, 0x00, 0x54, 0x01, 0x58, 0x00, 0xdc,
  5476. 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xb8, 0xf0, 0x48, 0xf4, 0x0e, 0xf7,
  5477. 0x0a, 0x00, 0x9b, 0x00, 0x9c, 0x00, 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00,
  5478. 0xd0, 0x00, 0xe7, 0x00, 0xf0, 0x03, 0x69, 0x08, 0xe9, 0x09, 0x5c, 0x0c,
  5479. 0xb6, 0x12, 0xbc, 0x19, 0xd8, 0x1b, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c,
  5480. 0x42, 0x1d, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46,
  5481. 0x89, 0x48, 0x68, 0x54, 0x83, 0x55, 0x83, 0x59, 0x31, 0xe4, 0x02, 0xe6,
  5482. 0x07, 0xf0, 0x08, 0xf0, 0x0b, 0xf0, 0x0c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8,
  5483. 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa, 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00,
  5484. 0xa8, 0x00, 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0x22, 0x01,
  5485. 0x26, 0x01, 0x60, 0x01, 0x7a, 0x01, 0x82, 0x01, 0xc8, 0x01, 0xca, 0x01,
  5486. 0x86, 0x02, 0x6a, 0x03, 0x18, 0x05, 0xb2, 0x07, 0x68, 0x08, 0x10, 0x0d,
  5487. 0x06, 0x10, 0x0a, 0x10, 0x0e, 0x10, 0x12, 0x10, 0x60, 0x10, 0xed, 0x10,
  5488. 0xf3, 0x10, 0x06, 0x12, 0x10, 0x12, 0x1e, 0x12, 0x0c, 0x13, 0x0e, 0x13,
  5489. 0x10, 0x13, 0xfe, 0x9c, 0xf0, 0x35, 0x05, 0xfe, 0xec, 0x0e, 0xff, 0x10,
  5490. 0x00, 0x00, 0xe9, 0xfe, 0x34, 0x1f, 0x00, 0xe8, 0xfe, 0x88, 0x01, 0xff,
  5491. 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
  5492. 0x00, 0xfe, 0x57, 0x24, 0x00, 0xfe, 0x4c, 0x00, 0x65, 0xff, 0x04, 0x00,
  5493. 0x00, 0x1a, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 0x01, 0x01, 0xff, 0x08,
  5494. 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x13,
  5495. 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
  5496. 0xfe, 0x04, 0xf7, 0xe8, 0x37, 0x7d, 0x0d, 0x01, 0xfe, 0x4a, 0x11, 0xfe,
  5497. 0x04, 0xf7, 0xe8, 0x7d, 0x0d, 0x51, 0x37, 0xfe, 0x3d, 0xf0, 0xfe, 0x0c,
  5498. 0x02, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x91, 0xf0, 0xfe, 0xf8, 0x01, 0xfe,
  5499. 0x90, 0xf0, 0xfe, 0xf8, 0x01, 0xfe, 0x8f, 0xf0, 0xbc, 0x03, 0x67, 0x4d,
  5500. 0x05, 0xfe, 0x08, 0x0f, 0x01, 0xfe, 0x78, 0x0f, 0xfe, 0xdd, 0x12, 0x05,
  5501. 0xfe, 0x0e, 0x03, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 0x00, 0xfe, 0xd1,
  5502. 0x12, 0x3e, 0x22, 0xfe, 0xa6, 0x00, 0xac, 0xfe, 0x48, 0xf0, 0xfe, 0x90,
  5503. 0x02, 0xfe, 0x49, 0xf0, 0xfe, 0xaa, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc8,
  5504. 0x02, 0xfe, 0x46, 0xf0, 0xfe, 0x5a, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x60,
  5505. 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x4e, 0x02, 0xfe, 0x44, 0xf0, 0xfe, 0x52,
  5506. 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x56, 0x02, 0x1c, 0x0d, 0xa2, 0x1c, 0x07,
  5507. 0x22, 0xb7, 0x05, 0x35, 0xfe, 0x00, 0x1c, 0xfe, 0xf1, 0x10, 0xfe, 0x02,
  5508. 0x1c, 0xf5, 0xfe, 0x1e, 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0x5f, 0xfe, 0xe7,
  5509. 0x10, 0xfe, 0x06, 0xfc, 0xde, 0x0a, 0x81, 0x01, 0xa3, 0x05, 0x35, 0x1f,
  5510. 0x95, 0x47, 0xb8, 0x01, 0xfe, 0xe4, 0x11, 0x0a, 0x81, 0x01, 0x5c, 0xfe,
  5511. 0xbd, 0x10, 0x0a, 0x81, 0x01, 0x5c, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c,
  5512. 0xfe, 0x58, 0x1c, 0x1c, 0x07, 0x22, 0xb7, 0x37, 0x2a, 0x35, 0xfe, 0x3d,
  5513. 0xf0, 0xfe, 0x0c, 0x02, 0x2b, 0xfe, 0x9e, 0x02, 0xfe, 0x5a, 0x1c, 0xfe,
  5514. 0x12, 0x1c, 0xfe, 0x14, 0x1c, 0x1f, 0xfe, 0x30, 0x00, 0x47, 0xb8, 0x01,
  5515. 0xfe, 0xd4, 0x11, 0x1c, 0x07, 0x22, 0xb7, 0x05, 0xe9, 0x21, 0x2c, 0x09,
  5516. 0x1a, 0x31, 0xfe, 0x69, 0x10, 0x1c, 0x07, 0x22, 0xb7, 0xfe, 0x04, 0xec,
  5517. 0x2c, 0x60, 0x01, 0xfe, 0x1e, 0x1e, 0x20, 0x2c, 0xfe, 0x05, 0xf6, 0xde,
  5518. 0x01, 0xfe, 0x62, 0x1b, 0x01, 0x0c, 0x61, 0x4a, 0x44, 0x15, 0x56, 0x51,
  5519. 0x01, 0xfe, 0x9e, 0x1e, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x0a, 0x57,
  5520. 0x01, 0x18, 0x09, 0x00, 0x36, 0x01, 0x85, 0xfe, 0x18, 0x10, 0xfe, 0x41,
  5521. 0x58, 0x0a, 0xba, 0x01, 0x18, 0xfe, 0xc8, 0x54, 0x7b, 0xfe, 0x1c, 0x03,
  5522. 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x37, 0x60, 0xfe, 0x02, 0xe8, 0x30,
  5523. 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe, 0x27, 0xf0,
  5524. 0xfe, 0xe4, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x40,
  5525. 0x1c, 0x2a, 0xeb, 0xfe, 0x26, 0xf0, 0xfe, 0x66, 0x03, 0xfe, 0xa0, 0xf0,
  5526. 0xfe, 0x54, 0x03, 0xfe, 0x11, 0xf0, 0xbc, 0xfe, 0xef, 0x10, 0xfe, 0x9f,
  5527. 0xf0, 0xfe, 0x74, 0x03, 0xfe, 0x46, 0x1c, 0x19, 0xfe, 0x11, 0x00, 0x05,
  5528. 0x70, 0x37, 0xfe, 0x48, 0x1c, 0xfe, 0x46, 0x1c, 0x01, 0x0c, 0x06, 0x28,
  5529. 0xfe, 0x18, 0x13, 0x26, 0x21, 0xb9, 0xc7, 0x20, 0xb9, 0x0a, 0x57, 0x01,
  5530. 0x18, 0xc7, 0x89, 0x01, 0xfe, 0xc8, 0x1a, 0x15, 0xe1, 0x2a, 0xeb, 0xfe,
  5531. 0x01, 0xf0, 0xeb, 0xfe, 0x82, 0xf0, 0xfe, 0xa4, 0x03, 0xfe, 0x9c, 0x32,
  5532. 0x15, 0xfe, 0xe4, 0x00, 0x2f, 0xfe, 0xb6, 0x03, 0x2a, 0x3c, 0x16, 0xfe,
  5533. 0xc6, 0x03, 0x01, 0x41, 0xfe, 0x06, 0xf0, 0xfe, 0xd6, 0x03, 0xaf, 0xa0,
  5534. 0xfe, 0x0a, 0xf0, 0xfe, 0xa2, 0x07, 0x05, 0x29, 0x03, 0x81, 0x1e, 0x1b,
  5535. 0xfe, 0x24, 0x05, 0x1f, 0x63, 0x01, 0x42, 0x8f, 0xfe, 0x70, 0x02, 0x05,
  5536. 0xea, 0xfe, 0x46, 0x1c, 0x37, 0x7d, 0x1d, 0xfe, 0x67, 0x1b, 0xfe, 0xbf,
  5537. 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c, 0x75, 0x01, 0xa6, 0x86, 0x0a,
  5538. 0x57, 0x01, 0x18, 0x09, 0x00, 0x1b, 0xec, 0x0a, 0xe1, 0x01, 0x18, 0x77,
  5539. 0x50, 0x40, 0x8d, 0x30, 0x03, 0x81, 0x1e, 0xf8, 0x1f, 0x63, 0x01, 0x42,
  5540. 0x8f, 0xfe, 0x70, 0x02, 0x05, 0xea, 0xd7, 0x99, 0xd8, 0x9c, 0x2a, 0x29,
  5541. 0x2f, 0xfe, 0x4e, 0x04, 0x16, 0xfe, 0x4a, 0x04, 0x7e, 0xfe, 0xa0, 0x00,
  5542. 0xfe, 0x9b, 0x57, 0xfe, 0x54, 0x12, 0x32, 0xff, 0x02, 0x00, 0x10, 0x01,
  5543. 0x08, 0x16, 0xfe, 0x02, 0x05, 0x32, 0x01, 0x08, 0x16, 0x29, 0x27, 0x25,
  5544. 0xee, 0xfe, 0x4c, 0x44, 0xfe, 0x58, 0x12, 0x50, 0xfe, 0x44, 0x48, 0x13,
  5545. 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x60, 0x8d, 0x30, 0x01, 0xfe, 0x4e,
  5546. 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x7c, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xfe,
  5547. 0x32, 0x13, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x68, 0x13, 0xfe, 0x26, 0x10,
  5548. 0x13, 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x01, 0xfe, 0x4e, 0x1e, 0xfe,
  5549. 0x48, 0x47, 0xfe, 0x54, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xa5, 0x01, 0x43,
  5550. 0x09, 0x9b, 0xfe, 0x40, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xf9, 0x1f, 0x7f,
  5551. 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42, 0x8f,
  5552. 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x32, 0x15, 0xfe, 0xe6, 0x00, 0x0f, 0xfe,
  5553. 0x1c, 0x90, 0x04, 0xfe, 0x9c, 0x93, 0x3a, 0x0b, 0x0e, 0x8b, 0x02, 0x1f,
  5554. 0x7f, 0x01, 0x42, 0x05, 0x35, 0xfe, 0x42, 0x5b, 0x7d, 0x1d, 0xfe, 0x46,
  5555. 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0x0f, 0xfe, 0x87, 0x80, 0x04,
  5556. 0xfe, 0x87, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xd0, 0x65, 0x01, 0x0c,
  5557. 0x06, 0x0d, 0xfe, 0x98, 0x13, 0x0f, 0xfe, 0x20, 0x80, 0x04, 0xfe, 0xa0,
  5558. 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x1d, 0xfe, 0x84, 0x12, 0x01, 0x38, 0x06,
  5559. 0x07, 0xfe, 0x70, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x1e, 0x1b, 0xfe, 0xda,
  5560. 0x05, 0xd0, 0x54, 0x01, 0x38, 0x06, 0x0d, 0xfe, 0x58, 0x13, 0x03, 0xfe,
  5561. 0xa0, 0x00, 0x1e, 0xfe, 0x50, 0x12, 0x5e, 0xff, 0x02, 0x00, 0x10, 0x2f,
  5562. 0xfe, 0x90, 0x05, 0x2a, 0x3c, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe,
  5563. 0x9e, 0x05, 0x17, 0xfe, 0xf4, 0x05, 0x15, 0xfe, 0xe3, 0x00, 0x26, 0x01,
  5564. 0x38, 0xfe, 0x4a, 0xf0, 0xfe, 0xc0, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0xba,
  5565. 0x05, 0x71, 0x2e, 0xfe, 0x21, 0x00, 0xf1, 0x2e, 0xfe, 0x22, 0x00, 0xa2,
  5566. 0x2e, 0x4a, 0xfe, 0x09, 0x48, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe, 0xd0,
  5567. 0x05, 0x17, 0xfe, 0xf4, 0x05, 0xfe, 0xe2, 0x08, 0x01, 0x38, 0x06, 0xfe,
  5568. 0x1c, 0x00, 0x4d, 0x01, 0xa7, 0x2e, 0x07, 0x20, 0xe4, 0x47, 0xfe, 0x27,
  5569. 0x01, 0x01, 0x0c, 0x06, 0x28, 0xfe, 0x24, 0x12, 0x3e, 0x01, 0x84, 0x1f,
  5570. 0x7f, 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42,
  5571. 0x8f, 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x03, 0xe6, 0x1e, 0xfe, 0xca, 0x13,
  5572. 0x03, 0xb6, 0x1e, 0xfe, 0x40, 0x12, 0x03, 0x66, 0x1e, 0xfe, 0x38, 0x13,
  5573. 0x3e, 0x01, 0x84, 0x17, 0xfe, 0x72, 0x06, 0x0a, 0x07, 0x01, 0x38, 0x06,
  5574. 0x24, 0xfe, 0x02, 0x12, 0x4f, 0x01, 0xfe, 0x56, 0x19, 0x16, 0xfe, 0x68,
  5575. 0x06, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x66, 0x8a, 0x10, 0x66,
  5576. 0x03, 0x9a, 0x1e, 0xfe, 0x70, 0x12, 0x03, 0x55, 0x1e, 0xfe, 0x68, 0x13,
  5577. 0x01, 0xc6, 0x09, 0x12, 0x48, 0xfe, 0x92, 0x06, 0x2e, 0x12, 0x01, 0xfe,
  5578. 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0x13, 0x58, 0xff, 0x02, 0x00,
  5579. 0x57, 0x52, 0xad, 0x23, 0x3f, 0x4e, 0x62, 0x49, 0x3e, 0x01, 0x84, 0x17,
  5580. 0xfe, 0xea, 0x06, 0x01, 0x38, 0x06, 0x12, 0xf7, 0x45, 0x0a, 0x95, 0x01,
  5581. 0xfe, 0x84, 0x19, 0x16, 0xfe, 0xe0, 0x06, 0x15, 0x82, 0x01, 0x41, 0x15,
  5582. 0xe2, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x1c, 0x07, 0x01, 0x84, 0xfe, 0xae,
  5583. 0x10, 0x03, 0x6f, 0x1e, 0xfe, 0x9e, 0x13, 0x3e, 0x01, 0x84, 0x03, 0x9a,
  5584. 0x1e, 0xfe, 0x1a, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfc, 0x01, 0xc6, 0x01,
  5585. 0xfe, 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0xf0, 0x45, 0x0a, 0x95,
  5586. 0x03, 0xb6, 0x1e, 0xf8, 0x01, 0x38, 0x06, 0x24, 0x36, 0xfe, 0x02, 0xf6,
  5587. 0x07, 0x71, 0x78, 0x8c, 0x00, 0x4d, 0x62, 0x49, 0x3e, 0x2d, 0x93, 0x4e,
  5588. 0xd0, 0x0d, 0x17, 0xfe, 0x9a, 0x07, 0x01, 0xfe, 0xc0, 0x19, 0x16, 0xfe,
  5589. 0x90, 0x07, 0x26, 0x20, 0x9e, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x21,
  5590. 0x9e, 0x09, 0x07, 0xfb, 0x03, 0xe6, 0xfe, 0x58, 0x57, 0x10, 0xe6, 0x05,
  5591. 0xfe, 0x2a, 0x06, 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x1c, 0x07, 0x01, 0x84,
  5592. 0xfe, 0x9c, 0x32, 0x5f, 0x75, 0x01, 0xa6, 0x86, 0x15, 0xfe, 0xe2, 0x00,
  5593. 0x2f, 0xed, 0x2a, 0x3c, 0xfe, 0x0a, 0xf0, 0xfe, 0xce, 0x07, 0xae, 0xfe,
  5594. 0x96, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x9e, 0x08, 0xaf, 0xa0, 0x05, 0x29,
  5595. 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x2e, 0x12, 0x14, 0x1d, 0x01, 0x08, 0x14,
  5596. 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0xfe,
  5597. 0x99, 0xa4, 0x01, 0x08, 0x14, 0x00, 0x05, 0xfe, 0xc6, 0x09, 0x01, 0x76,
  5598. 0x06, 0x12, 0xfe, 0x3a, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x30, 0x13,
  5599. 0x14, 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00,
  5600. 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x07, 0x01, 0x08, 0x14, 0x00,
  5601. 0x05, 0xef, 0x7c, 0x4a, 0x78, 0x4f, 0x0f, 0xfe, 0x9a, 0x81, 0x04, 0xfe,
  5602. 0x9a, 0x83, 0xfe, 0xcb, 0x47, 0x0b, 0x0e, 0x2d, 0x28, 0x48, 0xfe, 0x6c,
  5603. 0x08, 0x0a, 0x28, 0xfe, 0x09, 0x6f, 0xca, 0xfe, 0xca, 0x45, 0xfe, 0x32,
  5604. 0x12, 0x53, 0x63, 0x4e, 0x7c, 0x97, 0x2f, 0xfe, 0x7e, 0x08, 0x2a, 0x3c,
  5605. 0xfe, 0x0a, 0xf0, 0xfe, 0x6c, 0x08, 0xaf, 0xa0, 0xae, 0xfe, 0x96, 0x08,
  5606. 0x05, 0x29, 0x01, 0x41, 0x05, 0xed, 0x14, 0x24, 0x05, 0xed, 0xfe, 0x9c,
  5607. 0xf7, 0x9f, 0x01, 0xfe, 0xae, 0x1e, 0xfe, 0x18, 0x58, 0x01, 0xfe, 0xbe,
  5608. 0x1e, 0xfe, 0x99, 0x58, 0xfe, 0x78, 0x18, 0xfe, 0xf9, 0x18, 0x8e, 0xfe,
  5609. 0x16, 0x09, 0x10, 0x6a, 0x22, 0x6b, 0x01, 0x0c, 0x61, 0x54, 0x44, 0x21,
  5610. 0x2c, 0x09, 0x1a, 0xf8, 0x77, 0x01, 0xfe, 0x7e, 0x1e, 0x47, 0x2c, 0x7a,
  5611. 0x30, 0xf0, 0xfe, 0x83, 0xe7, 0xfe, 0x3f, 0x00, 0x71, 0xfe, 0x03, 0x40,
  5612. 0x01, 0x0c, 0x61, 0x65, 0x44, 0x01, 0xc2, 0xc8, 0xfe, 0x1f, 0x40, 0x20,
  5613. 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe,
  5614. 0x44, 0x51, 0xfe, 0xc6, 0x51, 0xfe, 0x10, 0x10, 0x01, 0xfe, 0xce, 0x1e,
  5615. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x01, 0xfe, 0xee, 0x1e,
  5616. 0x01, 0xfe, 0xfe, 0x1e, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x10, 0x4b,
  5617. 0x22, 0x4c, 0xfe, 0x8a, 0x10, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x50, 0x12,
  5618. 0x01, 0xfe, 0xae, 0x1e, 0x01, 0xfe, 0xbe, 0x1e, 0x10, 0x6a, 0x22, 0x6b,
  5619. 0x01, 0x0c, 0x06, 0x65, 0x4e, 0x01, 0xc2, 0x0f, 0xfe, 0x1f, 0x80, 0x04,
  5620. 0xfe, 0x9f, 0x83, 0x33, 0x0b, 0x0e, 0x20, 0x6e, 0x0f, 0xfe, 0x44, 0x90,
  5621. 0x04, 0xfe, 0xc4, 0x93, 0x3a, 0x0b, 0xfe, 0xc6, 0x90, 0x04, 0xfe, 0xc6,
  5622. 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x6c, 0x22, 0x6d, 0x01, 0xfe, 0xce, 0x1e,
  5623. 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x0f, 0xfe, 0x40, 0x90,
  5624. 0x04, 0xfe, 0xc0, 0x93, 0x3a, 0x0b, 0xfe, 0xc2, 0x90, 0x04, 0xfe, 0xc2,
  5625. 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x4b, 0x22, 0x4c, 0x10, 0x64, 0x22, 0x34,
  5626. 0x01, 0x0c, 0x61, 0x24, 0x44, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe,
  5627. 0xde, 0x09, 0xfe, 0x9e, 0xf0, 0xfe, 0xf2, 0x09, 0xfe, 0x01, 0x48, 0x1b,
  5628. 0x3c, 0x37, 0x88, 0xf5, 0xd4, 0xfe, 0x1e, 0x0a, 0xd5, 0xfe, 0x42, 0x0a,
  5629. 0xd2, 0xfe, 0x1e, 0x0a, 0xd3, 0xfe, 0x42, 0x0a, 0xae, 0xfe, 0x12, 0x0a,
  5630. 0xfe, 0x06, 0xf0, 0xfe, 0x18, 0x0a, 0xaf, 0xa0, 0x05, 0x29, 0x01, 0x41,
  5631. 0xfe, 0xc1, 0x10, 0x14, 0x24, 0xfe, 0xc1, 0x10, 0x01, 0x76, 0x06, 0x07,
  5632. 0xfe, 0x14, 0x12, 0x01, 0x76, 0x06, 0x0d, 0x5d, 0x01, 0x0c, 0x06, 0x0d,
  5633. 0xfe, 0x74, 0x12, 0xfe, 0x2e, 0x1c, 0x05, 0xfe, 0x1a, 0x0c, 0x01, 0x76,
  5634. 0x06, 0x07, 0x5d, 0x01, 0x76, 0x06, 0x0d, 0x41, 0xfe, 0x2c, 0x1c, 0xfe,
  5635. 0xaa, 0xf0, 0xfe, 0xce, 0x0a, 0xfe, 0xac, 0xf0, 0xfe, 0x66, 0x0a, 0xfe,
  5636. 0x92, 0x10, 0xc4, 0xf6, 0xfe, 0xad, 0xf0, 0xfe, 0x72, 0x0a, 0x05, 0xfe,
  5637. 0x1a, 0x0c, 0xc5, 0xfe, 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0xbf, 0xfe, 0x6b,
  5638. 0x18, 0x23, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xac, 0xfe, 0xd2, 0xf0,
  5639. 0xbf, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x1b, 0xbf, 0x03, 0xe3, 0x23, 0x07,
  5640. 0x1b, 0xbf, 0xd4, 0x5b, 0xd5, 0x5b, 0xd2, 0x5b, 0xd3, 0x5b, 0xc4, 0xc5,
  5641. 0xfe, 0xa9, 0x10, 0x75, 0x5e, 0x32, 0x1f, 0x7f, 0x01, 0x42, 0x19, 0xfe,
  5642. 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x70, 0x19, 0x98, 0x05, 0x70, 0xfe, 0x74,
  5643. 0x18, 0x23, 0xfe, 0x00, 0xf8, 0x1b, 0x5b, 0x7d, 0x12, 0x01, 0xfe, 0x78,
  5644. 0x0f, 0x4d, 0x01, 0xfe, 0x96, 0x1a, 0x21, 0x30, 0x77, 0x7d, 0x1d, 0x05,
  5645. 0x5b, 0x01, 0x0c, 0x06, 0x0d, 0x2b, 0xfe, 0xe2, 0x0b, 0x01, 0x0c, 0x06,
  5646. 0x54, 0xfe, 0xa6, 0x12, 0x01, 0x0c, 0x06, 0x24, 0xfe, 0x88, 0x13, 0x21,
  5647. 0x6e, 0xc7, 0x01, 0xfe, 0x1e, 0x1f, 0x0f, 0xfe, 0x83, 0x80, 0x04, 0xfe,
  5648. 0x83, 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0xfe, 0xc8, 0x44, 0xfe, 0x42,
  5649. 0x13, 0x0f, 0xfe, 0x04, 0x91, 0x04, 0xfe, 0x84, 0x93, 0xfe, 0xca, 0x57,
  5650. 0x0b, 0xfe, 0x86, 0x91, 0x04, 0xfe, 0x86, 0x93, 0xfe, 0xcb, 0x57, 0x0b,
  5651. 0x0e, 0x7a, 0x30, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x8e, 0x40, 0x03,
  5652. 0x6a, 0x3b, 0x6b, 0x10, 0x97, 0x22, 0x98, 0xd9, 0x6a, 0xda, 0x6b, 0x01,
  5653. 0xc2, 0xc8, 0x7a, 0x30, 0x20, 0x6e, 0xdb, 0x64, 0xdc, 0x34, 0x91, 0x6c,
  5654. 0x7e, 0x6d, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xfe, 0x04, 0xfa, 0x64,
  5655. 0xfe, 0x05, 0xfa, 0x34, 0x01, 0xfe, 0x6a, 0x16, 0xa3, 0x26, 0x10, 0x97,
  5656. 0x10, 0x98, 0x91, 0x6c, 0x7e, 0x6d, 0xfe, 0x14, 0x10, 0x01, 0x0c, 0x06,
  5657. 0x24, 0x1b, 0x40, 0x91, 0x4b, 0x7e, 0x4c, 0x01, 0x0c, 0x06, 0xfe, 0xf7,
  5658. 0x00, 0x44, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58,
  5659. 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x05, 0x5b, 0x01, 0x0c, 0x06, 0x24,
  5660. 0x1b, 0x40, 0x01, 0x0c, 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x78, 0x01, 0xfe,
  5661. 0x8e, 0x1e, 0x4f, 0x0f, 0xfe, 0x10, 0x90, 0x04, 0xfe, 0x90, 0x93, 0x3a,
  5662. 0x0b, 0xfe, 0x92, 0x90, 0x04, 0xfe, 0x92, 0x93, 0x79, 0x0b, 0x0e, 0xfe,
  5663. 0xbd, 0x10, 0x01, 0x43, 0x09, 0xbb, 0x1b, 0xfe, 0x6e, 0x0a, 0x15, 0xbb,
  5664. 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x14, 0x13, 0x03, 0x4b, 0x3b, 0x4c, 0x8e,
  5665. 0xfe, 0x6e, 0x0a, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 0x58, 0x05, 0x5b, 0x26,
  5666. 0x3e, 0x0f, 0xfe, 0x19, 0x80, 0x04, 0xfe, 0x99, 0x83, 0x33, 0x0b, 0x0e,
  5667. 0xfe, 0xe5, 0x10, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1a, 0x12, 0xfe, 0x6c,
  5668. 0x19, 0xfe, 0x19, 0x41, 0xfe, 0x6b, 0x18, 0xac, 0xfe, 0xd1, 0xf0, 0xef,
  5669. 0x1f, 0x92, 0x01, 0x42, 0x19, 0xfe, 0x44, 0x00, 0xfe, 0x90, 0x10, 0xfe,
  5670. 0x6c, 0x19, 0xd9, 0x4b, 0xfe, 0xed, 0x19, 0xda, 0x4c, 0xfe, 0x0c, 0x51,
  5671. 0xfe, 0x8e, 0x51, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xff, 0x31, 0xfe,
  5672. 0x76, 0x10, 0xac, 0xfe, 0xd2, 0xf0, 0xfe, 0xba, 0x0c, 0xfe, 0x76, 0x18,
  5673. 0x23, 0x1d, 0x5d, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0x08, 0x13, 0x19, 0xfe,
  5674. 0x16, 0x00, 0x05, 0x70, 0xfe, 0xd1, 0xf0, 0xfe, 0xcc, 0x0c, 0x1f, 0x92,
  5675. 0x01, 0x42, 0x19, 0xfe, 0x17, 0x00, 0x5c, 0xfe, 0xce, 0xf0, 0xfe, 0xd2,
  5676. 0x0c, 0xfe, 0x3e, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xde, 0x0c, 0x19, 0xfe,
  5677. 0x22, 0x00, 0x05, 0x70, 0xfe, 0xcb, 0xf0, 0xfe, 0xea, 0x0c, 0x19, 0xfe,
  5678. 0x24, 0x00, 0x05, 0x70, 0xfe, 0xd0, 0xf0, 0xfe, 0xf4, 0x0c, 0x19, 0x94,
  5679. 0xfe, 0x1c, 0x10, 0xfe, 0xcf, 0xf0, 0xfe, 0xfe, 0x0c, 0x19, 0x4a, 0xf3,
  5680. 0xfe, 0xcc, 0xf0, 0xef, 0x01, 0x76, 0x06, 0x24, 0x4d, 0x19, 0xfe, 0x12,
  5681. 0x00, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe, 0x16, 0x0d, 0xfe, 0x9e,
  5682. 0xf0, 0xfe, 0x2a, 0x0d, 0xfe, 0x01, 0x48, 0x1b, 0x3c, 0x37, 0x88, 0xf5,
  5683. 0xd4, 0x29, 0xd5, 0x29, 0xd2, 0x29, 0xd3, 0x29, 0x37, 0xfe, 0x9c, 0x32,
  5684. 0x2f, 0xfe, 0x3e, 0x0d, 0x2a, 0x3c, 0xae, 0xfe, 0x62, 0x0d, 0xaf, 0xa0,
  5685. 0xd4, 0x9f, 0xd5, 0x9f, 0xd2, 0x9f, 0xd3, 0x9f, 0x05, 0x29, 0x01, 0x41,
  5686. 0xfe, 0xd3, 0x10, 0x15, 0xfe, 0xe8, 0x00, 0xc4, 0xc5, 0x75, 0xd7, 0x99,
  5687. 0xd8, 0x9c, 0xfe, 0x89, 0xf0, 0x29, 0x27, 0x25, 0xbe, 0xd7, 0x99, 0xd8,
  5688. 0x9c, 0x2f, 0xfe, 0x8c, 0x0d, 0x16, 0x29, 0x27, 0x25, 0xbd, 0xfe, 0x01,
  5689. 0x48, 0xa4, 0x19, 0xfe, 0x42, 0x00, 0x05, 0x70, 0x90, 0x07, 0xfe, 0x81,
  5690. 0x49, 0x1b, 0xfe, 0x64, 0x0e, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x44, 0x13,
  5691. 0x19, 0x00, 0x2d, 0x0d, 0xfe, 0x54, 0x12, 0x2d, 0xfe, 0x28, 0x00, 0x2b,
  5692. 0xfe, 0xda, 0x0e, 0x0a, 0x57, 0x01, 0x18, 0x09, 0x00, 0x36, 0x46, 0xfe,
  5693. 0x28, 0x00, 0xfe, 0xfa, 0x10, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00,
  5694. 0x1d, 0x0a, 0xba, 0x01, 0xfe, 0x58, 0x10, 0x40, 0x15, 0x56, 0x01, 0x85,
  5695. 0x05, 0x35, 0x19, 0xfe, 0x44, 0x00, 0x2d, 0x0d, 0xf7, 0x46, 0x0d, 0xfe,
  5696. 0xcc, 0x10, 0x01, 0xa7, 0x46, 0x0d, 0xfe, 0xc2, 0x10, 0x01, 0xa7, 0x0f,
  5697. 0xfe, 0x19, 0x82, 0x04, 0xfe, 0x99, 0x83, 0xfe, 0xcc, 0x47, 0x0b, 0x0e,
  5698. 0xfe, 0x34, 0x46, 0xa5, 0x46, 0x0d, 0x19, 0xfe, 0x43, 0x00, 0xfe, 0xa2,
  5699. 0x10, 0x01, 0x0c, 0x61, 0x0d, 0x44, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe,
  5700. 0x00, 0x1d, 0x40, 0x15, 0x56, 0x01, 0x85, 0x7d, 0x0d, 0x40, 0x51, 0x01,
  5701. 0xfe, 0x9e, 0x1e, 0x05, 0xfe, 0x3a, 0x03, 0x01, 0x0c, 0x06, 0x0d, 0x5d,
  5702. 0x46, 0x0d, 0x19, 0x00, 0xfe, 0x62, 0x10, 0x01, 0x76, 0x06, 0x12, 0xfe,
  5703. 0x5c, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x52, 0x13, 0xfe, 0x1c, 0x1c,
  5704. 0xfe, 0x9d, 0xf0, 0xfe, 0x8e, 0x0e, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0,
  5705. 0xfe, 0x94, 0x0e, 0x01, 0x0c, 0x61, 0x12, 0x44, 0xfe, 0x9f, 0x10, 0x19,
  5706. 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0d, 0x4f, 0xfe, 0x2e, 0x10, 0x19,
  5707. 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x19, 0xfe, 0x47, 0x00, 0xf1, 0x19,
  5708. 0xfe, 0x41, 0x00, 0xa2, 0x19, 0xfe, 0x24, 0x00, 0x86, 0xc4, 0xc5, 0x75,
  5709. 0x03, 0x81, 0x1e, 0x2b, 0xea, 0x4f, 0xfe, 0x04, 0xe6, 0x12, 0xfe, 0x9d,
  5710. 0x41, 0xfe, 0x1c, 0x42, 0x40, 0x01, 0xf4, 0x05, 0x35, 0xfe, 0x12, 0x1c,
  5711. 0x1f, 0x0d, 0x47, 0xb5, 0xc3, 0x1f, 0xfe, 0x31, 0x00, 0x47, 0xb8, 0x01,
  5712. 0xfe, 0xd4, 0x11, 0x05, 0xe9, 0x51, 0xfe, 0x06, 0xec, 0xe0, 0xfe, 0x0e,
  5713. 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0x06, 0xea, 0xe0,
  5714. 0xfe, 0x47, 0x4b, 0x45, 0xfe, 0x75, 0x57, 0x03, 0x67, 0xfe, 0x98, 0x56,
  5715. 0xfe, 0x38, 0x12, 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x44, 0x48, 0x60, 0x01,
  5716. 0x0c, 0x06, 0x28, 0xfe, 0x18, 0x13, 0x0a, 0x57, 0x01, 0x18, 0x3e, 0xfe,
  5717. 0x41, 0x58, 0x0a, 0xba, 0xfe, 0xfa, 0x14, 0xfe, 0x49, 0x54, 0xb0, 0xfe,
  5718. 0x5e, 0x0f, 0x05, 0xfe, 0x3a, 0x03, 0x0a, 0x67, 0xfe, 0xe0, 0x14, 0xfe,
  5719. 0x0e, 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0xce, 0x47,
  5720. 0xfe, 0xad, 0x13, 0x05, 0x35, 0x21, 0x2c, 0x09, 0x1a, 0xfe, 0x98, 0x12,
  5721. 0x26, 0x20, 0x96, 0x20, 0xe7, 0xfe, 0x08, 0x1c, 0xfe, 0x7c, 0x19, 0xfe,
  5722. 0xfd, 0x19, 0xfe, 0x0a, 0x1c, 0x03, 0xe5, 0xfe, 0x48, 0x55, 0xa5, 0x3b,
  5723. 0xfe, 0x62, 0x01, 0xfe, 0xc9, 0x55, 0x31, 0xfe, 0x74, 0x10, 0x01, 0xfe,
  5724. 0xf0, 0x1a, 0x03, 0xfe, 0x38, 0x01, 0x3b, 0xfe, 0x3a, 0x01, 0x8e, 0xfe,
  5725. 0x1e, 0x10, 0xfe, 0x02, 0xec, 0xe7, 0x53, 0x00, 0x36, 0xfe, 0x04, 0xec,
  5726. 0x2c, 0x60, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x62, 0x1b,
  5727. 0x01, 0xfe, 0xce, 0x1e, 0xb2, 0x11, 0xfe, 0x18, 0x13, 0xca, 0xfe, 0x02,
  5728. 0xea, 0xe7, 0x53, 0x92, 0xfe, 0xc3, 0x13, 0x1f, 0x12, 0x47, 0xb5, 0xc3,
  5729. 0xfe, 0x2a, 0x10, 0x03, 0xfe, 0x38, 0x01, 0x23, 0xfe, 0xf0, 0xff, 0x10,
  5730. 0xe5, 0x03, 0xfe, 0x3a, 0x01, 0x10, 0xfe, 0x62, 0x01, 0x01, 0xfe, 0x1e,
  5731. 0x1e, 0x20, 0x2c, 0x15, 0x56, 0x01, 0xfe, 0x9e, 0x1e, 0x13, 0x07, 0x02,
  5732. 0x26, 0x02, 0x21, 0x96, 0xc7, 0x20, 0x96, 0x09, 0x92, 0xfe, 0x79, 0x13,
  5733. 0x1f, 0x1d, 0x47, 0xb5, 0xc3, 0xfe, 0xe1, 0x10, 0xcf, 0xfe, 0x03, 0xdc,
  5734. 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xcf, 0xfe, 0x03, 0xdc, 0xfe,
  5735. 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x26, 0xfe,
  5736. 0x00, 0xcc, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x89, 0x02, 0x01, 0x0c, 0x06,
  5737. 0x4a, 0xfe, 0x4e, 0x13, 0x0f, 0xfe, 0x1c, 0x80, 0x04, 0xfe, 0x9c, 0x83,
  5738. 0x33, 0x0b, 0x0e, 0x09, 0x07, 0xfe, 0x3a, 0x13, 0x0f, 0xfe, 0x1e, 0x80,
  5739. 0x04, 0xfe, 0x9e, 0x83, 0x33, 0x0b, 0x0e, 0xfe, 0x2a, 0x13, 0x0f, 0xfe,
  5740. 0x1d, 0x80, 0x04, 0xfe, 0x9d, 0x83, 0xfe, 0xf9, 0x13, 0x0e, 0xfe, 0x1c,
  5741. 0x13, 0x01, 0xfe, 0xee, 0x1e, 0xac, 0xfe, 0x14, 0x13, 0x01, 0xfe, 0xfe,
  5742. 0x1e, 0xfe, 0x81, 0x58, 0xfa, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4,
  5743. 0x0d, 0xfe, 0x3c, 0x50, 0xa2, 0x01, 0xfe, 0x92, 0x1b, 0x01, 0x43, 0x09,
  5744. 0x56, 0xfb, 0x01, 0xfe, 0xc8, 0x1a, 0x01, 0x0c, 0x06, 0x28, 0xa4, 0x01,
  5745. 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x15, 0xfe, 0xe9, 0x00, 0x01,
  5746. 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13, 0x01, 0xfe, 0x22, 0x1b, 0xfe, 0x1e,
  5747. 0x1c, 0x0f, 0xfe, 0x14, 0x90, 0x04, 0xfe, 0x94, 0x93, 0x3a, 0x0b, 0xfe,
  5748. 0x96, 0x90, 0x04, 0xfe, 0x96, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0xfe, 0x64,
  5749. 0x01, 0x22, 0xfe, 0x66, 0x01, 0x01, 0x0c, 0x06, 0x65, 0xf9, 0x0f, 0xfe,
  5750. 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x0e, 0x77, 0xfe, 0x01,
  5751. 0xec, 0x2c, 0xfe, 0x80, 0x40, 0x20, 0x2c, 0x7a, 0x30, 0x15, 0xdf, 0x40,
  5752. 0x21, 0x2c, 0xfe, 0x00, 0x40, 0x8d, 0x2c, 0x02, 0xfe, 0x08, 0x1c, 0x03,
  5753. 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58, 0x03, 0xfe, 0xae, 0x00, 0xfe, 0x07,
  5754. 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00,
  5755. 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c, 0x2e, 0x49, 0x20, 0xe0, 0x26, 0x10,
  5756. 0x66, 0x10, 0x55, 0x10, 0x6f, 0x13, 0x57, 0x52, 0x4f, 0x1c, 0x28, 0xfe,
  5757. 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe, 0x88, 0x11, 0x46, 0x1a, 0x13,
  5758. 0x5a, 0x52, 0x1c, 0x4a, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe,
  5759. 0x9e, 0x11, 0x2e, 0x1a, 0x20, 0x2c, 0x90, 0x34, 0x60, 0x21, 0x2c, 0xfe,
  5760. 0x00, 0x40, 0x8d, 0x2c, 0x15, 0xdf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0,
  5761. 0xfe, 0xb2, 0x11, 0xfe, 0x12, 0x1c, 0x75, 0xfe, 0x14, 0x1c, 0xfe, 0x10,
  5762. 0x1c, 0xfe, 0x18, 0x1c, 0x02, 0x51, 0xfe, 0x0c, 0x14, 0xfe, 0x0e, 0x47,
  5763. 0xfe, 0x07, 0xe6, 0x28, 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x02, 0x01,
  5764. 0xa7, 0x90, 0x34, 0x60, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42,
  5765. 0x13, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x34, 0x13, 0x0a, 0x5a, 0x01,
  5766. 0x18, 0xcb, 0xfe, 0x36, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
  5767. 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f, 0x89,
  5768. 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x5c, 0x01, 0x85,
  5769. 0xf2, 0x09, 0x9b, 0xa4, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0xec,
  5770. 0x11, 0x02, 0xfe, 0x44, 0x58, 0x77, 0xfe, 0x01, 0xec, 0xb8, 0xfe, 0x9e,
  5771. 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x12, 0x8d, 0x30, 0x01,
  5772. 0xf4, 0xfe, 0xdd, 0x10, 0x37, 0xd7, 0x99, 0xd8, 0x9c, 0x27, 0x25, 0xee,
  5773. 0x09, 0x12, 0xfe, 0x48, 0x12, 0x09, 0x0d, 0xfe, 0x56, 0x12, 0x09, 0x1d,
  5774. 0xfe, 0x30, 0x12, 0x09, 0xdd, 0x1b, 0xfe, 0xc4, 0x13, 0x09, 0xfe, 0x23,
  5775. 0x00, 0x1b, 0xfe, 0xd0, 0x13, 0x09, 0x07, 0x1b, 0xfe, 0x34, 0x14, 0x09,
  5776. 0x24, 0xfe, 0x12, 0x12, 0x09, 0x00, 0x1b, 0x29, 0x1f, 0xdd, 0x01, 0x42,
  5777. 0xa1, 0x32, 0x01, 0x08, 0xae, 0x41, 0x02, 0x32, 0xfe, 0x62, 0x08, 0x0a,
  5778. 0xe1, 0x01, 0xfe, 0x58, 0x10, 0x15, 0x9b, 0x05, 0x35, 0x32, 0x01, 0x43,
  5779. 0x09, 0xbb, 0xfe, 0xd7, 0x13, 0x91, 0x4b, 0x7e, 0x4c, 0x8e, 0xfe, 0x80,
  5780. 0x13, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0x72, 0x12, 0xdb, 0x64, 0xdc, 0x34,
  5781. 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xb0, 0xfe, 0x4a, 0x13, 0x21, 0x6e,
  5782. 0xfe, 0x26, 0x13, 0x03, 0x97, 0x3b, 0x98, 0x8e, 0xfe, 0xb6, 0x0e, 0x10,
  5783. 0x6a, 0x22, 0x6b, 0x26, 0x10, 0x97, 0x10, 0x98, 0x01, 0xc2, 0x2e, 0x49,
  5784. 0x88, 0x20, 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
  5785. 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x64, 0xfe, 0x05, 0xfa,
  5786. 0x34, 0xfe, 0x8f, 0x10, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x40, 0x56, 0xfe,
  5787. 0xe1, 0x56, 0x10, 0x6c, 0x22, 0x6d, 0x71, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
  5788. 0x44, 0x55, 0xfe, 0xe5, 0x55, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x00, 0x56,
  5789. 0xfe, 0xa1, 0x56, 0x10, 0x68, 0x22, 0x69, 0x01, 0x0c, 0x06, 0x54, 0xf9,
  5790. 0x21, 0x6e, 0xfe, 0x1f, 0x40, 0x03, 0x6a, 0x3b, 0x6b, 0xfe, 0x2c, 0x50,
  5791. 0xfe, 0xae, 0x50, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x44, 0x50, 0xfe, 0xc6,
  5792. 0x50, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03,
  5793. 0x4b, 0x3b, 0x4c, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x05, 0x73, 0x2e,
  5794. 0x07, 0x20, 0x9e, 0x05, 0x72, 0x32, 0x01, 0x08, 0x16, 0x3d, 0x27, 0x25,
  5795. 0xee, 0x09, 0x07, 0x2b, 0x3d, 0x01, 0x43, 0x09, 0xbb, 0x2b, 0x72, 0x01,
  5796. 0xa6, 0x23, 0x3f, 0x1b, 0x3d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1e, 0x13,
  5797. 0x91, 0x4b, 0x7e, 0x4c, 0xfe, 0x0a, 0x55, 0x31, 0xfe, 0x8b, 0x55, 0xd9,
  5798. 0x4b, 0xda, 0x4c, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x05, 0x72, 0x01,
  5799. 0xfe, 0x8e, 0x1e, 0xca, 0xfe, 0x19, 0x41, 0x05, 0x72, 0x32, 0x01, 0x08,
  5800. 0x2a, 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbe, 0x2d, 0x1d, 0xc0, 0x2d, 0x0d,
  5801. 0x83, 0x2d, 0x7f, 0x1b, 0xfe, 0x66, 0x15, 0x05, 0x3d, 0x01, 0x08, 0x2a,
  5802. 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbd, 0x09, 0x1d, 0x2b, 0x3d, 0x01, 0x08,
  5803. 0x16, 0xc0, 0x27, 0x25, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x50, 0x03,
  5804. 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa1, 0xfe, 0xbb, 0x45,
  5805. 0x2d, 0x00, 0xa4, 0x46, 0x07, 0x90, 0x3f, 0x01, 0xfe, 0xf8, 0x15, 0x01,
  5806. 0xa6, 0x86, 0xfe, 0x4b, 0x45, 0xfe, 0x20, 0x13, 0x01, 0x43, 0x09, 0x82,
  5807. 0xfe, 0x16, 0x13, 0x03, 0x9a, 0x1e, 0x5d, 0x03, 0x55, 0x1e, 0x31, 0x5e,
  5808. 0x05, 0x72, 0xfe, 0xc0, 0x5d, 0x01, 0xa7, 0xfe, 0x03, 0x17, 0x03, 0x66,
  5809. 0x8a, 0x10, 0x66, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01, 0xfe, 0x56,
  5810. 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d, 0x27, 0x25, 0xbd,
  5811. 0x09, 0x07, 0x2b, 0x3d, 0x01, 0xfe, 0xbe, 0x16, 0xfe, 0x42, 0x58, 0xfe,
  5812. 0xe8, 0x14, 0x01, 0xa6, 0x86, 0xfe, 0x4a, 0xf4, 0x0d, 0x1b, 0x3d, 0xfe,
  5813. 0x4a, 0xf4, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05,
  5814. 0x72, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73,
  5815. 0x01, 0xfe, 0x84, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d,
  5816. 0x27, 0x25, 0xbd, 0x09, 0x12, 0x2b, 0x3d, 0x01, 0xfe, 0xe8, 0x17, 0x8b,
  5817. 0xfe, 0xaa, 0x14, 0xfe, 0xb6, 0x14, 0x86, 0xa8, 0xb2, 0x0d, 0x1b, 0x3d,
  5818. 0xb2, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05, 0x72,
  5819. 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01,
  5820. 0xfe, 0xc0, 0x19, 0x05, 0x73, 0x13, 0x07, 0x2f, 0xfe, 0xcc, 0x15, 0x17,
  5821. 0xfe, 0xe2, 0x15, 0x5f, 0xcc, 0x01, 0x08, 0x26, 0x5f, 0x02, 0x8f, 0xfe,
  5822. 0xde, 0x15, 0x2a, 0xfe, 0xde, 0x15, 0x16, 0xfe, 0xcc, 0x15, 0x5e, 0x32,
  5823. 0x01, 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
  5824. 0xad, 0x23, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02,
  5825. 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0x23, 0x3f, 0xfe, 0x30,
  5826. 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
  5827. 0xad, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xfe, 0x00, 0x5e,
  5828. 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0xfe, 0x0b, 0x58,
  5829. 0x02, 0x0a, 0x66, 0x01, 0x5c, 0x0a, 0x55, 0x01, 0x5c, 0x0a, 0x6f, 0x01,
  5830. 0x5c, 0x02, 0x01, 0xfe, 0x1e, 0x1f, 0x23, 0x1a, 0xff, 0x03, 0x00, 0x54,
  5831. 0xfe, 0x00, 0xf4, 0x24, 0x52, 0x0f, 0xfe, 0x00, 0x7c, 0x04, 0xfe, 0x07,
  5832. 0x7c, 0x3a, 0x0b, 0x0e, 0xfe, 0x00, 0x71, 0xfe, 0xf9, 0x18, 0xfe, 0x7a,
  5833. 0x19, 0xfe, 0xfb, 0x19, 0xfe, 0x1a, 0xf7, 0x00, 0xfe, 0x1b, 0xf7, 0x00,
  5834. 0x7a, 0x30, 0x10, 0x68, 0x22, 0x69, 0xd9, 0x6c, 0xda, 0x6d, 0x02, 0xfe,
  5835. 0x62, 0x08, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x77,
  5836. 0x02, 0x01, 0xc6, 0xfe, 0x42, 0x48, 0x4f, 0x50, 0x45, 0x01, 0x08, 0x16,
  5837. 0xfe, 0xe0, 0x17, 0x27, 0x25, 0xbe, 0x01, 0x08, 0x16, 0xfe, 0xe0, 0x17,
  5838. 0x27, 0x25, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0x9a, 0x1e, 0xfe,
  5839. 0xda, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfe, 0xd0, 0x13, 0x26, 0x53, 0x12,
  5840. 0x48, 0xfe, 0x08, 0x17, 0xd1, 0x12, 0x53, 0x12, 0xfe, 0x1e, 0x13, 0x2d,
  5841. 0xb4, 0x7b, 0xfe, 0x26, 0x17, 0x4d, 0x13, 0x07, 0x1c, 0xb4, 0x90, 0x04,
  5842. 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xf1, 0xff, 0x02, 0x83, 0x55,
  5843. 0x53, 0x1d, 0xfe, 0x12, 0x13, 0xd6, 0xfe, 0x30, 0x00, 0xb0, 0xfe, 0x80,
  5844. 0x17, 0x1c, 0x63, 0x13, 0x07, 0xfe, 0x56, 0x10, 0x53, 0x0d, 0xfe, 0x16,
  5845. 0x13, 0xd6, 0xfe, 0x64, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0x64,
  5846. 0x00, 0x1c, 0x94, 0x13, 0x07, 0xfe, 0x28, 0x10, 0x53, 0x07, 0xfe, 0x60,
  5847. 0x13, 0xd6, 0xfe, 0xc8, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0xc8,
  5848. 0x00, 0x1c, 0x95, 0x13, 0x07, 0x71, 0xd6, 0xfe, 0x90, 0x01, 0x48, 0xfe,
  5849. 0x8c, 0x17, 0x45, 0xf3, 0xfe, 0x43, 0xf4, 0x96, 0xfe, 0x56, 0xf0, 0xfe,
  5850. 0x9e, 0x17, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x43, 0xf4, 0x94, 0xf6, 0x8b,
  5851. 0x01, 0xfe, 0x24, 0x16, 0x23, 0x3f, 0xfc, 0xa8, 0x8c, 0x49, 0x48, 0xfe,
  5852. 0xda, 0x17, 0x62, 0x49, 0xfe, 0x1c, 0x10, 0xa8, 0x8c, 0x80, 0x48, 0xfe,
  5853. 0xda, 0x17, 0x62, 0x80, 0x71, 0x50, 0x26, 0xfe, 0x4d, 0xf4, 0x00, 0xf7,
  5854. 0x45, 0x13, 0x07, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58, 0x02, 0x50, 0x13,
  5855. 0x0d, 0x02, 0x50, 0x3e, 0x78, 0x4f, 0x45, 0x01, 0x08, 0x16, 0xa9, 0x27,
  5856. 0x25, 0xbe, 0xfe, 0x03, 0xea, 0xfe, 0x7e, 0x01, 0x01, 0x08, 0x16, 0xa9,
  5857. 0x27, 0x25, 0xfe, 0xe9, 0x0a, 0x01, 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe,
  5858. 0xe9, 0x0a, 0xfe, 0x05, 0xea, 0xfe, 0x7f, 0x01, 0x01, 0x08, 0x16, 0xa9,
  5859. 0x27, 0x25, 0xfe, 0x69, 0x09, 0xfe, 0x02, 0xea, 0xfe, 0x80, 0x01, 0x01,
  5860. 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe, 0xe8, 0x08, 0x47, 0xfe, 0x81, 0x01,
  5861. 0x03, 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 0x31, 0xa2, 0x78, 0xf2,
  5862. 0x53, 0x07, 0x36, 0xfe, 0x34, 0xf4, 0x3f, 0xa1, 0x78, 0x03, 0x9a, 0x1e,
  5863. 0x83, 0x01, 0x38, 0x06, 0x12, 0x31, 0xf0, 0x4f, 0x45, 0xfe, 0x90, 0x10,
  5864. 0xfe, 0x40, 0x5a, 0x23, 0x3f, 0xfb, 0x8c, 0x49, 0x48, 0xfe, 0xaa, 0x18,
  5865. 0x62, 0x49, 0x71, 0x8c, 0x80, 0x48, 0xfe, 0xaa, 0x18, 0x62, 0x80, 0xfe,
  5866. 0xb4, 0x56, 0xfe, 0x40, 0x5d, 0x01, 0xc6, 0x01, 0xfe, 0xac, 0x1d, 0xfe,
  5867. 0x02, 0x17, 0xfe, 0xc8, 0x45, 0xfe, 0x5a, 0xf0, 0xfe, 0xc0, 0x18, 0xfe,
  5868. 0x43, 0x48, 0x2d, 0x93, 0x36, 0xfe, 0x34, 0xf4, 0xfe, 0x00, 0x11, 0xfe,
  5869. 0x40, 0x10, 0x2d, 0xb4, 0x36, 0xfe, 0x34, 0xf4, 0x04, 0xfe, 0x34, 0x10,
  5870. 0x2d, 0xfe, 0x0b, 0x00, 0x36, 0x46, 0x63, 0xfe, 0x28, 0x10, 0xfe, 0xc0,
  5871. 0x49, 0xff, 0x02, 0x00, 0x54, 0xb2, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0xfa,
  5872. 0x18, 0x45, 0xfe, 0x1c, 0xf4, 0x3f, 0xf3, 0xfe, 0x40, 0xf4, 0x96, 0xfe,
  5873. 0x56, 0xf0, 0xfe, 0x0c, 0x19, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x40, 0xf4,
  5874. 0x94, 0xf6, 0x3e, 0x2d, 0x93, 0x4e, 0xd0, 0x0d, 0x21, 0xfe, 0x7f, 0x01,
  5875. 0xfe, 0xc8, 0x46, 0xfe, 0x24, 0x13, 0x8c, 0x00, 0x5d, 0x26, 0x21, 0xfe,
  5876. 0x7e, 0x01, 0xfe, 0xc8, 0x45, 0xfe, 0x14, 0x13, 0x21, 0xfe, 0x80, 0x01,
  5877. 0xfe, 0x48, 0x45, 0xfa, 0x21, 0xfe, 0x81, 0x01, 0xfe, 0xc8, 0x44, 0x4e,
  5878. 0x26, 0x02, 0x13, 0x07, 0x02, 0x78, 0x45, 0x50, 0x13, 0x0d, 0x02, 0x14,
  5879. 0x07, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x14, 0x0d, 0x01, 0x08, 0x17,
  5880. 0xfe, 0x82, 0x19, 0x14, 0x1d, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x5f,
  5881. 0xfe, 0x89, 0x49, 0x01, 0x08, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
  5882. 0x14, 0x1d, 0x01, 0x08, 0x17, 0xc1, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1,
  5883. 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0xc1, 0x5f, 0xfe, 0x89, 0x4a, 0x01,
  5884. 0x08, 0x02, 0x50, 0x02, 0x14, 0x07, 0x01, 0x08, 0x17, 0x74, 0x14, 0x7f,
  5885. 0x01, 0x08, 0x17, 0x74, 0x14, 0x12, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x89,
  5886. 0x49, 0x01, 0x08, 0x17, 0x74, 0x14, 0x00, 0x01, 0x08, 0x17, 0x74, 0xfe,
  5887. 0x89, 0x4a, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x09, 0x49, 0x01, 0x08, 0x17,
  5888. 0x74, 0x5f, 0xcc, 0x01, 0x08, 0x02, 0x21, 0xe4, 0x09, 0x07, 0xfe, 0x4c,
  5889. 0x13, 0xc8, 0x20, 0xe4, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x5f, 0xa1, 0x5e,
  5890. 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f,
  5891. 0xfe, 0x3e, 0x1a, 0x01, 0x43, 0x09, 0xfe, 0xe3, 0x00, 0xfe, 0x22, 0x13,
  5892. 0x16, 0xfe, 0x64, 0x1a, 0x26, 0x20, 0x9e, 0x01, 0x41, 0x21, 0x9e, 0x09,
  5893. 0x07, 0x5d, 0x01, 0x0c, 0x61, 0x07, 0x44, 0x02, 0x0a, 0x5a, 0x01, 0x18,
  5894. 0xfe, 0x00, 0x40, 0xaa, 0x09, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01,
  5895. 0x18, 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x9d, 0x01, 0x18, 0xaa,
  5896. 0xfe, 0x80, 0xe7, 0x1a, 0x09, 0x1a, 0x5d, 0xfe, 0x45, 0x58, 0x01, 0xfe,
  5897. 0xb2, 0x16, 0xaa, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0xaa, 0x0a, 0x67, 0x01,
  5898. 0xa3, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x01, 0xfe, 0x7e, 0x1e, 0xfe, 0x80,
  5899. 0x4c, 0xfe, 0x49, 0xe4, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01, 0x18,
  5900. 0xfe, 0x80, 0x4c, 0x0a, 0x67, 0x01, 0x5c, 0x02, 0x1c, 0x1a, 0x87, 0x7c,
  5901. 0xe5, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24, 0x1c, 0xfe, 0x1d,
  5902. 0xf7, 0x28, 0xb1, 0xfe, 0x04, 0x1b, 0x01, 0xfe, 0x2a, 0x1c, 0xfa, 0xb3,
  5903. 0x28, 0x7c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x02, 0xc9, 0x2b, 0xfe,
  5904. 0xf4, 0x1a, 0xfe, 0xfa, 0x10, 0x1c, 0x1a, 0x87, 0x03, 0xfe, 0x64, 0x01,
  5905. 0xfe, 0x00, 0xf4, 0x24, 0xfe, 0x18, 0x58, 0x03, 0xfe, 0x66, 0x01, 0xfe,
  5906. 0x19, 0x58, 0xb3, 0x24, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4, 0x07,
  5907. 0xfe, 0x3c, 0x50, 0x7c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c,
  5908. 0xf7, 0x24, 0xb1, 0xfe, 0x50, 0x1b, 0xfe, 0xd4, 0x14, 0x31, 0x02, 0xc9,
  5909. 0x2b, 0xfe, 0x26, 0x1b, 0xfe, 0xba, 0x10, 0x1c, 0x1a, 0x87, 0xfe, 0x83,
  5910. 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x54, 0xb1,
  5911. 0xfe, 0x72, 0x1b, 0xfe, 0xb2, 0x14, 0xfc, 0xb3, 0x54, 0x7c, 0x12, 0xfe,
  5912. 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 0x02, 0xc9, 0x2b, 0xfe, 0x66, 0x1b,
  5913. 0xfe, 0x8a, 0x10, 0x1c, 0x1a, 0x87, 0x8b, 0x0f, 0xfe, 0x30, 0x90, 0x04,
  5914. 0xfe, 0xb0, 0x93, 0x3a, 0x0b, 0xfe, 0x18, 0x58, 0xfe, 0x32, 0x90, 0x04,
  5915. 0xfe, 0xb2, 0x93, 0x3a, 0x0b, 0xfe, 0x19, 0x58, 0x0e, 0xa8, 0xb3, 0x4a,
  5916. 0x7c, 0x12, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x4a, 0xb1, 0xfe, 0xc6,
  5917. 0x1b, 0xfe, 0x5e, 0x14, 0x31, 0x02, 0xc9, 0x2b, 0xfe, 0x96, 0x1b, 0x5c,
  5918. 0xfe, 0x02, 0xf6, 0x1a, 0x87, 0xfe, 0x18, 0xfe, 0x6a, 0xfe, 0x19, 0xfe,
  5919. 0x6b, 0x01, 0xfe, 0x1e, 0x1f, 0xfe, 0x1d, 0xf7, 0x65, 0xb1, 0xfe, 0xee,
  5920. 0x1b, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13, 0xb3, 0x65, 0x3e, 0xfe, 0x83,
  5921. 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x1a, 0xfe, 0x81, 0xe7, 0x1a,
  5922. 0x15, 0xfe, 0xdd, 0x00, 0x7a, 0x30, 0x02, 0x7a, 0x30, 0xfe, 0x12, 0x45,
  5923. 0x2b, 0xfe, 0xdc, 0x1b, 0x1f, 0x07, 0x47, 0xb5, 0xc3, 0x05, 0x35, 0xfe,
  5924. 0x39, 0xf0, 0x75, 0x26, 0x02, 0xfe, 0x7e, 0x18, 0x23, 0x1d, 0x36, 0x13,
  5925. 0x11, 0x02, 0x87, 0x03, 0xe3, 0x23, 0x07, 0xfe, 0xef, 0x12, 0xfe, 0xe1,
  5926. 0x10, 0x90, 0x34, 0x60, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x3c, 0x13,
  5927. 0xfe, 0x82, 0x14, 0xfe, 0x42, 0x13, 0x51, 0xfe, 0x06, 0x83, 0x0a, 0x5a,
  5928. 0x01, 0x18, 0xcb, 0xfe, 0x3e, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48,
  5929. 0x01, 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f,
  5930. 0x89, 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x4c, 0x01,
  5931. 0x85, 0xfe, 0x16, 0x10, 0x09, 0x9b, 0x4e, 0xfe, 0x40, 0x14, 0xfe, 0x24,
  5932. 0x12, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x52, 0x1c, 0x1c, 0x0d,
  5933. 0x02, 0xfe, 0x9c, 0xe7, 0x0d, 0x19, 0xfe, 0x15, 0x00, 0x40, 0x8d, 0x30,
  5934. 0x01, 0xf4, 0x1c, 0x07, 0x02, 0x51, 0xfe, 0x06, 0x83, 0xfe, 0x18, 0x80,
  5935. 0x61, 0x28, 0x44, 0x15, 0x56, 0x01, 0x85, 0x1c, 0x07, 0x02, 0xfe, 0x38,
  5936. 0x90, 0xfe, 0xba, 0x90, 0x91, 0xde, 0x7e, 0xdf, 0xfe, 0x48, 0x55, 0x31,
  5937. 0xfe, 0xc9, 0x55, 0x02, 0x21, 0xb9, 0x88, 0x20, 0xb9, 0x02, 0x0a, 0xba,
  5938. 0x01, 0x18, 0xfe, 0x41, 0x48, 0x0a, 0x57, 0x01, 0x18, 0xfe, 0x49, 0x44,
  5939. 0x1b, 0xfe, 0x1e, 0x1d, 0x88, 0x89, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x09,
  5940. 0x1a, 0xa4, 0x0a, 0x67, 0x01, 0xa3, 0x0a, 0x57, 0x01, 0x18, 0x88, 0x89,
  5941. 0x02, 0xfe, 0x4e, 0xe4, 0x1d, 0x7b, 0xfe, 0x52, 0x1d, 0x03, 0xfe, 0x90,
  5942. 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe, 0x4e, 0xe4, 0xdd, 0x7b,
  5943. 0xfe, 0x64, 0x1d, 0x03, 0xfe, 0x92, 0x00, 0xd1, 0x12, 0xfe, 0x1a, 0x10,
  5944. 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x7b, 0xfe, 0x76, 0x1d, 0x03, 0xfe,
  5945. 0x94, 0x00, 0xd1, 0x24, 0xfe, 0x08, 0x10, 0x03, 0xfe, 0x96, 0x00, 0xd1,
  5946. 0x63, 0xfe, 0x4e, 0x45, 0x83, 0xca, 0xff, 0x04, 0x68, 0x54, 0xfe, 0xf1,
  5947. 0x10, 0x23, 0x49, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c,
  5948. 0xfe, 0x1a, 0xf4, 0xfe, 0x00, 0x04, 0x83, 0xb2, 0x1d, 0x48, 0xfe, 0xaa,
  5949. 0x1d, 0x13, 0x1d, 0x02, 0x09, 0x92, 0xfe, 0x5a, 0xf0, 0xfe, 0xba, 0x1d,
  5950. 0x2e, 0x93, 0xfe, 0x34, 0x10, 0x09, 0x12, 0xfe, 0x5a, 0xf0, 0xfe, 0xc8,
  5951. 0x1d, 0x2e, 0xb4, 0xfe, 0x26, 0x10, 0x09, 0x1d, 0x36, 0x2e, 0x63, 0xfe,
  5952. 0x1a, 0x10, 0x09, 0x0d, 0x36, 0x2e, 0x94, 0xf2, 0x09, 0x07, 0x36, 0x2e,
  5953. 0x95, 0xa1, 0xc8, 0x02, 0x1f, 0x93, 0x01, 0x42, 0xfe, 0x04, 0xfe, 0x99,
  5954. 0x03, 0x9c, 0x8b, 0x02, 0x2a, 0xfe, 0x1c, 0x1e, 0xfe, 0x14, 0xf0, 0x08,
  5955. 0x2f, 0xfe, 0x0c, 0x1e, 0x2a, 0xfe, 0x1c, 0x1e, 0x8f, 0xfe, 0x1c, 0x1e,
  5956. 0xfe, 0x82, 0xf0, 0xfe, 0x10, 0x1e, 0x02, 0x0f, 0x3f, 0x04, 0xfe, 0x80,
  5957. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x18, 0x80, 0x04, 0xfe, 0x98,
  5958. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x02, 0x80, 0x04, 0xfe, 0x82,
  5959. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x80, 0x04, 0xfe, 0x86,
  5960. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x1b, 0x80, 0x04, 0xfe, 0x9b,
  5961. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x04, 0x80, 0x04, 0xfe, 0x84,
  5962. 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x80, 0x80, 0x04, 0xfe, 0x80,
  5963. 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x19, 0x81, 0x04,
  5964. 0xfe, 0x99, 0x83, 0xfe, 0xca, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06,
  5965. 0x83, 0x04, 0xfe, 0x86, 0x83, 0xfe, 0xce, 0x47, 0x0b, 0x0e, 0x02, 0x0f,
  5966. 0xfe, 0x2c, 0x90, 0x04, 0xfe, 0xac, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  5967. 0xfe, 0xae, 0x90, 0x04, 0xfe, 0xae, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  5968. 0xfe, 0x08, 0x90, 0x04, 0xfe, 0x88, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  5969. 0xfe, 0x8a, 0x90, 0x04, 0xfe, 0x8a, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  5970. 0xfe, 0x0c, 0x90, 0x04, 0xfe, 0x8c, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f,
  5971. 0xfe, 0x8e, 0x90, 0x04, 0xfe, 0x8e, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
  5972. 0xfe, 0x3c, 0x90, 0x04, 0xfe, 0xbc, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x8b,
  5973. 0x0f, 0xfe, 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x77, 0x0e,
  5974. 0xa8, 0x02, 0xff, 0x66, 0x00, 0x00,
  5975. };
  5976. static unsigned short _adv_asc38C1600_size = sizeof(_adv_asc38C1600_buf); /* 0x1673 */
  5977. static ADV_DCNT _adv_asc38C1600_chksum = 0x0604EF77UL; /* Expanded little-endian checksum. */
  5978. static void AscInitQLinkVar(ASC_DVC_VAR *asc_dvc)
  5979. {
  5980. PortAddr iop_base;
  5981. int i;
  5982. ushort lram_addr;
  5983. iop_base = asc_dvc->iop_base;
  5984. AscPutRiscVarFreeQHead(iop_base, 1);
  5985. AscPutRiscVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  5986. AscPutVarFreeQHead(iop_base, 1);
  5987. AscPutVarDoneQTail(iop_base, asc_dvc->max_total_qng);
  5988. AscWriteLramByte(iop_base, ASCV_BUSY_QHEAD_B,
  5989. (uchar)((int)asc_dvc->max_total_qng + 1));
  5990. AscWriteLramByte(iop_base, ASCV_DISC1_QHEAD_B,
  5991. (uchar)((int)asc_dvc->max_total_qng + 2));
  5992. AscWriteLramByte(iop_base, (ushort)ASCV_TOTAL_READY_Q_B,
  5993. asc_dvc->max_total_qng);
  5994. AscWriteLramWord(iop_base, ASCV_ASCDVC_ERR_CODE_W, 0);
  5995. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  5996. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, 0);
  5997. AscWriteLramByte(iop_base, ASCV_SCSIBUSY_B, 0);
  5998. AscWriteLramByte(iop_base, ASCV_WTM_FLAG_B, 0);
  5999. AscPutQDoneInProgress(iop_base, 0);
  6000. lram_addr = ASC_QADR_BEG;
  6001. for (i = 0; i < 32; i++, lram_addr += 2) {
  6002. AscWriteLramWord(iop_base, lram_addr, 0);
  6003. }
  6004. }
  6005. static ushort AscInitMicroCodeVar(ASC_DVC_VAR *asc_dvc)
  6006. {
  6007. int i;
  6008. ushort warn_code;
  6009. PortAddr iop_base;
  6010. ASC_PADDR phy_addr;
  6011. ASC_DCNT phy_size;
  6012. iop_base = asc_dvc->iop_base;
  6013. warn_code = 0;
  6014. for (i = 0; i <= ASC_MAX_TID; i++) {
  6015. AscPutMCodeInitSDTRAtID(iop_base, i,
  6016. asc_dvc->cfg->sdtr_period_offset[i]);
  6017. }
  6018. AscInitQLinkVar(asc_dvc);
  6019. AscWriteLramByte(iop_base, ASCV_DISC_ENABLE_B,
  6020. asc_dvc->cfg->disc_enable);
  6021. AscWriteLramByte(iop_base, ASCV_HOSTSCSI_ID_B,
  6022. ASC_TID_TO_TARGET_ID(asc_dvc->cfg->chip_scsi_id));
  6023. /* Align overrun buffer on an 8 byte boundary. */
  6024. phy_addr = virt_to_bus(asc_dvc->cfg->overrun_buf);
  6025. phy_addr = cpu_to_le32((phy_addr + 7) & ~0x7);
  6026. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_PADDR_D,
  6027. (uchar *)&phy_addr, 1);
  6028. phy_size = cpu_to_le32(ASC_OVERRUN_BSIZE - 8);
  6029. AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_BSIZE_D,
  6030. (uchar *)&phy_size, 1);
  6031. asc_dvc->cfg->mcode_date =
  6032. AscReadLramWord(iop_base, (ushort)ASCV_MC_DATE_W);
  6033. asc_dvc->cfg->mcode_version =
  6034. AscReadLramWord(iop_base, (ushort)ASCV_MC_VER_W);
  6035. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  6036. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  6037. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  6038. return warn_code;
  6039. }
  6040. if (AscStartChip(iop_base) != 1) {
  6041. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  6042. return warn_code;
  6043. }
  6044. return warn_code;
  6045. }
  6046. static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
  6047. {
  6048. ushort warn_code;
  6049. PortAddr iop_base;
  6050. iop_base = asc_dvc->iop_base;
  6051. warn_code = 0;
  6052. if ((asc_dvc->dvc_cntl & ASC_CNTL_RESET_SCSI) &&
  6053. !(asc_dvc->init_state & ASC_INIT_RESET_SCSI_DONE)) {
  6054. AscResetChipAndScsiBus(asc_dvc);
  6055. mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
  6056. }
  6057. asc_dvc->init_state |= ASC_INIT_STATE_BEG_LOAD_MC;
  6058. if (asc_dvc->err_code != 0)
  6059. return UW_ERR;
  6060. if (!AscFindSignature(asc_dvc->iop_base)) {
  6061. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  6062. return warn_code;
  6063. }
  6064. AscDisableInterrupt(iop_base);
  6065. warn_code |= AscInitLram(asc_dvc);
  6066. if (asc_dvc->err_code != 0)
  6067. return UW_ERR;
  6068. ASC_DBG1(1, "AscInitAsc1000Driver: _asc_mcode_chksum 0x%lx\n",
  6069. (ulong)_asc_mcode_chksum);
  6070. if (AscLoadMicroCode(iop_base, 0, _asc_mcode_buf,
  6071. _asc_mcode_size) != _asc_mcode_chksum) {
  6072. asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
  6073. return warn_code;
  6074. }
  6075. warn_code |= AscInitMicroCodeVar(asc_dvc);
  6076. asc_dvc->init_state |= ASC_INIT_STATE_END_LOAD_MC;
  6077. AscEnableInterrupt(iop_base);
  6078. return warn_code;
  6079. }
  6080. /*
  6081. * Load the Microcode
  6082. *
  6083. * Write the microcode image to RISC memory starting at address 0.
  6084. *
  6085. * The microcode is stored compressed in the following format:
  6086. *
  6087. * 254 word (508 byte) table indexed by byte code followed
  6088. * by the following byte codes:
  6089. *
  6090. * 1-Byte Code:
  6091. * 00: Emit word 0 in table.
  6092. * 01: Emit word 1 in table.
  6093. * .
  6094. * FD: Emit word 253 in table.
  6095. *
  6096. * Multi-Byte Code:
  6097. * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
  6098. * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
  6099. *
  6100. * Returns 0 or an error if the checksum doesn't match
  6101. */
  6102. static int AdvLoadMicrocode(AdvPortAddr iop_base, unsigned char *buf, int size,
  6103. int memsize, int chksum)
  6104. {
  6105. int i, j, end, len = 0;
  6106. ADV_DCNT sum;
  6107. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  6108. for (i = 253 * 2; i < size; i++) {
  6109. if (buf[i] == 0xff) {
  6110. unsigned short word = (buf[i + 3] << 8) | buf[i + 2];
  6111. for (j = 0; j < buf[i + 1]; j++) {
  6112. AdvWriteWordAutoIncLram(iop_base, word);
  6113. len += 2;
  6114. }
  6115. i += 3;
  6116. } else if (buf[i] == 0xfe) {
  6117. unsigned short word = (buf[i + 2] << 8) | buf[i + 1];
  6118. AdvWriteWordAutoIncLram(iop_base, word);
  6119. i += 2;
  6120. len += 2;
  6121. } else {
  6122. unsigned char off = buf[i] * 2;
  6123. unsigned short word = (buf[off + 1] << 8) | buf[off];
  6124. AdvWriteWordAutoIncLram(iop_base, word);
  6125. len += 2;
  6126. }
  6127. }
  6128. end = len;
  6129. while (len < memsize) {
  6130. AdvWriteWordAutoIncLram(iop_base, 0);
  6131. len += 2;
  6132. }
  6133. /* Verify the microcode checksum. */
  6134. sum = 0;
  6135. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
  6136. for (len = 0; len < end; len += 2) {
  6137. sum += AdvReadWordAutoIncLram(iop_base);
  6138. }
  6139. if (sum != chksum)
  6140. return ASC_IERR_MCODE_CHKSUM;
  6141. return 0;
  6142. }
  6143. /*
  6144. * DvcGetPhyAddr()
  6145. *
  6146. * Return the physical address of 'vaddr' and set '*lenp' to the
  6147. * number of physically contiguous bytes that follow 'vaddr'.
  6148. * 'flag' indicates the type of structure whose physical address
  6149. * is being translated.
  6150. *
  6151. * Note: Because Linux currently doesn't page the kernel and all
  6152. * kernel buffers are physically contiguous, leave '*lenp' unchanged.
  6153. */
  6154. ADV_PADDR
  6155. DvcGetPhyAddr(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq,
  6156. uchar *vaddr, ADV_SDCNT *lenp, int flag)
  6157. {
  6158. ADV_PADDR paddr = virt_to_bus(vaddr);
  6159. ASC_DBG4(4, "DvcGetPhyAddr: vaddr 0x%p, lenp 0x%p *lenp %lu, paddr 0x%lx\n",
  6160. vaddr, lenp, (ulong)*((ulong *)lenp), (ulong)paddr);
  6161. return paddr;
  6162. }
  6163. static void AdvBuildCarrierFreelist(struct adv_dvc_var *asc_dvc)
  6164. {
  6165. ADV_CARR_T *carrp;
  6166. ADV_SDCNT buf_size;
  6167. ADV_PADDR carr_paddr;
  6168. BUG_ON(!asc_dvc->carrier_buf);
  6169. carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
  6170. asc_dvc->carr_freelist = NULL;
  6171. if (carrp == asc_dvc->carrier_buf) {
  6172. buf_size = ADV_CARRIER_BUFSIZE;
  6173. } else {
  6174. buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
  6175. }
  6176. do {
  6177. /* Get physical address of the carrier 'carrp'. */
  6178. ADV_DCNT contig_len = sizeof(ADV_CARR_T);
  6179. carr_paddr = cpu_to_le32(DvcGetPhyAddr(asc_dvc, NULL,
  6180. (uchar *)carrp,
  6181. (ADV_SDCNT *)&contig_len,
  6182. ADV_IS_CARRIER_FLAG));
  6183. buf_size -= sizeof(ADV_CARR_T);
  6184. /*
  6185. * If the current carrier is not physically contiguous, then
  6186. * maybe there was a page crossing. Try the next carrier
  6187. * aligned start address.
  6188. */
  6189. if (contig_len < sizeof(ADV_CARR_T)) {
  6190. carrp++;
  6191. continue;
  6192. }
  6193. carrp->carr_pa = carr_paddr;
  6194. carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
  6195. /*
  6196. * Insert the carrier at the beginning of the freelist.
  6197. */
  6198. carrp->next_vpa =
  6199. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  6200. asc_dvc->carr_freelist = carrp;
  6201. carrp++;
  6202. } while (buf_size > 0);
  6203. }
  6204. /*
  6205. * Send an idle command to the chip and wait for completion.
  6206. *
  6207. * Command completion is polled for once per microsecond.
  6208. *
  6209. * The function can be called from anywhere including an interrupt handler.
  6210. * But the function is not re-entrant, so it uses the DvcEnter/LeaveCritical()
  6211. * functions to prevent reentrancy.
  6212. *
  6213. * Return Values:
  6214. * ADV_TRUE - command completed successfully
  6215. * ADV_FALSE - command failed
  6216. * ADV_ERROR - command timed out
  6217. */
  6218. static int
  6219. AdvSendIdleCmd(ADV_DVC_VAR *asc_dvc,
  6220. ushort idle_cmd, ADV_DCNT idle_cmd_parameter)
  6221. {
  6222. int result;
  6223. ADV_DCNT i, j;
  6224. AdvPortAddr iop_base;
  6225. iop_base = asc_dvc->iop_base;
  6226. /*
  6227. * Clear the idle command status which is set by the microcode
  6228. * to a non-zero value to indicate when the command is completed.
  6229. * The non-zero result is one of the IDLE_CMD_STATUS_* values
  6230. */
  6231. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS, (ushort)0);
  6232. /*
  6233. * Write the idle command value after the idle command parameter
  6234. * has been written to avoid a race condition. If the order is not
  6235. * followed, the microcode may process the idle command before the
  6236. * parameters have been written to LRAM.
  6237. */
  6238. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IDLE_CMD_PARAMETER,
  6239. cpu_to_le32(idle_cmd_parameter));
  6240. AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD, idle_cmd);
  6241. /*
  6242. * Tickle the RISC to tell it to process the idle command.
  6243. */
  6244. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_B);
  6245. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  6246. /*
  6247. * Clear the tickle value. In the ASC-3550 the RISC flag
  6248. * command 'clr_tickle_b' does not work unless the host
  6249. * value is cleared.
  6250. */
  6251. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
  6252. }
  6253. /* Wait for up to 100 millisecond for the idle command to timeout. */
  6254. for (i = 0; i < SCSI_WAIT_100_MSEC; i++) {
  6255. /* Poll once each microsecond for command completion. */
  6256. for (j = 0; j < SCSI_US_PER_MSEC; j++) {
  6257. AdvReadWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS,
  6258. result);
  6259. if (result != 0)
  6260. return result;
  6261. udelay(1);
  6262. }
  6263. }
  6264. BUG(); /* The idle command should never timeout. */
  6265. return ADV_ERROR;
  6266. }
  6267. /*
  6268. * Reset SCSI Bus and purge all outstanding requests.
  6269. *
  6270. * Return Value:
  6271. * ADV_TRUE(1) - All requests are purged and SCSI Bus is reset.
  6272. * ADV_FALSE(0) - Microcode command failed.
  6273. * ADV_ERROR(-1) - Microcode command timed-out. Microcode or IC
  6274. * may be hung which requires driver recovery.
  6275. */
  6276. static int AdvResetSB(ADV_DVC_VAR *asc_dvc)
  6277. {
  6278. int status;
  6279. /*
  6280. * Send the SCSI Bus Reset idle start idle command which asserts
  6281. * the SCSI Bus Reset signal.
  6282. */
  6283. status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_START, 0L);
  6284. if (status != ADV_TRUE) {
  6285. return status;
  6286. }
  6287. /*
  6288. * Delay for the specified SCSI Bus Reset hold time.
  6289. *
  6290. * The hold time delay is done on the host because the RISC has no
  6291. * microsecond accurate timer.
  6292. */
  6293. udelay(ASC_SCSI_RESET_HOLD_TIME_US);
  6294. /*
  6295. * Send the SCSI Bus Reset end idle command which de-asserts
  6296. * the SCSI Bus Reset signal and purges any pending requests.
  6297. */
  6298. status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_END, 0L);
  6299. if (status != ADV_TRUE) {
  6300. return status;
  6301. }
  6302. mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
  6303. return status;
  6304. }
  6305. /*
  6306. * Initialize the ASC-3550.
  6307. *
  6308. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  6309. *
  6310. * For a non-fatal error return a warning code. If there are no warnings
  6311. * then 0 is returned.
  6312. *
  6313. * Needed after initialization for error recovery.
  6314. */
  6315. static int AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
  6316. {
  6317. AdvPortAddr iop_base;
  6318. ushort warn_code;
  6319. int begin_addr;
  6320. int end_addr;
  6321. ushort code_sum;
  6322. int word;
  6323. int i;
  6324. ushort scsi_cfg1;
  6325. uchar tid;
  6326. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  6327. ushort wdtr_able = 0, sdtr_able, tagqng_able;
  6328. uchar max_cmd[ADV_MAX_TID + 1];
  6329. /* If there is already an error, don't continue. */
  6330. if (asc_dvc->err_code != 0)
  6331. return ADV_ERROR;
  6332. /*
  6333. * The caller must set 'chip_type' to ADV_CHIP_ASC3550.
  6334. */
  6335. if (asc_dvc->chip_type != ADV_CHIP_ASC3550) {
  6336. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  6337. return ADV_ERROR;
  6338. }
  6339. warn_code = 0;
  6340. iop_base = asc_dvc->iop_base;
  6341. /*
  6342. * Save the RISC memory BIOS region before writing the microcode.
  6343. * The BIOS may already be loaded and using its RISC LRAM region
  6344. * so its region must be saved and restored.
  6345. *
  6346. * Note: This code makes the assumption, which is currently true,
  6347. * that a chip reset does not clear RISC LRAM.
  6348. */
  6349. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6350. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6351. bios_mem[i]);
  6352. }
  6353. /*
  6354. * Save current per TID negotiated values.
  6355. */
  6356. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] == 0x55AA) {
  6357. ushort bios_version, major, minor;
  6358. bios_version =
  6359. bios_mem[(ASC_MC_BIOS_VERSION - ASC_MC_BIOSMEM) / 2];
  6360. major = (bios_version >> 12) & 0xF;
  6361. minor = (bios_version >> 8) & 0xF;
  6362. if (major < 3 || (major == 3 && minor == 1)) {
  6363. /* BIOS 3.1 and earlier location of 'wdtr_able' variable. */
  6364. AdvReadWordLram(iop_base, 0x120, wdtr_able);
  6365. } else {
  6366. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6367. }
  6368. }
  6369. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6370. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  6371. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6372. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6373. max_cmd[tid]);
  6374. }
  6375. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc3550_buf,
  6376. _adv_asc3550_size, ADV_3550_MEMSIZE,
  6377. _adv_asc3550_chksum);
  6378. if (asc_dvc->err_code)
  6379. return ADV_ERROR;
  6380. /*
  6381. * Restore the RISC memory BIOS region.
  6382. */
  6383. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6384. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6385. bios_mem[i]);
  6386. }
  6387. /*
  6388. * Calculate and write the microcode code checksum to the microcode
  6389. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  6390. */
  6391. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  6392. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  6393. code_sum = 0;
  6394. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  6395. for (word = begin_addr; word < end_addr; word += 2) {
  6396. code_sum += AdvReadWordAutoIncLram(iop_base);
  6397. }
  6398. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  6399. /*
  6400. * Read and save microcode version and date.
  6401. */
  6402. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  6403. asc_dvc->cfg->mcode_date);
  6404. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  6405. asc_dvc->cfg->mcode_version);
  6406. /*
  6407. * Set the chip type to indicate the ASC3550.
  6408. */
  6409. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC3550);
  6410. /*
  6411. * If the PCI Configuration Command Register "Parity Error Response
  6412. * Control" Bit was clear (0), then set the microcode variable
  6413. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  6414. * to ignore DMA parity errors.
  6415. */
  6416. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  6417. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6418. word |= CONTROL_FLAG_IGNORE_PERR;
  6419. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6420. }
  6421. /*
  6422. * For ASC-3550, setting the START_CTL_EMFU [3:2] bits sets a FIFO
  6423. * threshold of 128 bytes. This register is only accessible to the host.
  6424. */
  6425. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  6426. START_CTL_EMFU | READ_CMD_MRM);
  6427. /*
  6428. * Microcode operating variables for WDTR, SDTR, and command tag
  6429. * queuing will be set in slave_configure() based on what a
  6430. * device reports it is capable of in Inquiry byte 7.
  6431. *
  6432. * If SCSI Bus Resets have been disabled, then directly set
  6433. * SDTR and WDTR from the EEPROM configuration. This will allow
  6434. * the BIOS and warm boot to work without a SCSI bus hang on
  6435. * the Inquiry caused by host and target mismatched DTR values.
  6436. * Without the SCSI Bus Reset, before an Inquiry a device can't
  6437. * be assumed to be in Asynchronous, Narrow mode.
  6438. */
  6439. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  6440. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  6441. asc_dvc->wdtr_able);
  6442. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  6443. asc_dvc->sdtr_able);
  6444. }
  6445. /*
  6446. * Set microcode operating variables for SDTR_SPEED1, SDTR_SPEED2,
  6447. * SDTR_SPEED3, and SDTR_SPEED4 based on the ULTRA EEPROM per TID
  6448. * bitmask. These values determine the maximum SDTR speed negotiated
  6449. * with a device.
  6450. *
  6451. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  6452. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  6453. * without determining here whether the device supports SDTR.
  6454. *
  6455. * 4-bit speed SDTR speed name
  6456. * =========== ===============
  6457. * 0000b (0x0) SDTR disabled
  6458. * 0001b (0x1) 5 Mhz
  6459. * 0010b (0x2) 10 Mhz
  6460. * 0011b (0x3) 20 Mhz (Ultra)
  6461. * 0100b (0x4) 40 Mhz (LVD/Ultra2)
  6462. * 0101b (0x5) 80 Mhz (LVD2/Ultra3)
  6463. * 0110b (0x6) Undefined
  6464. * .
  6465. * 1111b (0xF) Undefined
  6466. */
  6467. word = 0;
  6468. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6469. if (ADV_TID_TO_TIDMASK(tid) & asc_dvc->ultra_able) {
  6470. /* Set Ultra speed for TID 'tid'. */
  6471. word |= (0x3 << (4 * (tid % 4)));
  6472. } else {
  6473. /* Set Fast speed for TID 'tid'. */
  6474. word |= (0x2 << (4 * (tid % 4)));
  6475. }
  6476. if (tid == 3) { /* Check if done with sdtr_speed1. */
  6477. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, word);
  6478. word = 0;
  6479. } else if (tid == 7) { /* Check if done with sdtr_speed2. */
  6480. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, word);
  6481. word = 0;
  6482. } else if (tid == 11) { /* Check if done with sdtr_speed3. */
  6483. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, word);
  6484. word = 0;
  6485. } else if (tid == 15) { /* Check if done with sdtr_speed4. */
  6486. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, word);
  6487. /* End of loop. */
  6488. }
  6489. }
  6490. /*
  6491. * Set microcode operating variable for the disconnect per TID bitmask.
  6492. */
  6493. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  6494. asc_dvc->cfg->disc_enable);
  6495. /*
  6496. * Set SCSI_CFG0 Microcode Default Value.
  6497. *
  6498. * The microcode will set the SCSI_CFG0 register using this value
  6499. * after it is started below.
  6500. */
  6501. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  6502. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  6503. asc_dvc->chip_scsi_id);
  6504. /*
  6505. * Determine SCSI_CFG1 Microcode Default Value.
  6506. *
  6507. * The microcode will set the SCSI_CFG1 register using this value
  6508. * after it is started below.
  6509. */
  6510. /* Read current SCSI_CFG1 Register value. */
  6511. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  6512. /*
  6513. * If all three connectors are in use, return an error.
  6514. */
  6515. if ((scsi_cfg1 & CABLE_ILLEGAL_A) == 0 ||
  6516. (scsi_cfg1 & CABLE_ILLEGAL_B) == 0) {
  6517. asc_dvc->err_code |= ASC_IERR_ILLEGAL_CONNECTION;
  6518. return ADV_ERROR;
  6519. }
  6520. /*
  6521. * If the internal narrow cable is reversed all of the SCSI_CTRL
  6522. * register signals will be set. Check for and return an error if
  6523. * this condition is found.
  6524. */
  6525. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  6526. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  6527. return ADV_ERROR;
  6528. }
  6529. /*
  6530. * If this is a differential board and a single-ended device
  6531. * is attached to one of the connectors, return an error.
  6532. */
  6533. if ((scsi_cfg1 & DIFF_MODE) && (scsi_cfg1 & DIFF_SENSE) == 0) {
  6534. asc_dvc->err_code |= ASC_IERR_SINGLE_END_DEVICE;
  6535. return ADV_ERROR;
  6536. }
  6537. /*
  6538. * If automatic termination control is enabled, then set the
  6539. * termination value based on a table listed in a_condor.h.
  6540. *
  6541. * If manual termination was specified with an EEPROM setting
  6542. * then 'termination' was set-up in AdvInitFrom3550EEPROM() and
  6543. * is ready to be 'ored' into SCSI_CFG1.
  6544. */
  6545. if (asc_dvc->cfg->termination == 0) {
  6546. /*
  6547. * The software always controls termination by setting TERM_CTL_SEL.
  6548. * If TERM_CTL_SEL were set to 0, the hardware would set termination.
  6549. */
  6550. asc_dvc->cfg->termination |= TERM_CTL_SEL;
  6551. switch (scsi_cfg1 & CABLE_DETECT) {
  6552. /* TERM_CTL_H: on, TERM_CTL_L: on */
  6553. case 0x3:
  6554. case 0x7:
  6555. case 0xB:
  6556. case 0xD:
  6557. case 0xE:
  6558. case 0xF:
  6559. asc_dvc->cfg->termination |= (TERM_CTL_H | TERM_CTL_L);
  6560. break;
  6561. /* TERM_CTL_H: on, TERM_CTL_L: off */
  6562. case 0x1:
  6563. case 0x5:
  6564. case 0x9:
  6565. case 0xA:
  6566. case 0xC:
  6567. asc_dvc->cfg->termination |= TERM_CTL_H;
  6568. break;
  6569. /* TERM_CTL_H: off, TERM_CTL_L: off */
  6570. case 0x2:
  6571. case 0x6:
  6572. break;
  6573. }
  6574. }
  6575. /*
  6576. * Clear any set TERM_CTL_H and TERM_CTL_L bits.
  6577. */
  6578. scsi_cfg1 &= ~TERM_CTL;
  6579. /*
  6580. * Invert the TERM_CTL_H and TERM_CTL_L bits and then
  6581. * set 'scsi_cfg1'. The TERM_POL bit does not need to be
  6582. * referenced, because the hardware internally inverts
  6583. * the Termination High and Low bits if TERM_POL is set.
  6584. */
  6585. scsi_cfg1 |= (TERM_CTL_SEL | (~asc_dvc->cfg->termination & TERM_CTL));
  6586. /*
  6587. * Set SCSI_CFG1 Microcode Default Value
  6588. *
  6589. * Set filter value and possibly modified termination control
  6590. * bits in the Microcode SCSI_CFG1 Register Value.
  6591. *
  6592. * The microcode will set the SCSI_CFG1 register using this value
  6593. * after it is started below.
  6594. */
  6595. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1,
  6596. FLTR_DISABLE | scsi_cfg1);
  6597. /*
  6598. * Set MEM_CFG Microcode Default Value
  6599. *
  6600. * The microcode will set the MEM_CFG register using this value
  6601. * after it is started below.
  6602. *
  6603. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  6604. * are defined.
  6605. *
  6606. * ASC-3550 has 8KB internal memory.
  6607. */
  6608. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  6609. BIOS_EN | RAM_SZ_8KB);
  6610. /*
  6611. * Set SEL_MASK Microcode Default Value
  6612. *
  6613. * The microcode will set the SEL_MASK register using this value
  6614. * after it is started below.
  6615. */
  6616. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  6617. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  6618. AdvBuildCarrierFreelist(asc_dvc);
  6619. /*
  6620. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  6621. */
  6622. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  6623. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  6624. return ADV_ERROR;
  6625. }
  6626. asc_dvc->carr_freelist = (ADV_CARR_T *)
  6627. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  6628. /*
  6629. * The first command issued will be placed in the stopper carrier.
  6630. */
  6631. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  6632. /*
  6633. * Set RISC ICQ physical address start value.
  6634. */
  6635. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  6636. /*
  6637. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  6638. */
  6639. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  6640. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  6641. return ADV_ERROR;
  6642. }
  6643. asc_dvc->carr_freelist = (ADV_CARR_T *)
  6644. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  6645. /*
  6646. * The first command completed by the RISC will be placed in
  6647. * the stopper.
  6648. *
  6649. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  6650. * completed the RISC will set the ASC_RQ_STOPPER bit.
  6651. */
  6652. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  6653. /*
  6654. * Set RISC IRQ physical address start value.
  6655. */
  6656. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  6657. asc_dvc->carr_pending_cnt = 0;
  6658. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  6659. (ADV_INTR_ENABLE_HOST_INTR |
  6660. ADV_INTR_ENABLE_GLOBAL_INTR));
  6661. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  6662. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  6663. /* finally, finally, gentlemen, start your engine */
  6664. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  6665. /*
  6666. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  6667. * Resets should be performed. The RISC has to be running
  6668. * to issue a SCSI Bus Reset.
  6669. */
  6670. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  6671. /*
  6672. * If the BIOS Signature is present in memory, restore the
  6673. * BIOS Handshake Configuration Table and do not perform
  6674. * a SCSI Bus Reset.
  6675. */
  6676. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  6677. 0x55AA) {
  6678. /*
  6679. * Restore per TID negotiated values.
  6680. */
  6681. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6682. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6683. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  6684. tagqng_able);
  6685. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6686. AdvWriteByteLram(iop_base,
  6687. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6688. max_cmd[tid]);
  6689. }
  6690. } else {
  6691. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  6692. warn_code = ASC_WARN_BUSRESET_ERROR;
  6693. }
  6694. }
  6695. }
  6696. return warn_code;
  6697. }
  6698. /*
  6699. * Initialize the ASC-38C0800.
  6700. *
  6701. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  6702. *
  6703. * For a non-fatal error return a warning code. If there are no warnings
  6704. * then 0 is returned.
  6705. *
  6706. * Needed after initialization for error recovery.
  6707. */
  6708. static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
  6709. {
  6710. AdvPortAddr iop_base;
  6711. ushort warn_code;
  6712. int begin_addr;
  6713. int end_addr;
  6714. ushort code_sum;
  6715. int word;
  6716. int i;
  6717. ushort scsi_cfg1;
  6718. uchar byte;
  6719. uchar tid;
  6720. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  6721. ushort wdtr_able, sdtr_able, tagqng_able;
  6722. uchar max_cmd[ADV_MAX_TID + 1];
  6723. /* If there is already an error, don't continue. */
  6724. if (asc_dvc->err_code != 0)
  6725. return ADV_ERROR;
  6726. /*
  6727. * The caller must set 'chip_type' to ADV_CHIP_ASC38C0800.
  6728. */
  6729. if (asc_dvc->chip_type != ADV_CHIP_ASC38C0800) {
  6730. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  6731. return ADV_ERROR;
  6732. }
  6733. warn_code = 0;
  6734. iop_base = asc_dvc->iop_base;
  6735. /*
  6736. * Save the RISC memory BIOS region before writing the microcode.
  6737. * The BIOS may already be loaded and using its RISC LRAM region
  6738. * so its region must be saved and restored.
  6739. *
  6740. * Note: This code makes the assumption, which is currently true,
  6741. * that a chip reset does not clear RISC LRAM.
  6742. */
  6743. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6744. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6745. bios_mem[i]);
  6746. }
  6747. /*
  6748. * Save current per TID negotiated values.
  6749. */
  6750. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  6751. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  6752. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  6753. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  6754. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  6755. max_cmd[tid]);
  6756. }
  6757. /*
  6758. * RAM BIST (RAM Built-In Self Test)
  6759. *
  6760. * Address : I/O base + offset 0x38h register (byte).
  6761. * Function: Bit 7-6(RW) : RAM mode
  6762. * Normal Mode : 0x00
  6763. * Pre-test Mode : 0x40
  6764. * RAM Test Mode : 0x80
  6765. * Bit 5 : unused
  6766. * Bit 4(RO) : Done bit
  6767. * Bit 3-0(RO) : Status
  6768. * Host Error : 0x08
  6769. * Int_RAM Error : 0x04
  6770. * RISC Error : 0x02
  6771. * SCSI Error : 0x01
  6772. * No Error : 0x00
  6773. *
  6774. * Note: RAM BIST code should be put right here, before loading the
  6775. * microcode and after saving the RISC memory BIOS region.
  6776. */
  6777. /*
  6778. * LRAM Pre-test
  6779. *
  6780. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  6781. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  6782. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  6783. * to NORMAL_MODE, return an error too.
  6784. */
  6785. for (i = 0; i < 2; i++) {
  6786. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  6787. mdelay(10); /* Wait for 10ms before reading back. */
  6788. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  6789. if ((byte & RAM_TEST_DONE) == 0
  6790. || (byte & 0x0F) != PRE_TEST_VALUE) {
  6791. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  6792. return ADV_ERROR;
  6793. }
  6794. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  6795. mdelay(10); /* Wait for 10ms before reading back. */
  6796. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  6797. != NORMAL_VALUE) {
  6798. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  6799. return ADV_ERROR;
  6800. }
  6801. }
  6802. /*
  6803. * LRAM Test - It takes about 1.5 ms to run through the test.
  6804. *
  6805. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  6806. * If Done bit not set or Status not 0, save register byte, set the
  6807. * err_code, and return an error.
  6808. */
  6809. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  6810. mdelay(10); /* Wait for 10ms before checking status. */
  6811. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  6812. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
  6813. /* Get here if Done bit not set or Status not 0. */
  6814. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  6815. asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
  6816. return ADV_ERROR;
  6817. }
  6818. /* We need to reset back to normal mode after LRAM test passes. */
  6819. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  6820. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C0800_buf,
  6821. _adv_asc38C0800_size, ADV_38C0800_MEMSIZE,
  6822. _adv_asc38C0800_chksum);
  6823. if (asc_dvc->err_code)
  6824. return ADV_ERROR;
  6825. /*
  6826. * Restore the RISC memory BIOS region.
  6827. */
  6828. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  6829. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  6830. bios_mem[i]);
  6831. }
  6832. /*
  6833. * Calculate and write the microcode code checksum to the microcode
  6834. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  6835. */
  6836. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  6837. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  6838. code_sum = 0;
  6839. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  6840. for (word = begin_addr; word < end_addr; word += 2) {
  6841. code_sum += AdvReadWordAutoIncLram(iop_base);
  6842. }
  6843. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  6844. /*
  6845. * Read microcode version and date.
  6846. */
  6847. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  6848. asc_dvc->cfg->mcode_date);
  6849. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  6850. asc_dvc->cfg->mcode_version);
  6851. /*
  6852. * Set the chip type to indicate the ASC38C0800.
  6853. */
  6854. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C0800);
  6855. /*
  6856. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  6857. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  6858. * cable detection and then we are able to read C_DET[3:0].
  6859. *
  6860. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  6861. * Microcode Default Value' section below.
  6862. */
  6863. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  6864. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
  6865. scsi_cfg1 | DIS_TERM_DRV);
  6866. /*
  6867. * If the PCI Configuration Command Register "Parity Error Response
  6868. * Control" Bit was clear (0), then set the microcode variable
  6869. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  6870. * to ignore DMA parity errors.
  6871. */
  6872. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  6873. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6874. word |= CONTROL_FLAG_IGNORE_PERR;
  6875. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  6876. }
  6877. /*
  6878. * For ASC-38C0800, set FIFO_THRESH_80B [6:4] bits and START_CTL_TH [3:2]
  6879. * bits for the default FIFO threshold.
  6880. *
  6881. * Note: ASC-38C0800 FIFO threshold has been changed to 256 bytes.
  6882. *
  6883. * For DMA Errata #4 set the BC_THRESH_ENB bit.
  6884. */
  6885. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  6886. BC_THRESH_ENB | FIFO_THRESH_80B | START_CTL_TH |
  6887. READ_CMD_MRM);
  6888. /*
  6889. * Microcode operating variables for WDTR, SDTR, and command tag
  6890. * queuing will be set in slave_configure() based on what a
  6891. * device reports it is capable of in Inquiry byte 7.
  6892. *
  6893. * If SCSI Bus Resets have been disabled, then directly set
  6894. * SDTR and WDTR from the EEPROM configuration. This will allow
  6895. * the BIOS and warm boot to work without a SCSI bus hang on
  6896. * the Inquiry caused by host and target mismatched DTR values.
  6897. * Without the SCSI Bus Reset, before an Inquiry a device can't
  6898. * be assumed to be in Asynchronous, Narrow mode.
  6899. */
  6900. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  6901. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  6902. asc_dvc->wdtr_able);
  6903. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  6904. asc_dvc->sdtr_able);
  6905. }
  6906. /*
  6907. * Set microcode operating variables for DISC and SDTR_SPEED1,
  6908. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  6909. * configuration values.
  6910. *
  6911. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  6912. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  6913. * without determining here whether the device supports SDTR.
  6914. */
  6915. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  6916. asc_dvc->cfg->disc_enable);
  6917. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  6918. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  6919. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  6920. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  6921. /*
  6922. * Set SCSI_CFG0 Microcode Default Value.
  6923. *
  6924. * The microcode will set the SCSI_CFG0 register using this value
  6925. * after it is started below.
  6926. */
  6927. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  6928. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  6929. asc_dvc->chip_scsi_id);
  6930. /*
  6931. * Determine SCSI_CFG1 Microcode Default Value.
  6932. *
  6933. * The microcode will set the SCSI_CFG1 register using this value
  6934. * after it is started below.
  6935. */
  6936. /* Read current SCSI_CFG1 Register value. */
  6937. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  6938. /*
  6939. * If the internal narrow cable is reversed all of the SCSI_CTRL
  6940. * register signals will be set. Check for and return an error if
  6941. * this condition is found.
  6942. */
  6943. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  6944. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  6945. return ADV_ERROR;
  6946. }
  6947. /*
  6948. * All kind of combinations of devices attached to one of four
  6949. * connectors are acceptable except HVD device attached. For example,
  6950. * LVD device can be attached to SE connector while SE device attached
  6951. * to LVD connector. If LVD device attached to SE connector, it only
  6952. * runs up to Ultra speed.
  6953. *
  6954. * If an HVD device is attached to one of LVD connectors, return an
  6955. * error. However, there is no way to detect HVD device attached to
  6956. * SE connectors.
  6957. */
  6958. if (scsi_cfg1 & HVD) {
  6959. asc_dvc->err_code = ASC_IERR_HVD_DEVICE;
  6960. return ADV_ERROR;
  6961. }
  6962. /*
  6963. * If either SE or LVD automatic termination control is enabled, then
  6964. * set the termination value based on a table listed in a_condor.h.
  6965. *
  6966. * If manual termination was specified with an EEPROM setting then
  6967. * 'termination' was set-up in AdvInitFrom38C0800EEPROM() and is ready
  6968. * to be 'ored' into SCSI_CFG1.
  6969. */
  6970. if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
  6971. /* SE automatic termination control is enabled. */
  6972. switch (scsi_cfg1 & C_DET_SE) {
  6973. /* TERM_SE_HI: on, TERM_SE_LO: on */
  6974. case 0x1:
  6975. case 0x2:
  6976. case 0x3:
  6977. asc_dvc->cfg->termination |= TERM_SE;
  6978. break;
  6979. /* TERM_SE_HI: on, TERM_SE_LO: off */
  6980. case 0x0:
  6981. asc_dvc->cfg->termination |= TERM_SE_HI;
  6982. break;
  6983. }
  6984. }
  6985. if ((asc_dvc->cfg->termination & TERM_LVD) == 0) {
  6986. /* LVD automatic termination control is enabled. */
  6987. switch (scsi_cfg1 & C_DET_LVD) {
  6988. /* TERM_LVD_HI: on, TERM_LVD_LO: on */
  6989. case 0x4:
  6990. case 0x8:
  6991. case 0xC:
  6992. asc_dvc->cfg->termination |= TERM_LVD;
  6993. break;
  6994. /* TERM_LVD_HI: off, TERM_LVD_LO: off */
  6995. case 0x0:
  6996. break;
  6997. }
  6998. }
  6999. /*
  7000. * Clear any set TERM_SE and TERM_LVD bits.
  7001. */
  7002. scsi_cfg1 &= (~TERM_SE & ~TERM_LVD);
  7003. /*
  7004. * Invert the TERM_SE and TERM_LVD bits and then set 'scsi_cfg1'.
  7005. */
  7006. scsi_cfg1 |= (~asc_dvc->cfg->termination & 0xF0);
  7007. /*
  7008. * Clear BIG_ENDIAN, DIS_TERM_DRV, Terminator Polarity and HVD/LVD/SE
  7009. * bits and set possibly modified termination control bits in the
  7010. * Microcode SCSI_CFG1 Register Value.
  7011. */
  7012. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL & ~HVD_LVD_SE);
  7013. /*
  7014. * Set SCSI_CFG1 Microcode Default Value
  7015. *
  7016. * Set possibly modified termination control and reset DIS_TERM_DRV
  7017. * bits in the Microcode SCSI_CFG1 Register Value.
  7018. *
  7019. * The microcode will set the SCSI_CFG1 register using this value
  7020. * after it is started below.
  7021. */
  7022. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  7023. /*
  7024. * Set MEM_CFG Microcode Default Value
  7025. *
  7026. * The microcode will set the MEM_CFG register using this value
  7027. * after it is started below.
  7028. *
  7029. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  7030. * are defined.
  7031. *
  7032. * ASC-38C0800 has 16KB internal memory.
  7033. */
  7034. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  7035. BIOS_EN | RAM_SZ_16KB);
  7036. /*
  7037. * Set SEL_MASK Microcode Default Value
  7038. *
  7039. * The microcode will set the SEL_MASK register using this value
  7040. * after it is started below.
  7041. */
  7042. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  7043. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  7044. AdvBuildCarrierFreelist(asc_dvc);
  7045. /*
  7046. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  7047. */
  7048. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  7049. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  7050. return ADV_ERROR;
  7051. }
  7052. asc_dvc->carr_freelist = (ADV_CARR_T *)
  7053. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  7054. /*
  7055. * The first command issued will be placed in the stopper carrier.
  7056. */
  7057. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  7058. /*
  7059. * Set RISC ICQ physical address start value.
  7060. * carr_pa is LE, must be native before write
  7061. */
  7062. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  7063. /*
  7064. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  7065. */
  7066. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  7067. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  7068. return ADV_ERROR;
  7069. }
  7070. asc_dvc->carr_freelist = (ADV_CARR_T *)
  7071. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  7072. /*
  7073. * The first command completed by the RISC will be placed in
  7074. * the stopper.
  7075. *
  7076. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  7077. * completed the RISC will set the ASC_RQ_STOPPER bit.
  7078. */
  7079. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  7080. /*
  7081. * Set RISC IRQ physical address start value.
  7082. *
  7083. * carr_pa is LE, must be native before write *
  7084. */
  7085. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  7086. asc_dvc->carr_pending_cnt = 0;
  7087. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  7088. (ADV_INTR_ENABLE_HOST_INTR |
  7089. ADV_INTR_ENABLE_GLOBAL_INTR));
  7090. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  7091. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  7092. /* finally, finally, gentlemen, start your engine */
  7093. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  7094. /*
  7095. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  7096. * Resets should be performed. The RISC has to be running
  7097. * to issue a SCSI Bus Reset.
  7098. */
  7099. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  7100. /*
  7101. * If the BIOS Signature is present in memory, restore the
  7102. * BIOS Handshake Configuration Table and do not perform
  7103. * a SCSI Bus Reset.
  7104. */
  7105. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  7106. 0x55AA) {
  7107. /*
  7108. * Restore per TID negotiated values.
  7109. */
  7110. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7111. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7112. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  7113. tagqng_able);
  7114. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  7115. AdvWriteByteLram(iop_base,
  7116. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7117. max_cmd[tid]);
  7118. }
  7119. } else {
  7120. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  7121. warn_code = ASC_WARN_BUSRESET_ERROR;
  7122. }
  7123. }
  7124. }
  7125. return warn_code;
  7126. }
  7127. /*
  7128. * Initialize the ASC-38C1600.
  7129. *
  7130. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  7131. *
  7132. * For a non-fatal error return a warning code. If there are no warnings
  7133. * then 0 is returned.
  7134. *
  7135. * Needed after initialization for error recovery.
  7136. */
  7137. static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
  7138. {
  7139. AdvPortAddr iop_base;
  7140. ushort warn_code;
  7141. int begin_addr;
  7142. int end_addr;
  7143. ushort code_sum;
  7144. long word;
  7145. int i;
  7146. ushort scsi_cfg1;
  7147. uchar byte;
  7148. uchar tid;
  7149. ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
  7150. ushort wdtr_able, sdtr_able, ppr_able, tagqng_able;
  7151. uchar max_cmd[ASC_MAX_TID + 1];
  7152. /* If there is already an error, don't continue. */
  7153. if (asc_dvc->err_code != 0) {
  7154. return ADV_ERROR;
  7155. }
  7156. /*
  7157. * The caller must set 'chip_type' to ADV_CHIP_ASC38C1600.
  7158. */
  7159. if (asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
  7160. asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
  7161. return ADV_ERROR;
  7162. }
  7163. warn_code = 0;
  7164. iop_base = asc_dvc->iop_base;
  7165. /*
  7166. * Save the RISC memory BIOS region before writing the microcode.
  7167. * The BIOS may already be loaded and using its RISC LRAM region
  7168. * so its region must be saved and restored.
  7169. *
  7170. * Note: This code makes the assumption, which is currently true,
  7171. * that a chip reset does not clear RISC LRAM.
  7172. */
  7173. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  7174. AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  7175. bios_mem[i]);
  7176. }
  7177. /*
  7178. * Save current per TID negotiated values.
  7179. */
  7180. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7181. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7182. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  7183. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  7184. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  7185. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7186. max_cmd[tid]);
  7187. }
  7188. /*
  7189. * RAM BIST (Built-In Self Test)
  7190. *
  7191. * Address : I/O base + offset 0x38h register (byte).
  7192. * Function: Bit 7-6(RW) : RAM mode
  7193. * Normal Mode : 0x00
  7194. * Pre-test Mode : 0x40
  7195. * RAM Test Mode : 0x80
  7196. * Bit 5 : unused
  7197. * Bit 4(RO) : Done bit
  7198. * Bit 3-0(RO) : Status
  7199. * Host Error : 0x08
  7200. * Int_RAM Error : 0x04
  7201. * RISC Error : 0x02
  7202. * SCSI Error : 0x01
  7203. * No Error : 0x00
  7204. *
  7205. * Note: RAM BIST code should be put right here, before loading the
  7206. * microcode and after saving the RISC memory BIOS region.
  7207. */
  7208. /*
  7209. * LRAM Pre-test
  7210. *
  7211. * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
  7212. * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
  7213. * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
  7214. * to NORMAL_MODE, return an error too.
  7215. */
  7216. for (i = 0; i < 2; i++) {
  7217. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
  7218. mdelay(10); /* Wait for 10ms before reading back. */
  7219. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  7220. if ((byte & RAM_TEST_DONE) == 0
  7221. || (byte & 0x0F) != PRE_TEST_VALUE) {
  7222. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  7223. return ADV_ERROR;
  7224. }
  7225. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  7226. mdelay(10); /* Wait for 10ms before reading back. */
  7227. if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
  7228. != NORMAL_VALUE) {
  7229. asc_dvc->err_code = ASC_IERR_BIST_PRE_TEST;
  7230. return ADV_ERROR;
  7231. }
  7232. }
  7233. /*
  7234. * LRAM Test - It takes about 1.5 ms to run through the test.
  7235. *
  7236. * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
  7237. * If Done bit not set or Status not 0, save register byte, set the
  7238. * err_code, and return an error.
  7239. */
  7240. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
  7241. mdelay(10); /* Wait for 10ms before checking status. */
  7242. byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
  7243. if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
  7244. /* Get here if Done bit not set or Status not 0. */
  7245. asc_dvc->bist_err_code = byte; /* for BIOS display message */
  7246. asc_dvc->err_code = ASC_IERR_BIST_RAM_TEST;
  7247. return ADV_ERROR;
  7248. }
  7249. /* We need to reset back to normal mode after LRAM test passes. */
  7250. AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
  7251. asc_dvc->err_code = AdvLoadMicrocode(iop_base, _adv_asc38C1600_buf,
  7252. _adv_asc38C1600_size, ADV_38C1600_MEMSIZE,
  7253. _adv_asc38C1600_chksum);
  7254. if (asc_dvc->err_code)
  7255. return ADV_ERROR;
  7256. /*
  7257. * Restore the RISC memory BIOS region.
  7258. */
  7259. for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
  7260. AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
  7261. bios_mem[i]);
  7262. }
  7263. /*
  7264. * Calculate and write the microcode code checksum to the microcode
  7265. * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
  7266. */
  7267. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
  7268. AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
  7269. code_sum = 0;
  7270. AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
  7271. for (word = begin_addr; word < end_addr; word += 2) {
  7272. code_sum += AdvReadWordAutoIncLram(iop_base);
  7273. }
  7274. AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
  7275. /*
  7276. * Read microcode version and date.
  7277. */
  7278. AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
  7279. asc_dvc->cfg->mcode_date);
  7280. AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
  7281. asc_dvc->cfg->mcode_version);
  7282. /*
  7283. * Set the chip type to indicate the ASC38C1600.
  7284. */
  7285. AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C1600);
  7286. /*
  7287. * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
  7288. * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
  7289. * cable detection and then we are able to read C_DET[3:0].
  7290. *
  7291. * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
  7292. * Microcode Default Value' section below.
  7293. */
  7294. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  7295. AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
  7296. scsi_cfg1 | DIS_TERM_DRV);
  7297. /*
  7298. * If the PCI Configuration Command Register "Parity Error Response
  7299. * Control" Bit was clear (0), then set the microcode variable
  7300. * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
  7301. * to ignore DMA parity errors.
  7302. */
  7303. if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
  7304. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7305. word |= CONTROL_FLAG_IGNORE_PERR;
  7306. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7307. }
  7308. /*
  7309. * If the BIOS control flag AIPP (Asynchronous Information
  7310. * Phase Protection) disable bit is not set, then set the firmware
  7311. * 'control_flag' CONTROL_FLAG_ENABLE_AIPP bit to enable
  7312. * AIPP checking and encoding.
  7313. */
  7314. if ((asc_dvc->bios_ctrl & BIOS_CTRL_AIPP_DIS) == 0) {
  7315. AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7316. word |= CONTROL_FLAG_ENABLE_AIPP;
  7317. AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
  7318. }
  7319. /*
  7320. * For ASC-38C1600 use DMA_CFG0 default values: FIFO_THRESH_80B [6:4],
  7321. * and START_CTL_TH [3:2].
  7322. */
  7323. AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
  7324. FIFO_THRESH_80B | START_CTL_TH | READ_CMD_MRM);
  7325. /*
  7326. * Microcode operating variables for WDTR, SDTR, and command tag
  7327. * queuing will be set in slave_configure() based on what a
  7328. * device reports it is capable of in Inquiry byte 7.
  7329. *
  7330. * If SCSI Bus Resets have been disabled, then directly set
  7331. * SDTR and WDTR from the EEPROM configuration. This will allow
  7332. * the BIOS and warm boot to work without a SCSI bus hang on
  7333. * the Inquiry caused by host and target mismatched DTR values.
  7334. * Without the SCSI Bus Reset, before an Inquiry a device can't
  7335. * be assumed to be in Asynchronous, Narrow mode.
  7336. */
  7337. if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
  7338. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
  7339. asc_dvc->wdtr_able);
  7340. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
  7341. asc_dvc->sdtr_able);
  7342. }
  7343. /*
  7344. * Set microcode operating variables for DISC and SDTR_SPEED1,
  7345. * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
  7346. * configuration values.
  7347. *
  7348. * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
  7349. * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
  7350. * without determining here whether the device supports SDTR.
  7351. */
  7352. AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
  7353. asc_dvc->cfg->disc_enable);
  7354. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
  7355. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
  7356. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
  7357. AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
  7358. /*
  7359. * Set SCSI_CFG0 Microcode Default Value.
  7360. *
  7361. * The microcode will set the SCSI_CFG0 register using this value
  7362. * after it is started below.
  7363. */
  7364. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
  7365. PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
  7366. asc_dvc->chip_scsi_id);
  7367. /*
  7368. * Calculate SCSI_CFG1 Microcode Default Value.
  7369. *
  7370. * The microcode will set the SCSI_CFG1 register using this value
  7371. * after it is started below.
  7372. *
  7373. * Each ASC-38C1600 function has only two cable detect bits.
  7374. * The bus mode override bits are in IOPB_SOFT_OVER_WR.
  7375. */
  7376. scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
  7377. /*
  7378. * If the cable is reversed all of the SCSI_CTRL register signals
  7379. * will be set. Check for and return an error if this condition is
  7380. * found.
  7381. */
  7382. if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
  7383. asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
  7384. return ADV_ERROR;
  7385. }
  7386. /*
  7387. * Each ASC-38C1600 function has two connectors. Only an HVD device
  7388. * can not be connected to either connector. An LVD device or SE device
  7389. * may be connected to either connecor. If an SE device is connected,
  7390. * then at most Ultra speed (20 Mhz) can be used on both connectors.
  7391. *
  7392. * If an HVD device is attached, return an error.
  7393. */
  7394. if (scsi_cfg1 & HVD) {
  7395. asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
  7396. return ADV_ERROR;
  7397. }
  7398. /*
  7399. * Each function in the ASC-38C1600 uses only the SE cable detect and
  7400. * termination because there are two connectors for each function. Each
  7401. * function may use either LVD or SE mode. Corresponding the SE automatic
  7402. * termination control EEPROM bits are used for each function. Each
  7403. * function has its own EEPROM. If SE automatic control is enabled for
  7404. * the function, then set the termination value based on a table listed
  7405. * in a_condor.h.
  7406. *
  7407. * If manual termination is specified in the EEPROM for the function,
  7408. * then 'termination' was set-up in AscInitFrom38C1600EEPROM() and is
  7409. * ready to be 'ored' into SCSI_CFG1.
  7410. */
  7411. if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
  7412. struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
  7413. /* SE automatic termination control is enabled. */
  7414. switch (scsi_cfg1 & C_DET_SE) {
  7415. /* TERM_SE_HI: on, TERM_SE_LO: on */
  7416. case 0x1:
  7417. case 0x2:
  7418. case 0x3:
  7419. asc_dvc->cfg->termination |= TERM_SE;
  7420. break;
  7421. case 0x0:
  7422. if (PCI_FUNC(pdev->devfn) == 0) {
  7423. /* Function 0 - TERM_SE_HI: off, TERM_SE_LO: off */
  7424. } else {
  7425. /* Function 1 - TERM_SE_HI: on, TERM_SE_LO: off */
  7426. asc_dvc->cfg->termination |= TERM_SE_HI;
  7427. }
  7428. break;
  7429. }
  7430. }
  7431. /*
  7432. * Clear any set TERM_SE bits.
  7433. */
  7434. scsi_cfg1 &= ~TERM_SE;
  7435. /*
  7436. * Invert the TERM_SE bits and then set 'scsi_cfg1'.
  7437. */
  7438. scsi_cfg1 |= (~asc_dvc->cfg->termination & TERM_SE);
  7439. /*
  7440. * Clear Big Endian and Terminator Polarity bits and set possibly
  7441. * modified termination control bits in the Microcode SCSI_CFG1
  7442. * Register Value.
  7443. *
  7444. * Big Endian bit is not used even on big endian machines.
  7445. */
  7446. scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL);
  7447. /*
  7448. * Set SCSI_CFG1 Microcode Default Value
  7449. *
  7450. * Set possibly modified termination control bits in the Microcode
  7451. * SCSI_CFG1 Register Value.
  7452. *
  7453. * The microcode will set the SCSI_CFG1 register using this value
  7454. * after it is started below.
  7455. */
  7456. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
  7457. /*
  7458. * Set MEM_CFG Microcode Default Value
  7459. *
  7460. * The microcode will set the MEM_CFG register using this value
  7461. * after it is started below.
  7462. *
  7463. * MEM_CFG may be accessed as a word or byte, but only bits 0-7
  7464. * are defined.
  7465. *
  7466. * ASC-38C1600 has 32KB internal memory.
  7467. *
  7468. * XXX - Since ASC38C1600 Rev.3 has a Local RAM failure issue, we come
  7469. * out a special 16K Adv Library and Microcode version. After the issue
  7470. * resolved, we should turn back to the 32K support. Both a_condor.h and
  7471. * mcode.sas files also need to be updated.
  7472. *
  7473. * AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  7474. * BIOS_EN | RAM_SZ_32KB);
  7475. */
  7476. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
  7477. BIOS_EN | RAM_SZ_16KB);
  7478. /*
  7479. * Set SEL_MASK Microcode Default Value
  7480. *
  7481. * The microcode will set the SEL_MASK register using this value
  7482. * after it is started below.
  7483. */
  7484. AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
  7485. ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
  7486. AdvBuildCarrierFreelist(asc_dvc);
  7487. /*
  7488. * Set-up the Host->RISC Initiator Command Queue (ICQ).
  7489. */
  7490. if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
  7491. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  7492. return ADV_ERROR;
  7493. }
  7494. asc_dvc->carr_freelist = (ADV_CARR_T *)
  7495. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
  7496. /*
  7497. * The first command issued will be placed in the stopper carrier.
  7498. */
  7499. asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  7500. /*
  7501. * Set RISC ICQ physical address start value. Initialize the
  7502. * COMMA register to the same value otherwise the RISC will
  7503. * prematurely detect a command is available.
  7504. */
  7505. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
  7506. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  7507. le32_to_cpu(asc_dvc->icq_sp->carr_pa));
  7508. /*
  7509. * Set-up the RISC->Host Initiator Response Queue (IRQ).
  7510. */
  7511. if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
  7512. asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
  7513. return ADV_ERROR;
  7514. }
  7515. asc_dvc->carr_freelist = (ADV_CARR_T *)
  7516. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
  7517. /*
  7518. * The first command completed by the RISC will be placed in
  7519. * the stopper.
  7520. *
  7521. * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
  7522. * completed the RISC will set the ASC_RQ_STOPPER bit.
  7523. */
  7524. asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  7525. /*
  7526. * Set RISC IRQ physical address start value.
  7527. */
  7528. AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
  7529. asc_dvc->carr_pending_cnt = 0;
  7530. AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
  7531. (ADV_INTR_ENABLE_HOST_INTR |
  7532. ADV_INTR_ENABLE_GLOBAL_INTR));
  7533. AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
  7534. AdvWriteWordRegister(iop_base, IOPW_PC, word);
  7535. /* finally, finally, gentlemen, start your engine */
  7536. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
  7537. /*
  7538. * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
  7539. * Resets should be performed. The RISC has to be running
  7540. * to issue a SCSI Bus Reset.
  7541. */
  7542. if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
  7543. /*
  7544. * If the BIOS Signature is present in memory, restore the
  7545. * per TID microcode operating variables.
  7546. */
  7547. if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
  7548. 0x55AA) {
  7549. /*
  7550. * Restore per TID negotiated values.
  7551. */
  7552. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7553. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7554. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  7555. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  7556. tagqng_able);
  7557. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  7558. AdvWriteByteLram(iop_base,
  7559. ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7560. max_cmd[tid]);
  7561. }
  7562. } else {
  7563. if (AdvResetSB(asc_dvc) != ADV_TRUE) {
  7564. warn_code = ASC_WARN_BUSRESET_ERROR;
  7565. }
  7566. }
  7567. }
  7568. return warn_code;
  7569. }
  7570. /*
  7571. * Reset chip and SCSI Bus.
  7572. *
  7573. * Return Value:
  7574. * ADV_TRUE(1) - Chip re-initialization and SCSI Bus Reset successful.
  7575. * ADV_FALSE(0) - Chip re-initialization and SCSI Bus Reset failure.
  7576. */
  7577. static int AdvResetChipAndSB(ADV_DVC_VAR *asc_dvc)
  7578. {
  7579. int status;
  7580. ushort wdtr_able, sdtr_able, tagqng_able;
  7581. ushort ppr_able = 0;
  7582. uchar tid, max_cmd[ADV_MAX_TID + 1];
  7583. AdvPortAddr iop_base;
  7584. ushort bios_sig;
  7585. iop_base = asc_dvc->iop_base;
  7586. /*
  7587. * Save current per TID negotiated values.
  7588. */
  7589. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7590. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7591. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  7592. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  7593. }
  7594. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  7595. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  7596. AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7597. max_cmd[tid]);
  7598. }
  7599. /*
  7600. * Force the AdvInitAsc3550/38C0800Driver() function to
  7601. * perform a SCSI Bus Reset by clearing the BIOS signature word.
  7602. * The initialization functions assumes a SCSI Bus Reset is not
  7603. * needed if the BIOS signature word is present.
  7604. */
  7605. AdvReadWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  7606. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, 0);
  7607. /*
  7608. * Stop chip and reset it.
  7609. */
  7610. AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_STOP);
  7611. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, ADV_CTRL_REG_CMD_RESET);
  7612. mdelay(100);
  7613. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  7614. ADV_CTRL_REG_CMD_WR_IO_REG);
  7615. /*
  7616. * Reset Adv Library error code, if any, and try
  7617. * re-initializing the chip.
  7618. */
  7619. asc_dvc->err_code = 0;
  7620. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  7621. status = AdvInitAsc38C1600Driver(asc_dvc);
  7622. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  7623. status = AdvInitAsc38C0800Driver(asc_dvc);
  7624. } else {
  7625. status = AdvInitAsc3550Driver(asc_dvc);
  7626. }
  7627. /* Translate initialization return value to status value. */
  7628. if (status == 0) {
  7629. status = ADV_TRUE;
  7630. } else {
  7631. status = ADV_FALSE;
  7632. }
  7633. /*
  7634. * Restore the BIOS signature word.
  7635. */
  7636. AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
  7637. /*
  7638. * Restore per TID negotiated values.
  7639. */
  7640. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
  7641. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
  7642. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  7643. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
  7644. }
  7645. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
  7646. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  7647. AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
  7648. max_cmd[tid]);
  7649. }
  7650. return status;
  7651. }
  7652. /*
  7653. * adv_async_callback() - Adv Library asynchronous event callback function.
  7654. */
  7655. static void adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
  7656. {
  7657. switch (code) {
  7658. case ADV_ASYNC_SCSI_BUS_RESET_DET:
  7659. /*
  7660. * The firmware detected a SCSI Bus reset.
  7661. */
  7662. ASC_DBG(0,
  7663. "adv_async_callback: ADV_ASYNC_SCSI_BUS_RESET_DET\n");
  7664. break;
  7665. case ADV_ASYNC_RDMA_FAILURE:
  7666. /*
  7667. * Handle RDMA failure by resetting the SCSI Bus and
  7668. * possibly the chip if it is unresponsive. Log the error
  7669. * with a unique code.
  7670. */
  7671. ASC_DBG(0, "adv_async_callback: ADV_ASYNC_RDMA_FAILURE\n");
  7672. AdvResetChipAndSB(adv_dvc_varp);
  7673. break;
  7674. case ADV_HOST_SCSI_BUS_RESET:
  7675. /*
  7676. * Host generated SCSI bus reset occurred.
  7677. */
  7678. ASC_DBG(0, "adv_async_callback: ADV_HOST_SCSI_BUS_RESET\n");
  7679. break;
  7680. default:
  7681. ASC_DBG1(0, "DvcAsyncCallBack: unknown code 0x%x\n", code);
  7682. break;
  7683. }
  7684. }
  7685. /*
  7686. * adv_isr_callback() - Second Level Interrupt Handler called by AdvISR().
  7687. *
  7688. * Callback function for the Wide SCSI Adv Library.
  7689. */
  7690. static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
  7691. {
  7692. asc_board_t *boardp;
  7693. adv_req_t *reqp;
  7694. adv_sgblk_t *sgblkp;
  7695. struct scsi_cmnd *scp;
  7696. struct Scsi_Host *shost;
  7697. ADV_DCNT resid_cnt;
  7698. ASC_DBG2(1, "adv_isr_callback: adv_dvc_varp 0x%lx, scsiqp 0x%lx\n",
  7699. (ulong)adv_dvc_varp, (ulong)scsiqp);
  7700. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  7701. /*
  7702. * Get the adv_req_t structure for the command that has been
  7703. * completed. The adv_req_t structure actually contains the
  7704. * completed ADV_SCSI_REQ_Q structure.
  7705. */
  7706. reqp = (adv_req_t *)ADV_U32_TO_VADDR(scsiqp->srb_ptr);
  7707. ASC_DBG1(1, "adv_isr_callback: reqp 0x%lx\n", (ulong)reqp);
  7708. if (reqp == NULL) {
  7709. ASC_PRINT("adv_isr_callback: reqp is NULL\n");
  7710. return;
  7711. }
  7712. /*
  7713. * Get the struct scsi_cmnd structure and Scsi_Host structure for the
  7714. * command that has been completed.
  7715. *
  7716. * Note: The adv_req_t request structure and adv_sgblk_t structure,
  7717. * if any, are dropped, because a board structure pointer can not be
  7718. * determined.
  7719. */
  7720. scp = reqp->cmndp;
  7721. ASC_DBG1(1, "adv_isr_callback: scp 0x%lx\n", (ulong)scp);
  7722. if (scp == NULL) {
  7723. ASC_PRINT
  7724. ("adv_isr_callback: scp is NULL; adv_req_t dropped.\n");
  7725. return;
  7726. }
  7727. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  7728. shost = scp->device->host;
  7729. ASC_STATS(shost, callback);
  7730. ASC_DBG1(1, "adv_isr_callback: shost 0x%lx\n", (ulong)shost);
  7731. boardp = ASC_BOARDP(shost);
  7732. BUG_ON(adv_dvc_varp != &boardp->dvc_var.adv_dvc_var);
  7733. /*
  7734. * 'done_status' contains the command's ending status.
  7735. */
  7736. switch (scsiqp->done_status) {
  7737. case QD_NO_ERROR:
  7738. ASC_DBG(2, "adv_isr_callback: QD_NO_ERROR\n");
  7739. scp->result = 0;
  7740. /*
  7741. * Check for an underrun condition.
  7742. *
  7743. * If there was no error and an underrun condition, then
  7744. * then return the number of underrun bytes.
  7745. */
  7746. resid_cnt = le32_to_cpu(scsiqp->data_cnt);
  7747. if (scp->request_bufflen != 0 && resid_cnt != 0 &&
  7748. resid_cnt <= scp->request_bufflen) {
  7749. ASC_DBG1(1,
  7750. "adv_isr_callback: underrun condition %lu bytes\n",
  7751. (ulong)resid_cnt);
  7752. scp->resid = resid_cnt;
  7753. }
  7754. break;
  7755. case QD_WITH_ERROR:
  7756. ASC_DBG(2, "adv_isr_callback: QD_WITH_ERROR\n");
  7757. switch (scsiqp->host_status) {
  7758. case QHSTA_NO_ERROR:
  7759. if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
  7760. ASC_DBG(2,
  7761. "adv_isr_callback: SAM_STAT_CHECK_CONDITION\n");
  7762. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  7763. sizeof(scp->sense_buffer));
  7764. /*
  7765. * Note: The 'status_byte()' macro used by
  7766. * target drivers defined in scsi.h shifts the
  7767. * status byte returned by host drivers right
  7768. * by 1 bit. This is why target drivers also
  7769. * use right shifted status byte definitions.
  7770. * For instance target drivers use
  7771. * CHECK_CONDITION, defined to 0x1, instead of
  7772. * the SCSI defined check condition value of
  7773. * 0x2. Host drivers are supposed to return
  7774. * the status byte as it is defined by SCSI.
  7775. */
  7776. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  7777. STATUS_BYTE(scsiqp->scsi_status);
  7778. } else {
  7779. scp->result = STATUS_BYTE(scsiqp->scsi_status);
  7780. }
  7781. break;
  7782. default:
  7783. /* Some other QHSTA error occurred. */
  7784. ASC_DBG1(1, "adv_isr_callback: host_status 0x%x\n",
  7785. scsiqp->host_status);
  7786. scp->result = HOST_BYTE(DID_BAD_TARGET);
  7787. break;
  7788. }
  7789. break;
  7790. case QD_ABORTED_BY_HOST:
  7791. ASC_DBG(1, "adv_isr_callback: QD_ABORTED_BY_HOST\n");
  7792. scp->result =
  7793. HOST_BYTE(DID_ABORT) | STATUS_BYTE(scsiqp->scsi_status);
  7794. break;
  7795. default:
  7796. ASC_DBG1(1, "adv_isr_callback: done_status 0x%x\n",
  7797. scsiqp->done_status);
  7798. scp->result =
  7799. HOST_BYTE(DID_ERROR) | STATUS_BYTE(scsiqp->scsi_status);
  7800. break;
  7801. }
  7802. /*
  7803. * If the 'init_tidmask' bit isn't already set for the target and the
  7804. * current request finished normally, then set the bit for the target
  7805. * to indicate that a device is present.
  7806. */
  7807. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  7808. scsiqp->done_status == QD_NO_ERROR &&
  7809. scsiqp->host_status == QHSTA_NO_ERROR) {
  7810. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  7811. }
  7812. asc_scsi_done(scp);
  7813. /*
  7814. * Free all 'adv_sgblk_t' structures allocated for the request.
  7815. */
  7816. while ((sgblkp = reqp->sgblkp) != NULL) {
  7817. /* Remove 'sgblkp' from the request list. */
  7818. reqp->sgblkp = sgblkp->next_sgblkp;
  7819. /* Add 'sgblkp' to the board free list. */
  7820. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  7821. boardp->adv_sgblkp = sgblkp;
  7822. }
  7823. /*
  7824. * Free the adv_req_t structure used with the command by adding
  7825. * it back to the board free list.
  7826. */
  7827. reqp->next_reqp = boardp->adv_reqp;
  7828. boardp->adv_reqp = reqp;
  7829. ASC_DBG(1, "adv_isr_callback: done\n");
  7830. return;
  7831. }
  7832. /*
  7833. * Adv Library Interrupt Service Routine
  7834. *
  7835. * This function is called by a driver's interrupt service routine.
  7836. * The function disables and re-enables interrupts.
  7837. *
  7838. * When a microcode idle command is completed, the ADV_DVC_VAR
  7839. * 'idle_cmd_done' field is set to ADV_TRUE.
  7840. *
  7841. * Note: AdvISR() can be called when interrupts are disabled or even
  7842. * when there is no hardware interrupt condition present. It will
  7843. * always check for completed idle commands and microcode requests.
  7844. * This is an important feature that shouldn't be changed because it
  7845. * allows commands to be completed from polling mode loops.
  7846. *
  7847. * Return:
  7848. * ADV_TRUE(1) - interrupt was pending
  7849. * ADV_FALSE(0) - no interrupt was pending
  7850. */
  7851. static int AdvISR(ADV_DVC_VAR *asc_dvc)
  7852. {
  7853. AdvPortAddr iop_base;
  7854. uchar int_stat;
  7855. ushort target_bit;
  7856. ADV_CARR_T *free_carrp;
  7857. ADV_VADDR irq_next_vpa;
  7858. ADV_SCSI_REQ_Q *scsiq;
  7859. iop_base = asc_dvc->iop_base;
  7860. /* Reading the register clears the interrupt. */
  7861. int_stat = AdvReadByteRegister(iop_base, IOPB_INTR_STATUS_REG);
  7862. if ((int_stat & (ADV_INTR_STATUS_INTRA | ADV_INTR_STATUS_INTRB |
  7863. ADV_INTR_STATUS_INTRC)) == 0) {
  7864. return ADV_FALSE;
  7865. }
  7866. /*
  7867. * Notify the driver of an asynchronous microcode condition by
  7868. * calling the adv_async_callback function. The function
  7869. * is passed the microcode ASC_MC_INTRB_CODE byte value.
  7870. */
  7871. if (int_stat & ADV_INTR_STATUS_INTRB) {
  7872. uchar intrb_code;
  7873. AdvReadByteLram(iop_base, ASC_MC_INTRB_CODE, intrb_code);
  7874. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  7875. asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  7876. if (intrb_code == ADV_ASYNC_CARRIER_READY_FAILURE &&
  7877. asc_dvc->carr_pending_cnt != 0) {
  7878. AdvWriteByteRegister(iop_base, IOPB_TICKLE,
  7879. ADV_TICKLE_A);
  7880. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  7881. AdvWriteByteRegister(iop_base,
  7882. IOPB_TICKLE,
  7883. ADV_TICKLE_NOP);
  7884. }
  7885. }
  7886. }
  7887. adv_async_callback(asc_dvc, intrb_code);
  7888. }
  7889. /*
  7890. * Check if the IRQ stopper carrier contains a completed request.
  7891. */
  7892. while (((irq_next_vpa =
  7893. le32_to_cpu(asc_dvc->irq_sp->next_vpa)) & ASC_RQ_DONE) != 0) {
  7894. /*
  7895. * Get a pointer to the newly completed ADV_SCSI_REQ_Q structure.
  7896. * The RISC will have set 'areq_vpa' to a virtual address.
  7897. *
  7898. * The firmware will have copied the ASC_SCSI_REQ_Q.scsiq_ptr
  7899. * field to the carrier ADV_CARR_T.areq_vpa field. The conversion
  7900. * below complements the conversion of ASC_SCSI_REQ_Q.scsiq_ptr'
  7901. * in AdvExeScsiQueue().
  7902. */
  7903. scsiq = (ADV_SCSI_REQ_Q *)
  7904. ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->areq_vpa));
  7905. /*
  7906. * Request finished with good status and the queue was not
  7907. * DMAed to host memory by the firmware. Set all status fields
  7908. * to indicate good status.
  7909. */
  7910. if ((irq_next_vpa & ASC_RQ_GOOD) != 0) {
  7911. scsiq->done_status = QD_NO_ERROR;
  7912. scsiq->host_status = scsiq->scsi_status = 0;
  7913. scsiq->data_cnt = 0L;
  7914. }
  7915. /*
  7916. * Advance the stopper pointer to the next carrier
  7917. * ignoring the lower four bits. Free the previous
  7918. * stopper carrier.
  7919. */
  7920. free_carrp = asc_dvc->irq_sp;
  7921. asc_dvc->irq_sp = (ADV_CARR_T *)
  7922. ADV_U32_TO_VADDR(ASC_GET_CARRP(irq_next_vpa));
  7923. free_carrp->next_vpa =
  7924. cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
  7925. asc_dvc->carr_freelist = free_carrp;
  7926. asc_dvc->carr_pending_cnt--;
  7927. target_bit = ADV_TID_TO_TIDMASK(scsiq->target_id);
  7928. /*
  7929. * Clear request microcode control flag.
  7930. */
  7931. scsiq->cntl = 0;
  7932. /*
  7933. * Notify the driver of the completed request by passing
  7934. * the ADV_SCSI_REQ_Q pointer to its callback function.
  7935. */
  7936. scsiq->a_flag |= ADV_SCSIQ_DONE;
  7937. adv_isr_callback(asc_dvc, scsiq);
  7938. /*
  7939. * Note: After the driver callback function is called, 'scsiq'
  7940. * can no longer be referenced.
  7941. *
  7942. * Fall through and continue processing other completed
  7943. * requests...
  7944. */
  7945. }
  7946. return ADV_TRUE;
  7947. }
  7948. static int AscSetLibErrorCode(ASC_DVC_VAR *asc_dvc, ushort err_code)
  7949. {
  7950. if (asc_dvc->err_code == 0) {
  7951. asc_dvc->err_code = err_code;
  7952. AscWriteLramWord(asc_dvc->iop_base, ASCV_ASCDVC_ERR_CODE_W,
  7953. err_code);
  7954. }
  7955. return err_code;
  7956. }
  7957. static void AscAckInterrupt(PortAddr iop_base)
  7958. {
  7959. uchar host_flag;
  7960. uchar risc_flag;
  7961. ushort loop;
  7962. loop = 0;
  7963. do {
  7964. risc_flag = AscReadLramByte(iop_base, ASCV_RISC_FLAG_B);
  7965. if (loop++ > 0x7FFF) {
  7966. break;
  7967. }
  7968. } while ((risc_flag & ASC_RISC_FLAG_GEN_INT) != 0);
  7969. host_flag =
  7970. AscReadLramByte(iop_base,
  7971. ASCV_HOST_FLAG_B) & (~ASC_HOST_FLAG_ACK_INT);
  7972. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  7973. (uchar)(host_flag | ASC_HOST_FLAG_ACK_INT));
  7974. AscSetChipStatus(iop_base, CIW_INT_ACK);
  7975. loop = 0;
  7976. while (AscGetChipStatus(iop_base) & CSW_INT_PENDING) {
  7977. AscSetChipStatus(iop_base, CIW_INT_ACK);
  7978. if (loop++ > 3) {
  7979. break;
  7980. }
  7981. }
  7982. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  7983. return;
  7984. }
  7985. static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *asc_dvc, uchar syn_time)
  7986. {
  7987. uchar *period_table;
  7988. int max_index;
  7989. int min_index;
  7990. int i;
  7991. period_table = asc_dvc->sdtr_period_tbl;
  7992. max_index = (int)asc_dvc->max_sdtr_index;
  7993. min_index = (int)asc_dvc->host_init_sdtr_index;
  7994. if ((syn_time <= period_table[max_index])) {
  7995. for (i = min_index; i < (max_index - 1); i++) {
  7996. if (syn_time <= period_table[i]) {
  7997. return (uchar)i;
  7998. }
  7999. }
  8000. return (uchar)max_index;
  8001. } else {
  8002. return (uchar)(max_index + 1);
  8003. }
  8004. }
  8005. static uchar
  8006. AscMsgOutSDTR(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar sdtr_offset)
  8007. {
  8008. EXT_MSG sdtr_buf;
  8009. uchar sdtr_period_index;
  8010. PortAddr iop_base;
  8011. iop_base = asc_dvc->iop_base;
  8012. sdtr_buf.msg_type = EXTENDED_MESSAGE;
  8013. sdtr_buf.msg_len = MS_SDTR_LEN;
  8014. sdtr_buf.msg_req = EXTENDED_SDTR;
  8015. sdtr_buf.xfer_period = sdtr_period;
  8016. sdtr_offset &= ASC_SYN_MAX_OFFSET;
  8017. sdtr_buf.req_ack_offset = sdtr_offset;
  8018. sdtr_period_index = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
  8019. if (sdtr_period_index <= asc_dvc->max_sdtr_index) {
  8020. AscMemWordCopyPtrToLram(iop_base, ASCV_MSGOUT_BEG,
  8021. (uchar *)&sdtr_buf,
  8022. sizeof(EXT_MSG) >> 1);
  8023. return ((sdtr_period_index << 4) | sdtr_offset);
  8024. } else {
  8025. sdtr_buf.req_ack_offset = 0;
  8026. AscMemWordCopyPtrToLram(iop_base, ASCV_MSGOUT_BEG,
  8027. (uchar *)&sdtr_buf,
  8028. sizeof(EXT_MSG) >> 1);
  8029. return 0;
  8030. }
  8031. }
  8032. static uchar
  8033. AscCalSDTRData(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar syn_offset)
  8034. {
  8035. uchar byte;
  8036. uchar sdtr_period_ix;
  8037. sdtr_period_ix = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
  8038. if (sdtr_period_ix > asc_dvc->max_sdtr_index) {
  8039. return 0xFF;
  8040. }
  8041. byte = (sdtr_period_ix << 4) | (syn_offset & ASC_SYN_MAX_OFFSET);
  8042. return byte;
  8043. }
  8044. static int AscSetChipSynRegAtID(PortAddr iop_base, uchar id, uchar sdtr_data)
  8045. {
  8046. ASC_SCSI_BIT_ID_TYPE org_id;
  8047. int i;
  8048. int sta = TRUE;
  8049. AscSetBank(iop_base, 1);
  8050. org_id = AscReadChipDvcID(iop_base);
  8051. for (i = 0; i <= ASC_MAX_TID; i++) {
  8052. if (org_id == (0x01 << i))
  8053. break;
  8054. }
  8055. org_id = (ASC_SCSI_BIT_ID_TYPE) i;
  8056. AscWriteChipDvcID(iop_base, id);
  8057. if (AscReadChipDvcID(iop_base) == (0x01 << id)) {
  8058. AscSetBank(iop_base, 0);
  8059. AscSetChipSyn(iop_base, sdtr_data);
  8060. if (AscGetChipSyn(iop_base) != sdtr_data) {
  8061. sta = FALSE;
  8062. }
  8063. } else {
  8064. sta = FALSE;
  8065. }
  8066. AscSetBank(iop_base, 1);
  8067. AscWriteChipDvcID(iop_base, org_id);
  8068. AscSetBank(iop_base, 0);
  8069. return (sta);
  8070. }
  8071. static void AscSetChipSDTR(PortAddr iop_base, uchar sdtr_data, uchar tid_no)
  8072. {
  8073. AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  8074. AscPutMCodeSDTRDoneAtID(iop_base, tid_no, sdtr_data);
  8075. }
  8076. static int AscIsrChipHalted(ASC_DVC_VAR *asc_dvc)
  8077. {
  8078. EXT_MSG ext_msg;
  8079. EXT_MSG out_msg;
  8080. ushort halt_q_addr;
  8081. int sdtr_accept;
  8082. ushort int_halt_code;
  8083. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  8084. ASC_SCSI_BIT_ID_TYPE target_id;
  8085. PortAddr iop_base;
  8086. uchar tag_code;
  8087. uchar q_status;
  8088. uchar halt_qp;
  8089. uchar sdtr_data;
  8090. uchar target_ix;
  8091. uchar q_cntl, tid_no;
  8092. uchar cur_dvc_qng;
  8093. uchar asyn_sdtr;
  8094. uchar scsi_status;
  8095. asc_board_t *boardp;
  8096. BUG_ON(!asc_dvc->drv_ptr);
  8097. boardp = asc_dvc->drv_ptr;
  8098. iop_base = asc_dvc->iop_base;
  8099. int_halt_code = AscReadLramWord(iop_base, ASCV_HALTCODE_W);
  8100. halt_qp = AscReadLramByte(iop_base, ASCV_CURCDB_B);
  8101. halt_q_addr = ASC_QNO_TO_QADDR(halt_qp);
  8102. target_ix = AscReadLramByte(iop_base,
  8103. (ushort)(halt_q_addr +
  8104. (ushort)ASC_SCSIQ_B_TARGET_IX));
  8105. q_cntl = AscReadLramByte(iop_base,
  8106. (ushort)(halt_q_addr + (ushort)ASC_SCSIQ_B_CNTL));
  8107. tid_no = ASC_TIX_TO_TID(target_ix);
  8108. target_id = (uchar)ASC_TID_TO_TARGET_ID(tid_no);
  8109. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  8110. asyn_sdtr = ASYN_SDTR_DATA_FIX_PCI_REV_AB;
  8111. } else {
  8112. asyn_sdtr = 0;
  8113. }
  8114. if (int_halt_code == ASC_HALT_DISABLE_ASYN_USE_SYN_FIX) {
  8115. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  8116. AscSetChipSDTR(iop_base, 0, tid_no);
  8117. boardp->sdtr_data[tid_no] = 0;
  8118. }
  8119. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8120. return (0);
  8121. } else if (int_halt_code == ASC_HALT_ENABLE_ASYN_USE_SYN_FIX) {
  8122. if (asc_dvc->pci_fix_asyn_xfer & target_id) {
  8123. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  8124. boardp->sdtr_data[tid_no] = asyn_sdtr;
  8125. }
  8126. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8127. return (0);
  8128. } else if (int_halt_code == ASC_HALT_EXTMSG_IN) {
  8129. AscMemWordCopyPtrFromLram(iop_base,
  8130. ASCV_MSGIN_BEG,
  8131. (uchar *)&ext_msg,
  8132. sizeof(EXT_MSG) >> 1);
  8133. if (ext_msg.msg_type == EXTENDED_MESSAGE &&
  8134. ext_msg.msg_req == EXTENDED_SDTR &&
  8135. ext_msg.msg_len == MS_SDTR_LEN) {
  8136. sdtr_accept = TRUE;
  8137. if ((ext_msg.req_ack_offset > ASC_SYN_MAX_OFFSET)) {
  8138. sdtr_accept = FALSE;
  8139. ext_msg.req_ack_offset = ASC_SYN_MAX_OFFSET;
  8140. }
  8141. if ((ext_msg.xfer_period <
  8142. asc_dvc->sdtr_period_tbl[asc_dvc->
  8143. host_init_sdtr_index])
  8144. || (ext_msg.xfer_period >
  8145. asc_dvc->sdtr_period_tbl[asc_dvc->
  8146. max_sdtr_index])) {
  8147. sdtr_accept = FALSE;
  8148. ext_msg.xfer_period =
  8149. asc_dvc->sdtr_period_tbl[asc_dvc->
  8150. host_init_sdtr_index];
  8151. }
  8152. if (sdtr_accept) {
  8153. sdtr_data =
  8154. AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
  8155. ext_msg.req_ack_offset);
  8156. if ((sdtr_data == 0xFF)) {
  8157. q_cntl |= QC_MSG_OUT;
  8158. asc_dvc->init_sdtr &= ~target_id;
  8159. asc_dvc->sdtr_done &= ~target_id;
  8160. AscSetChipSDTR(iop_base, asyn_sdtr,
  8161. tid_no);
  8162. boardp->sdtr_data[tid_no] = asyn_sdtr;
  8163. }
  8164. }
  8165. if (ext_msg.req_ack_offset == 0) {
  8166. q_cntl &= ~QC_MSG_OUT;
  8167. asc_dvc->init_sdtr &= ~target_id;
  8168. asc_dvc->sdtr_done &= ~target_id;
  8169. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  8170. } else {
  8171. if (sdtr_accept && (q_cntl & QC_MSG_OUT)) {
  8172. q_cntl &= ~QC_MSG_OUT;
  8173. asc_dvc->sdtr_done |= target_id;
  8174. asc_dvc->init_sdtr |= target_id;
  8175. asc_dvc->pci_fix_asyn_xfer &=
  8176. ~target_id;
  8177. sdtr_data =
  8178. AscCalSDTRData(asc_dvc,
  8179. ext_msg.xfer_period,
  8180. ext_msg.
  8181. req_ack_offset);
  8182. AscSetChipSDTR(iop_base, sdtr_data,
  8183. tid_no);
  8184. boardp->sdtr_data[tid_no] = sdtr_data;
  8185. } else {
  8186. q_cntl |= QC_MSG_OUT;
  8187. AscMsgOutSDTR(asc_dvc,
  8188. ext_msg.xfer_period,
  8189. ext_msg.req_ack_offset);
  8190. asc_dvc->pci_fix_asyn_xfer &=
  8191. ~target_id;
  8192. sdtr_data =
  8193. AscCalSDTRData(asc_dvc,
  8194. ext_msg.xfer_period,
  8195. ext_msg.
  8196. req_ack_offset);
  8197. AscSetChipSDTR(iop_base, sdtr_data,
  8198. tid_no);
  8199. boardp->sdtr_data[tid_no] = sdtr_data;
  8200. asc_dvc->sdtr_done |= target_id;
  8201. asc_dvc->init_sdtr |= target_id;
  8202. }
  8203. }
  8204. AscWriteLramByte(iop_base,
  8205. (ushort)(halt_q_addr +
  8206. (ushort)ASC_SCSIQ_B_CNTL),
  8207. q_cntl);
  8208. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8209. return (0);
  8210. } else if (ext_msg.msg_type == EXTENDED_MESSAGE &&
  8211. ext_msg.msg_req == EXTENDED_WDTR &&
  8212. ext_msg.msg_len == MS_WDTR_LEN) {
  8213. ext_msg.wdtr_width = 0;
  8214. AscMemWordCopyPtrToLram(iop_base,
  8215. ASCV_MSGOUT_BEG,
  8216. (uchar *)&ext_msg,
  8217. sizeof(EXT_MSG) >> 1);
  8218. q_cntl |= QC_MSG_OUT;
  8219. AscWriteLramByte(iop_base,
  8220. (ushort)(halt_q_addr +
  8221. (ushort)ASC_SCSIQ_B_CNTL),
  8222. q_cntl);
  8223. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8224. return (0);
  8225. } else {
  8226. ext_msg.msg_type = MESSAGE_REJECT;
  8227. AscMemWordCopyPtrToLram(iop_base,
  8228. ASCV_MSGOUT_BEG,
  8229. (uchar *)&ext_msg,
  8230. sizeof(EXT_MSG) >> 1);
  8231. q_cntl |= QC_MSG_OUT;
  8232. AscWriteLramByte(iop_base,
  8233. (ushort)(halt_q_addr +
  8234. (ushort)ASC_SCSIQ_B_CNTL),
  8235. q_cntl);
  8236. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8237. return (0);
  8238. }
  8239. } else if (int_halt_code == ASC_HALT_CHK_CONDITION) {
  8240. q_cntl |= QC_REQ_SENSE;
  8241. if ((asc_dvc->init_sdtr & target_id) != 0) {
  8242. asc_dvc->sdtr_done &= ~target_id;
  8243. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  8244. q_cntl |= QC_MSG_OUT;
  8245. AscMsgOutSDTR(asc_dvc,
  8246. asc_dvc->
  8247. sdtr_period_tbl[(sdtr_data >> 4) &
  8248. (uchar)(asc_dvc->
  8249. max_sdtr_index -
  8250. 1)],
  8251. (uchar)(sdtr_data & (uchar)
  8252. ASC_SYN_MAX_OFFSET));
  8253. }
  8254. AscWriteLramByte(iop_base,
  8255. (ushort)(halt_q_addr +
  8256. (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
  8257. tag_code = AscReadLramByte(iop_base,
  8258. (ushort)(halt_q_addr + (ushort)
  8259. ASC_SCSIQ_B_TAG_CODE));
  8260. tag_code &= 0xDC;
  8261. if ((asc_dvc->pci_fix_asyn_xfer & target_id)
  8262. && !(asc_dvc->pci_fix_asyn_xfer_always & target_id)
  8263. ) {
  8264. tag_code |= (ASC_TAG_FLAG_DISABLE_DISCONNECT
  8265. | ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX);
  8266. }
  8267. AscWriteLramByte(iop_base,
  8268. (ushort)(halt_q_addr +
  8269. (ushort)ASC_SCSIQ_B_TAG_CODE),
  8270. tag_code);
  8271. q_status = AscReadLramByte(iop_base,
  8272. (ushort)(halt_q_addr + (ushort)
  8273. ASC_SCSIQ_B_STATUS));
  8274. q_status |= (QS_READY | QS_BUSY);
  8275. AscWriteLramByte(iop_base,
  8276. (ushort)(halt_q_addr +
  8277. (ushort)ASC_SCSIQ_B_STATUS),
  8278. q_status);
  8279. scsi_busy = AscReadLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B);
  8280. scsi_busy &= ~target_id;
  8281. AscWriteLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B, scsi_busy);
  8282. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8283. return (0);
  8284. } else if (int_halt_code == ASC_HALT_SDTR_REJECTED) {
  8285. AscMemWordCopyPtrFromLram(iop_base,
  8286. ASCV_MSGOUT_BEG,
  8287. (uchar *)&out_msg,
  8288. sizeof(EXT_MSG) >> 1);
  8289. if ((out_msg.msg_type == EXTENDED_MESSAGE) &&
  8290. (out_msg.msg_len == MS_SDTR_LEN) &&
  8291. (out_msg.msg_req == EXTENDED_SDTR)) {
  8292. asc_dvc->init_sdtr &= ~target_id;
  8293. asc_dvc->sdtr_done &= ~target_id;
  8294. AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
  8295. boardp->sdtr_data[tid_no] = asyn_sdtr;
  8296. }
  8297. q_cntl &= ~QC_MSG_OUT;
  8298. AscWriteLramByte(iop_base,
  8299. (ushort)(halt_q_addr +
  8300. (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
  8301. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8302. return (0);
  8303. } else if (int_halt_code == ASC_HALT_SS_QUEUE_FULL) {
  8304. scsi_status = AscReadLramByte(iop_base,
  8305. (ushort)((ushort)halt_q_addr +
  8306. (ushort)
  8307. ASC_SCSIQ_SCSI_STATUS));
  8308. cur_dvc_qng =
  8309. AscReadLramByte(iop_base,
  8310. (ushort)((ushort)ASC_QADR_BEG +
  8311. (ushort)target_ix));
  8312. if ((cur_dvc_qng > 0) && (asc_dvc->cur_dvc_qng[tid_no] > 0)) {
  8313. scsi_busy = AscReadLramByte(iop_base,
  8314. (ushort)ASCV_SCSIBUSY_B);
  8315. scsi_busy |= target_id;
  8316. AscWriteLramByte(iop_base,
  8317. (ushort)ASCV_SCSIBUSY_B, scsi_busy);
  8318. asc_dvc->queue_full_or_busy |= target_id;
  8319. if (scsi_status == SAM_STAT_TASK_SET_FULL) {
  8320. if (cur_dvc_qng > ASC_MIN_TAGGED_CMD) {
  8321. cur_dvc_qng -= 1;
  8322. asc_dvc->max_dvc_qng[tid_no] =
  8323. cur_dvc_qng;
  8324. AscWriteLramByte(iop_base,
  8325. (ushort)((ushort)
  8326. ASCV_MAX_DVC_QNG_BEG
  8327. + (ushort)
  8328. tid_no),
  8329. cur_dvc_qng);
  8330. /*
  8331. * Set the device queue depth to the
  8332. * number of active requests when the
  8333. * QUEUE FULL condition was encountered.
  8334. */
  8335. boardp->queue_full |= target_id;
  8336. boardp->queue_full_cnt[tid_no] =
  8337. cur_dvc_qng;
  8338. }
  8339. }
  8340. }
  8341. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8342. return (0);
  8343. }
  8344. #if CC_VERY_LONG_SG_LIST
  8345. else if (int_halt_code == ASC_HALT_HOST_COPY_SG_LIST_TO_RISC) {
  8346. uchar q_no;
  8347. ushort q_addr;
  8348. uchar sg_wk_q_no;
  8349. uchar first_sg_wk_q_no;
  8350. ASC_SCSI_Q *scsiq; /* Ptr to driver request. */
  8351. ASC_SG_HEAD *sg_head; /* Ptr to driver SG request. */
  8352. ASC_SG_LIST_Q scsi_sg_q; /* Structure written to queue. */
  8353. ushort sg_list_dwords;
  8354. ushort sg_entry_cnt;
  8355. uchar next_qp;
  8356. int i;
  8357. q_no = AscReadLramByte(iop_base, (ushort)ASCV_REQ_SG_LIST_QP);
  8358. if (q_no == ASC_QLINK_END)
  8359. return 0;
  8360. q_addr = ASC_QNO_TO_QADDR(q_no);
  8361. /*
  8362. * Convert the request's SRB pointer to a host ASC_SCSI_REQ
  8363. * structure pointer using a macro provided by the driver.
  8364. * The ASC_SCSI_REQ pointer provides a pointer to the
  8365. * host ASC_SG_HEAD structure.
  8366. */
  8367. /* Read request's SRB pointer. */
  8368. scsiq = (ASC_SCSI_Q *)
  8369. ASC_SRB2SCSIQ(ASC_U32_TO_VADDR(AscReadLramDWord(iop_base,
  8370. (ushort)
  8371. (q_addr +
  8372. ASC_SCSIQ_D_SRBPTR))));
  8373. /*
  8374. * Get request's first and working SG queue.
  8375. */
  8376. sg_wk_q_no = AscReadLramByte(iop_base,
  8377. (ushort)(q_addr +
  8378. ASC_SCSIQ_B_SG_WK_QP));
  8379. first_sg_wk_q_no = AscReadLramByte(iop_base,
  8380. (ushort)(q_addr +
  8381. ASC_SCSIQ_B_FIRST_SG_WK_QP));
  8382. /*
  8383. * Reset request's working SG queue back to the
  8384. * first SG queue.
  8385. */
  8386. AscWriteLramByte(iop_base,
  8387. (ushort)(q_addr +
  8388. (ushort)ASC_SCSIQ_B_SG_WK_QP),
  8389. first_sg_wk_q_no);
  8390. sg_head = scsiq->sg_head;
  8391. /*
  8392. * Set sg_entry_cnt to the number of SG elements
  8393. * that will be completed on this interrupt.
  8394. *
  8395. * Note: The allocated SG queues contain ASC_MAX_SG_LIST - 1
  8396. * SG elements. The data_cnt and data_addr fields which
  8397. * add 1 to the SG element capacity are not used when
  8398. * restarting SG handling after a halt.
  8399. */
  8400. if (scsiq->remain_sg_entry_cnt > (ASC_MAX_SG_LIST - 1)) {
  8401. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  8402. /*
  8403. * Keep track of remaining number of SG elements that
  8404. * will need to be handled on the next interrupt.
  8405. */
  8406. scsiq->remain_sg_entry_cnt -= (ASC_MAX_SG_LIST - 1);
  8407. } else {
  8408. sg_entry_cnt = scsiq->remain_sg_entry_cnt;
  8409. scsiq->remain_sg_entry_cnt = 0;
  8410. }
  8411. /*
  8412. * Copy SG elements into the list of allocated SG queues.
  8413. *
  8414. * Last index completed is saved in scsiq->next_sg_index.
  8415. */
  8416. next_qp = first_sg_wk_q_no;
  8417. q_addr = ASC_QNO_TO_QADDR(next_qp);
  8418. scsi_sg_q.sg_head_qp = q_no;
  8419. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  8420. for (i = 0; i < sg_head->queue_cnt; i++) {
  8421. scsi_sg_q.seq_no = i + 1;
  8422. if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
  8423. sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
  8424. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  8425. /*
  8426. * After very first SG queue RISC FW uses next
  8427. * SG queue first element then checks sg_list_cnt
  8428. * against zero and then decrements, so set
  8429. * sg_list_cnt 1 less than number of SG elements
  8430. * in each SG queue.
  8431. */
  8432. scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q - 1;
  8433. scsi_sg_q.sg_cur_list_cnt =
  8434. ASC_SG_LIST_PER_Q - 1;
  8435. } else {
  8436. /*
  8437. * This is the last SG queue in the list of
  8438. * allocated SG queues. If there are more
  8439. * SG elements than will fit in the allocated
  8440. * queues, then set the QCSG_SG_XFER_MORE flag.
  8441. */
  8442. if (scsiq->remain_sg_entry_cnt != 0) {
  8443. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  8444. } else {
  8445. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  8446. }
  8447. /* equals sg_entry_cnt * 2 */
  8448. sg_list_dwords = sg_entry_cnt << 1;
  8449. scsi_sg_q.sg_list_cnt = sg_entry_cnt - 1;
  8450. scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt - 1;
  8451. sg_entry_cnt = 0;
  8452. }
  8453. scsi_sg_q.q_no = next_qp;
  8454. AscMemWordCopyPtrToLram(iop_base,
  8455. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  8456. (uchar *)&scsi_sg_q,
  8457. sizeof(ASC_SG_LIST_Q) >> 1);
  8458. AscMemDWordCopyPtrToLram(iop_base,
  8459. q_addr + ASC_SGQ_LIST_BEG,
  8460. (uchar *)&sg_head->
  8461. sg_list[scsiq->next_sg_index],
  8462. sg_list_dwords);
  8463. scsiq->next_sg_index += ASC_SG_LIST_PER_Q;
  8464. /*
  8465. * If the just completed SG queue contained the
  8466. * last SG element, then no more SG queues need
  8467. * to be written.
  8468. */
  8469. if (scsi_sg_q.cntl & QCSG_SG_XFER_END) {
  8470. break;
  8471. }
  8472. next_qp = AscReadLramByte(iop_base,
  8473. (ushort)(q_addr +
  8474. ASC_SCSIQ_B_FWD));
  8475. q_addr = ASC_QNO_TO_QADDR(next_qp);
  8476. }
  8477. /*
  8478. * Clear the halt condition so the RISC will be restarted
  8479. * after the return.
  8480. */
  8481. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
  8482. return (0);
  8483. }
  8484. #endif /* CC_VERY_LONG_SG_LIST */
  8485. return (0);
  8486. }
  8487. /*
  8488. * void
  8489. * DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  8490. *
  8491. * Calling/Exit State:
  8492. * none
  8493. *
  8494. * Description:
  8495. * Input an ASC_QDONE_INFO structure from the chip
  8496. */
  8497. static void
  8498. DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
  8499. {
  8500. int i;
  8501. ushort word;
  8502. AscSetChipLramAddr(iop_base, s_addr);
  8503. for (i = 0; i < 2 * words; i += 2) {
  8504. if (i == 10) {
  8505. continue;
  8506. }
  8507. word = inpw(iop_base + IOP_RAM_DATA);
  8508. inbuf[i] = word & 0xff;
  8509. inbuf[i + 1] = (word >> 8) & 0xff;
  8510. }
  8511. ASC_DBG_PRT_HEX(2, "DvcGetQinfo", inbuf, 2 * words);
  8512. }
  8513. static uchar
  8514. _AscCopyLramScsiDoneQ(PortAddr iop_base,
  8515. ushort q_addr,
  8516. ASC_QDONE_INFO *scsiq, ASC_DCNT max_dma_count)
  8517. {
  8518. ushort _val;
  8519. uchar sg_queue_cnt;
  8520. DvcGetQinfo(iop_base,
  8521. q_addr + ASC_SCSIQ_DONE_INFO_BEG,
  8522. (uchar *)scsiq,
  8523. (sizeof(ASC_SCSIQ_2) + sizeof(ASC_SCSIQ_3)) / 2);
  8524. _val = AscReadLramWord(iop_base,
  8525. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS));
  8526. scsiq->q_status = (uchar)_val;
  8527. scsiq->q_no = (uchar)(_val >> 8);
  8528. _val = AscReadLramWord(iop_base,
  8529. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_CNTL));
  8530. scsiq->cntl = (uchar)_val;
  8531. sg_queue_cnt = (uchar)(_val >> 8);
  8532. _val = AscReadLramWord(iop_base,
  8533. (ushort)(q_addr +
  8534. (ushort)ASC_SCSIQ_B_SENSE_LEN));
  8535. scsiq->sense_len = (uchar)_val;
  8536. scsiq->extra_bytes = (uchar)(_val >> 8);
  8537. /*
  8538. * Read high word of remain bytes from alternate location.
  8539. */
  8540. scsiq->remain_bytes = (((ADV_DCNT)AscReadLramWord(iop_base,
  8541. (ushort)(q_addr +
  8542. (ushort)
  8543. ASC_SCSIQ_W_ALT_DC1)))
  8544. << 16);
  8545. /*
  8546. * Read low word of remain bytes from original location.
  8547. */
  8548. scsiq->remain_bytes += AscReadLramWord(iop_base,
  8549. (ushort)(q_addr + (ushort)
  8550. ASC_SCSIQ_DW_REMAIN_XFER_CNT));
  8551. scsiq->remain_bytes &= max_dma_count;
  8552. return sg_queue_cnt;
  8553. }
  8554. /*
  8555. * asc_isr_callback() - Second Level Interrupt Handler called by AscISR().
  8556. *
  8557. * Interrupt callback function for the Narrow SCSI Asc Library.
  8558. */
  8559. static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
  8560. {
  8561. asc_board_t *boardp;
  8562. struct scsi_cmnd *scp;
  8563. struct Scsi_Host *shost;
  8564. ASC_DBG2(1, "asc_isr_callback: asc_dvc_varp 0x%lx, qdonep 0x%lx\n",
  8565. (ulong)asc_dvc_varp, (ulong)qdonep);
  8566. ASC_DBG_PRT_ASC_QDONE_INFO(2, qdonep);
  8567. /*
  8568. * Get the struct scsi_cmnd structure and Scsi_Host structure for the
  8569. * command that has been completed.
  8570. */
  8571. scp = (struct scsi_cmnd *)ASC_U32_TO_VADDR(qdonep->d2.srb_ptr);
  8572. ASC_DBG1(1, "asc_isr_callback: scp 0x%lx\n", (ulong)scp);
  8573. if (scp == NULL) {
  8574. ASC_PRINT("asc_isr_callback: scp is NULL\n");
  8575. return;
  8576. }
  8577. ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
  8578. shost = scp->device->host;
  8579. ASC_STATS(shost, callback);
  8580. ASC_DBG1(1, "asc_isr_callback: shost 0x%lx\n", (ulong)shost);
  8581. boardp = ASC_BOARDP(shost);
  8582. BUG_ON(asc_dvc_varp != &boardp->dvc_var.asc_dvc_var);
  8583. /*
  8584. * 'qdonep' contains the command's ending status.
  8585. */
  8586. switch (qdonep->d3.done_stat) {
  8587. case QD_NO_ERROR:
  8588. ASC_DBG(2, "asc_isr_callback: QD_NO_ERROR\n");
  8589. scp->result = 0;
  8590. /*
  8591. * Check for an underrun condition.
  8592. *
  8593. * If there was no error and an underrun condition, then
  8594. * return the number of underrun bytes.
  8595. */
  8596. if (scp->request_bufflen != 0 && qdonep->remain_bytes != 0 &&
  8597. qdonep->remain_bytes <= scp->request_bufflen) {
  8598. ASC_DBG1(1,
  8599. "asc_isr_callback: underrun condition %u bytes\n",
  8600. (unsigned)qdonep->remain_bytes);
  8601. scp->resid = qdonep->remain_bytes;
  8602. }
  8603. break;
  8604. case QD_WITH_ERROR:
  8605. ASC_DBG(2, "asc_isr_callback: QD_WITH_ERROR\n");
  8606. switch (qdonep->d3.host_stat) {
  8607. case QHSTA_NO_ERROR:
  8608. if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
  8609. ASC_DBG(2,
  8610. "asc_isr_callback: SAM_STAT_CHECK_CONDITION\n");
  8611. ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
  8612. sizeof(scp->sense_buffer));
  8613. /*
  8614. * Note: The 'status_byte()' macro used by
  8615. * target drivers defined in scsi.h shifts the
  8616. * status byte returned by host drivers right
  8617. * by 1 bit. This is why target drivers also
  8618. * use right shifted status byte definitions.
  8619. * For instance target drivers use
  8620. * CHECK_CONDITION, defined to 0x1, instead of
  8621. * the SCSI defined check condition value of
  8622. * 0x2. Host drivers are supposed to return
  8623. * the status byte as it is defined by SCSI.
  8624. */
  8625. scp->result = DRIVER_BYTE(DRIVER_SENSE) |
  8626. STATUS_BYTE(qdonep->d3.scsi_stat);
  8627. } else {
  8628. scp->result = STATUS_BYTE(qdonep->d3.scsi_stat);
  8629. }
  8630. break;
  8631. default:
  8632. /* QHSTA error occurred */
  8633. ASC_DBG1(1, "asc_isr_callback: host_stat 0x%x\n",
  8634. qdonep->d3.host_stat);
  8635. scp->result = HOST_BYTE(DID_BAD_TARGET);
  8636. break;
  8637. }
  8638. break;
  8639. case QD_ABORTED_BY_HOST:
  8640. ASC_DBG(1, "asc_isr_callback: QD_ABORTED_BY_HOST\n");
  8641. scp->result =
  8642. HOST_BYTE(DID_ABORT) | MSG_BYTE(qdonep->d3.
  8643. scsi_msg) |
  8644. STATUS_BYTE(qdonep->d3.scsi_stat);
  8645. break;
  8646. default:
  8647. ASC_DBG1(1, "asc_isr_callback: done_stat 0x%x\n",
  8648. qdonep->d3.done_stat);
  8649. scp->result =
  8650. HOST_BYTE(DID_ERROR) | MSG_BYTE(qdonep->d3.
  8651. scsi_msg) |
  8652. STATUS_BYTE(qdonep->d3.scsi_stat);
  8653. break;
  8654. }
  8655. /*
  8656. * If the 'init_tidmask' bit isn't already set for the target and the
  8657. * current request finished normally, then set the bit for the target
  8658. * to indicate that a device is present.
  8659. */
  8660. if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
  8661. qdonep->d3.done_stat == QD_NO_ERROR &&
  8662. qdonep->d3.host_stat == QHSTA_NO_ERROR) {
  8663. boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
  8664. }
  8665. asc_scsi_done(scp);
  8666. return;
  8667. }
  8668. static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
  8669. {
  8670. uchar next_qp;
  8671. uchar n_q_used;
  8672. uchar sg_list_qp;
  8673. uchar sg_queue_cnt;
  8674. uchar q_cnt;
  8675. uchar done_q_tail;
  8676. uchar tid_no;
  8677. ASC_SCSI_BIT_ID_TYPE scsi_busy;
  8678. ASC_SCSI_BIT_ID_TYPE target_id;
  8679. PortAddr iop_base;
  8680. ushort q_addr;
  8681. ushort sg_q_addr;
  8682. uchar cur_target_qng;
  8683. ASC_QDONE_INFO scsiq_buf;
  8684. ASC_QDONE_INFO *scsiq;
  8685. int false_overrun;
  8686. iop_base = asc_dvc->iop_base;
  8687. n_q_used = 1;
  8688. scsiq = (ASC_QDONE_INFO *)&scsiq_buf;
  8689. done_q_tail = (uchar)AscGetVarDoneQTail(iop_base);
  8690. q_addr = ASC_QNO_TO_QADDR(done_q_tail);
  8691. next_qp = AscReadLramByte(iop_base,
  8692. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_FWD));
  8693. if (next_qp != ASC_QLINK_END) {
  8694. AscPutVarDoneQTail(iop_base, next_qp);
  8695. q_addr = ASC_QNO_TO_QADDR(next_qp);
  8696. sg_queue_cnt = _AscCopyLramScsiDoneQ(iop_base, q_addr, scsiq,
  8697. asc_dvc->max_dma_count);
  8698. AscWriteLramByte(iop_base,
  8699. (ushort)(q_addr +
  8700. (ushort)ASC_SCSIQ_B_STATUS),
  8701. (uchar)(scsiq->
  8702. q_status & (uchar)~(QS_READY |
  8703. QS_ABORTED)));
  8704. tid_no = ASC_TIX_TO_TID(scsiq->d2.target_ix);
  8705. target_id = ASC_TIX_TO_TARGET_ID(scsiq->d2.target_ix);
  8706. if ((scsiq->cntl & QC_SG_HEAD) != 0) {
  8707. sg_q_addr = q_addr;
  8708. sg_list_qp = next_qp;
  8709. for (q_cnt = 0; q_cnt < sg_queue_cnt; q_cnt++) {
  8710. sg_list_qp = AscReadLramByte(iop_base,
  8711. (ushort)(sg_q_addr
  8712. + (ushort)
  8713. ASC_SCSIQ_B_FWD));
  8714. sg_q_addr = ASC_QNO_TO_QADDR(sg_list_qp);
  8715. if (sg_list_qp == ASC_QLINK_END) {
  8716. AscSetLibErrorCode(asc_dvc,
  8717. ASCQ_ERR_SG_Q_LINKS);
  8718. scsiq->d3.done_stat = QD_WITH_ERROR;
  8719. scsiq->d3.host_stat =
  8720. QHSTA_D_QDONE_SG_LIST_CORRUPTED;
  8721. goto FATAL_ERR_QDONE;
  8722. }
  8723. AscWriteLramByte(iop_base,
  8724. (ushort)(sg_q_addr + (ushort)
  8725. ASC_SCSIQ_B_STATUS),
  8726. QS_FREE);
  8727. }
  8728. n_q_used = sg_queue_cnt + 1;
  8729. AscPutVarDoneQTail(iop_base, sg_list_qp);
  8730. }
  8731. if (asc_dvc->queue_full_or_busy & target_id) {
  8732. cur_target_qng = AscReadLramByte(iop_base,
  8733. (ushort)((ushort)
  8734. ASC_QADR_BEG
  8735. + (ushort)
  8736. scsiq->d2.
  8737. target_ix));
  8738. if (cur_target_qng < asc_dvc->max_dvc_qng[tid_no]) {
  8739. scsi_busy = AscReadLramByte(iop_base, (ushort)
  8740. ASCV_SCSIBUSY_B);
  8741. scsi_busy &= ~target_id;
  8742. AscWriteLramByte(iop_base,
  8743. (ushort)ASCV_SCSIBUSY_B,
  8744. scsi_busy);
  8745. asc_dvc->queue_full_or_busy &= ~target_id;
  8746. }
  8747. }
  8748. if (asc_dvc->cur_total_qng >= n_q_used) {
  8749. asc_dvc->cur_total_qng -= n_q_used;
  8750. if (asc_dvc->cur_dvc_qng[tid_no] != 0) {
  8751. asc_dvc->cur_dvc_qng[tid_no]--;
  8752. }
  8753. } else {
  8754. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CUR_QNG);
  8755. scsiq->d3.done_stat = QD_WITH_ERROR;
  8756. goto FATAL_ERR_QDONE;
  8757. }
  8758. if ((scsiq->d2.srb_ptr == 0UL) ||
  8759. ((scsiq->q_status & QS_ABORTED) != 0)) {
  8760. return (0x11);
  8761. } else if (scsiq->q_status == QS_DONE) {
  8762. false_overrun = FALSE;
  8763. if (scsiq->extra_bytes != 0) {
  8764. scsiq->remain_bytes +=
  8765. (ADV_DCNT)scsiq->extra_bytes;
  8766. }
  8767. if (scsiq->d3.done_stat == QD_WITH_ERROR) {
  8768. if (scsiq->d3.host_stat ==
  8769. QHSTA_M_DATA_OVER_RUN) {
  8770. if ((scsiq->
  8771. cntl & (QC_DATA_IN | QC_DATA_OUT))
  8772. == 0) {
  8773. scsiq->d3.done_stat =
  8774. QD_NO_ERROR;
  8775. scsiq->d3.host_stat =
  8776. QHSTA_NO_ERROR;
  8777. } else if (false_overrun) {
  8778. scsiq->d3.done_stat =
  8779. QD_NO_ERROR;
  8780. scsiq->d3.host_stat =
  8781. QHSTA_NO_ERROR;
  8782. }
  8783. } else if (scsiq->d3.host_stat ==
  8784. QHSTA_M_HUNG_REQ_SCSI_BUS_RESET) {
  8785. AscStopChip(iop_base);
  8786. AscSetChipControl(iop_base,
  8787. (uchar)(CC_SCSI_RESET
  8788. | CC_HALT));
  8789. udelay(60);
  8790. AscSetChipControl(iop_base, CC_HALT);
  8791. AscSetChipStatus(iop_base,
  8792. CIW_CLR_SCSI_RESET_INT);
  8793. AscSetChipStatus(iop_base, 0);
  8794. AscSetChipControl(iop_base, 0);
  8795. }
  8796. }
  8797. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  8798. asc_isr_callback(asc_dvc, scsiq);
  8799. } else {
  8800. if ((AscReadLramByte(iop_base,
  8801. (ushort)(q_addr + (ushort)
  8802. ASC_SCSIQ_CDB_BEG))
  8803. == START_STOP)) {
  8804. asc_dvc->unit_not_ready &= ~target_id;
  8805. if (scsiq->d3.done_stat != QD_NO_ERROR) {
  8806. asc_dvc->start_motor &=
  8807. ~target_id;
  8808. }
  8809. }
  8810. }
  8811. return (1);
  8812. } else {
  8813. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_Q_STATUS);
  8814. FATAL_ERR_QDONE:
  8815. if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
  8816. asc_isr_callback(asc_dvc, scsiq);
  8817. }
  8818. return (0x80);
  8819. }
  8820. }
  8821. return (0);
  8822. }
  8823. static int AscISR(ASC_DVC_VAR *asc_dvc)
  8824. {
  8825. ASC_CS_TYPE chipstat;
  8826. PortAddr iop_base;
  8827. ushort saved_ram_addr;
  8828. uchar ctrl_reg;
  8829. uchar saved_ctrl_reg;
  8830. int int_pending;
  8831. int status;
  8832. uchar host_flag;
  8833. iop_base = asc_dvc->iop_base;
  8834. int_pending = FALSE;
  8835. if (AscIsIntPending(iop_base) == 0)
  8836. return int_pending;
  8837. if ((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0) {
  8838. return ERR;
  8839. }
  8840. if (asc_dvc->in_critical_cnt != 0) {
  8841. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_ON_CRITICAL);
  8842. return ERR;
  8843. }
  8844. if (asc_dvc->is_in_int) {
  8845. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_RE_ENTRY);
  8846. return ERR;
  8847. }
  8848. asc_dvc->is_in_int = TRUE;
  8849. ctrl_reg = AscGetChipControl(iop_base);
  8850. saved_ctrl_reg = ctrl_reg & (~(CC_SCSI_RESET | CC_CHIP_RESET |
  8851. CC_SINGLE_STEP | CC_DIAG | CC_TEST));
  8852. chipstat = AscGetChipStatus(iop_base);
  8853. if (chipstat & CSW_SCSI_RESET_LATCH) {
  8854. if (!(asc_dvc->bus_type & (ASC_IS_VL | ASC_IS_EISA))) {
  8855. int i = 10;
  8856. int_pending = TRUE;
  8857. asc_dvc->sdtr_done = 0;
  8858. saved_ctrl_reg &= (uchar)(~CC_HALT);
  8859. while ((AscGetChipStatus(iop_base) &
  8860. CSW_SCSI_RESET_ACTIVE) && (i-- > 0)) {
  8861. mdelay(100);
  8862. }
  8863. AscSetChipControl(iop_base, (CC_CHIP_RESET | CC_HALT));
  8864. AscSetChipControl(iop_base, CC_HALT);
  8865. AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
  8866. AscSetChipStatus(iop_base, 0);
  8867. chipstat = AscGetChipStatus(iop_base);
  8868. }
  8869. }
  8870. saved_ram_addr = AscGetChipLramAddr(iop_base);
  8871. host_flag = AscReadLramByte(iop_base,
  8872. ASCV_HOST_FLAG_B) &
  8873. (uchar)(~ASC_HOST_FLAG_IN_ISR);
  8874. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
  8875. (uchar)(host_flag | (uchar)ASC_HOST_FLAG_IN_ISR));
  8876. if ((chipstat & CSW_INT_PENDING) || (int_pending)) {
  8877. AscAckInterrupt(iop_base);
  8878. int_pending = TRUE;
  8879. if ((chipstat & CSW_HALTED) && (ctrl_reg & CC_SINGLE_STEP)) {
  8880. if (AscIsrChipHalted(asc_dvc) == ERR) {
  8881. goto ISR_REPORT_QDONE_FATAL_ERROR;
  8882. } else {
  8883. saved_ctrl_reg &= (uchar)(~CC_HALT);
  8884. }
  8885. } else {
  8886. ISR_REPORT_QDONE_FATAL_ERROR:
  8887. if ((asc_dvc->dvc_cntl & ASC_CNTL_INT_MULTI_Q) != 0) {
  8888. while (((status =
  8889. AscIsrQDone(asc_dvc)) & 0x01) != 0) {
  8890. }
  8891. } else {
  8892. do {
  8893. if ((status =
  8894. AscIsrQDone(asc_dvc)) == 1) {
  8895. break;
  8896. }
  8897. } while (status == 0x11);
  8898. }
  8899. if ((status & 0x80) != 0)
  8900. int_pending = ERR;
  8901. }
  8902. }
  8903. AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
  8904. AscSetChipLramAddr(iop_base, saved_ram_addr);
  8905. AscSetChipControl(iop_base, saved_ctrl_reg);
  8906. asc_dvc->is_in_int = FALSE;
  8907. return int_pending;
  8908. }
  8909. /*
  8910. * advansys_reset()
  8911. *
  8912. * Reset the bus associated with the command 'scp'.
  8913. *
  8914. * This function runs its own thread. Interrupts must be blocked but
  8915. * sleeping is allowed and no locking other than for host structures is
  8916. * required. Returns SUCCESS or FAILED.
  8917. */
  8918. static int advansys_reset(struct scsi_cmnd *scp)
  8919. {
  8920. struct Scsi_Host *shost = scp->device->host;
  8921. struct asc_board *boardp = ASC_BOARDP(shost);
  8922. unsigned long flags;
  8923. int status;
  8924. int ret = SUCCESS;
  8925. ASC_DBG1(1, "advansys_reset: 0x%p\n", scp);
  8926. ASC_STATS(shost, reset);
  8927. scmd_printk(KERN_INFO, scp, "SCSI bus reset started...\n");
  8928. if (ASC_NARROW_BOARD(boardp)) {
  8929. ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  8930. /* Reset the chip and SCSI bus. */
  8931. ASC_DBG(1, "advansys_reset: before AscInitAsc1000Driver()\n");
  8932. status = AscInitAsc1000Driver(asc_dvc);
  8933. /* Refer to ASC_IERR_* defintions for meaning of 'err_code'. */
  8934. if (asc_dvc->err_code) {
  8935. scmd_printk(KERN_INFO, scp, "SCSI bus reset error: "
  8936. "0x%x\n", asc_dvc->err_code);
  8937. ret = FAILED;
  8938. } else if (status) {
  8939. scmd_printk(KERN_INFO, scp, "SCSI bus reset warning: "
  8940. "0x%x\n", status);
  8941. } else {
  8942. scmd_printk(KERN_INFO, scp, "SCSI bus reset "
  8943. "successful\n");
  8944. }
  8945. ASC_DBG(1, "advansys_reset: after AscInitAsc1000Driver()\n");
  8946. spin_lock_irqsave(&boardp->lock, flags);
  8947. } else {
  8948. /*
  8949. * If the suggest reset bus flags are set, then reset the bus.
  8950. * Otherwise only reset the device.
  8951. */
  8952. ADV_DVC_VAR *adv_dvc = &boardp->dvc_var.adv_dvc_var;
  8953. /*
  8954. * Reset the target's SCSI bus.
  8955. */
  8956. ASC_DBG(1, "advansys_reset: before AdvResetChipAndSB()\n");
  8957. switch (AdvResetChipAndSB(adv_dvc)) {
  8958. case ASC_TRUE:
  8959. scmd_printk(KERN_INFO, scp, "SCSI bus reset "
  8960. "successful\n");
  8961. break;
  8962. case ASC_FALSE:
  8963. default:
  8964. scmd_printk(KERN_INFO, scp, "SCSI bus reset error\n");
  8965. ret = FAILED;
  8966. break;
  8967. }
  8968. spin_lock_irqsave(&boardp->lock, flags);
  8969. AdvISR(adv_dvc);
  8970. }
  8971. /* Save the time of the most recently completed reset. */
  8972. boardp->last_reset = jiffies;
  8973. spin_unlock_irqrestore(&boardp->lock, flags);
  8974. ASC_DBG1(1, "advansys_reset: ret %d\n", ret);
  8975. return ret;
  8976. }
  8977. /*
  8978. * advansys_biosparam()
  8979. *
  8980. * Translate disk drive geometry if the "BIOS greater than 1 GB"
  8981. * support is enabled for a drive.
  8982. *
  8983. * ip (information pointer) is an int array with the following definition:
  8984. * ip[0]: heads
  8985. * ip[1]: sectors
  8986. * ip[2]: cylinders
  8987. */
  8988. static int
  8989. advansys_biosparam(struct scsi_device *sdev, struct block_device *bdev,
  8990. sector_t capacity, int ip[])
  8991. {
  8992. asc_board_t *boardp;
  8993. ASC_DBG(1, "advansys_biosparam: begin\n");
  8994. ASC_STATS(sdev->host, biosparam);
  8995. boardp = ASC_BOARDP(sdev->host);
  8996. if (ASC_NARROW_BOARD(boardp)) {
  8997. if ((boardp->dvc_var.asc_dvc_var.dvc_cntl &
  8998. ASC_CNTL_BIOS_GT_1GB) && capacity > 0x200000) {
  8999. ip[0] = 255;
  9000. ip[1] = 63;
  9001. } else {
  9002. ip[0] = 64;
  9003. ip[1] = 32;
  9004. }
  9005. } else {
  9006. if ((boardp->dvc_var.adv_dvc_var.bios_ctrl &
  9007. BIOS_CTRL_EXTENDED_XLAT) && capacity > 0x200000) {
  9008. ip[0] = 255;
  9009. ip[1] = 63;
  9010. } else {
  9011. ip[0] = 64;
  9012. ip[1] = 32;
  9013. }
  9014. }
  9015. ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
  9016. ASC_DBG(1, "advansys_biosparam: end\n");
  9017. return 0;
  9018. }
  9019. /*
  9020. * First-level interrupt handler.
  9021. *
  9022. * 'dev_id' is a pointer to the interrupting adapter's Scsi_Host.
  9023. */
  9024. static irqreturn_t advansys_interrupt(int irq, void *dev_id)
  9025. {
  9026. unsigned long flags;
  9027. struct Scsi_Host *shost = dev_id;
  9028. asc_board_t *boardp = ASC_BOARDP(shost);
  9029. irqreturn_t result = IRQ_NONE;
  9030. ASC_DBG1(2, "advansys_interrupt: boardp 0x%p\n", boardp);
  9031. spin_lock_irqsave(&boardp->lock, flags);
  9032. if (ASC_NARROW_BOARD(boardp)) {
  9033. if (AscIsIntPending(shost->io_port)) {
  9034. result = IRQ_HANDLED;
  9035. ASC_STATS(shost, interrupt);
  9036. ASC_DBG(1, "advansys_interrupt: before AscISR()\n");
  9037. AscISR(&boardp->dvc_var.asc_dvc_var);
  9038. }
  9039. } else {
  9040. ASC_DBG(1, "advansys_interrupt: before AdvISR()\n");
  9041. if (AdvISR(&boardp->dvc_var.adv_dvc_var)) {
  9042. result = IRQ_HANDLED;
  9043. ASC_STATS(shost, interrupt);
  9044. }
  9045. }
  9046. spin_unlock_irqrestore(&boardp->lock, flags);
  9047. ASC_DBG(1, "advansys_interrupt: end\n");
  9048. return result;
  9049. }
  9050. static int AscHostReqRiscHalt(PortAddr iop_base)
  9051. {
  9052. int count = 0;
  9053. int sta = 0;
  9054. uchar saved_stop_code;
  9055. if (AscIsChipHalted(iop_base))
  9056. return (1);
  9057. saved_stop_code = AscReadLramByte(iop_base, ASCV_STOP_CODE_B);
  9058. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  9059. ASC_STOP_HOST_REQ_RISC_HALT | ASC_STOP_REQ_RISC_STOP);
  9060. do {
  9061. if (AscIsChipHalted(iop_base)) {
  9062. sta = 1;
  9063. break;
  9064. }
  9065. mdelay(100);
  9066. } while (count++ < 20);
  9067. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, saved_stop_code);
  9068. return (sta);
  9069. }
  9070. static int
  9071. AscSetRunChipSynRegAtID(PortAddr iop_base, uchar tid_no, uchar sdtr_data)
  9072. {
  9073. int sta = FALSE;
  9074. if (AscHostReqRiscHalt(iop_base)) {
  9075. sta = AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
  9076. AscStartChip(iop_base);
  9077. }
  9078. return sta;
  9079. }
  9080. static void AscAsyncFix(ASC_DVC_VAR *asc_dvc, struct scsi_device *sdev)
  9081. {
  9082. char type = sdev->type;
  9083. ASC_SCSI_BIT_ID_TYPE tid_bits = 1 << sdev->id;
  9084. if (!(asc_dvc->bug_fix_cntl & ASC_BUG_FIX_ASYN_USE_SYN))
  9085. return;
  9086. if (asc_dvc->init_sdtr & tid_bits)
  9087. return;
  9088. if ((type == TYPE_ROM) && (strncmp(sdev->vendor, "HP ", 3) == 0))
  9089. asc_dvc->pci_fix_asyn_xfer_always |= tid_bits;
  9090. asc_dvc->pci_fix_asyn_xfer |= tid_bits;
  9091. if ((type == TYPE_PROCESSOR) || (type == TYPE_SCANNER) ||
  9092. (type == TYPE_ROM) || (type == TYPE_TAPE))
  9093. asc_dvc->pci_fix_asyn_xfer &= ~tid_bits;
  9094. if (asc_dvc->pci_fix_asyn_xfer & tid_bits)
  9095. AscSetRunChipSynRegAtID(asc_dvc->iop_base, sdev->id,
  9096. ASYN_SDTR_DATA_FIX_PCI_REV_AB);
  9097. }
  9098. static void
  9099. advansys_narrow_slave_configure(struct scsi_device *sdev, ASC_DVC_VAR *asc_dvc)
  9100. {
  9101. ASC_SCSI_BIT_ID_TYPE tid_bit = 1 << sdev->id;
  9102. ASC_SCSI_BIT_ID_TYPE orig_use_tagged_qng = asc_dvc->use_tagged_qng;
  9103. if (sdev->lun == 0) {
  9104. ASC_SCSI_BIT_ID_TYPE orig_init_sdtr = asc_dvc->init_sdtr;
  9105. if ((asc_dvc->cfg->sdtr_enable & tid_bit) && sdev->sdtr) {
  9106. asc_dvc->init_sdtr |= tid_bit;
  9107. } else {
  9108. asc_dvc->init_sdtr &= ~tid_bit;
  9109. }
  9110. if (orig_init_sdtr != asc_dvc->init_sdtr)
  9111. AscAsyncFix(asc_dvc, sdev);
  9112. }
  9113. if (sdev->tagged_supported) {
  9114. if (asc_dvc->cfg->cmd_qng_enabled & tid_bit) {
  9115. if (sdev->lun == 0) {
  9116. asc_dvc->cfg->can_tagged_qng |= tid_bit;
  9117. asc_dvc->use_tagged_qng |= tid_bit;
  9118. }
  9119. scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
  9120. asc_dvc->max_dvc_qng[sdev->id]);
  9121. }
  9122. } else {
  9123. if (sdev->lun == 0) {
  9124. asc_dvc->cfg->can_tagged_qng &= ~tid_bit;
  9125. asc_dvc->use_tagged_qng &= ~tid_bit;
  9126. }
  9127. scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
  9128. }
  9129. if ((sdev->lun == 0) &&
  9130. (orig_use_tagged_qng != asc_dvc->use_tagged_qng)) {
  9131. AscWriteLramByte(asc_dvc->iop_base, ASCV_DISC_ENABLE_B,
  9132. asc_dvc->cfg->disc_enable);
  9133. AscWriteLramByte(asc_dvc->iop_base, ASCV_USE_TAGGED_QNG_B,
  9134. asc_dvc->use_tagged_qng);
  9135. AscWriteLramByte(asc_dvc->iop_base, ASCV_CAN_TAGGED_QNG_B,
  9136. asc_dvc->cfg->can_tagged_qng);
  9137. asc_dvc->max_dvc_qng[sdev->id] =
  9138. asc_dvc->cfg->max_tag_qng[sdev->id];
  9139. AscWriteLramByte(asc_dvc->iop_base,
  9140. (ushort)(ASCV_MAX_DVC_QNG_BEG + sdev->id),
  9141. asc_dvc->max_dvc_qng[sdev->id]);
  9142. }
  9143. }
  9144. /*
  9145. * Wide Transfers
  9146. *
  9147. * If the EEPROM enabled WDTR for the device and the device supports wide
  9148. * bus (16 bit) transfers, then turn on the device's 'wdtr_able' bit and
  9149. * write the new value to the microcode.
  9150. */
  9151. static void
  9152. advansys_wide_enable_wdtr(AdvPortAddr iop_base, unsigned short tidmask)
  9153. {
  9154. unsigned short cfg_word;
  9155. AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
  9156. if ((cfg_word & tidmask) != 0)
  9157. return;
  9158. cfg_word |= tidmask;
  9159. AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
  9160. /*
  9161. * Clear the microcode SDTR and WDTR negotiation done indicators for
  9162. * the target to cause it to negotiate with the new setting set above.
  9163. * WDTR when accepted causes the target to enter asynchronous mode, so
  9164. * SDTR must be negotiated.
  9165. */
  9166. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  9167. cfg_word &= ~tidmask;
  9168. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  9169. AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
  9170. cfg_word &= ~tidmask;
  9171. AdvWriteWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word);
  9172. }
  9173. /*
  9174. * Synchronous Transfers
  9175. *
  9176. * If the EEPROM enabled SDTR for the device and the device
  9177. * supports synchronous transfers, then turn on the device's
  9178. * 'sdtr_able' bit. Write the new value to the microcode.
  9179. */
  9180. static void
  9181. advansys_wide_enable_sdtr(AdvPortAddr iop_base, unsigned short tidmask)
  9182. {
  9183. unsigned short cfg_word;
  9184. AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
  9185. if ((cfg_word & tidmask) != 0)
  9186. return;
  9187. cfg_word |= tidmask;
  9188. AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
  9189. /*
  9190. * Clear the microcode "SDTR negotiation" done indicator for the
  9191. * target to cause it to negotiate with the new setting set above.
  9192. */
  9193. AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  9194. cfg_word &= ~tidmask;
  9195. AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word);
  9196. }
  9197. /*
  9198. * PPR (Parallel Protocol Request) Capable
  9199. *
  9200. * If the device supports DT mode, then it must be PPR capable.
  9201. * The PPR message will be used in place of the SDTR and WDTR
  9202. * messages to negotiate synchronous speed and offset, transfer
  9203. * width, and protocol options.
  9204. */
  9205. static void advansys_wide_enable_ppr(ADV_DVC_VAR *adv_dvc,
  9206. AdvPortAddr iop_base, unsigned short tidmask)
  9207. {
  9208. AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
  9209. adv_dvc->ppr_able |= tidmask;
  9210. AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, adv_dvc->ppr_able);
  9211. }
  9212. static void
  9213. advansys_wide_slave_configure(struct scsi_device *sdev, ADV_DVC_VAR *adv_dvc)
  9214. {
  9215. AdvPortAddr iop_base = adv_dvc->iop_base;
  9216. unsigned short tidmask = 1 << sdev->id;
  9217. if (sdev->lun == 0) {
  9218. /*
  9219. * Handle WDTR, SDTR, and Tag Queuing. If the feature
  9220. * is enabled in the EEPROM and the device supports the
  9221. * feature, then enable it in the microcode.
  9222. */
  9223. if ((adv_dvc->wdtr_able & tidmask) && sdev->wdtr)
  9224. advansys_wide_enable_wdtr(iop_base, tidmask);
  9225. if ((adv_dvc->sdtr_able & tidmask) && sdev->sdtr)
  9226. advansys_wide_enable_sdtr(iop_base, tidmask);
  9227. if (adv_dvc->chip_type == ADV_CHIP_ASC38C1600 && sdev->ppr)
  9228. advansys_wide_enable_ppr(adv_dvc, iop_base, tidmask);
  9229. /*
  9230. * Tag Queuing is disabled for the BIOS which runs in polled
  9231. * mode and would see no benefit from Tag Queuing. Also by
  9232. * disabling Tag Queuing in the BIOS devices with Tag Queuing
  9233. * bugs will at least work with the BIOS.
  9234. */
  9235. if ((adv_dvc->tagqng_able & tidmask) &&
  9236. sdev->tagged_supported) {
  9237. unsigned short cfg_word;
  9238. AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, cfg_word);
  9239. cfg_word |= tidmask;
  9240. AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
  9241. cfg_word);
  9242. AdvWriteByteLram(iop_base,
  9243. ASC_MC_NUMBER_OF_MAX_CMD + sdev->id,
  9244. adv_dvc->max_dvc_qng);
  9245. }
  9246. }
  9247. if ((adv_dvc->tagqng_able & tidmask) && sdev->tagged_supported) {
  9248. scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
  9249. adv_dvc->max_dvc_qng);
  9250. } else {
  9251. scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
  9252. }
  9253. }
  9254. /*
  9255. * Set the number of commands to queue per device for the
  9256. * specified host adapter.
  9257. */
  9258. static int advansys_slave_configure(struct scsi_device *sdev)
  9259. {
  9260. asc_board_t *boardp = ASC_BOARDP(sdev->host);
  9261. if (ASC_NARROW_BOARD(boardp))
  9262. advansys_narrow_slave_configure(sdev,
  9263. &boardp->dvc_var.asc_dvc_var);
  9264. else
  9265. advansys_wide_slave_configure(sdev,
  9266. &boardp->dvc_var.adv_dvc_var);
  9267. return 0;
  9268. }
  9269. static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
  9270. struct asc_scsi_q *asc_scsi_q)
  9271. {
  9272. memset(asc_scsi_q, 0, sizeof(*asc_scsi_q));
  9273. /*
  9274. * Point the ASC_SCSI_Q to the 'struct scsi_cmnd'.
  9275. */
  9276. asc_scsi_q->q2.srb_ptr = ASC_VADDR_TO_U32(scp);
  9277. /*
  9278. * Build the ASC_SCSI_Q request.
  9279. */
  9280. asc_scsi_q->cdbptr = &scp->cmnd[0];
  9281. asc_scsi_q->q2.cdb_len = scp->cmd_len;
  9282. asc_scsi_q->q1.target_id = ASC_TID_TO_TARGET_ID(scp->device->id);
  9283. asc_scsi_q->q1.target_lun = scp->device->lun;
  9284. asc_scsi_q->q2.target_ix =
  9285. ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
  9286. asc_scsi_q->q1.sense_addr =
  9287. cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
  9288. asc_scsi_q->q1.sense_len = sizeof(scp->sense_buffer);
  9289. /*
  9290. * If there are any outstanding requests for the current target,
  9291. * then every 255th request send an ORDERED request. This heuristic
  9292. * tries to retain the benefit of request sorting while preventing
  9293. * request starvation. 255 is the max number of tags or pending commands
  9294. * a device may have outstanding.
  9295. *
  9296. * The request count is incremented below for every successfully
  9297. * started request.
  9298. *
  9299. */
  9300. if ((boardp->dvc_var.asc_dvc_var.cur_dvc_qng[scp->device->id] > 0) &&
  9301. (boardp->reqcnt[scp->device->id] % 255) == 0) {
  9302. asc_scsi_q->q2.tag_code = MSG_ORDERED_TAG;
  9303. } else {
  9304. asc_scsi_q->q2.tag_code = MSG_SIMPLE_TAG;
  9305. }
  9306. /*
  9307. * Build ASC_SCSI_Q for a contiguous buffer or a scatter-gather
  9308. * buffer command.
  9309. */
  9310. if (scp->use_sg == 0) {
  9311. /*
  9312. * CDB request of single contiguous buffer.
  9313. */
  9314. ASC_STATS(scp->device->host, cont_cnt);
  9315. scp->SCp.dma_handle = scp->request_bufflen ?
  9316. dma_map_single(boardp->dev, scp->request_buffer,
  9317. scp->request_bufflen,
  9318. scp->sc_data_direction) : 0;
  9319. asc_scsi_q->q1.data_addr = cpu_to_le32(scp->SCp.dma_handle);
  9320. asc_scsi_q->q1.data_cnt = cpu_to_le32(scp->request_bufflen);
  9321. ASC_STATS_ADD(scp->device->host, cont_xfer,
  9322. ASC_CEILING(scp->request_bufflen, 512));
  9323. asc_scsi_q->q1.sg_queue_cnt = 0;
  9324. asc_scsi_q->sg_head = NULL;
  9325. } else {
  9326. /*
  9327. * CDB scatter-gather request list.
  9328. */
  9329. int sgcnt;
  9330. int use_sg;
  9331. struct scatterlist *slp;
  9332. struct asc_sg_head *asc_sg_head;
  9333. slp = (struct scatterlist *)scp->request_buffer;
  9334. use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
  9335. scp->sc_data_direction);
  9336. if (use_sg > scp->device->host->sg_tablesize) {
  9337. ASC_PRINT3("asc_build_req: board %d: use_sg %d > "
  9338. "sg_tablesize %d\n", boardp->id, use_sg,
  9339. scp->device->host->sg_tablesize);
  9340. dma_unmap_sg(boardp->dev, slp, scp->use_sg,
  9341. scp->sc_data_direction);
  9342. scp->result = HOST_BYTE(DID_ERROR);
  9343. return ASC_ERROR;
  9344. }
  9345. ASC_STATS(scp->device->host, sg_cnt);
  9346. asc_sg_head = kzalloc(sizeof(asc_scsi_q->sg_head) +
  9347. use_sg * sizeof(struct asc_sg_list), GFP_ATOMIC);
  9348. if (!asc_sg_head) {
  9349. dma_unmap_sg(boardp->dev, slp, scp->use_sg,
  9350. scp->sc_data_direction);
  9351. scp->result = HOST_BYTE(DID_SOFT_ERROR);
  9352. return ASC_ERROR;
  9353. }
  9354. asc_scsi_q->q1.cntl |= QC_SG_HEAD;
  9355. asc_scsi_q->sg_head = asc_sg_head;
  9356. asc_scsi_q->q1.data_cnt = 0;
  9357. asc_scsi_q->q1.data_addr = 0;
  9358. /* This is a byte value, otherwise it would need to be swapped. */
  9359. asc_sg_head->entry_cnt = asc_scsi_q->q1.sg_queue_cnt = use_sg;
  9360. ASC_STATS_ADD(scp->device->host, sg_elem,
  9361. asc_sg_head->entry_cnt);
  9362. /*
  9363. * Convert scatter-gather list into ASC_SG_HEAD list.
  9364. */
  9365. for (sgcnt = 0; sgcnt < use_sg; sgcnt++, slp++) {
  9366. asc_sg_head->sg_list[sgcnt].addr =
  9367. cpu_to_le32(sg_dma_address(slp));
  9368. asc_sg_head->sg_list[sgcnt].bytes =
  9369. cpu_to_le32(sg_dma_len(slp));
  9370. ASC_STATS_ADD(scp->device->host, sg_xfer,
  9371. ASC_CEILING(sg_dma_len(slp), 512));
  9372. }
  9373. }
  9374. ASC_DBG_PRT_ASC_SCSI_Q(2, &asc_scsi_q);
  9375. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  9376. return ASC_NOERROR;
  9377. }
  9378. /*
  9379. * Build scatter-gather list for Adv Library (Wide Board).
  9380. *
  9381. * Additional ADV_SG_BLOCK structures will need to be allocated
  9382. * if the total number of scatter-gather elements exceeds
  9383. * NO_OF_SG_PER_BLOCK (15). The ADV_SG_BLOCK structures are
  9384. * assumed to be physically contiguous.
  9385. *
  9386. * Return:
  9387. * ADV_SUCCESS(1) - SG List successfully created
  9388. * ADV_ERROR(-1) - SG List creation failed
  9389. */
  9390. static int
  9391. adv_get_sglist(asc_board_t *boardp, adv_req_t *reqp, struct scsi_cmnd *scp,
  9392. int use_sg)
  9393. {
  9394. adv_sgblk_t *sgblkp;
  9395. ADV_SCSI_REQ_Q *scsiqp;
  9396. struct scatterlist *slp;
  9397. int sg_elem_cnt;
  9398. ADV_SG_BLOCK *sg_block, *prev_sg_block;
  9399. ADV_PADDR sg_block_paddr;
  9400. int i;
  9401. scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
  9402. slp = (struct scatterlist *)scp->request_buffer;
  9403. sg_elem_cnt = use_sg;
  9404. prev_sg_block = NULL;
  9405. reqp->sgblkp = NULL;
  9406. for (;;) {
  9407. /*
  9408. * Allocate a 'adv_sgblk_t' structure from the board free
  9409. * list. One 'adv_sgblk_t' structure holds NO_OF_SG_PER_BLOCK
  9410. * (15) scatter-gather elements.
  9411. */
  9412. if ((sgblkp = boardp->adv_sgblkp) == NULL) {
  9413. ASC_DBG(1, "adv_get_sglist: no free adv_sgblk_t\n");
  9414. ASC_STATS(scp->device->host, adv_build_nosg);
  9415. /*
  9416. * Allocation failed. Free 'adv_sgblk_t' structures
  9417. * already allocated for the request.
  9418. */
  9419. while ((sgblkp = reqp->sgblkp) != NULL) {
  9420. /* Remove 'sgblkp' from the request list. */
  9421. reqp->sgblkp = sgblkp->next_sgblkp;
  9422. /* Add 'sgblkp' to the board free list. */
  9423. sgblkp->next_sgblkp = boardp->adv_sgblkp;
  9424. boardp->adv_sgblkp = sgblkp;
  9425. }
  9426. return ASC_BUSY;
  9427. }
  9428. /* Complete 'adv_sgblk_t' board allocation. */
  9429. boardp->adv_sgblkp = sgblkp->next_sgblkp;
  9430. sgblkp->next_sgblkp = NULL;
  9431. /*
  9432. * Get 8 byte aligned virtual and physical addresses
  9433. * for the allocated ADV_SG_BLOCK structure.
  9434. */
  9435. sg_block = (ADV_SG_BLOCK *)ADV_8BALIGN(&sgblkp->sg_block);
  9436. sg_block_paddr = virt_to_bus(sg_block);
  9437. /*
  9438. * Check if this is the first 'adv_sgblk_t' for the
  9439. * request.
  9440. */
  9441. if (reqp->sgblkp == NULL) {
  9442. /* Request's first scatter-gather block. */
  9443. reqp->sgblkp = sgblkp;
  9444. /*
  9445. * Set ADV_SCSI_REQ_T ADV_SG_BLOCK virtual and physical
  9446. * address pointers.
  9447. */
  9448. scsiqp->sg_list_ptr = sg_block;
  9449. scsiqp->sg_real_addr = cpu_to_le32(sg_block_paddr);
  9450. } else {
  9451. /* Request's second or later scatter-gather block. */
  9452. sgblkp->next_sgblkp = reqp->sgblkp;
  9453. reqp->sgblkp = sgblkp;
  9454. /*
  9455. * Point the previous ADV_SG_BLOCK structure to
  9456. * the newly allocated ADV_SG_BLOCK structure.
  9457. */
  9458. prev_sg_block->sg_ptr = cpu_to_le32(sg_block_paddr);
  9459. }
  9460. for (i = 0; i < NO_OF_SG_PER_BLOCK; i++) {
  9461. sg_block->sg_list[i].sg_addr =
  9462. cpu_to_le32(sg_dma_address(slp));
  9463. sg_block->sg_list[i].sg_count =
  9464. cpu_to_le32(sg_dma_len(slp));
  9465. ASC_STATS_ADD(scp->device->host, sg_xfer,
  9466. ASC_CEILING(sg_dma_len(slp), 512));
  9467. if (--sg_elem_cnt == 0) { /* Last ADV_SG_BLOCK and scatter-gather entry. */
  9468. sg_block->sg_cnt = i + 1;
  9469. sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in list. */
  9470. return ADV_SUCCESS;
  9471. }
  9472. slp++;
  9473. }
  9474. sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
  9475. prev_sg_block = sg_block;
  9476. }
  9477. }
  9478. /*
  9479. * Build a request structure for the Adv Library (Wide Board).
  9480. *
  9481. * If an adv_req_t can not be allocated to issue the request,
  9482. * then return ASC_BUSY. If an error occurs, then return ASC_ERROR.
  9483. *
  9484. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the
  9485. * microcode for DMA addresses or math operations are byte swapped
  9486. * to little-endian order.
  9487. */
  9488. static int
  9489. adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
  9490. ADV_SCSI_REQ_Q **adv_scsiqpp)
  9491. {
  9492. adv_req_t *reqp;
  9493. ADV_SCSI_REQ_Q *scsiqp;
  9494. int i;
  9495. int ret;
  9496. /*
  9497. * Allocate an adv_req_t structure from the board to execute
  9498. * the command.
  9499. */
  9500. if (boardp->adv_reqp == NULL) {
  9501. ASC_DBG(1, "adv_build_req: no free adv_req_t\n");
  9502. ASC_STATS(scp->device->host, adv_build_noreq);
  9503. return ASC_BUSY;
  9504. } else {
  9505. reqp = boardp->adv_reqp;
  9506. boardp->adv_reqp = reqp->next_reqp;
  9507. reqp->next_reqp = NULL;
  9508. }
  9509. /*
  9510. * Get 32-byte aligned ADV_SCSI_REQ_Q and ADV_SG_BLOCK pointers.
  9511. */
  9512. scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
  9513. /*
  9514. * Initialize the structure.
  9515. */
  9516. scsiqp->cntl = scsiqp->scsi_cntl = scsiqp->done_status = 0;
  9517. /*
  9518. * Set the ADV_SCSI_REQ_Q 'srb_ptr' to point to the adv_req_t structure.
  9519. */
  9520. scsiqp->srb_ptr = ASC_VADDR_TO_U32(reqp);
  9521. /*
  9522. * Set the adv_req_t 'cmndp' to point to the struct scsi_cmnd structure.
  9523. */
  9524. reqp->cmndp = scp;
  9525. /*
  9526. * Build the ADV_SCSI_REQ_Q request.
  9527. */
  9528. /* Set CDB length and copy it to the request structure. */
  9529. scsiqp->cdb_len = scp->cmd_len;
  9530. /* Copy first 12 CDB bytes to cdb[]. */
  9531. for (i = 0; i < scp->cmd_len && i < 12; i++) {
  9532. scsiqp->cdb[i] = scp->cmnd[i];
  9533. }
  9534. /* Copy last 4 CDB bytes, if present, to cdb16[]. */
  9535. for (; i < scp->cmd_len; i++) {
  9536. scsiqp->cdb16[i - 12] = scp->cmnd[i];
  9537. }
  9538. scsiqp->target_id = scp->device->id;
  9539. scsiqp->target_lun = scp->device->lun;
  9540. scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
  9541. scsiqp->sense_len = sizeof(scp->sense_buffer);
  9542. /*
  9543. * Build ADV_SCSI_REQ_Q for a contiguous buffer or a scatter-gather
  9544. * buffer command.
  9545. */
  9546. scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
  9547. scsiqp->vdata_addr = scp->request_buffer;
  9548. scsiqp->data_addr = cpu_to_le32(virt_to_bus(scp->request_buffer));
  9549. if (scp->use_sg == 0) {
  9550. /*
  9551. * CDB request of single contiguous buffer.
  9552. */
  9553. reqp->sgblkp = NULL;
  9554. scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
  9555. if (scp->request_bufflen) {
  9556. scsiqp->vdata_addr = scp->request_buffer;
  9557. scp->SCp.dma_handle =
  9558. dma_map_single(boardp->dev, scp->request_buffer,
  9559. scp->request_bufflen,
  9560. scp->sc_data_direction);
  9561. } else {
  9562. scsiqp->vdata_addr = NULL;
  9563. scp->SCp.dma_handle = 0;
  9564. }
  9565. scsiqp->data_addr = cpu_to_le32(scp->SCp.dma_handle);
  9566. scsiqp->sg_list_ptr = NULL;
  9567. scsiqp->sg_real_addr = 0;
  9568. ASC_STATS(scp->device->host, cont_cnt);
  9569. ASC_STATS_ADD(scp->device->host, cont_xfer,
  9570. ASC_CEILING(scp->request_bufflen, 512));
  9571. } else {
  9572. /*
  9573. * CDB scatter-gather request list.
  9574. */
  9575. struct scatterlist *slp;
  9576. int use_sg;
  9577. slp = (struct scatterlist *)scp->request_buffer;
  9578. use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
  9579. scp->sc_data_direction);
  9580. if (use_sg > ADV_MAX_SG_LIST) {
  9581. ASC_PRINT3("adv_build_req: board %d: use_sg %d > "
  9582. "ADV_MAX_SG_LIST %d\n", boardp->id, use_sg,
  9583. scp->device->host->sg_tablesize);
  9584. dma_unmap_sg(boardp->dev, slp, scp->use_sg,
  9585. scp->sc_data_direction);
  9586. scp->result = HOST_BYTE(DID_ERROR);
  9587. /*
  9588. * Free the 'adv_req_t' structure by adding it back
  9589. * to the board free list.
  9590. */
  9591. reqp->next_reqp = boardp->adv_reqp;
  9592. boardp->adv_reqp = reqp;
  9593. return ASC_ERROR;
  9594. }
  9595. ret = adv_get_sglist(boardp, reqp, scp, use_sg);
  9596. if (ret != ADV_SUCCESS) {
  9597. /*
  9598. * Free the adv_req_t structure by adding it back to
  9599. * the board free list.
  9600. */
  9601. reqp->next_reqp = boardp->adv_reqp;
  9602. boardp->adv_reqp = reqp;
  9603. return ret;
  9604. }
  9605. ASC_STATS(scp->device->host, sg_cnt);
  9606. ASC_STATS_ADD(scp->device->host, sg_elem, use_sg);
  9607. }
  9608. ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
  9609. ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
  9610. *adv_scsiqpp = scsiqp;
  9611. return ASC_NOERROR;
  9612. }
  9613. static int AscSgListToQueue(int sg_list)
  9614. {
  9615. int n_sg_list_qs;
  9616. n_sg_list_qs = ((sg_list - 1) / ASC_SG_LIST_PER_Q);
  9617. if (((sg_list - 1) % ASC_SG_LIST_PER_Q) != 0)
  9618. n_sg_list_qs++;
  9619. return n_sg_list_qs + 1;
  9620. }
  9621. static uint
  9622. AscGetNumOfFreeQueue(ASC_DVC_VAR *asc_dvc, uchar target_ix, uchar n_qs)
  9623. {
  9624. uint cur_used_qs;
  9625. uint cur_free_qs;
  9626. ASC_SCSI_BIT_ID_TYPE target_id;
  9627. uchar tid_no;
  9628. target_id = ASC_TIX_TO_TARGET_ID(target_ix);
  9629. tid_no = ASC_TIX_TO_TID(target_ix);
  9630. if ((asc_dvc->unit_not_ready & target_id) ||
  9631. (asc_dvc->queue_full_or_busy & target_id)) {
  9632. return 0;
  9633. }
  9634. if (n_qs == 1) {
  9635. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  9636. (uint) asc_dvc->last_q_shortage + (uint) ASC_MIN_FREE_Q;
  9637. } else {
  9638. cur_used_qs = (uint) asc_dvc->cur_total_qng +
  9639. (uint) ASC_MIN_FREE_Q;
  9640. }
  9641. if ((uint) (cur_used_qs + n_qs) <= (uint) asc_dvc->max_total_qng) {
  9642. cur_free_qs = (uint) asc_dvc->max_total_qng - cur_used_qs;
  9643. if (asc_dvc->cur_dvc_qng[tid_no] >=
  9644. asc_dvc->max_dvc_qng[tid_no]) {
  9645. return 0;
  9646. }
  9647. return cur_free_qs;
  9648. }
  9649. if (n_qs > 1) {
  9650. if ((n_qs > asc_dvc->last_q_shortage)
  9651. && (n_qs <= (asc_dvc->max_total_qng - ASC_MIN_FREE_Q))) {
  9652. asc_dvc->last_q_shortage = n_qs;
  9653. }
  9654. }
  9655. return 0;
  9656. }
  9657. static uchar AscAllocFreeQueue(PortAddr iop_base, uchar free_q_head)
  9658. {
  9659. ushort q_addr;
  9660. uchar next_qp;
  9661. uchar q_status;
  9662. q_addr = ASC_QNO_TO_QADDR(free_q_head);
  9663. q_status = (uchar)AscReadLramByte(iop_base,
  9664. (ushort)(q_addr +
  9665. ASC_SCSIQ_B_STATUS));
  9666. next_qp = AscReadLramByte(iop_base, (ushort)(q_addr + ASC_SCSIQ_B_FWD));
  9667. if (((q_status & QS_READY) == 0) && (next_qp != ASC_QLINK_END))
  9668. return next_qp;
  9669. return ASC_QLINK_END;
  9670. }
  9671. static uchar
  9672. AscAllocMultipleFreeQueue(PortAddr iop_base, uchar free_q_head, uchar n_free_q)
  9673. {
  9674. uchar i;
  9675. for (i = 0; i < n_free_q; i++) {
  9676. free_q_head = AscAllocFreeQueue(iop_base, free_q_head);
  9677. if (free_q_head == ASC_QLINK_END)
  9678. break;
  9679. }
  9680. return free_q_head;
  9681. }
  9682. /*
  9683. * void
  9684. * DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  9685. *
  9686. * Calling/Exit State:
  9687. * none
  9688. *
  9689. * Description:
  9690. * Output an ASC_SCSI_Q structure to the chip
  9691. */
  9692. static void
  9693. DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
  9694. {
  9695. int i;
  9696. ASC_DBG_PRT_HEX(2, "DvcPutScsiQ", outbuf, 2 * words);
  9697. AscSetChipLramAddr(iop_base, s_addr);
  9698. for (i = 0; i < 2 * words; i += 2) {
  9699. if (i == 4 || i == 20) {
  9700. continue;
  9701. }
  9702. outpw(iop_base + IOP_RAM_DATA,
  9703. ((ushort)outbuf[i + 1] << 8) | outbuf[i]);
  9704. }
  9705. }
  9706. static int AscPutReadyQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
  9707. {
  9708. ushort q_addr;
  9709. uchar tid_no;
  9710. uchar sdtr_data;
  9711. uchar syn_period_ix;
  9712. uchar syn_offset;
  9713. PortAddr iop_base;
  9714. iop_base = asc_dvc->iop_base;
  9715. if (((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) &&
  9716. ((asc_dvc->sdtr_done & scsiq->q1.target_id) == 0)) {
  9717. tid_no = ASC_TIX_TO_TID(scsiq->q2.target_ix);
  9718. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  9719. syn_period_ix =
  9720. (sdtr_data >> 4) & (asc_dvc->max_sdtr_index - 1);
  9721. syn_offset = sdtr_data & ASC_SYN_MAX_OFFSET;
  9722. AscMsgOutSDTR(asc_dvc,
  9723. asc_dvc->sdtr_period_tbl[syn_period_ix],
  9724. syn_offset);
  9725. scsiq->q1.cntl |= QC_MSG_OUT;
  9726. }
  9727. q_addr = ASC_QNO_TO_QADDR(q_no);
  9728. if ((scsiq->q1.target_id & asc_dvc->use_tagged_qng) == 0) {
  9729. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
  9730. }
  9731. scsiq->q1.status = QS_FREE;
  9732. AscMemWordCopyPtrToLram(iop_base,
  9733. q_addr + ASC_SCSIQ_CDB_BEG,
  9734. (uchar *)scsiq->cdbptr, scsiq->q2.cdb_len >> 1);
  9735. DvcPutScsiQ(iop_base,
  9736. q_addr + ASC_SCSIQ_CPY_BEG,
  9737. (uchar *)&scsiq->q1.cntl,
  9738. ((sizeof(ASC_SCSIQ_1) + sizeof(ASC_SCSIQ_2)) / 2) - 1);
  9739. AscWriteLramWord(iop_base,
  9740. (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS),
  9741. (ushort)(((ushort)scsiq->q1.
  9742. q_no << 8) | (ushort)QS_READY));
  9743. return 1;
  9744. }
  9745. static int
  9746. AscPutReadySgListQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
  9747. {
  9748. int sta;
  9749. int i;
  9750. ASC_SG_HEAD *sg_head;
  9751. ASC_SG_LIST_Q scsi_sg_q;
  9752. ASC_DCNT saved_data_addr;
  9753. ASC_DCNT saved_data_cnt;
  9754. PortAddr iop_base;
  9755. ushort sg_list_dwords;
  9756. ushort sg_index;
  9757. ushort sg_entry_cnt;
  9758. ushort q_addr;
  9759. uchar next_qp;
  9760. iop_base = asc_dvc->iop_base;
  9761. sg_head = scsiq->sg_head;
  9762. saved_data_addr = scsiq->q1.data_addr;
  9763. saved_data_cnt = scsiq->q1.data_cnt;
  9764. scsiq->q1.data_addr = (ASC_PADDR) sg_head->sg_list[0].addr;
  9765. scsiq->q1.data_cnt = (ASC_DCNT) sg_head->sg_list[0].bytes;
  9766. #if CC_VERY_LONG_SG_LIST
  9767. /*
  9768. * If sg_head->entry_cnt is greater than ASC_MAX_SG_LIST
  9769. * then not all SG elements will fit in the allocated queues.
  9770. * The rest of the SG elements will be copied when the RISC
  9771. * completes the SG elements that fit and halts.
  9772. */
  9773. if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
  9774. /*
  9775. * Set sg_entry_cnt to be the number of SG elements that
  9776. * will fit in the allocated SG queues. It is minus 1, because
  9777. * the first SG element is handled above. ASC_MAX_SG_LIST is
  9778. * already inflated by 1 to account for this. For example it
  9779. * may be 50 which is 1 + 7 queues * 7 SG elements.
  9780. */
  9781. sg_entry_cnt = ASC_MAX_SG_LIST - 1;
  9782. /*
  9783. * Keep track of remaining number of SG elements that will
  9784. * need to be handled from a_isr.c.
  9785. */
  9786. scsiq->remain_sg_entry_cnt =
  9787. sg_head->entry_cnt - ASC_MAX_SG_LIST;
  9788. } else {
  9789. #endif /* CC_VERY_LONG_SG_LIST */
  9790. /*
  9791. * Set sg_entry_cnt to be the number of SG elements that
  9792. * will fit in the allocated SG queues. It is minus 1, because
  9793. * the first SG element is handled above.
  9794. */
  9795. sg_entry_cnt = sg_head->entry_cnt - 1;
  9796. #if CC_VERY_LONG_SG_LIST
  9797. }
  9798. #endif /* CC_VERY_LONG_SG_LIST */
  9799. if (sg_entry_cnt != 0) {
  9800. scsiq->q1.cntl |= QC_SG_HEAD;
  9801. q_addr = ASC_QNO_TO_QADDR(q_no);
  9802. sg_index = 1;
  9803. scsiq->q1.sg_queue_cnt = sg_head->queue_cnt;
  9804. scsi_sg_q.sg_head_qp = q_no;
  9805. scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
  9806. for (i = 0; i < sg_head->queue_cnt; i++) {
  9807. scsi_sg_q.seq_no = i + 1;
  9808. if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
  9809. sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
  9810. sg_entry_cnt -= ASC_SG_LIST_PER_Q;
  9811. if (i == 0) {
  9812. scsi_sg_q.sg_list_cnt =
  9813. ASC_SG_LIST_PER_Q;
  9814. scsi_sg_q.sg_cur_list_cnt =
  9815. ASC_SG_LIST_PER_Q;
  9816. } else {
  9817. scsi_sg_q.sg_list_cnt =
  9818. ASC_SG_LIST_PER_Q - 1;
  9819. scsi_sg_q.sg_cur_list_cnt =
  9820. ASC_SG_LIST_PER_Q - 1;
  9821. }
  9822. } else {
  9823. #if CC_VERY_LONG_SG_LIST
  9824. /*
  9825. * This is the last SG queue in the list of
  9826. * allocated SG queues. If there are more
  9827. * SG elements than will fit in the allocated
  9828. * queues, then set the QCSG_SG_XFER_MORE flag.
  9829. */
  9830. if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
  9831. scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
  9832. } else {
  9833. #endif /* CC_VERY_LONG_SG_LIST */
  9834. scsi_sg_q.cntl |= QCSG_SG_XFER_END;
  9835. #if CC_VERY_LONG_SG_LIST
  9836. }
  9837. #endif /* CC_VERY_LONG_SG_LIST */
  9838. sg_list_dwords = sg_entry_cnt << 1;
  9839. if (i == 0) {
  9840. scsi_sg_q.sg_list_cnt = sg_entry_cnt;
  9841. scsi_sg_q.sg_cur_list_cnt =
  9842. sg_entry_cnt;
  9843. } else {
  9844. scsi_sg_q.sg_list_cnt =
  9845. sg_entry_cnt - 1;
  9846. scsi_sg_q.sg_cur_list_cnt =
  9847. sg_entry_cnt - 1;
  9848. }
  9849. sg_entry_cnt = 0;
  9850. }
  9851. next_qp = AscReadLramByte(iop_base,
  9852. (ushort)(q_addr +
  9853. ASC_SCSIQ_B_FWD));
  9854. scsi_sg_q.q_no = next_qp;
  9855. q_addr = ASC_QNO_TO_QADDR(next_qp);
  9856. AscMemWordCopyPtrToLram(iop_base,
  9857. q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
  9858. (uchar *)&scsi_sg_q,
  9859. sizeof(ASC_SG_LIST_Q) >> 1);
  9860. AscMemDWordCopyPtrToLram(iop_base,
  9861. q_addr + ASC_SGQ_LIST_BEG,
  9862. (uchar *)&sg_head->
  9863. sg_list[sg_index],
  9864. sg_list_dwords);
  9865. sg_index += ASC_SG_LIST_PER_Q;
  9866. scsiq->next_sg_index = sg_index;
  9867. }
  9868. } else {
  9869. scsiq->q1.cntl &= ~QC_SG_HEAD;
  9870. }
  9871. sta = AscPutReadyQueue(asc_dvc, scsiq, q_no);
  9872. scsiq->q1.data_addr = saved_data_addr;
  9873. scsiq->q1.data_cnt = saved_data_cnt;
  9874. return (sta);
  9875. }
  9876. static int
  9877. AscSendScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar n_q_required)
  9878. {
  9879. PortAddr iop_base;
  9880. uchar free_q_head;
  9881. uchar next_qp;
  9882. uchar tid_no;
  9883. uchar target_ix;
  9884. int sta;
  9885. iop_base = asc_dvc->iop_base;
  9886. target_ix = scsiq->q2.target_ix;
  9887. tid_no = ASC_TIX_TO_TID(target_ix);
  9888. sta = 0;
  9889. free_q_head = (uchar)AscGetVarFreeQHead(iop_base);
  9890. if (n_q_required > 1) {
  9891. next_qp = AscAllocMultipleFreeQueue(iop_base, free_q_head,
  9892. (uchar)n_q_required);
  9893. if (next_qp != ASC_QLINK_END) {
  9894. asc_dvc->last_q_shortage = 0;
  9895. scsiq->sg_head->queue_cnt = n_q_required - 1;
  9896. scsiq->q1.q_no = free_q_head;
  9897. sta = AscPutReadySgListQueue(asc_dvc, scsiq,
  9898. free_q_head);
  9899. }
  9900. } else if (n_q_required == 1) {
  9901. next_qp = AscAllocFreeQueue(iop_base, free_q_head);
  9902. if (next_qp != ASC_QLINK_END) {
  9903. scsiq->q1.q_no = free_q_head;
  9904. sta = AscPutReadyQueue(asc_dvc, scsiq, free_q_head);
  9905. }
  9906. }
  9907. if (sta == 1) {
  9908. AscPutVarFreeQHead(iop_base, next_qp);
  9909. asc_dvc->cur_total_qng += n_q_required;
  9910. asc_dvc->cur_dvc_qng[tid_no]++;
  9911. }
  9912. return sta;
  9913. }
  9914. #define ASC_SYN_OFFSET_ONE_DISABLE_LIST 16
  9915. static uchar _syn_offset_one_disable_cmd[ASC_SYN_OFFSET_ONE_DISABLE_LIST] = {
  9916. INQUIRY,
  9917. REQUEST_SENSE,
  9918. READ_CAPACITY,
  9919. READ_TOC,
  9920. MODE_SELECT,
  9921. MODE_SENSE,
  9922. MODE_SELECT_10,
  9923. MODE_SENSE_10,
  9924. 0xFF,
  9925. 0xFF,
  9926. 0xFF,
  9927. 0xFF,
  9928. 0xFF,
  9929. 0xFF,
  9930. 0xFF,
  9931. 0xFF
  9932. };
  9933. static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
  9934. {
  9935. PortAddr iop_base;
  9936. int sta;
  9937. int n_q_required;
  9938. int disable_syn_offset_one_fix;
  9939. int i;
  9940. ASC_PADDR addr;
  9941. ushort sg_entry_cnt = 0;
  9942. ushort sg_entry_cnt_minus_one = 0;
  9943. uchar target_ix;
  9944. uchar tid_no;
  9945. uchar sdtr_data;
  9946. uchar extra_bytes;
  9947. uchar scsi_cmd;
  9948. uchar disable_cmd;
  9949. ASC_SG_HEAD *sg_head;
  9950. ASC_DCNT data_cnt;
  9951. iop_base = asc_dvc->iop_base;
  9952. sg_head = scsiq->sg_head;
  9953. if (asc_dvc->err_code != 0)
  9954. return (ERR);
  9955. scsiq->q1.q_no = 0;
  9956. if ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES) == 0) {
  9957. scsiq->q1.extra_bytes = 0;
  9958. }
  9959. sta = 0;
  9960. target_ix = scsiq->q2.target_ix;
  9961. tid_no = ASC_TIX_TO_TID(target_ix);
  9962. n_q_required = 1;
  9963. if (scsiq->cdbptr[0] == REQUEST_SENSE) {
  9964. if ((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) {
  9965. asc_dvc->sdtr_done &= ~scsiq->q1.target_id;
  9966. sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
  9967. AscMsgOutSDTR(asc_dvc,
  9968. asc_dvc->
  9969. sdtr_period_tbl[(sdtr_data >> 4) &
  9970. (uchar)(asc_dvc->
  9971. max_sdtr_index -
  9972. 1)],
  9973. (uchar)(sdtr_data & (uchar)
  9974. ASC_SYN_MAX_OFFSET));
  9975. scsiq->q1.cntl |= (QC_MSG_OUT | QC_URGENT);
  9976. }
  9977. }
  9978. if (asc_dvc->in_critical_cnt != 0) {
  9979. AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CRITICAL_RE_ENTRY);
  9980. return (ERR);
  9981. }
  9982. asc_dvc->in_critical_cnt++;
  9983. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  9984. if ((sg_entry_cnt = sg_head->entry_cnt) == 0) {
  9985. asc_dvc->in_critical_cnt--;
  9986. return (ERR);
  9987. }
  9988. #if !CC_VERY_LONG_SG_LIST
  9989. if (sg_entry_cnt > ASC_MAX_SG_LIST) {
  9990. asc_dvc->in_critical_cnt--;
  9991. return (ERR);
  9992. }
  9993. #endif /* !CC_VERY_LONG_SG_LIST */
  9994. if (sg_entry_cnt == 1) {
  9995. scsiq->q1.data_addr =
  9996. (ADV_PADDR)sg_head->sg_list[0].addr;
  9997. scsiq->q1.data_cnt =
  9998. (ADV_DCNT)sg_head->sg_list[0].bytes;
  9999. scsiq->q1.cntl &= ~(QC_SG_HEAD | QC_SG_SWAP_QUEUE);
  10000. }
  10001. sg_entry_cnt_minus_one = sg_entry_cnt - 1;
  10002. }
  10003. scsi_cmd = scsiq->cdbptr[0];
  10004. disable_syn_offset_one_fix = FALSE;
  10005. if ((asc_dvc->pci_fix_asyn_xfer & scsiq->q1.target_id) &&
  10006. !(asc_dvc->pci_fix_asyn_xfer_always & scsiq->q1.target_id)) {
  10007. if (scsiq->q1.cntl & QC_SG_HEAD) {
  10008. data_cnt = 0;
  10009. for (i = 0; i < sg_entry_cnt; i++) {
  10010. data_cnt +=
  10011. (ADV_DCNT)le32_to_cpu(sg_head->sg_list[i].
  10012. bytes);
  10013. }
  10014. } else {
  10015. data_cnt = le32_to_cpu(scsiq->q1.data_cnt);
  10016. }
  10017. if (data_cnt != 0UL) {
  10018. if (data_cnt < 512UL) {
  10019. disable_syn_offset_one_fix = TRUE;
  10020. } else {
  10021. for (i = 0; i < ASC_SYN_OFFSET_ONE_DISABLE_LIST;
  10022. i++) {
  10023. disable_cmd =
  10024. _syn_offset_one_disable_cmd[i];
  10025. if (disable_cmd == 0xFF) {
  10026. break;
  10027. }
  10028. if (scsi_cmd == disable_cmd) {
  10029. disable_syn_offset_one_fix =
  10030. TRUE;
  10031. break;
  10032. }
  10033. }
  10034. }
  10035. }
  10036. }
  10037. if (disable_syn_offset_one_fix) {
  10038. scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
  10039. scsiq->q2.tag_code |= (ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX |
  10040. ASC_TAG_FLAG_DISABLE_DISCONNECT);
  10041. } else {
  10042. scsiq->q2.tag_code &= 0x27;
  10043. }
  10044. if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
  10045. if (asc_dvc->bug_fix_cntl) {
  10046. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  10047. if ((scsi_cmd == READ_6) ||
  10048. (scsi_cmd == READ_10)) {
  10049. addr =
  10050. (ADV_PADDR)le32_to_cpu(sg_head->
  10051. sg_list
  10052. [sg_entry_cnt_minus_one].
  10053. addr) +
  10054. (ADV_DCNT)le32_to_cpu(sg_head->
  10055. sg_list
  10056. [sg_entry_cnt_minus_one].
  10057. bytes);
  10058. extra_bytes =
  10059. (uchar)((ushort)addr & 0x0003);
  10060. if ((extra_bytes != 0)
  10061. &&
  10062. ((scsiq->q2.
  10063. tag_code &
  10064. ASC_TAG_FLAG_EXTRA_BYTES)
  10065. == 0)) {
  10066. scsiq->q2.tag_code |=
  10067. ASC_TAG_FLAG_EXTRA_BYTES;
  10068. scsiq->q1.extra_bytes =
  10069. extra_bytes;
  10070. data_cnt =
  10071. le32_to_cpu(sg_head->
  10072. sg_list
  10073. [sg_entry_cnt_minus_one].
  10074. bytes);
  10075. data_cnt -=
  10076. (ASC_DCNT) extra_bytes;
  10077. sg_head->
  10078. sg_list
  10079. [sg_entry_cnt_minus_one].
  10080. bytes =
  10081. cpu_to_le32(data_cnt);
  10082. }
  10083. }
  10084. }
  10085. }
  10086. sg_head->entry_to_copy = sg_head->entry_cnt;
  10087. #if CC_VERY_LONG_SG_LIST
  10088. /*
  10089. * Set the sg_entry_cnt to the maximum possible. The rest of
  10090. * the SG elements will be copied when the RISC completes the
  10091. * SG elements that fit and halts.
  10092. */
  10093. if (sg_entry_cnt > ASC_MAX_SG_LIST) {
  10094. sg_entry_cnt = ASC_MAX_SG_LIST;
  10095. }
  10096. #endif /* CC_VERY_LONG_SG_LIST */
  10097. n_q_required = AscSgListToQueue(sg_entry_cnt);
  10098. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, n_q_required) >=
  10099. (uint) n_q_required)
  10100. || ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  10101. if ((sta =
  10102. AscSendScsiQueue(asc_dvc, scsiq,
  10103. n_q_required)) == 1) {
  10104. asc_dvc->in_critical_cnt--;
  10105. return (sta);
  10106. }
  10107. }
  10108. } else {
  10109. if (asc_dvc->bug_fix_cntl) {
  10110. if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
  10111. if ((scsi_cmd == READ_6) ||
  10112. (scsi_cmd == READ_10)) {
  10113. addr =
  10114. le32_to_cpu(scsiq->q1.data_addr) +
  10115. le32_to_cpu(scsiq->q1.data_cnt);
  10116. extra_bytes =
  10117. (uchar)((ushort)addr & 0x0003);
  10118. if ((extra_bytes != 0)
  10119. &&
  10120. ((scsiq->q2.
  10121. tag_code &
  10122. ASC_TAG_FLAG_EXTRA_BYTES)
  10123. == 0)) {
  10124. data_cnt =
  10125. le32_to_cpu(scsiq->q1.
  10126. data_cnt);
  10127. if (((ushort)data_cnt & 0x01FF)
  10128. == 0) {
  10129. scsiq->q2.tag_code |=
  10130. ASC_TAG_FLAG_EXTRA_BYTES;
  10131. data_cnt -= (ASC_DCNT)
  10132. extra_bytes;
  10133. scsiq->q1.data_cnt =
  10134. cpu_to_le32
  10135. (data_cnt);
  10136. scsiq->q1.extra_bytes =
  10137. extra_bytes;
  10138. }
  10139. }
  10140. }
  10141. }
  10142. }
  10143. n_q_required = 1;
  10144. if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, 1) >= 1) ||
  10145. ((scsiq->q1.cntl & QC_URGENT) != 0)) {
  10146. if ((sta = AscSendScsiQueue(asc_dvc, scsiq,
  10147. n_q_required)) == 1) {
  10148. asc_dvc->in_critical_cnt--;
  10149. return (sta);
  10150. }
  10151. }
  10152. }
  10153. asc_dvc->in_critical_cnt--;
  10154. return (sta);
  10155. }
  10156. /*
  10157. * AdvExeScsiQueue() - Send a request to the RISC microcode program.
  10158. *
  10159. * Allocate a carrier structure, point the carrier to the ADV_SCSI_REQ_Q,
  10160. * add the carrier to the ICQ (Initiator Command Queue), and tickle the
  10161. * RISC to notify it a new command is ready to be executed.
  10162. *
  10163. * If 'done_status' is not set to QD_DO_RETRY, then 'error_retry' will be
  10164. * set to SCSI_MAX_RETRY.
  10165. *
  10166. * Multi-byte fields in the ASC_SCSI_REQ_Q that are used by the microcode
  10167. * for DMA addresses or math operations are byte swapped to little-endian
  10168. * order.
  10169. *
  10170. * Return:
  10171. * ADV_SUCCESS(1) - The request was successfully queued.
  10172. * ADV_BUSY(0) - Resource unavailable; Retry again after pending
  10173. * request completes.
  10174. * ADV_ERROR(-1) - Invalid ADV_SCSI_REQ_Q request structure
  10175. * host IC error.
  10176. */
  10177. static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
  10178. {
  10179. AdvPortAddr iop_base;
  10180. ADV_DCNT req_size;
  10181. ADV_PADDR req_paddr;
  10182. ADV_CARR_T *new_carrp;
  10183. /*
  10184. * The ADV_SCSI_REQ_Q 'target_id' field should never exceed ADV_MAX_TID.
  10185. */
  10186. if (scsiq->target_id > ADV_MAX_TID) {
  10187. scsiq->host_status = QHSTA_M_INVALID_DEVICE;
  10188. scsiq->done_status = QD_WITH_ERROR;
  10189. return ADV_ERROR;
  10190. }
  10191. iop_base = asc_dvc->iop_base;
  10192. /*
  10193. * Allocate a carrier ensuring at least one carrier always
  10194. * remains on the freelist and initialize fields.
  10195. */
  10196. if ((new_carrp = asc_dvc->carr_freelist) == NULL) {
  10197. return ADV_BUSY;
  10198. }
  10199. asc_dvc->carr_freelist = (ADV_CARR_T *)
  10200. ADV_U32_TO_VADDR(le32_to_cpu(new_carrp->next_vpa));
  10201. asc_dvc->carr_pending_cnt++;
  10202. /*
  10203. * Set the carrier to be a stopper by setting 'next_vpa'
  10204. * to the stopper value. The current stopper will be changed
  10205. * below to point to the new stopper.
  10206. */
  10207. new_carrp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
  10208. /*
  10209. * Clear the ADV_SCSI_REQ_Q done flag.
  10210. */
  10211. scsiq->a_flag &= ~ADV_SCSIQ_DONE;
  10212. req_size = sizeof(ADV_SCSI_REQ_Q);
  10213. req_paddr = DvcGetPhyAddr(asc_dvc, scsiq, (uchar *)scsiq,
  10214. (ADV_SDCNT *)&req_size, ADV_IS_SCSIQ_FLAG);
  10215. BUG_ON(req_paddr & 31);
  10216. BUG_ON(req_size < sizeof(ADV_SCSI_REQ_Q));
  10217. /* Wait for assertion before making little-endian */
  10218. req_paddr = cpu_to_le32(req_paddr);
  10219. /* Save virtual and physical address of ADV_SCSI_REQ_Q and carrier. */
  10220. scsiq->scsiq_ptr = cpu_to_le32(ADV_VADDR_TO_U32(scsiq));
  10221. scsiq->scsiq_rptr = req_paddr;
  10222. scsiq->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->icq_sp));
  10223. /*
  10224. * Every ADV_CARR_T.carr_pa is byte swapped to little-endian
  10225. * order during initialization.
  10226. */
  10227. scsiq->carr_pa = asc_dvc->icq_sp->carr_pa;
  10228. /*
  10229. * Use the current stopper to send the ADV_SCSI_REQ_Q command to
  10230. * the microcode. The newly allocated stopper will become the new
  10231. * stopper.
  10232. */
  10233. asc_dvc->icq_sp->areq_vpa = req_paddr;
  10234. /*
  10235. * Set the 'next_vpa' pointer for the old stopper to be the
  10236. * physical address of the new stopper. The RISC can only
  10237. * follow physical addresses.
  10238. */
  10239. asc_dvc->icq_sp->next_vpa = new_carrp->carr_pa;
  10240. /*
  10241. * Set the host adapter stopper pointer to point to the new carrier.
  10242. */
  10243. asc_dvc->icq_sp = new_carrp;
  10244. if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
  10245. asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  10246. /*
  10247. * Tickle the RISC to tell it to read its Command Queue Head pointer.
  10248. */
  10249. AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_A);
  10250. if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
  10251. /*
  10252. * Clear the tickle value. In the ASC-3550 the RISC flag
  10253. * command 'clr_tickle_a' does not work unless the host
  10254. * value is cleared.
  10255. */
  10256. AdvWriteByteRegister(iop_base, IOPB_TICKLE,
  10257. ADV_TICKLE_NOP);
  10258. }
  10259. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  10260. /*
  10261. * Notify the RISC a carrier is ready by writing the physical
  10262. * address of the new carrier stopper to the COMMA register.
  10263. */
  10264. AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
  10265. le32_to_cpu(new_carrp->carr_pa));
  10266. }
  10267. return ADV_SUCCESS;
  10268. }
  10269. /*
  10270. * Execute a single 'Scsi_Cmnd'.
  10271. *
  10272. * The function 'done' is called when the request has been completed.
  10273. *
  10274. * Scsi_Cmnd:
  10275. *
  10276. * host - board controlling device
  10277. * device - device to send command
  10278. * target - target of device
  10279. * lun - lun of device
  10280. * cmd_len - length of SCSI CDB
  10281. * cmnd - buffer for SCSI 8, 10, or 12 byte CDB
  10282. * use_sg - if non-zero indicates scatter-gather request with use_sg elements
  10283. *
  10284. * if (use_sg == 0) {
  10285. * request_buffer - buffer address for request
  10286. * request_bufflen - length of request buffer
  10287. * } else {
  10288. * request_buffer - pointer to scatterlist structure
  10289. * }
  10290. *
  10291. * sense_buffer - sense command buffer
  10292. *
  10293. * result (4 bytes of an int):
  10294. * Byte Meaning
  10295. * 0 SCSI Status Byte Code
  10296. * 1 SCSI One Byte Message Code
  10297. * 2 Host Error Code
  10298. * 3 Mid-Level Error Code
  10299. *
  10300. * host driver fields:
  10301. * SCp - Scsi_Pointer used for command processing status
  10302. * scsi_done - used to save caller's done function
  10303. * host_scribble - used for pointer to another struct scsi_cmnd
  10304. *
  10305. * If this function returns ASC_NOERROR the request will be completed
  10306. * from the interrupt handler.
  10307. *
  10308. * If this function returns ASC_ERROR the host error code has been set,
  10309. * and the called must call asc_scsi_done.
  10310. *
  10311. * If ASC_BUSY is returned the request will be returned to the midlayer
  10312. * and re-tried later.
  10313. */
  10314. static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
  10315. {
  10316. int ret, err_code;
  10317. asc_board_t *boardp = ASC_BOARDP(scp->device->host);
  10318. ASC_DBG1(1, "asc_execute_scsi_cmnd: scp 0x%p\n", scp);
  10319. if (ASC_NARROW_BOARD(boardp)) {
  10320. ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  10321. struct asc_scsi_q asc_scsi_q;
  10322. /* asc_build_req() can not return ASC_BUSY. */
  10323. ret = asc_build_req(boardp, scp, &asc_scsi_q);
  10324. if (ret == ASC_ERROR) {
  10325. ASC_STATS(scp->device->host, build_error);
  10326. return ASC_ERROR;
  10327. }
  10328. ret = AscExeScsiQueue(asc_dvc, &asc_scsi_q);
  10329. kfree(asc_scsi_q.sg_head);
  10330. err_code = asc_dvc->err_code;
  10331. } else {
  10332. ADV_DVC_VAR *adv_dvc = &boardp->dvc_var.adv_dvc_var;
  10333. ADV_SCSI_REQ_Q *adv_scsiqp;
  10334. switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
  10335. case ASC_NOERROR:
  10336. ASC_DBG(3, "asc_execute_scsi_cmnd: adv_build_req "
  10337. "ASC_NOERROR\n");
  10338. break;
  10339. case ASC_BUSY:
  10340. ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req "
  10341. "ASC_BUSY\n");
  10342. /*
  10343. * The asc_stats fields 'adv_build_noreq' and
  10344. * 'adv_build_nosg' count wide board busy conditions.
  10345. * They are updated in adv_build_req and
  10346. * adv_get_sglist, respectively.
  10347. */
  10348. return ASC_BUSY;
  10349. case ASC_ERROR:
  10350. default:
  10351. ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req "
  10352. "ASC_ERROR\n");
  10353. ASC_STATS(scp->device->host, build_error);
  10354. return ASC_ERROR;
  10355. }
  10356. ret = AdvExeScsiQueue(adv_dvc, adv_scsiqp);
  10357. err_code = adv_dvc->err_code;
  10358. }
  10359. switch (ret) {
  10360. case ASC_NOERROR:
  10361. ASC_STATS(scp->device->host, exe_noerror);
  10362. /*
  10363. * Increment monotonically increasing per device
  10364. * successful request counter. Wrapping doesn't matter.
  10365. */
  10366. boardp->reqcnt[scp->device->id]++;
  10367. ASC_DBG(1, "asc_execute_scsi_cmnd: ExeScsiQueue(), "
  10368. "ASC_NOERROR\n");
  10369. break;
  10370. case ASC_BUSY:
  10371. ASC_STATS(scp->device->host, exe_busy);
  10372. break;
  10373. case ASC_ERROR:
  10374. ASC_PRINT2("asc_execute_scsi_cmnd: board %d: ExeScsiQueue() "
  10375. "ASC_ERROR, err_code 0x%x\n", boardp->id, err_code);
  10376. ASC_STATS(scp->device->host, exe_error);
  10377. scp->result = HOST_BYTE(DID_ERROR);
  10378. break;
  10379. default:
  10380. ASC_PRINT2("asc_execute_scsi_cmnd: board %d: ExeScsiQueue() "
  10381. "unknown, err_code 0x%x\n", boardp->id, err_code);
  10382. ASC_STATS(scp->device->host, exe_unknown);
  10383. scp->result = HOST_BYTE(DID_ERROR);
  10384. break;
  10385. }
  10386. ASC_DBG(1, "asc_execute_scsi_cmnd: end\n");
  10387. return ret;
  10388. }
  10389. /*
  10390. * advansys_queuecommand() - interrupt-driven I/O entrypoint.
  10391. *
  10392. * This function always returns 0. Command return status is saved
  10393. * in the 'scp' result field.
  10394. */
  10395. static int
  10396. advansys_queuecommand(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *))
  10397. {
  10398. struct Scsi_Host *shost = scp->device->host;
  10399. asc_board_t *boardp = ASC_BOARDP(shost);
  10400. unsigned long flags;
  10401. int asc_res, result = 0;
  10402. ASC_STATS(shost, queuecommand);
  10403. scp->scsi_done = done;
  10404. /*
  10405. * host_lock taken by mid-level prior to call, but need
  10406. * to protect against own ISR
  10407. */
  10408. spin_lock_irqsave(&boardp->lock, flags);
  10409. asc_res = asc_execute_scsi_cmnd(scp);
  10410. spin_unlock_irqrestore(&boardp->lock, flags);
  10411. switch (asc_res) {
  10412. case ASC_NOERROR:
  10413. break;
  10414. case ASC_BUSY:
  10415. result = SCSI_MLQUEUE_HOST_BUSY;
  10416. break;
  10417. case ASC_ERROR:
  10418. default:
  10419. asc_scsi_done(scp);
  10420. break;
  10421. }
  10422. return result;
  10423. }
  10424. static ushort __devinit AscGetEisaChipCfg(PortAddr iop_base)
  10425. {
  10426. PortAddr eisa_cfg_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  10427. (PortAddr) (ASC_EISA_CFG_IOP_MASK);
  10428. return inpw(eisa_cfg_iop);
  10429. }
  10430. /*
  10431. * Return the BIOS address of the adapter at the specified
  10432. * I/O port and with the specified bus type.
  10433. */
  10434. static unsigned short __devinit
  10435. AscGetChipBiosAddress(PortAddr iop_base, unsigned short bus_type)
  10436. {
  10437. unsigned short cfg_lsw;
  10438. unsigned short bios_addr;
  10439. /*
  10440. * The PCI BIOS is re-located by the motherboard BIOS. Because
  10441. * of this the driver can not determine where a PCI BIOS is
  10442. * loaded and executes.
  10443. */
  10444. if (bus_type & ASC_IS_PCI)
  10445. return 0;
  10446. if ((bus_type & ASC_IS_EISA) != 0) {
  10447. cfg_lsw = AscGetEisaChipCfg(iop_base);
  10448. cfg_lsw &= 0x000F;
  10449. bios_addr = ASC_BIOS_MIN_ADDR + cfg_lsw * ASC_BIOS_BANK_SIZE;
  10450. return bios_addr;
  10451. }
  10452. cfg_lsw = AscGetChipCfgLsw(iop_base);
  10453. /*
  10454. * ISA PnP uses the top bit as the 32K BIOS flag
  10455. */
  10456. if (bus_type == ASC_IS_ISAPNP)
  10457. cfg_lsw &= 0x7FFF;
  10458. bios_addr = ASC_BIOS_MIN_ADDR + (cfg_lsw >> 12) * ASC_BIOS_BANK_SIZE;
  10459. return bios_addr;
  10460. }
  10461. static uchar __devinit AscSetChipScsiID(PortAddr iop_base, uchar new_host_id)
  10462. {
  10463. ushort cfg_lsw;
  10464. if (AscGetChipScsiID(iop_base) == new_host_id) {
  10465. return (new_host_id);
  10466. }
  10467. cfg_lsw = AscGetChipCfgLsw(iop_base);
  10468. cfg_lsw &= 0xF8FF;
  10469. cfg_lsw |= (ushort)((new_host_id & ASC_MAX_TID) << 8);
  10470. AscSetChipCfgLsw(iop_base, cfg_lsw);
  10471. return (AscGetChipScsiID(iop_base));
  10472. }
  10473. static unsigned char __devinit AscGetChipScsiCtrl(PortAddr iop_base)
  10474. {
  10475. unsigned char sc;
  10476. AscSetBank(iop_base, 1);
  10477. sc = inp(iop_base + IOP_REG_SC);
  10478. AscSetBank(iop_base, 0);
  10479. return sc;
  10480. }
  10481. static unsigned char __devinit
  10482. AscGetChipVersion(PortAddr iop_base, unsigned short bus_type)
  10483. {
  10484. if (bus_type & ASC_IS_EISA) {
  10485. PortAddr eisa_iop;
  10486. unsigned char revision;
  10487. eisa_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
  10488. (PortAddr) ASC_EISA_REV_IOP_MASK;
  10489. revision = inp(eisa_iop);
  10490. return ASC_CHIP_MIN_VER_EISA - 1 + revision;
  10491. }
  10492. return AscGetChipVerNo(iop_base);
  10493. }
  10494. static void __devinit AscToggleIRQAct(PortAddr iop_base)
  10495. {
  10496. AscSetChipStatus(iop_base, CIW_IRQ_ACT);
  10497. AscSetChipStatus(iop_base, 0);
  10498. return;
  10499. }
  10500. static uchar __devinit AscGetChipIRQ(PortAddr iop_base, ushort bus_type)
  10501. {
  10502. ushort cfg_lsw;
  10503. uchar chip_irq;
  10504. if ((bus_type & ASC_IS_EISA) != 0) {
  10505. cfg_lsw = AscGetEisaChipCfg(iop_base);
  10506. chip_irq = (uchar)(((cfg_lsw >> 8) & 0x07) + 10);
  10507. if ((chip_irq == 13) || (chip_irq > 15)) {
  10508. return (0);
  10509. }
  10510. return (chip_irq);
  10511. }
  10512. if ((bus_type & ASC_IS_VL) != 0) {
  10513. cfg_lsw = AscGetChipCfgLsw(iop_base);
  10514. chip_irq = (uchar)(((cfg_lsw >> 2) & 0x07));
  10515. if ((chip_irq == 0) || (chip_irq == 4) || (chip_irq == 7)) {
  10516. return (0);
  10517. }
  10518. return ((uchar)(chip_irq + (ASC_MIN_IRQ_NO - 1)));
  10519. }
  10520. cfg_lsw = AscGetChipCfgLsw(iop_base);
  10521. chip_irq = (uchar)(((cfg_lsw >> 2) & 0x03));
  10522. if (chip_irq == 3)
  10523. chip_irq += (uchar)2;
  10524. return ((uchar)(chip_irq + ASC_MIN_IRQ_NO));
  10525. }
  10526. static uchar __devinit
  10527. AscSetChipIRQ(PortAddr iop_base, uchar irq_no, ushort bus_type)
  10528. {
  10529. ushort cfg_lsw;
  10530. if ((bus_type & ASC_IS_VL) != 0) {
  10531. if (irq_no != 0) {
  10532. if ((irq_no < ASC_MIN_IRQ_NO)
  10533. || (irq_no > ASC_MAX_IRQ_NO)) {
  10534. irq_no = 0;
  10535. } else {
  10536. irq_no -= (uchar)((ASC_MIN_IRQ_NO - 1));
  10537. }
  10538. }
  10539. cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFE3);
  10540. cfg_lsw |= (ushort)0x0010;
  10541. AscSetChipCfgLsw(iop_base, cfg_lsw);
  10542. AscToggleIRQAct(iop_base);
  10543. cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFE0);
  10544. cfg_lsw |= (ushort)((irq_no & 0x07) << 2);
  10545. AscSetChipCfgLsw(iop_base, cfg_lsw);
  10546. AscToggleIRQAct(iop_base);
  10547. return (AscGetChipIRQ(iop_base, bus_type));
  10548. }
  10549. if ((bus_type & (ASC_IS_ISA)) != 0) {
  10550. if (irq_no == 15)
  10551. irq_no -= (uchar)2;
  10552. irq_no -= (uchar)ASC_MIN_IRQ_NO;
  10553. cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFF3);
  10554. cfg_lsw |= (ushort)((irq_no & 0x03) << 2);
  10555. AscSetChipCfgLsw(iop_base, cfg_lsw);
  10556. return (AscGetChipIRQ(iop_base, bus_type));
  10557. }
  10558. return (0);
  10559. }
  10560. #ifdef CONFIG_ISA
  10561. static void __devinit AscEnableIsaDma(uchar dma_channel)
  10562. {
  10563. if (dma_channel < 4) {
  10564. outp(0x000B, (ushort)(0xC0 | dma_channel));
  10565. outp(0x000A, dma_channel);
  10566. } else if (dma_channel < 8) {
  10567. outp(0x00D6, (ushort)(0xC0 | (dma_channel - 4)));
  10568. outp(0x00D4, (ushort)(dma_channel - 4));
  10569. }
  10570. return;
  10571. }
  10572. #endif /* CONFIG_ISA */
  10573. static int AscStopQueueExe(PortAddr iop_base)
  10574. {
  10575. int count = 0;
  10576. if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) == 0) {
  10577. AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
  10578. ASC_STOP_REQ_RISC_STOP);
  10579. do {
  10580. if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) &
  10581. ASC_STOP_ACK_RISC_STOP) {
  10582. return (1);
  10583. }
  10584. mdelay(100);
  10585. } while (count++ < 20);
  10586. }
  10587. return (0);
  10588. }
  10589. static ASC_DCNT __devinit AscGetMaxDmaCount(ushort bus_type)
  10590. {
  10591. if (bus_type & ASC_IS_ISA)
  10592. return ASC_MAX_ISA_DMA_COUNT;
  10593. else if (bus_type & (ASC_IS_EISA | ASC_IS_VL))
  10594. return ASC_MAX_VL_DMA_COUNT;
  10595. return ASC_MAX_PCI_DMA_COUNT;
  10596. }
  10597. #ifdef CONFIG_ISA
  10598. static ushort __devinit AscGetIsaDmaChannel(PortAddr iop_base)
  10599. {
  10600. ushort channel;
  10601. channel = AscGetChipCfgLsw(iop_base) & 0x0003;
  10602. if (channel == 0x03)
  10603. return (0);
  10604. else if (channel == 0x00)
  10605. return (7);
  10606. return (channel + 4);
  10607. }
  10608. static ushort __devinit AscSetIsaDmaChannel(PortAddr iop_base, ushort dma_channel)
  10609. {
  10610. ushort cfg_lsw;
  10611. uchar value;
  10612. if ((dma_channel >= 5) && (dma_channel <= 7)) {
  10613. if (dma_channel == 7)
  10614. value = 0x00;
  10615. else
  10616. value = dma_channel - 4;
  10617. cfg_lsw = AscGetChipCfgLsw(iop_base) & 0xFFFC;
  10618. cfg_lsw |= value;
  10619. AscSetChipCfgLsw(iop_base, cfg_lsw);
  10620. return (AscGetIsaDmaChannel(iop_base));
  10621. }
  10622. return 0;
  10623. }
  10624. static uchar __devinit AscGetIsaDmaSpeed(PortAddr iop_base)
  10625. {
  10626. uchar speed_value;
  10627. AscSetBank(iop_base, 1);
  10628. speed_value = AscReadChipDmaSpeed(iop_base);
  10629. speed_value &= 0x07;
  10630. AscSetBank(iop_base, 0);
  10631. return speed_value;
  10632. }
  10633. static uchar __devinit AscSetIsaDmaSpeed(PortAddr iop_base, uchar speed_value)
  10634. {
  10635. speed_value &= 0x07;
  10636. AscSetBank(iop_base, 1);
  10637. AscWriteChipDmaSpeed(iop_base, speed_value);
  10638. AscSetBank(iop_base, 0);
  10639. return AscGetIsaDmaSpeed(iop_base);
  10640. }
  10641. #endif /* CONFIG_ISA */
  10642. static ushort __devinit AscInitAscDvcVar(ASC_DVC_VAR *asc_dvc)
  10643. {
  10644. int i;
  10645. PortAddr iop_base;
  10646. ushort warn_code;
  10647. uchar chip_version;
  10648. iop_base = asc_dvc->iop_base;
  10649. warn_code = 0;
  10650. asc_dvc->err_code = 0;
  10651. if ((asc_dvc->bus_type &
  10652. (ASC_IS_ISA | ASC_IS_PCI | ASC_IS_EISA | ASC_IS_VL)) == 0) {
  10653. asc_dvc->err_code |= ASC_IERR_NO_BUS_TYPE;
  10654. }
  10655. AscSetChipControl(iop_base, CC_HALT);
  10656. AscSetChipStatus(iop_base, 0);
  10657. asc_dvc->bug_fix_cntl = 0;
  10658. asc_dvc->pci_fix_asyn_xfer = 0;
  10659. asc_dvc->pci_fix_asyn_xfer_always = 0;
  10660. /* asc_dvc->init_state initalized in AscInitGetConfig(). */
  10661. asc_dvc->sdtr_done = 0;
  10662. asc_dvc->cur_total_qng = 0;
  10663. asc_dvc->is_in_int = 0;
  10664. asc_dvc->in_critical_cnt = 0;
  10665. asc_dvc->last_q_shortage = 0;
  10666. asc_dvc->use_tagged_qng = 0;
  10667. asc_dvc->no_scam = 0;
  10668. asc_dvc->unit_not_ready = 0;
  10669. asc_dvc->queue_full_or_busy = 0;
  10670. asc_dvc->redo_scam = 0;
  10671. asc_dvc->res2 = 0;
  10672. asc_dvc->host_init_sdtr_index = 0;
  10673. asc_dvc->cfg->can_tagged_qng = 0;
  10674. asc_dvc->cfg->cmd_qng_enabled = 0;
  10675. asc_dvc->dvc_cntl = ASC_DEF_DVC_CNTL;
  10676. asc_dvc->init_sdtr = 0;
  10677. asc_dvc->max_total_qng = ASC_DEF_MAX_TOTAL_QNG;
  10678. asc_dvc->scsi_reset_wait = 3;
  10679. asc_dvc->start_motor = ASC_SCSI_WIDTH_BIT_SET;
  10680. asc_dvc->max_dma_count = AscGetMaxDmaCount(asc_dvc->bus_type);
  10681. asc_dvc->cfg->sdtr_enable = ASC_SCSI_WIDTH_BIT_SET;
  10682. asc_dvc->cfg->disc_enable = ASC_SCSI_WIDTH_BIT_SET;
  10683. asc_dvc->cfg->chip_scsi_id = ASC_DEF_CHIP_SCSI_ID;
  10684. asc_dvc->cfg->lib_serial_no = ASC_LIB_SERIAL_NUMBER;
  10685. asc_dvc->cfg->lib_version = (ASC_LIB_VERSION_MAJOR << 8) |
  10686. ASC_LIB_VERSION_MINOR;
  10687. chip_version = AscGetChipVersion(iop_base, asc_dvc->bus_type);
  10688. asc_dvc->cfg->chip_version = chip_version;
  10689. asc_dvc->sdtr_period_tbl[0] = SYN_XFER_NS_0;
  10690. asc_dvc->sdtr_period_tbl[1] = SYN_XFER_NS_1;
  10691. asc_dvc->sdtr_period_tbl[2] = SYN_XFER_NS_2;
  10692. asc_dvc->sdtr_period_tbl[3] = SYN_XFER_NS_3;
  10693. asc_dvc->sdtr_period_tbl[4] = SYN_XFER_NS_4;
  10694. asc_dvc->sdtr_period_tbl[5] = SYN_XFER_NS_5;
  10695. asc_dvc->sdtr_period_tbl[6] = SYN_XFER_NS_6;
  10696. asc_dvc->sdtr_period_tbl[7] = SYN_XFER_NS_7;
  10697. asc_dvc->max_sdtr_index = 7;
  10698. if ((asc_dvc->bus_type & ASC_IS_PCI) &&
  10699. (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3150)) {
  10700. asc_dvc->bus_type = ASC_IS_PCI_ULTRA;
  10701. asc_dvc->sdtr_period_tbl[0] = SYN_ULTRA_XFER_NS_0;
  10702. asc_dvc->sdtr_period_tbl[1] = SYN_ULTRA_XFER_NS_1;
  10703. asc_dvc->sdtr_period_tbl[2] = SYN_ULTRA_XFER_NS_2;
  10704. asc_dvc->sdtr_period_tbl[3] = SYN_ULTRA_XFER_NS_3;
  10705. asc_dvc->sdtr_period_tbl[4] = SYN_ULTRA_XFER_NS_4;
  10706. asc_dvc->sdtr_period_tbl[5] = SYN_ULTRA_XFER_NS_5;
  10707. asc_dvc->sdtr_period_tbl[6] = SYN_ULTRA_XFER_NS_6;
  10708. asc_dvc->sdtr_period_tbl[7] = SYN_ULTRA_XFER_NS_7;
  10709. asc_dvc->sdtr_period_tbl[8] = SYN_ULTRA_XFER_NS_8;
  10710. asc_dvc->sdtr_period_tbl[9] = SYN_ULTRA_XFER_NS_9;
  10711. asc_dvc->sdtr_period_tbl[10] = SYN_ULTRA_XFER_NS_10;
  10712. asc_dvc->sdtr_period_tbl[11] = SYN_ULTRA_XFER_NS_11;
  10713. asc_dvc->sdtr_period_tbl[12] = SYN_ULTRA_XFER_NS_12;
  10714. asc_dvc->sdtr_period_tbl[13] = SYN_ULTRA_XFER_NS_13;
  10715. asc_dvc->sdtr_period_tbl[14] = SYN_ULTRA_XFER_NS_14;
  10716. asc_dvc->sdtr_period_tbl[15] = SYN_ULTRA_XFER_NS_15;
  10717. asc_dvc->max_sdtr_index = 15;
  10718. if (chip_version == ASC_CHIP_VER_PCI_ULTRA_3150) {
  10719. AscSetExtraControl(iop_base,
  10720. (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  10721. } else if (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3050) {
  10722. AscSetExtraControl(iop_base,
  10723. (SEC_ACTIVE_NEGATE |
  10724. SEC_ENABLE_FILTER));
  10725. }
  10726. }
  10727. if (asc_dvc->bus_type == ASC_IS_PCI) {
  10728. AscSetExtraControl(iop_base,
  10729. (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
  10730. }
  10731. asc_dvc->cfg->isa_dma_speed = ASC_DEF_ISA_DMA_SPEED;
  10732. #ifdef CONFIG_ISA
  10733. if ((asc_dvc->bus_type & ASC_IS_ISA) != 0) {
  10734. if (chip_version >= ASC_CHIP_MIN_VER_ISA_PNP) {
  10735. AscSetChipIFC(iop_base, IFC_INIT_DEFAULT);
  10736. asc_dvc->bus_type = ASC_IS_ISAPNP;
  10737. }
  10738. asc_dvc->cfg->isa_dma_channel =
  10739. (uchar)AscGetIsaDmaChannel(iop_base);
  10740. }
  10741. #endif /* CONFIG_ISA */
  10742. for (i = 0; i <= ASC_MAX_TID; i++) {
  10743. asc_dvc->cur_dvc_qng[i] = 0;
  10744. asc_dvc->max_dvc_qng[i] = ASC_MAX_SCSI1_QNG;
  10745. asc_dvc->scsiq_busy_head[i] = (ASC_SCSI_Q *)0L;
  10746. asc_dvc->scsiq_busy_tail[i] = (ASC_SCSI_Q *)0L;
  10747. asc_dvc->cfg->max_tag_qng[i] = ASC_MAX_INRAM_TAG_QNG;
  10748. }
  10749. return warn_code;
  10750. }
  10751. static int __devinit AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg)
  10752. {
  10753. int retry;
  10754. for (retry = 0; retry < ASC_EEP_MAX_RETRY; retry++) {
  10755. unsigned char read_back;
  10756. AscSetChipEEPCmd(iop_base, cmd_reg);
  10757. mdelay(1);
  10758. read_back = AscGetChipEEPCmd(iop_base);
  10759. if (read_back == cmd_reg)
  10760. return 1;
  10761. }
  10762. return 0;
  10763. }
  10764. static void __devinit AscWaitEEPRead(void)
  10765. {
  10766. mdelay(1);
  10767. }
  10768. static ushort __devinit AscReadEEPWord(PortAddr iop_base, uchar addr)
  10769. {
  10770. ushort read_wval;
  10771. uchar cmd_reg;
  10772. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  10773. AscWaitEEPRead();
  10774. cmd_reg = addr | ASC_EEP_CMD_READ;
  10775. AscWriteEEPCmdReg(iop_base, cmd_reg);
  10776. AscWaitEEPRead();
  10777. read_wval = AscGetChipEEPData(iop_base);
  10778. AscWaitEEPRead();
  10779. return read_wval;
  10780. }
  10781. static ushort __devinit
  10782. AscGetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  10783. {
  10784. ushort wval;
  10785. ushort sum;
  10786. ushort *wbuf;
  10787. int cfg_beg;
  10788. int cfg_end;
  10789. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  10790. int s_addr;
  10791. wbuf = (ushort *)cfg_buf;
  10792. sum = 0;
  10793. /* Read two config words; Byte-swapping done by AscReadEEPWord(). */
  10794. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  10795. *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
  10796. sum += *wbuf;
  10797. }
  10798. if (bus_type & ASC_IS_VL) {
  10799. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  10800. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  10801. } else {
  10802. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  10803. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  10804. }
  10805. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  10806. wval = AscReadEEPWord(iop_base, (uchar)s_addr);
  10807. if (s_addr <= uchar_end_in_config) {
  10808. /*
  10809. * Swap all char fields - must unswap bytes already swapped
  10810. * by AscReadEEPWord().
  10811. */
  10812. *wbuf = le16_to_cpu(wval);
  10813. } else {
  10814. /* Don't swap word field at the end - cntl field. */
  10815. *wbuf = wval;
  10816. }
  10817. sum += wval; /* Checksum treats all EEPROM data as words. */
  10818. }
  10819. /*
  10820. * Read the checksum word which will be compared against 'sum'
  10821. * by the caller. Word field already swapped.
  10822. */
  10823. *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
  10824. return sum;
  10825. }
  10826. static int __devinit AscTestExternalLram(ASC_DVC_VAR *asc_dvc)
  10827. {
  10828. PortAddr iop_base;
  10829. ushort q_addr;
  10830. ushort saved_word;
  10831. int sta;
  10832. iop_base = asc_dvc->iop_base;
  10833. sta = 0;
  10834. q_addr = ASC_QNO_TO_QADDR(241);
  10835. saved_word = AscReadLramWord(iop_base, q_addr);
  10836. AscSetChipLramAddr(iop_base, q_addr);
  10837. AscSetChipLramData(iop_base, 0x55AA);
  10838. mdelay(10);
  10839. AscSetChipLramAddr(iop_base, q_addr);
  10840. if (AscGetChipLramData(iop_base) == 0x55AA) {
  10841. sta = 1;
  10842. AscWriteLramWord(iop_base, q_addr, saved_word);
  10843. }
  10844. return (sta);
  10845. }
  10846. static void __devinit AscWaitEEPWrite(void)
  10847. {
  10848. mdelay(20);
  10849. return;
  10850. }
  10851. static int __devinit AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg)
  10852. {
  10853. ushort read_back;
  10854. int retry;
  10855. retry = 0;
  10856. while (TRUE) {
  10857. AscSetChipEEPData(iop_base, data_reg);
  10858. mdelay(1);
  10859. read_back = AscGetChipEEPData(iop_base);
  10860. if (read_back == data_reg) {
  10861. return (1);
  10862. }
  10863. if (retry++ > ASC_EEP_MAX_RETRY) {
  10864. return (0);
  10865. }
  10866. }
  10867. }
  10868. static ushort __devinit
  10869. AscWriteEEPWord(PortAddr iop_base, uchar addr, ushort word_val)
  10870. {
  10871. ushort read_wval;
  10872. read_wval = AscReadEEPWord(iop_base, addr);
  10873. if (read_wval != word_val) {
  10874. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_ABLE);
  10875. AscWaitEEPRead();
  10876. AscWriteEEPDataReg(iop_base, word_val);
  10877. AscWaitEEPRead();
  10878. AscWriteEEPCmdReg(iop_base,
  10879. (uchar)((uchar)ASC_EEP_CMD_WRITE | addr));
  10880. AscWaitEEPWrite();
  10881. AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
  10882. AscWaitEEPRead();
  10883. return (AscReadEEPWord(iop_base, addr));
  10884. }
  10885. return (read_wval);
  10886. }
  10887. static int __devinit
  10888. AscSetEEPConfigOnce(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  10889. {
  10890. int n_error;
  10891. ushort *wbuf;
  10892. ushort word;
  10893. ushort sum;
  10894. int s_addr;
  10895. int cfg_beg;
  10896. int cfg_end;
  10897. int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
  10898. wbuf = (ushort *)cfg_buf;
  10899. n_error = 0;
  10900. sum = 0;
  10901. /* Write two config words; AscWriteEEPWord() will swap bytes. */
  10902. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  10903. sum += *wbuf;
  10904. if (*wbuf != AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
  10905. n_error++;
  10906. }
  10907. }
  10908. if (bus_type & ASC_IS_VL) {
  10909. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  10910. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  10911. } else {
  10912. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  10913. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  10914. }
  10915. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  10916. if (s_addr <= uchar_end_in_config) {
  10917. /*
  10918. * This is a char field. Swap char fields before they are
  10919. * swapped again by AscWriteEEPWord().
  10920. */
  10921. word = cpu_to_le16(*wbuf);
  10922. if (word !=
  10923. AscWriteEEPWord(iop_base, (uchar)s_addr, word)) {
  10924. n_error++;
  10925. }
  10926. } else {
  10927. /* Don't swap word field at the end - cntl field. */
  10928. if (*wbuf !=
  10929. AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
  10930. n_error++;
  10931. }
  10932. }
  10933. sum += *wbuf; /* Checksum calculated from word values. */
  10934. }
  10935. /* Write checksum word. It will be swapped by AscWriteEEPWord(). */
  10936. *wbuf = sum;
  10937. if (sum != AscWriteEEPWord(iop_base, (uchar)s_addr, sum)) {
  10938. n_error++;
  10939. }
  10940. /* Read EEPROM back again. */
  10941. wbuf = (ushort *)cfg_buf;
  10942. /*
  10943. * Read two config words; Byte-swapping done by AscReadEEPWord().
  10944. */
  10945. for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
  10946. if (*wbuf != AscReadEEPWord(iop_base, (uchar)s_addr)) {
  10947. n_error++;
  10948. }
  10949. }
  10950. if (bus_type & ASC_IS_VL) {
  10951. cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
  10952. cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
  10953. } else {
  10954. cfg_beg = ASC_EEP_DVC_CFG_BEG;
  10955. cfg_end = ASC_EEP_MAX_DVC_ADDR;
  10956. }
  10957. for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
  10958. if (s_addr <= uchar_end_in_config) {
  10959. /*
  10960. * Swap all char fields. Must unswap bytes already swapped
  10961. * by AscReadEEPWord().
  10962. */
  10963. word =
  10964. le16_to_cpu(AscReadEEPWord
  10965. (iop_base, (uchar)s_addr));
  10966. } else {
  10967. /* Don't swap word field at the end - cntl field. */
  10968. word = AscReadEEPWord(iop_base, (uchar)s_addr);
  10969. }
  10970. if (*wbuf != word) {
  10971. n_error++;
  10972. }
  10973. }
  10974. /* Read checksum; Byte swapping not needed. */
  10975. if (AscReadEEPWord(iop_base, (uchar)s_addr) != sum) {
  10976. n_error++;
  10977. }
  10978. return n_error;
  10979. }
  10980. static int __devinit
  10981. AscSetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
  10982. {
  10983. int retry;
  10984. int n_error;
  10985. retry = 0;
  10986. while (TRUE) {
  10987. if ((n_error = AscSetEEPConfigOnce(iop_base, cfg_buf,
  10988. bus_type)) == 0) {
  10989. break;
  10990. }
  10991. if (++retry > ASC_EEP_MAX_RETRY) {
  10992. break;
  10993. }
  10994. }
  10995. return n_error;
  10996. }
  10997. static ushort __devinit AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
  10998. {
  10999. ASCEEP_CONFIG eep_config_buf;
  11000. ASCEEP_CONFIG *eep_config;
  11001. PortAddr iop_base;
  11002. ushort chksum;
  11003. ushort warn_code;
  11004. ushort cfg_msw, cfg_lsw;
  11005. int i;
  11006. int write_eep = 0;
  11007. iop_base = asc_dvc->iop_base;
  11008. warn_code = 0;
  11009. AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0x00FE);
  11010. AscStopQueueExe(iop_base);
  11011. if ((AscStopChip(iop_base) == FALSE) ||
  11012. (AscGetChipScsiCtrl(iop_base) != 0)) {
  11013. asc_dvc->init_state |= ASC_INIT_RESET_SCSI_DONE;
  11014. AscResetChipAndScsiBus(asc_dvc);
  11015. mdelay(asc_dvc->scsi_reset_wait * 1000); /* XXX: msleep? */
  11016. }
  11017. if (AscIsChipHalted(iop_base) == FALSE) {
  11018. asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
  11019. return (warn_code);
  11020. }
  11021. AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
  11022. if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
  11023. asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
  11024. return (warn_code);
  11025. }
  11026. eep_config = (ASCEEP_CONFIG *)&eep_config_buf;
  11027. cfg_msw = AscGetChipCfgMsw(iop_base);
  11028. cfg_lsw = AscGetChipCfgLsw(iop_base);
  11029. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  11030. cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  11031. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  11032. AscSetChipCfgMsw(iop_base, cfg_msw);
  11033. }
  11034. chksum = AscGetEEPConfig(iop_base, eep_config, asc_dvc->bus_type);
  11035. ASC_DBG1(1, "AscInitFromEEP: chksum 0x%x\n", chksum);
  11036. if (chksum == 0) {
  11037. chksum = 0xaa55;
  11038. }
  11039. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  11040. warn_code |= ASC_WARN_AUTO_CONFIG;
  11041. if (asc_dvc->cfg->chip_version == 3) {
  11042. if (eep_config->cfg_lsw != cfg_lsw) {
  11043. warn_code |= ASC_WARN_EEPROM_RECOVER;
  11044. eep_config->cfg_lsw =
  11045. AscGetChipCfgLsw(iop_base);
  11046. }
  11047. if (eep_config->cfg_msw != cfg_msw) {
  11048. warn_code |= ASC_WARN_EEPROM_RECOVER;
  11049. eep_config->cfg_msw =
  11050. AscGetChipCfgMsw(iop_base);
  11051. }
  11052. }
  11053. }
  11054. eep_config->cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  11055. eep_config->cfg_lsw |= ASC_CFG0_HOST_INT_ON;
  11056. ASC_DBG1(1, "AscInitFromEEP: eep_config->chksum 0x%x\n",
  11057. eep_config->chksum);
  11058. if (chksum != eep_config->chksum) {
  11059. if (AscGetChipVersion(iop_base, asc_dvc->bus_type) ==
  11060. ASC_CHIP_VER_PCI_ULTRA_3050) {
  11061. ASC_DBG(1,
  11062. "AscInitFromEEP: chksum error ignored; EEPROM-less board\n");
  11063. eep_config->init_sdtr = 0xFF;
  11064. eep_config->disc_enable = 0xFF;
  11065. eep_config->start_motor = 0xFF;
  11066. eep_config->use_cmd_qng = 0;
  11067. eep_config->max_total_qng = 0xF0;
  11068. eep_config->max_tag_qng = 0x20;
  11069. eep_config->cntl = 0xBFFF;
  11070. ASC_EEP_SET_CHIP_ID(eep_config, 7);
  11071. eep_config->no_scam = 0;
  11072. eep_config->adapter_info[0] = 0;
  11073. eep_config->adapter_info[1] = 0;
  11074. eep_config->adapter_info[2] = 0;
  11075. eep_config->adapter_info[3] = 0;
  11076. eep_config->adapter_info[4] = 0;
  11077. /* Indicate EEPROM-less board. */
  11078. eep_config->adapter_info[5] = 0xBB;
  11079. } else {
  11080. ASC_PRINT
  11081. ("AscInitFromEEP: EEPROM checksum error; Will try to re-write EEPROM.\n");
  11082. write_eep = 1;
  11083. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  11084. }
  11085. }
  11086. asc_dvc->cfg->sdtr_enable = eep_config->init_sdtr;
  11087. asc_dvc->cfg->disc_enable = eep_config->disc_enable;
  11088. asc_dvc->cfg->cmd_qng_enabled = eep_config->use_cmd_qng;
  11089. asc_dvc->cfg->isa_dma_speed = ASC_EEP_GET_DMA_SPD(eep_config);
  11090. asc_dvc->start_motor = eep_config->start_motor;
  11091. asc_dvc->dvc_cntl = eep_config->cntl;
  11092. asc_dvc->no_scam = eep_config->no_scam;
  11093. asc_dvc->cfg->adapter_info[0] = eep_config->adapter_info[0];
  11094. asc_dvc->cfg->adapter_info[1] = eep_config->adapter_info[1];
  11095. asc_dvc->cfg->adapter_info[2] = eep_config->adapter_info[2];
  11096. asc_dvc->cfg->adapter_info[3] = eep_config->adapter_info[3];
  11097. asc_dvc->cfg->adapter_info[4] = eep_config->adapter_info[4];
  11098. asc_dvc->cfg->adapter_info[5] = eep_config->adapter_info[5];
  11099. if (!AscTestExternalLram(asc_dvc)) {
  11100. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) ==
  11101. ASC_IS_PCI_ULTRA)) {
  11102. eep_config->max_total_qng =
  11103. ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG;
  11104. eep_config->max_tag_qng =
  11105. ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG;
  11106. } else {
  11107. eep_config->cfg_msw |= 0x0800;
  11108. cfg_msw |= 0x0800;
  11109. AscSetChipCfgMsw(iop_base, cfg_msw);
  11110. eep_config->max_total_qng = ASC_MAX_PCI_INRAM_TOTAL_QNG;
  11111. eep_config->max_tag_qng = ASC_MAX_INRAM_TAG_QNG;
  11112. }
  11113. } else {
  11114. }
  11115. if (eep_config->max_total_qng < ASC_MIN_TOTAL_QNG) {
  11116. eep_config->max_total_qng = ASC_MIN_TOTAL_QNG;
  11117. }
  11118. if (eep_config->max_total_qng > ASC_MAX_TOTAL_QNG) {
  11119. eep_config->max_total_qng = ASC_MAX_TOTAL_QNG;
  11120. }
  11121. if (eep_config->max_tag_qng > eep_config->max_total_qng) {
  11122. eep_config->max_tag_qng = eep_config->max_total_qng;
  11123. }
  11124. if (eep_config->max_tag_qng < ASC_MIN_TAG_Q_PER_DVC) {
  11125. eep_config->max_tag_qng = ASC_MIN_TAG_Q_PER_DVC;
  11126. }
  11127. asc_dvc->max_total_qng = eep_config->max_total_qng;
  11128. if ((eep_config->use_cmd_qng & eep_config->disc_enable) !=
  11129. eep_config->use_cmd_qng) {
  11130. eep_config->disc_enable = eep_config->use_cmd_qng;
  11131. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  11132. }
  11133. if (asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL | ASC_IS_EISA)) {
  11134. asc_dvc->irq_no = AscGetChipIRQ(iop_base, asc_dvc->bus_type);
  11135. }
  11136. ASC_EEP_SET_CHIP_ID(eep_config,
  11137. ASC_EEP_GET_CHIP_ID(eep_config) & ASC_MAX_TID);
  11138. asc_dvc->cfg->chip_scsi_id = ASC_EEP_GET_CHIP_ID(eep_config);
  11139. if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) &&
  11140. !(asc_dvc->dvc_cntl & ASC_CNTL_SDTR_ENABLE_ULTRA)) {
  11141. asc_dvc->host_init_sdtr_index = ASC_SDTR_ULTRA_PCI_10MB_INDEX;
  11142. }
  11143. for (i = 0; i <= ASC_MAX_TID; i++) {
  11144. asc_dvc->dos_int13_table[i] = eep_config->dos_int13_table[i];
  11145. asc_dvc->cfg->max_tag_qng[i] = eep_config->max_tag_qng;
  11146. asc_dvc->cfg->sdtr_period_offset[i] =
  11147. (uchar)(ASC_DEF_SDTR_OFFSET |
  11148. (asc_dvc->host_init_sdtr_index << 4));
  11149. }
  11150. eep_config->cfg_msw = AscGetChipCfgMsw(iop_base);
  11151. if (write_eep) {
  11152. if ((i = AscSetEEPConfig(iop_base, eep_config,
  11153. asc_dvc->bus_type)) != 0) {
  11154. ASC_PRINT1
  11155. ("AscInitFromEEP: Failed to re-write EEPROM with %d errors.\n",
  11156. i);
  11157. } else {
  11158. ASC_PRINT
  11159. ("AscInitFromEEP: Successfully re-wrote EEPROM.\n");
  11160. }
  11161. }
  11162. return (warn_code);
  11163. }
  11164. static int __devinit AscInitGetConfig(asc_board_t *boardp)
  11165. {
  11166. ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  11167. unsigned short warn_code = 0;
  11168. asc_dvc->init_state = ASC_INIT_STATE_BEG_GET_CFG;
  11169. if (asc_dvc->err_code != 0)
  11170. return asc_dvc->err_code;
  11171. if (AscFindSignature(asc_dvc->iop_base)) {
  11172. warn_code |= AscInitAscDvcVar(asc_dvc);
  11173. warn_code |= AscInitFromEEP(asc_dvc);
  11174. asc_dvc->init_state |= ASC_INIT_STATE_END_GET_CFG;
  11175. if (asc_dvc->scsi_reset_wait > ASC_MAX_SCSI_RESET_WAIT)
  11176. asc_dvc->scsi_reset_wait = ASC_MAX_SCSI_RESET_WAIT;
  11177. } else {
  11178. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  11179. }
  11180. switch (warn_code) {
  11181. case 0: /* No error */
  11182. break;
  11183. case ASC_WARN_IO_PORT_ROTATE:
  11184. ASC_PRINT1("AscInitGetConfig: board %d: I/O port address "
  11185. "modified\n", boardp->id);
  11186. break;
  11187. case ASC_WARN_AUTO_CONFIG:
  11188. ASC_PRINT1("AscInitGetConfig: board %d: I/O port increment "
  11189. "switch enabled\n", boardp->id);
  11190. break;
  11191. case ASC_WARN_EEPROM_CHKSUM:
  11192. ASC_PRINT1("AscInitGetConfig: board %d: EEPROM checksum "
  11193. "error\n", boardp->id);
  11194. break;
  11195. case ASC_WARN_IRQ_MODIFIED:
  11196. ASC_PRINT1("AscInitGetConfig: board %d: IRQ modified\n",
  11197. boardp->id);
  11198. break;
  11199. case ASC_WARN_CMD_QNG_CONFLICT:
  11200. ASC_PRINT1("AscInitGetConfig: board %d: tag queuing enabled "
  11201. "w/o disconnects\n", boardp->id);
  11202. break;
  11203. default:
  11204. ASC_PRINT2("AscInitGetConfig: board %d: unknown warning: "
  11205. "0x%x\n", boardp->id, warn_code);
  11206. break;
  11207. }
  11208. if (asc_dvc->err_code != 0) {
  11209. ASC_PRINT3("AscInitGetConfig: board %d error: init_state 0x%x, "
  11210. "err_code 0x%x\n", boardp->id, asc_dvc->init_state,
  11211. asc_dvc->err_code);
  11212. }
  11213. return asc_dvc->err_code;
  11214. }
  11215. static int __devinit AscInitSetConfig(struct pci_dev *pdev, asc_board_t *boardp)
  11216. {
  11217. ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
  11218. PortAddr iop_base = asc_dvc->iop_base;
  11219. unsigned short cfg_msw;
  11220. unsigned short warn_code = 0;
  11221. asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
  11222. if (asc_dvc->err_code != 0)
  11223. return asc_dvc->err_code;
  11224. if (!AscFindSignature(asc_dvc->iop_base)) {
  11225. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  11226. return asc_dvc->err_code;
  11227. }
  11228. cfg_msw = AscGetChipCfgMsw(iop_base);
  11229. if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
  11230. cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
  11231. warn_code |= ASC_WARN_CFG_MSW_RECOVER;
  11232. AscSetChipCfgMsw(iop_base, cfg_msw);
  11233. }
  11234. if ((asc_dvc->cfg->cmd_qng_enabled & asc_dvc->cfg->disc_enable) !=
  11235. asc_dvc->cfg->cmd_qng_enabled) {
  11236. asc_dvc->cfg->disc_enable = asc_dvc->cfg->cmd_qng_enabled;
  11237. warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
  11238. }
  11239. if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
  11240. warn_code |= ASC_WARN_AUTO_CONFIG;
  11241. }
  11242. if ((asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL)) != 0) {
  11243. if (AscSetChipIRQ(iop_base, asc_dvc->irq_no, asc_dvc->bus_type)
  11244. != asc_dvc->irq_no) {
  11245. asc_dvc->err_code |= ASC_IERR_SET_IRQ_NO;
  11246. }
  11247. }
  11248. #ifdef CONFIG_PCI
  11249. if (asc_dvc->bus_type & ASC_IS_PCI) {
  11250. cfg_msw &= 0xFFC0;
  11251. AscSetChipCfgMsw(iop_base, cfg_msw);
  11252. if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) {
  11253. } else {
  11254. if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
  11255. (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
  11256. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_IF_NOT_DWB;
  11257. asc_dvc->bug_fix_cntl |=
  11258. ASC_BUG_FIX_ASYN_USE_SYN;
  11259. }
  11260. }
  11261. } else
  11262. #endif /* CONFIG_PCI */
  11263. if (asc_dvc->bus_type == ASC_IS_ISAPNP) {
  11264. if (AscGetChipVersion(iop_base, asc_dvc->bus_type)
  11265. == ASC_CHIP_VER_ASYN_BUG) {
  11266. asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN;
  11267. }
  11268. }
  11269. if (AscSetChipScsiID(iop_base, asc_dvc->cfg->chip_scsi_id) !=
  11270. asc_dvc->cfg->chip_scsi_id) {
  11271. asc_dvc->err_code |= ASC_IERR_SET_SCSI_ID;
  11272. }
  11273. #ifdef CONFIG_ISA
  11274. if (asc_dvc->bus_type & ASC_IS_ISA) {
  11275. AscSetIsaDmaChannel(iop_base, asc_dvc->cfg->isa_dma_channel);
  11276. AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed);
  11277. }
  11278. #endif /* CONFIG_ISA */
  11279. asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
  11280. switch (warn_code) {
  11281. case 0: /* No error. */
  11282. break;
  11283. case ASC_WARN_IO_PORT_ROTATE:
  11284. ASC_PRINT1("AscInitSetConfig: board %d: I/O port address "
  11285. "modified\n", boardp->id);
  11286. break;
  11287. case ASC_WARN_AUTO_CONFIG:
  11288. ASC_PRINT1("AscInitSetConfig: board %d: I/O port increment "
  11289. "switch enabled\n", boardp->id);
  11290. break;
  11291. case ASC_WARN_EEPROM_CHKSUM:
  11292. ASC_PRINT1("AscInitSetConfig: board %d: EEPROM checksum "
  11293. "error\n", boardp->id);
  11294. break;
  11295. case ASC_WARN_IRQ_MODIFIED:
  11296. ASC_PRINT1("AscInitSetConfig: board %d: IRQ modified\n",
  11297. boardp->id);
  11298. break;
  11299. case ASC_WARN_CMD_QNG_CONFLICT:
  11300. ASC_PRINT1("AscInitSetConfig: board %d: tag queuing w/o "
  11301. "disconnects\n",
  11302. boardp->id);
  11303. break;
  11304. default:
  11305. ASC_PRINT2("AscInitSetConfig: board %d: unknown warning: "
  11306. "0x%x\n", boardp->id, warn_code);
  11307. break;
  11308. }
  11309. if (asc_dvc->err_code != 0) {
  11310. ASC_PRINT3("AscInitSetConfig: board %d error: init_state 0x%x, "
  11311. "err_code 0x%x\n", boardp->id, asc_dvc->init_state,
  11312. asc_dvc->err_code);
  11313. }
  11314. return asc_dvc->err_code;
  11315. }
  11316. /*
  11317. * EEPROM Configuration.
  11318. *
  11319. * All drivers should use this structure to set the default EEPROM
  11320. * configuration. The BIOS now uses this structure when it is built.
  11321. * Additional structure information can be found in a_condor.h where
  11322. * the structure is defined.
  11323. *
  11324. * The *_Field_IsChar structs are needed to correct for endianness.
  11325. * These values are read from the board 16 bits at a time directly
  11326. * into the structs. Because some fields are char, the values will be
  11327. * in the wrong order. The *_Field_IsChar tells when to flip the
  11328. * bytes. Data read and written to PCI memory is automatically swapped
  11329. * on big-endian platforms so char fields read as words are actually being
  11330. * unswapped on big-endian platforms.
  11331. */
  11332. static ADVEEP_3550_CONFIG Default_3550_EEPROM_Config __devinitdata = {
  11333. ADV_EEPROM_BIOS_ENABLE, /* cfg_lsw */
  11334. 0x0000, /* cfg_msw */
  11335. 0xFFFF, /* disc_enable */
  11336. 0xFFFF, /* wdtr_able */
  11337. 0xFFFF, /* sdtr_able */
  11338. 0xFFFF, /* start_motor */
  11339. 0xFFFF, /* tagqng_able */
  11340. 0xFFFF, /* bios_scan */
  11341. 0, /* scam_tolerant */
  11342. 7, /* adapter_scsi_id */
  11343. 0, /* bios_boot_delay */
  11344. 3, /* scsi_reset_delay */
  11345. 0, /* bios_id_lun */
  11346. 0, /* termination */
  11347. 0, /* reserved1 */
  11348. 0xFFE7, /* bios_ctrl */
  11349. 0xFFFF, /* ultra_able */
  11350. 0, /* reserved2 */
  11351. ASC_DEF_MAX_HOST_QNG, /* max_host_qng */
  11352. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  11353. 0, /* dvc_cntl */
  11354. 0, /* bug_fix */
  11355. 0, /* serial_number_word1 */
  11356. 0, /* serial_number_word2 */
  11357. 0, /* serial_number_word3 */
  11358. 0, /* check_sum */
  11359. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  11360. , /* oem_name[16] */
  11361. 0, /* dvc_err_code */
  11362. 0, /* adv_err_code */
  11363. 0, /* adv_err_addr */
  11364. 0, /* saved_dvc_err_code */
  11365. 0, /* saved_adv_err_code */
  11366. 0, /* saved_adv_err_addr */
  11367. 0 /* num_of_err */
  11368. };
  11369. static ADVEEP_3550_CONFIG ADVEEP_3550_Config_Field_IsChar __devinitdata = {
  11370. 0, /* cfg_lsw */
  11371. 0, /* cfg_msw */
  11372. 0, /* -disc_enable */
  11373. 0, /* wdtr_able */
  11374. 0, /* sdtr_able */
  11375. 0, /* start_motor */
  11376. 0, /* tagqng_able */
  11377. 0, /* bios_scan */
  11378. 0, /* scam_tolerant */
  11379. 1, /* adapter_scsi_id */
  11380. 1, /* bios_boot_delay */
  11381. 1, /* scsi_reset_delay */
  11382. 1, /* bios_id_lun */
  11383. 1, /* termination */
  11384. 1, /* reserved1 */
  11385. 0, /* bios_ctrl */
  11386. 0, /* ultra_able */
  11387. 0, /* reserved2 */
  11388. 1, /* max_host_qng */
  11389. 1, /* max_dvc_qng */
  11390. 0, /* dvc_cntl */
  11391. 0, /* bug_fix */
  11392. 0, /* serial_number_word1 */
  11393. 0, /* serial_number_word2 */
  11394. 0, /* serial_number_word3 */
  11395. 0, /* check_sum */
  11396. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  11397. , /* oem_name[16] */
  11398. 0, /* dvc_err_code */
  11399. 0, /* adv_err_code */
  11400. 0, /* adv_err_addr */
  11401. 0, /* saved_dvc_err_code */
  11402. 0, /* saved_adv_err_code */
  11403. 0, /* saved_adv_err_addr */
  11404. 0 /* num_of_err */
  11405. };
  11406. static ADVEEP_38C0800_CONFIG Default_38C0800_EEPROM_Config __devinitdata = {
  11407. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  11408. 0x0000, /* 01 cfg_msw */
  11409. 0xFFFF, /* 02 disc_enable */
  11410. 0xFFFF, /* 03 wdtr_able */
  11411. 0x4444, /* 04 sdtr_speed1 */
  11412. 0xFFFF, /* 05 start_motor */
  11413. 0xFFFF, /* 06 tagqng_able */
  11414. 0xFFFF, /* 07 bios_scan */
  11415. 0, /* 08 scam_tolerant */
  11416. 7, /* 09 adapter_scsi_id */
  11417. 0, /* bios_boot_delay */
  11418. 3, /* 10 scsi_reset_delay */
  11419. 0, /* bios_id_lun */
  11420. 0, /* 11 termination_se */
  11421. 0, /* termination_lvd */
  11422. 0xFFE7, /* 12 bios_ctrl */
  11423. 0x4444, /* 13 sdtr_speed2 */
  11424. 0x4444, /* 14 sdtr_speed3 */
  11425. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  11426. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  11427. 0, /* 16 dvc_cntl */
  11428. 0x4444, /* 17 sdtr_speed4 */
  11429. 0, /* 18 serial_number_word1 */
  11430. 0, /* 19 serial_number_word2 */
  11431. 0, /* 20 serial_number_word3 */
  11432. 0, /* 21 check_sum */
  11433. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  11434. , /* 22-29 oem_name[16] */
  11435. 0, /* 30 dvc_err_code */
  11436. 0, /* 31 adv_err_code */
  11437. 0, /* 32 adv_err_addr */
  11438. 0, /* 33 saved_dvc_err_code */
  11439. 0, /* 34 saved_adv_err_code */
  11440. 0, /* 35 saved_adv_err_addr */
  11441. 0, /* 36 reserved */
  11442. 0, /* 37 reserved */
  11443. 0, /* 38 reserved */
  11444. 0, /* 39 reserved */
  11445. 0, /* 40 reserved */
  11446. 0, /* 41 reserved */
  11447. 0, /* 42 reserved */
  11448. 0, /* 43 reserved */
  11449. 0, /* 44 reserved */
  11450. 0, /* 45 reserved */
  11451. 0, /* 46 reserved */
  11452. 0, /* 47 reserved */
  11453. 0, /* 48 reserved */
  11454. 0, /* 49 reserved */
  11455. 0, /* 50 reserved */
  11456. 0, /* 51 reserved */
  11457. 0, /* 52 reserved */
  11458. 0, /* 53 reserved */
  11459. 0, /* 54 reserved */
  11460. 0, /* 55 reserved */
  11461. 0, /* 56 cisptr_lsw */
  11462. 0, /* 57 cisprt_msw */
  11463. PCI_VENDOR_ID_ASP, /* 58 subsysvid */
  11464. PCI_DEVICE_ID_38C0800_REV1, /* 59 subsysid */
  11465. 0, /* 60 reserved */
  11466. 0, /* 61 reserved */
  11467. 0, /* 62 reserved */
  11468. 0 /* 63 reserved */
  11469. };
  11470. static ADVEEP_38C0800_CONFIG ADVEEP_38C0800_Config_Field_IsChar __devinitdata = {
  11471. 0, /* 00 cfg_lsw */
  11472. 0, /* 01 cfg_msw */
  11473. 0, /* 02 disc_enable */
  11474. 0, /* 03 wdtr_able */
  11475. 0, /* 04 sdtr_speed1 */
  11476. 0, /* 05 start_motor */
  11477. 0, /* 06 tagqng_able */
  11478. 0, /* 07 bios_scan */
  11479. 0, /* 08 scam_tolerant */
  11480. 1, /* 09 adapter_scsi_id */
  11481. 1, /* bios_boot_delay */
  11482. 1, /* 10 scsi_reset_delay */
  11483. 1, /* bios_id_lun */
  11484. 1, /* 11 termination_se */
  11485. 1, /* termination_lvd */
  11486. 0, /* 12 bios_ctrl */
  11487. 0, /* 13 sdtr_speed2 */
  11488. 0, /* 14 sdtr_speed3 */
  11489. 1, /* 15 max_host_qng */
  11490. 1, /* max_dvc_qng */
  11491. 0, /* 16 dvc_cntl */
  11492. 0, /* 17 sdtr_speed4 */
  11493. 0, /* 18 serial_number_word1 */
  11494. 0, /* 19 serial_number_word2 */
  11495. 0, /* 20 serial_number_word3 */
  11496. 0, /* 21 check_sum */
  11497. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  11498. , /* 22-29 oem_name[16] */
  11499. 0, /* 30 dvc_err_code */
  11500. 0, /* 31 adv_err_code */
  11501. 0, /* 32 adv_err_addr */
  11502. 0, /* 33 saved_dvc_err_code */
  11503. 0, /* 34 saved_adv_err_code */
  11504. 0, /* 35 saved_adv_err_addr */
  11505. 0, /* 36 reserved */
  11506. 0, /* 37 reserved */
  11507. 0, /* 38 reserved */
  11508. 0, /* 39 reserved */
  11509. 0, /* 40 reserved */
  11510. 0, /* 41 reserved */
  11511. 0, /* 42 reserved */
  11512. 0, /* 43 reserved */
  11513. 0, /* 44 reserved */
  11514. 0, /* 45 reserved */
  11515. 0, /* 46 reserved */
  11516. 0, /* 47 reserved */
  11517. 0, /* 48 reserved */
  11518. 0, /* 49 reserved */
  11519. 0, /* 50 reserved */
  11520. 0, /* 51 reserved */
  11521. 0, /* 52 reserved */
  11522. 0, /* 53 reserved */
  11523. 0, /* 54 reserved */
  11524. 0, /* 55 reserved */
  11525. 0, /* 56 cisptr_lsw */
  11526. 0, /* 57 cisprt_msw */
  11527. 0, /* 58 subsysvid */
  11528. 0, /* 59 subsysid */
  11529. 0, /* 60 reserved */
  11530. 0, /* 61 reserved */
  11531. 0, /* 62 reserved */
  11532. 0 /* 63 reserved */
  11533. };
  11534. static ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config __devinitdata = {
  11535. ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
  11536. 0x0000, /* 01 cfg_msw */
  11537. 0xFFFF, /* 02 disc_enable */
  11538. 0xFFFF, /* 03 wdtr_able */
  11539. 0x5555, /* 04 sdtr_speed1 */
  11540. 0xFFFF, /* 05 start_motor */
  11541. 0xFFFF, /* 06 tagqng_able */
  11542. 0xFFFF, /* 07 bios_scan */
  11543. 0, /* 08 scam_tolerant */
  11544. 7, /* 09 adapter_scsi_id */
  11545. 0, /* bios_boot_delay */
  11546. 3, /* 10 scsi_reset_delay */
  11547. 0, /* bios_id_lun */
  11548. 0, /* 11 termination_se */
  11549. 0, /* termination_lvd */
  11550. 0xFFE7, /* 12 bios_ctrl */
  11551. 0x5555, /* 13 sdtr_speed2 */
  11552. 0x5555, /* 14 sdtr_speed3 */
  11553. ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
  11554. ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
  11555. 0, /* 16 dvc_cntl */
  11556. 0x5555, /* 17 sdtr_speed4 */
  11557. 0, /* 18 serial_number_word1 */
  11558. 0, /* 19 serial_number_word2 */
  11559. 0, /* 20 serial_number_word3 */
  11560. 0, /* 21 check_sum */
  11561. {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  11562. , /* 22-29 oem_name[16] */
  11563. 0, /* 30 dvc_err_code */
  11564. 0, /* 31 adv_err_code */
  11565. 0, /* 32 adv_err_addr */
  11566. 0, /* 33 saved_dvc_err_code */
  11567. 0, /* 34 saved_adv_err_code */
  11568. 0, /* 35 saved_adv_err_addr */
  11569. 0, /* 36 reserved */
  11570. 0, /* 37 reserved */
  11571. 0, /* 38 reserved */
  11572. 0, /* 39 reserved */
  11573. 0, /* 40 reserved */
  11574. 0, /* 41 reserved */
  11575. 0, /* 42 reserved */
  11576. 0, /* 43 reserved */
  11577. 0, /* 44 reserved */
  11578. 0, /* 45 reserved */
  11579. 0, /* 46 reserved */
  11580. 0, /* 47 reserved */
  11581. 0, /* 48 reserved */
  11582. 0, /* 49 reserved */
  11583. 0, /* 50 reserved */
  11584. 0, /* 51 reserved */
  11585. 0, /* 52 reserved */
  11586. 0, /* 53 reserved */
  11587. 0, /* 54 reserved */
  11588. 0, /* 55 reserved */
  11589. 0, /* 56 cisptr_lsw */
  11590. 0, /* 57 cisprt_msw */
  11591. PCI_VENDOR_ID_ASP, /* 58 subsysvid */
  11592. PCI_DEVICE_ID_38C1600_REV1, /* 59 subsysid */
  11593. 0, /* 60 reserved */
  11594. 0, /* 61 reserved */
  11595. 0, /* 62 reserved */
  11596. 0 /* 63 reserved */
  11597. };
  11598. static ADVEEP_38C1600_CONFIG ADVEEP_38C1600_Config_Field_IsChar __devinitdata = {
  11599. 0, /* 00 cfg_lsw */
  11600. 0, /* 01 cfg_msw */
  11601. 0, /* 02 disc_enable */
  11602. 0, /* 03 wdtr_able */
  11603. 0, /* 04 sdtr_speed1 */
  11604. 0, /* 05 start_motor */
  11605. 0, /* 06 tagqng_able */
  11606. 0, /* 07 bios_scan */
  11607. 0, /* 08 scam_tolerant */
  11608. 1, /* 09 adapter_scsi_id */
  11609. 1, /* bios_boot_delay */
  11610. 1, /* 10 scsi_reset_delay */
  11611. 1, /* bios_id_lun */
  11612. 1, /* 11 termination_se */
  11613. 1, /* termination_lvd */
  11614. 0, /* 12 bios_ctrl */
  11615. 0, /* 13 sdtr_speed2 */
  11616. 0, /* 14 sdtr_speed3 */
  11617. 1, /* 15 max_host_qng */
  11618. 1, /* max_dvc_qng */
  11619. 0, /* 16 dvc_cntl */
  11620. 0, /* 17 sdtr_speed4 */
  11621. 0, /* 18 serial_number_word1 */
  11622. 0, /* 19 serial_number_word2 */
  11623. 0, /* 20 serial_number_word3 */
  11624. 0, /* 21 check_sum */
  11625. {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
  11626. , /* 22-29 oem_name[16] */
  11627. 0, /* 30 dvc_err_code */
  11628. 0, /* 31 adv_err_code */
  11629. 0, /* 32 adv_err_addr */
  11630. 0, /* 33 saved_dvc_err_code */
  11631. 0, /* 34 saved_adv_err_code */
  11632. 0, /* 35 saved_adv_err_addr */
  11633. 0, /* 36 reserved */
  11634. 0, /* 37 reserved */
  11635. 0, /* 38 reserved */
  11636. 0, /* 39 reserved */
  11637. 0, /* 40 reserved */
  11638. 0, /* 41 reserved */
  11639. 0, /* 42 reserved */
  11640. 0, /* 43 reserved */
  11641. 0, /* 44 reserved */
  11642. 0, /* 45 reserved */
  11643. 0, /* 46 reserved */
  11644. 0, /* 47 reserved */
  11645. 0, /* 48 reserved */
  11646. 0, /* 49 reserved */
  11647. 0, /* 50 reserved */
  11648. 0, /* 51 reserved */
  11649. 0, /* 52 reserved */
  11650. 0, /* 53 reserved */
  11651. 0, /* 54 reserved */
  11652. 0, /* 55 reserved */
  11653. 0, /* 56 cisptr_lsw */
  11654. 0, /* 57 cisprt_msw */
  11655. 0, /* 58 subsysvid */
  11656. 0, /* 59 subsysid */
  11657. 0, /* 60 reserved */
  11658. 0, /* 61 reserved */
  11659. 0, /* 62 reserved */
  11660. 0 /* 63 reserved */
  11661. };
  11662. #ifdef CONFIG_PCI
  11663. /*
  11664. * Wait for EEPROM command to complete
  11665. */
  11666. static void __devinit AdvWaitEEPCmd(AdvPortAddr iop_base)
  11667. {
  11668. int eep_delay_ms;
  11669. for (eep_delay_ms = 0; eep_delay_ms < ADV_EEP_DELAY_MS; eep_delay_ms++) {
  11670. if (AdvReadWordRegister(iop_base, IOPW_EE_CMD) &
  11671. ASC_EEP_CMD_DONE) {
  11672. break;
  11673. }
  11674. mdelay(1);
  11675. }
  11676. if ((AdvReadWordRegister(iop_base, IOPW_EE_CMD) & ASC_EEP_CMD_DONE) ==
  11677. 0)
  11678. BUG();
  11679. }
  11680. /*
  11681. * Read the EEPROM from specified location
  11682. */
  11683. static ushort __devinit AdvReadEEPWord(AdvPortAddr iop_base, int eep_word_addr)
  11684. {
  11685. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11686. ASC_EEP_CMD_READ | eep_word_addr);
  11687. AdvWaitEEPCmd(iop_base);
  11688. return AdvReadWordRegister(iop_base, IOPW_EE_DATA);
  11689. }
  11690. /*
  11691. * Write the EEPROM from 'cfg_buf'.
  11692. */
  11693. void __devinit
  11694. AdvSet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  11695. {
  11696. ushort *wbuf;
  11697. ushort addr, chksum;
  11698. ushort *charfields;
  11699. wbuf = (ushort *)cfg_buf;
  11700. charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
  11701. chksum = 0;
  11702. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  11703. AdvWaitEEPCmd(iop_base);
  11704. /*
  11705. * Write EEPROM from word 0 to word 20.
  11706. */
  11707. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  11708. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  11709. ushort word;
  11710. if (*charfields++) {
  11711. word = cpu_to_le16(*wbuf);
  11712. } else {
  11713. word = *wbuf;
  11714. }
  11715. chksum += *wbuf; /* Checksum is calculated from word values. */
  11716. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11717. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11718. ASC_EEP_CMD_WRITE | addr);
  11719. AdvWaitEEPCmd(iop_base);
  11720. mdelay(ADV_EEP_DELAY_MS);
  11721. }
  11722. /*
  11723. * Write EEPROM checksum at word 21.
  11724. */
  11725. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  11726. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  11727. AdvWaitEEPCmd(iop_base);
  11728. wbuf++;
  11729. charfields++;
  11730. /*
  11731. * Write EEPROM OEM name at words 22 to 29.
  11732. */
  11733. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  11734. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  11735. ushort word;
  11736. if (*charfields++) {
  11737. word = cpu_to_le16(*wbuf);
  11738. } else {
  11739. word = *wbuf;
  11740. }
  11741. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11742. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11743. ASC_EEP_CMD_WRITE | addr);
  11744. AdvWaitEEPCmd(iop_base);
  11745. }
  11746. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  11747. AdvWaitEEPCmd(iop_base);
  11748. }
  11749. /*
  11750. * Write the EEPROM from 'cfg_buf'.
  11751. */
  11752. void __devinit
  11753. AdvSet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
  11754. {
  11755. ushort *wbuf;
  11756. ushort *charfields;
  11757. ushort addr, chksum;
  11758. wbuf = (ushort *)cfg_buf;
  11759. charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
  11760. chksum = 0;
  11761. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  11762. AdvWaitEEPCmd(iop_base);
  11763. /*
  11764. * Write EEPROM from word 0 to word 20.
  11765. */
  11766. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  11767. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  11768. ushort word;
  11769. if (*charfields++) {
  11770. word = cpu_to_le16(*wbuf);
  11771. } else {
  11772. word = *wbuf;
  11773. }
  11774. chksum += *wbuf; /* Checksum is calculated from word values. */
  11775. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11776. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11777. ASC_EEP_CMD_WRITE | addr);
  11778. AdvWaitEEPCmd(iop_base);
  11779. mdelay(ADV_EEP_DELAY_MS);
  11780. }
  11781. /*
  11782. * Write EEPROM checksum at word 21.
  11783. */
  11784. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  11785. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  11786. AdvWaitEEPCmd(iop_base);
  11787. wbuf++;
  11788. charfields++;
  11789. /*
  11790. * Write EEPROM OEM name at words 22 to 29.
  11791. */
  11792. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  11793. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  11794. ushort word;
  11795. if (*charfields++) {
  11796. word = cpu_to_le16(*wbuf);
  11797. } else {
  11798. word = *wbuf;
  11799. }
  11800. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11801. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11802. ASC_EEP_CMD_WRITE | addr);
  11803. AdvWaitEEPCmd(iop_base);
  11804. }
  11805. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  11806. AdvWaitEEPCmd(iop_base);
  11807. }
  11808. /*
  11809. * Write the EEPROM from 'cfg_buf'.
  11810. */
  11811. void __devinit
  11812. AdvSet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
  11813. {
  11814. ushort *wbuf;
  11815. ushort *charfields;
  11816. ushort addr, chksum;
  11817. wbuf = (ushort *)cfg_buf;
  11818. charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
  11819. chksum = 0;
  11820. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
  11821. AdvWaitEEPCmd(iop_base);
  11822. /*
  11823. * Write EEPROM from word 0 to word 20.
  11824. */
  11825. for (addr = ADV_EEP_DVC_CFG_BEGIN;
  11826. addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
  11827. ushort word;
  11828. if (*charfields++) {
  11829. word = cpu_to_le16(*wbuf);
  11830. } else {
  11831. word = *wbuf;
  11832. }
  11833. chksum += *wbuf; /* Checksum is calculated from word values. */
  11834. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11835. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11836. ASC_EEP_CMD_WRITE | addr);
  11837. AdvWaitEEPCmd(iop_base);
  11838. mdelay(ADV_EEP_DELAY_MS);
  11839. }
  11840. /*
  11841. * Write EEPROM checksum at word 21.
  11842. */
  11843. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
  11844. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
  11845. AdvWaitEEPCmd(iop_base);
  11846. wbuf++;
  11847. charfields++;
  11848. /*
  11849. * Write EEPROM OEM name at words 22 to 29.
  11850. */
  11851. for (addr = ADV_EEP_DVC_CTL_BEGIN;
  11852. addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
  11853. ushort word;
  11854. if (*charfields++) {
  11855. word = cpu_to_le16(*wbuf);
  11856. } else {
  11857. word = *wbuf;
  11858. }
  11859. AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
  11860. AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
  11861. ASC_EEP_CMD_WRITE | addr);
  11862. AdvWaitEEPCmd(iop_base);
  11863. }
  11864. AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
  11865. AdvWaitEEPCmd(iop_base);
  11866. }
  11867. /*
  11868. * Read EEPROM configuration into the specified buffer.
  11869. *
  11870. * Return a checksum based on the EEPROM configuration read.
  11871. */
  11872. static ushort __devinit
  11873. AdvGet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
  11874. {
  11875. ushort wval, chksum;
  11876. ushort *wbuf;
  11877. int eep_addr;
  11878. ushort *charfields;
  11879. charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
  11880. wbuf = (ushort *)cfg_buf;
  11881. chksum = 0;
  11882. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  11883. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  11884. wval = AdvReadEEPWord(iop_base, eep_addr);
  11885. chksum += wval; /* Checksum is calculated from word values. */
  11886. if (*charfields++) {
  11887. *wbuf = le16_to_cpu(wval);
  11888. } else {
  11889. *wbuf = wval;
  11890. }
  11891. }
  11892. /* Read checksum word. */
  11893. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11894. wbuf++;
  11895. charfields++;
  11896. /* Read rest of EEPROM not covered by the checksum. */
  11897. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  11898. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  11899. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11900. if (*charfields++) {
  11901. *wbuf = le16_to_cpu(*wbuf);
  11902. }
  11903. }
  11904. return chksum;
  11905. }
  11906. /*
  11907. * Read EEPROM configuration into the specified buffer.
  11908. *
  11909. * Return a checksum based on the EEPROM configuration read.
  11910. */
  11911. static ushort __devinit
  11912. AdvGet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
  11913. {
  11914. ushort wval, chksum;
  11915. ushort *wbuf;
  11916. int eep_addr;
  11917. ushort *charfields;
  11918. charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
  11919. wbuf = (ushort *)cfg_buf;
  11920. chksum = 0;
  11921. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  11922. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  11923. wval = AdvReadEEPWord(iop_base, eep_addr);
  11924. chksum += wval; /* Checksum is calculated from word values. */
  11925. if (*charfields++) {
  11926. *wbuf = le16_to_cpu(wval);
  11927. } else {
  11928. *wbuf = wval;
  11929. }
  11930. }
  11931. /* Read checksum word. */
  11932. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11933. wbuf++;
  11934. charfields++;
  11935. /* Read rest of EEPROM not covered by the checksum. */
  11936. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  11937. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  11938. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11939. if (*charfields++) {
  11940. *wbuf = le16_to_cpu(*wbuf);
  11941. }
  11942. }
  11943. return chksum;
  11944. }
  11945. /*
  11946. * Read EEPROM configuration into the specified buffer.
  11947. *
  11948. * Return a checksum based on the EEPROM configuration read.
  11949. */
  11950. static ushort __devinit
  11951. AdvGet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
  11952. {
  11953. ushort wval, chksum;
  11954. ushort *wbuf;
  11955. int eep_addr;
  11956. ushort *charfields;
  11957. charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
  11958. wbuf = (ushort *)cfg_buf;
  11959. chksum = 0;
  11960. for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
  11961. eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
  11962. wval = AdvReadEEPWord(iop_base, eep_addr);
  11963. chksum += wval; /* Checksum is calculated from word values. */
  11964. if (*charfields++) {
  11965. *wbuf = le16_to_cpu(wval);
  11966. } else {
  11967. *wbuf = wval;
  11968. }
  11969. }
  11970. /* Read checksum word. */
  11971. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11972. wbuf++;
  11973. charfields++;
  11974. /* Read rest of EEPROM not covered by the checksum. */
  11975. for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
  11976. eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
  11977. *wbuf = AdvReadEEPWord(iop_base, eep_addr);
  11978. if (*charfields++) {
  11979. *wbuf = le16_to_cpu(*wbuf);
  11980. }
  11981. }
  11982. return chksum;
  11983. }
  11984. /*
  11985. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  11986. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  11987. * all of this is done.
  11988. *
  11989. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  11990. *
  11991. * For a non-fatal error return a warning code. If there are no warnings
  11992. * then 0 is returned.
  11993. *
  11994. * Note: Chip is stopped on entry.
  11995. */
  11996. static int __devinit AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
  11997. {
  11998. AdvPortAddr iop_base;
  11999. ushort warn_code;
  12000. ADVEEP_3550_CONFIG eep_config;
  12001. iop_base = asc_dvc->iop_base;
  12002. warn_code = 0;
  12003. /*
  12004. * Read the board's EEPROM configuration.
  12005. *
  12006. * Set default values if a bad checksum is found.
  12007. */
  12008. if (AdvGet3550EEPConfig(iop_base, &eep_config) != eep_config.check_sum) {
  12009. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  12010. /*
  12011. * Set EEPROM default values.
  12012. */
  12013. memcpy(&eep_config, &Default_3550_EEPROM_Config,
  12014. sizeof(ADVEEP_3550_CONFIG));
  12015. /*
  12016. * Assume the 6 byte board serial number that was read from
  12017. * EEPROM is correct even if the EEPROM checksum failed.
  12018. */
  12019. eep_config.serial_number_word3 =
  12020. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  12021. eep_config.serial_number_word2 =
  12022. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  12023. eep_config.serial_number_word1 =
  12024. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  12025. AdvSet3550EEPConfig(iop_base, &eep_config);
  12026. }
  12027. /*
  12028. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  12029. * EEPROM configuration that was read.
  12030. *
  12031. * This is the mapping of EEPROM fields to Adv Library fields.
  12032. */
  12033. asc_dvc->wdtr_able = eep_config.wdtr_able;
  12034. asc_dvc->sdtr_able = eep_config.sdtr_able;
  12035. asc_dvc->ultra_able = eep_config.ultra_able;
  12036. asc_dvc->tagqng_able = eep_config.tagqng_able;
  12037. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  12038. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12039. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12040. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  12041. asc_dvc->start_motor = eep_config.start_motor;
  12042. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  12043. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  12044. asc_dvc->no_scam = eep_config.scam_tolerant;
  12045. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  12046. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  12047. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  12048. /*
  12049. * Set the host maximum queuing (max. 253, min. 16) and the per device
  12050. * maximum queuing (max. 63, min. 4).
  12051. */
  12052. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  12053. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12054. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  12055. /* If the value is zero, assume it is uninitialized. */
  12056. if (eep_config.max_host_qng == 0) {
  12057. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12058. } else {
  12059. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  12060. }
  12061. }
  12062. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  12063. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12064. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  12065. /* If the value is zero, assume it is uninitialized. */
  12066. if (eep_config.max_dvc_qng == 0) {
  12067. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12068. } else {
  12069. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  12070. }
  12071. }
  12072. /*
  12073. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  12074. * set 'max_dvc_qng' to 'max_host_qng'.
  12075. */
  12076. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  12077. eep_config.max_dvc_qng = eep_config.max_host_qng;
  12078. }
  12079. /*
  12080. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  12081. * values based on possibly adjusted EEPROM values.
  12082. */
  12083. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12084. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12085. /*
  12086. * If the EEPROM 'termination' field is set to automatic (0), then set
  12087. * the ADV_DVC_CFG 'termination' field to automatic also.
  12088. *
  12089. * If the termination is specified with a non-zero 'termination'
  12090. * value check that a legal value is set and set the ADV_DVC_CFG
  12091. * 'termination' field appropriately.
  12092. */
  12093. if (eep_config.termination == 0) {
  12094. asc_dvc->cfg->termination = 0; /* auto termination */
  12095. } else {
  12096. /* Enable manual control with low off / high off. */
  12097. if (eep_config.termination == 1) {
  12098. asc_dvc->cfg->termination = TERM_CTL_SEL;
  12099. /* Enable manual control with low off / high on. */
  12100. } else if (eep_config.termination == 2) {
  12101. asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H;
  12102. /* Enable manual control with low on / high on. */
  12103. } else if (eep_config.termination == 3) {
  12104. asc_dvc->cfg->termination =
  12105. TERM_CTL_SEL | TERM_CTL_H | TERM_CTL_L;
  12106. } else {
  12107. /*
  12108. * The EEPROM 'termination' field contains a bad value. Use
  12109. * automatic termination instead.
  12110. */
  12111. asc_dvc->cfg->termination = 0;
  12112. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12113. }
  12114. }
  12115. return warn_code;
  12116. }
  12117. /*
  12118. * Read the board's EEPROM configuration. Set fields in ADV_DVC_VAR and
  12119. * ADV_DVC_CFG based on the EEPROM settings. The chip is stopped while
  12120. * all of this is done.
  12121. *
  12122. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  12123. *
  12124. * For a non-fatal error return a warning code. If there are no warnings
  12125. * then 0 is returned.
  12126. *
  12127. * Note: Chip is stopped on entry.
  12128. */
  12129. static int __devinit AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
  12130. {
  12131. AdvPortAddr iop_base;
  12132. ushort warn_code;
  12133. ADVEEP_38C0800_CONFIG eep_config;
  12134. uchar tid, termination;
  12135. ushort sdtr_speed = 0;
  12136. iop_base = asc_dvc->iop_base;
  12137. warn_code = 0;
  12138. /*
  12139. * Read the board's EEPROM configuration.
  12140. *
  12141. * Set default values if a bad checksum is found.
  12142. */
  12143. if (AdvGet38C0800EEPConfig(iop_base, &eep_config) !=
  12144. eep_config.check_sum) {
  12145. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  12146. /*
  12147. * Set EEPROM default values.
  12148. */
  12149. memcpy(&eep_config, &Default_38C0800_EEPROM_Config,
  12150. sizeof(ADVEEP_38C0800_CONFIG));
  12151. /*
  12152. * Assume the 6 byte board serial number that was read from
  12153. * EEPROM is correct even if the EEPROM checksum failed.
  12154. */
  12155. eep_config.serial_number_word3 =
  12156. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  12157. eep_config.serial_number_word2 =
  12158. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  12159. eep_config.serial_number_word1 =
  12160. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  12161. AdvSet38C0800EEPConfig(iop_base, &eep_config);
  12162. }
  12163. /*
  12164. * Set ADV_DVC_VAR and ADV_DVC_CFG variables from the
  12165. * EEPROM configuration that was read.
  12166. *
  12167. * This is the mapping of EEPROM fields to Adv Library fields.
  12168. */
  12169. asc_dvc->wdtr_able = eep_config.wdtr_able;
  12170. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  12171. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  12172. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  12173. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  12174. asc_dvc->tagqng_able = eep_config.tagqng_able;
  12175. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  12176. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12177. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12178. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
  12179. asc_dvc->start_motor = eep_config.start_motor;
  12180. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  12181. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  12182. asc_dvc->no_scam = eep_config.scam_tolerant;
  12183. asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
  12184. asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
  12185. asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
  12186. /*
  12187. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  12188. * are set, then set an 'sdtr_able' bit for it.
  12189. */
  12190. asc_dvc->sdtr_able = 0;
  12191. for (tid = 0; tid <= ADV_MAX_TID; tid++) {
  12192. if (tid == 0) {
  12193. sdtr_speed = asc_dvc->sdtr_speed1;
  12194. } else if (tid == 4) {
  12195. sdtr_speed = asc_dvc->sdtr_speed2;
  12196. } else if (tid == 8) {
  12197. sdtr_speed = asc_dvc->sdtr_speed3;
  12198. } else if (tid == 12) {
  12199. sdtr_speed = asc_dvc->sdtr_speed4;
  12200. }
  12201. if (sdtr_speed & ADV_MAX_TID) {
  12202. asc_dvc->sdtr_able |= (1 << tid);
  12203. }
  12204. sdtr_speed >>= 4;
  12205. }
  12206. /*
  12207. * Set the host maximum queuing (max. 253, min. 16) and the per device
  12208. * maximum queuing (max. 63, min. 4).
  12209. */
  12210. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  12211. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12212. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  12213. /* If the value is zero, assume it is uninitialized. */
  12214. if (eep_config.max_host_qng == 0) {
  12215. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12216. } else {
  12217. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  12218. }
  12219. }
  12220. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  12221. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12222. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  12223. /* If the value is zero, assume it is uninitialized. */
  12224. if (eep_config.max_dvc_qng == 0) {
  12225. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12226. } else {
  12227. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  12228. }
  12229. }
  12230. /*
  12231. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  12232. * set 'max_dvc_qng' to 'max_host_qng'.
  12233. */
  12234. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  12235. eep_config.max_dvc_qng = eep_config.max_host_qng;
  12236. }
  12237. /*
  12238. * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
  12239. * values based on possibly adjusted EEPROM values.
  12240. */
  12241. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12242. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12243. /*
  12244. * If the EEPROM 'termination' field is set to automatic (0), then set
  12245. * the ADV_DVC_CFG 'termination' field to automatic also.
  12246. *
  12247. * If the termination is specified with a non-zero 'termination'
  12248. * value check that a legal value is set and set the ADV_DVC_CFG
  12249. * 'termination' field appropriately.
  12250. */
  12251. if (eep_config.termination_se == 0) {
  12252. termination = 0; /* auto termination for SE */
  12253. } else {
  12254. /* Enable manual control with low off / high off. */
  12255. if (eep_config.termination_se == 1) {
  12256. termination = 0;
  12257. /* Enable manual control with low off / high on. */
  12258. } else if (eep_config.termination_se == 2) {
  12259. termination = TERM_SE_HI;
  12260. /* Enable manual control with low on / high on. */
  12261. } else if (eep_config.termination_se == 3) {
  12262. termination = TERM_SE;
  12263. } else {
  12264. /*
  12265. * The EEPROM 'termination_se' field contains a bad value.
  12266. * Use automatic termination instead.
  12267. */
  12268. termination = 0;
  12269. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12270. }
  12271. }
  12272. if (eep_config.termination_lvd == 0) {
  12273. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  12274. } else {
  12275. /* Enable manual control with low off / high off. */
  12276. if (eep_config.termination_lvd == 1) {
  12277. asc_dvc->cfg->termination = termination;
  12278. /* Enable manual control with low off / high on. */
  12279. } else if (eep_config.termination_lvd == 2) {
  12280. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  12281. /* Enable manual control with low on / high on. */
  12282. } else if (eep_config.termination_lvd == 3) {
  12283. asc_dvc->cfg->termination = termination | TERM_LVD;
  12284. } else {
  12285. /*
  12286. * The EEPROM 'termination_lvd' field contains a bad value.
  12287. * Use automatic termination instead.
  12288. */
  12289. asc_dvc->cfg->termination = termination;
  12290. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12291. }
  12292. }
  12293. return warn_code;
  12294. }
  12295. /*
  12296. * Read the board's EEPROM configuration. Set fields in ASC_DVC_VAR and
  12297. * ASC_DVC_CFG based on the EEPROM settings. The chip is stopped while
  12298. * all of this is done.
  12299. *
  12300. * On failure set the ASC_DVC_VAR field 'err_code' and return ADV_ERROR.
  12301. *
  12302. * For a non-fatal error return a warning code. If there are no warnings
  12303. * then 0 is returned.
  12304. *
  12305. * Note: Chip is stopped on entry.
  12306. */
  12307. static int __devinit AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
  12308. {
  12309. AdvPortAddr iop_base;
  12310. ushort warn_code;
  12311. ADVEEP_38C1600_CONFIG eep_config;
  12312. uchar tid, termination;
  12313. ushort sdtr_speed = 0;
  12314. iop_base = asc_dvc->iop_base;
  12315. warn_code = 0;
  12316. /*
  12317. * Read the board's EEPROM configuration.
  12318. *
  12319. * Set default values if a bad checksum is found.
  12320. */
  12321. if (AdvGet38C1600EEPConfig(iop_base, &eep_config) !=
  12322. eep_config.check_sum) {
  12323. struct pci_dev *pdev = adv_dvc_to_pdev(asc_dvc);
  12324. warn_code |= ASC_WARN_EEPROM_CHKSUM;
  12325. /*
  12326. * Set EEPROM default values.
  12327. */
  12328. memcpy(&eep_config, &Default_38C1600_EEPROM_Config,
  12329. sizeof(ADVEEP_38C1600_CONFIG));
  12330. if (PCI_FUNC(pdev->devfn) != 0) {
  12331. u8 ints;
  12332. /*
  12333. * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60
  12334. * and old Mac system booting problem. The Expansion
  12335. * ROM must be disabled in Function 1 for these systems
  12336. */
  12337. eep_config.cfg_lsw &= ~ADV_EEPROM_BIOS_ENABLE;
  12338. /*
  12339. * Clear the INTAB (bit 11) if the GPIO 0 input
  12340. * indicates the Function 1 interrupt line is wired
  12341. * to INTB.
  12342. *
  12343. * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input:
  12344. * 1 - Function 1 interrupt line wired to INT A.
  12345. * 0 - Function 1 interrupt line wired to INT B.
  12346. *
  12347. * Note: Function 0 is always wired to INTA.
  12348. * Put all 5 GPIO bits in input mode and then read
  12349. * their input values.
  12350. */
  12351. AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, 0);
  12352. ints = AdvReadByteRegister(iop_base, IOPB_GPIO_DATA);
  12353. if ((ints & 0x01) == 0)
  12354. eep_config.cfg_lsw &= ~ADV_EEPROM_INTAB;
  12355. }
  12356. /*
  12357. * Assume the 6 byte board serial number that was read from
  12358. * EEPROM is correct even if the EEPROM checksum failed.
  12359. */
  12360. eep_config.serial_number_word3 =
  12361. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
  12362. eep_config.serial_number_word2 =
  12363. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
  12364. eep_config.serial_number_word1 =
  12365. AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
  12366. AdvSet38C1600EEPConfig(iop_base, &eep_config);
  12367. }
  12368. /*
  12369. * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
  12370. * EEPROM configuration that was read.
  12371. *
  12372. * This is the mapping of EEPROM fields to Adv Library fields.
  12373. */
  12374. asc_dvc->wdtr_able = eep_config.wdtr_able;
  12375. asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
  12376. asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
  12377. asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
  12378. asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
  12379. asc_dvc->ppr_able = 0;
  12380. asc_dvc->tagqng_able = eep_config.tagqng_able;
  12381. asc_dvc->cfg->disc_enable = eep_config.disc_enable;
  12382. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12383. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12384. asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ASC_MAX_TID);
  12385. asc_dvc->start_motor = eep_config.start_motor;
  12386. asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
  12387. asc_dvc->bios_ctrl = eep_config.bios_ctrl;
  12388. asc_dvc->no_scam = eep_config.scam_tolerant;
  12389. /*
  12390. * For every Target ID if any of its 'sdtr_speed[1234]' bits
  12391. * are set, then set an 'sdtr_able' bit for it.
  12392. */
  12393. asc_dvc->sdtr_able = 0;
  12394. for (tid = 0; tid <= ASC_MAX_TID; tid++) {
  12395. if (tid == 0) {
  12396. sdtr_speed = asc_dvc->sdtr_speed1;
  12397. } else if (tid == 4) {
  12398. sdtr_speed = asc_dvc->sdtr_speed2;
  12399. } else if (tid == 8) {
  12400. sdtr_speed = asc_dvc->sdtr_speed3;
  12401. } else if (tid == 12) {
  12402. sdtr_speed = asc_dvc->sdtr_speed4;
  12403. }
  12404. if (sdtr_speed & ASC_MAX_TID) {
  12405. asc_dvc->sdtr_able |= (1 << tid);
  12406. }
  12407. sdtr_speed >>= 4;
  12408. }
  12409. /*
  12410. * Set the host maximum queuing (max. 253, min. 16) and the per device
  12411. * maximum queuing (max. 63, min. 4).
  12412. */
  12413. if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
  12414. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12415. } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
  12416. /* If the value is zero, assume it is uninitialized. */
  12417. if (eep_config.max_host_qng == 0) {
  12418. eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
  12419. } else {
  12420. eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
  12421. }
  12422. }
  12423. if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
  12424. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12425. } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
  12426. /* If the value is zero, assume it is uninitialized. */
  12427. if (eep_config.max_dvc_qng == 0) {
  12428. eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
  12429. } else {
  12430. eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
  12431. }
  12432. }
  12433. /*
  12434. * If 'max_dvc_qng' is greater than 'max_host_qng', then
  12435. * set 'max_dvc_qng' to 'max_host_qng'.
  12436. */
  12437. if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
  12438. eep_config.max_dvc_qng = eep_config.max_host_qng;
  12439. }
  12440. /*
  12441. * Set ASC_DVC_VAR 'max_host_qng' and ASC_DVC_VAR 'max_dvc_qng'
  12442. * values based on possibly adjusted EEPROM values.
  12443. */
  12444. asc_dvc->max_host_qng = eep_config.max_host_qng;
  12445. asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
  12446. /*
  12447. * If the EEPROM 'termination' field is set to automatic (0), then set
  12448. * the ASC_DVC_CFG 'termination' field to automatic also.
  12449. *
  12450. * If the termination is specified with a non-zero 'termination'
  12451. * value check that a legal value is set and set the ASC_DVC_CFG
  12452. * 'termination' field appropriately.
  12453. */
  12454. if (eep_config.termination_se == 0) {
  12455. termination = 0; /* auto termination for SE */
  12456. } else {
  12457. /* Enable manual control with low off / high off. */
  12458. if (eep_config.termination_se == 1) {
  12459. termination = 0;
  12460. /* Enable manual control with low off / high on. */
  12461. } else if (eep_config.termination_se == 2) {
  12462. termination = TERM_SE_HI;
  12463. /* Enable manual control with low on / high on. */
  12464. } else if (eep_config.termination_se == 3) {
  12465. termination = TERM_SE;
  12466. } else {
  12467. /*
  12468. * The EEPROM 'termination_se' field contains a bad value.
  12469. * Use automatic termination instead.
  12470. */
  12471. termination = 0;
  12472. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12473. }
  12474. }
  12475. if (eep_config.termination_lvd == 0) {
  12476. asc_dvc->cfg->termination = termination; /* auto termination for LVD */
  12477. } else {
  12478. /* Enable manual control with low off / high off. */
  12479. if (eep_config.termination_lvd == 1) {
  12480. asc_dvc->cfg->termination = termination;
  12481. /* Enable manual control with low off / high on. */
  12482. } else if (eep_config.termination_lvd == 2) {
  12483. asc_dvc->cfg->termination = termination | TERM_LVD_HI;
  12484. /* Enable manual control with low on / high on. */
  12485. } else if (eep_config.termination_lvd == 3) {
  12486. asc_dvc->cfg->termination = termination | TERM_LVD;
  12487. } else {
  12488. /*
  12489. * The EEPROM 'termination_lvd' field contains a bad value.
  12490. * Use automatic termination instead.
  12491. */
  12492. asc_dvc->cfg->termination = termination;
  12493. warn_code |= ASC_WARN_EEPROM_TERMINATION;
  12494. }
  12495. }
  12496. return warn_code;
  12497. }
  12498. /*
  12499. * Initialize the ADV_DVC_VAR structure.
  12500. *
  12501. * On failure set the ADV_DVC_VAR field 'err_code' and return ADV_ERROR.
  12502. *
  12503. * For a non-fatal error return a warning code. If there are no warnings
  12504. * then 0 is returned.
  12505. */
  12506. static int __devinit
  12507. AdvInitGetConfig(struct pci_dev *pdev, asc_board_t *boardp)
  12508. {
  12509. ADV_DVC_VAR *asc_dvc = &boardp->dvc_var.adv_dvc_var;
  12510. unsigned short warn_code = 0;
  12511. AdvPortAddr iop_base = asc_dvc->iop_base;
  12512. u16 cmd;
  12513. int status;
  12514. asc_dvc->err_code = 0;
  12515. /*
  12516. * Save the state of the PCI Configuration Command Register
  12517. * "Parity Error Response Control" Bit. If the bit is clear (0),
  12518. * in AdvInitAsc3550/38C0800Driver() tell the microcode to ignore
  12519. * DMA parity errors.
  12520. */
  12521. asc_dvc->cfg->control_flag = 0;
  12522. pci_read_config_word(pdev, PCI_COMMAND, &cmd);
  12523. if ((cmd & PCI_COMMAND_PARITY) == 0)
  12524. asc_dvc->cfg->control_flag |= CONTROL_FLAG_IGNORE_PERR;
  12525. asc_dvc->cfg->lib_version = (ADV_LIB_VERSION_MAJOR << 8) |
  12526. ADV_LIB_VERSION_MINOR;
  12527. asc_dvc->cfg->chip_version =
  12528. AdvGetChipVersion(iop_base, asc_dvc->bus_type);
  12529. ASC_DBG2(1, "AdvInitGetConfig: iopb_chip_id_1: 0x%x 0x%x\n",
  12530. (ushort)AdvReadByteRegister(iop_base, IOPB_CHIP_ID_1),
  12531. (ushort)ADV_CHIP_ID_BYTE);
  12532. ASC_DBG2(1, "AdvInitGetConfig: iopw_chip_id_0: 0x%x 0x%x\n",
  12533. (ushort)AdvReadWordRegister(iop_base, IOPW_CHIP_ID_0),
  12534. (ushort)ADV_CHIP_ID_WORD);
  12535. /*
  12536. * Reset the chip to start and allow register writes.
  12537. */
  12538. if (AdvFindSignature(iop_base) == 0) {
  12539. asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
  12540. return ADV_ERROR;
  12541. } else {
  12542. /*
  12543. * The caller must set 'chip_type' to a valid setting.
  12544. */
  12545. if (asc_dvc->chip_type != ADV_CHIP_ASC3550 &&
  12546. asc_dvc->chip_type != ADV_CHIP_ASC38C0800 &&
  12547. asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
  12548. asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
  12549. return ADV_ERROR;
  12550. }
  12551. /*
  12552. * Reset Chip.
  12553. */
  12554. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  12555. ADV_CTRL_REG_CMD_RESET);
  12556. mdelay(100);
  12557. AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
  12558. ADV_CTRL_REG_CMD_WR_IO_REG);
  12559. if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
  12560. status = AdvInitFrom38C1600EEP(asc_dvc);
  12561. } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
  12562. status = AdvInitFrom38C0800EEP(asc_dvc);
  12563. } else {
  12564. status = AdvInitFrom3550EEP(asc_dvc);
  12565. }
  12566. warn_code |= status;
  12567. }
  12568. if (warn_code != 0) {
  12569. ASC_PRINT2("AdvInitGetConfig: board %d: warning: 0x%x\n",
  12570. boardp->id, warn_code);
  12571. }
  12572. if (asc_dvc->err_code) {
  12573. ASC_PRINT2("AdvInitGetConfig: board %d error: err_code 0x%x\n",
  12574. boardp->id, asc_dvc->err_code);
  12575. }
  12576. return asc_dvc->err_code;
  12577. }
  12578. #endif
  12579. static struct scsi_host_template advansys_template = {
  12580. .proc_name = DRV_NAME,
  12581. #ifdef CONFIG_PROC_FS
  12582. .proc_info = advansys_proc_info,
  12583. #endif
  12584. .name = DRV_NAME,
  12585. .info = advansys_info,
  12586. .queuecommand = advansys_queuecommand,
  12587. .eh_bus_reset_handler = advansys_reset,
  12588. .bios_param = advansys_biosparam,
  12589. .slave_configure = advansys_slave_configure,
  12590. /*
  12591. * Because the driver may control an ISA adapter 'unchecked_isa_dma'
  12592. * must be set. The flag will be cleared in advansys_board_found
  12593. * for non-ISA adapters.
  12594. */
  12595. .unchecked_isa_dma = 1,
  12596. /*
  12597. * All adapters controlled by this driver are capable of large
  12598. * scatter-gather lists. According to the mid-level SCSI documentation
  12599. * this obviates any performance gain provided by setting
  12600. * 'use_clustering'. But empirically while CPU utilization is increased
  12601. * by enabling clustering, I/O throughput increases as well.
  12602. */
  12603. .use_clustering = ENABLE_CLUSTERING,
  12604. };
  12605. static int __devinit
  12606. advansys_wide_init_chip(asc_board_t *boardp, ADV_DVC_VAR *adv_dvc_varp)
  12607. {
  12608. int req_cnt = 0;
  12609. adv_req_t *reqp = NULL;
  12610. int sg_cnt = 0;
  12611. adv_sgblk_t *sgp;
  12612. int warn_code, err_code;
  12613. /*
  12614. * Allocate buffer carrier structures. The total size
  12615. * is about 4 KB, so allocate all at once.
  12616. */
  12617. boardp->carrp = kmalloc(ADV_CARRIER_BUFSIZE, GFP_KERNEL);
  12618. ASC_DBG1(1, "advansys_wide_init_chip: carrp 0x%p\n", boardp->carrp);
  12619. if (!boardp->carrp)
  12620. goto kmalloc_failed;
  12621. /*
  12622. * Allocate up to 'max_host_qng' request structures for the Wide
  12623. * board. The total size is about 16 KB, so allocate all at once.
  12624. * If the allocation fails decrement and try again.
  12625. */
  12626. for (req_cnt = adv_dvc_varp->max_host_qng; req_cnt > 0; req_cnt--) {
  12627. reqp = kmalloc(sizeof(adv_req_t) * req_cnt, GFP_KERNEL);
  12628. ASC_DBG3(1, "advansys_wide_init_chip: reqp 0x%p, req_cnt %d, "
  12629. "bytes %lu\n", reqp, req_cnt,
  12630. (ulong)sizeof(adv_req_t) * req_cnt);
  12631. if (reqp)
  12632. break;
  12633. }
  12634. if (!reqp)
  12635. goto kmalloc_failed;
  12636. boardp->orig_reqp = reqp;
  12637. /*
  12638. * Allocate up to ADV_TOT_SG_BLOCK request structures for
  12639. * the Wide board. Each structure is about 136 bytes.
  12640. */
  12641. boardp->adv_sgblkp = NULL;
  12642. for (sg_cnt = 0; sg_cnt < ADV_TOT_SG_BLOCK; sg_cnt++) {
  12643. sgp = kmalloc(sizeof(adv_sgblk_t), GFP_KERNEL);
  12644. if (!sgp)
  12645. break;
  12646. sgp->next_sgblkp = boardp->adv_sgblkp;
  12647. boardp->adv_sgblkp = sgp;
  12648. }
  12649. ASC_DBG3(1, "advansys_wide_init_chip: sg_cnt %d * %u = %u bytes\n",
  12650. sg_cnt, sizeof(adv_sgblk_t),
  12651. (unsigned)(sizeof(adv_sgblk_t) * sg_cnt));
  12652. if (!boardp->adv_sgblkp)
  12653. goto kmalloc_failed;
  12654. adv_dvc_varp->carrier_buf = boardp->carrp;
  12655. /*
  12656. * Point 'adv_reqp' to the request structures and
  12657. * link them together.
  12658. */
  12659. req_cnt--;
  12660. reqp[req_cnt].next_reqp = NULL;
  12661. for (; req_cnt > 0; req_cnt--) {
  12662. reqp[req_cnt - 1].next_reqp = &reqp[req_cnt];
  12663. }
  12664. boardp->adv_reqp = &reqp[0];
  12665. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  12666. ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc3550Driver()\n");
  12667. warn_code = AdvInitAsc3550Driver(adv_dvc_varp);
  12668. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  12669. ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc38C0800Driver()"
  12670. "\n");
  12671. warn_code = AdvInitAsc38C0800Driver(adv_dvc_varp);
  12672. } else {
  12673. ASC_DBG(2, "advansys_wide_init_chip: AdvInitAsc38C1600Driver()"
  12674. "\n");
  12675. warn_code = AdvInitAsc38C1600Driver(adv_dvc_varp);
  12676. }
  12677. err_code = adv_dvc_varp->err_code;
  12678. if (warn_code || err_code) {
  12679. ASC_PRINT3("advansys_wide_init_chip: board %d error: warn 0x%x,"
  12680. " error 0x%x\n", boardp->id, warn_code, err_code);
  12681. }
  12682. goto exit;
  12683. kmalloc_failed:
  12684. ASC_PRINT1("advansys_wide_init_chip: board %d error: kmalloc() "
  12685. "failed\n", boardp->id);
  12686. err_code = ADV_ERROR;
  12687. exit:
  12688. return err_code;
  12689. }
  12690. static void advansys_wide_free_mem(asc_board_t *boardp)
  12691. {
  12692. kfree(boardp->carrp);
  12693. boardp->carrp = NULL;
  12694. kfree(boardp->orig_reqp);
  12695. boardp->orig_reqp = boardp->adv_reqp = NULL;
  12696. while (boardp->adv_sgblkp) {
  12697. adv_sgblk_t *sgp = boardp->adv_sgblkp;
  12698. boardp->adv_sgblkp = sgp->next_sgblkp;
  12699. kfree(sgp);
  12700. }
  12701. }
  12702. static struct Scsi_Host *__devinit
  12703. advansys_board_found(int iop, struct device *dev, int bus_type)
  12704. {
  12705. struct Scsi_Host *shost;
  12706. struct pci_dev *pdev = bus_type == ASC_IS_PCI ? to_pci_dev(dev) : NULL;
  12707. asc_board_t *boardp;
  12708. ASC_DVC_VAR *asc_dvc_varp = NULL;
  12709. ADV_DVC_VAR *adv_dvc_varp = NULL;
  12710. int share_irq;
  12711. int warn_code, err_code;
  12712. int ret;
  12713. /*
  12714. * Register the adapter, get its configuration, and
  12715. * initialize it.
  12716. */
  12717. ASC_DBG(2, "advansys_board_found: scsi_host_alloc()\n");
  12718. shost = scsi_host_alloc(&advansys_template, sizeof(asc_board_t));
  12719. if (!shost)
  12720. return NULL;
  12721. /* Initialize private per board data */
  12722. boardp = ASC_BOARDP(shost);
  12723. memset(boardp, 0, sizeof(asc_board_t));
  12724. boardp->id = asc_board_count++;
  12725. spin_lock_init(&boardp->lock);
  12726. boardp->dev = dev;
  12727. /*
  12728. * Handle both narrow and wide boards.
  12729. *
  12730. * If a Wide board was detected, set the board structure
  12731. * wide board flag. Set-up the board structure based on
  12732. * the board type.
  12733. */
  12734. #ifdef CONFIG_PCI
  12735. if (bus_type == ASC_IS_PCI &&
  12736. (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW ||
  12737. pdev->device == PCI_DEVICE_ID_38C0800_REV1 ||
  12738. pdev->device == PCI_DEVICE_ID_38C1600_REV1)) {
  12739. boardp->flags |= ASC_IS_WIDE_BOARD;
  12740. }
  12741. #endif /* CONFIG_PCI */
  12742. if (ASC_NARROW_BOARD(boardp)) {
  12743. ASC_DBG(1, "advansys_board_found: narrow board\n");
  12744. asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
  12745. asc_dvc_varp->bus_type = bus_type;
  12746. asc_dvc_varp->drv_ptr = boardp;
  12747. asc_dvc_varp->cfg = &boardp->dvc_cfg.asc_dvc_cfg;
  12748. asc_dvc_varp->cfg->overrun_buf = &overrun_buf[0];
  12749. asc_dvc_varp->iop_base = iop;
  12750. } else {
  12751. #ifdef CONFIG_PCI
  12752. ASC_DBG(1, "advansys_board_found: wide board\n");
  12753. adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
  12754. adv_dvc_varp->drv_ptr = boardp;
  12755. adv_dvc_varp->cfg = &boardp->dvc_cfg.adv_dvc_cfg;
  12756. if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW) {
  12757. ASC_DBG(1, "advansys_board_found: ASC-3550\n");
  12758. adv_dvc_varp->chip_type = ADV_CHIP_ASC3550;
  12759. } else if (pdev->device == PCI_DEVICE_ID_38C0800_REV1) {
  12760. ASC_DBG(1, "advansys_board_found: ASC-38C0800\n");
  12761. adv_dvc_varp->chip_type = ADV_CHIP_ASC38C0800;
  12762. } else {
  12763. ASC_DBG(1, "advansys_board_found: ASC-38C1600\n");
  12764. adv_dvc_varp->chip_type = ADV_CHIP_ASC38C1600;
  12765. }
  12766. boardp->asc_n_io_port = pci_resource_len(pdev, 1);
  12767. boardp->ioremap_addr = ioremap(pci_resource_start(pdev, 1),
  12768. boardp->asc_n_io_port);
  12769. if (!boardp->ioremap_addr) {
  12770. ASC_PRINT3
  12771. ("advansys_board_found: board %d: ioremap(%x, %d) returned NULL\n",
  12772. boardp->id, pci_resource_start(pdev, 1),
  12773. boardp->asc_n_io_port);
  12774. goto err_shost;
  12775. }
  12776. adv_dvc_varp->iop_base = (AdvPortAddr)boardp->ioremap_addr
  12777. ASC_DBG1(1, "advansys_board_found: iop_base: 0x%lx\n",
  12778. adv_dvc_varp->iop_base);
  12779. /*
  12780. * Even though it isn't used to access wide boards, other
  12781. * than for the debug line below, save I/O Port address so
  12782. * that it can be reported.
  12783. */
  12784. boardp->ioport = iop;
  12785. ASC_DBG2(1, "advansys_board_found: iopb_chip_id_1 0x%x, "
  12786. "iopw_chip_id_0 0x%x\n", (ushort)inp(iop + 1),
  12787. (ushort)inpw(iop));
  12788. #endif /* CONFIG_PCI */
  12789. }
  12790. #ifdef CONFIG_PROC_FS
  12791. /*
  12792. * Allocate buffer for printing information from
  12793. * /proc/scsi/advansys/[0...].
  12794. */
  12795. boardp->prtbuf = kmalloc(ASC_PRTBUF_SIZE, GFP_KERNEL);
  12796. if (!boardp->prtbuf) {
  12797. ASC_PRINT2("advansys_board_found: board %d: kmalloc(%d) "
  12798. "returned NULL\n", boardp->id, ASC_PRTBUF_SIZE);
  12799. goto err_unmap;
  12800. }
  12801. #endif /* CONFIG_PROC_FS */
  12802. if (ASC_NARROW_BOARD(boardp)) {
  12803. /*
  12804. * Set the board bus type and PCI IRQ before
  12805. * calling AscInitGetConfig().
  12806. */
  12807. switch (asc_dvc_varp->bus_type) {
  12808. #ifdef CONFIG_ISA
  12809. case ASC_IS_ISA:
  12810. shost->unchecked_isa_dma = TRUE;
  12811. share_irq = 0;
  12812. break;
  12813. case ASC_IS_VL:
  12814. shost->unchecked_isa_dma = FALSE;
  12815. share_irq = 0;
  12816. break;
  12817. case ASC_IS_EISA:
  12818. shost->unchecked_isa_dma = FALSE;
  12819. share_irq = IRQF_SHARED;
  12820. break;
  12821. #endif /* CONFIG_ISA */
  12822. #ifdef CONFIG_PCI
  12823. case ASC_IS_PCI:
  12824. shost->irq = asc_dvc_varp->irq_no = pdev->irq;
  12825. shost->unchecked_isa_dma = FALSE;
  12826. share_irq = IRQF_SHARED;
  12827. break;
  12828. #endif /* CONFIG_PCI */
  12829. default:
  12830. ASC_PRINT2
  12831. ("advansys_board_found: board %d: unknown adapter type: %d\n",
  12832. boardp->id, asc_dvc_varp->bus_type);
  12833. shost->unchecked_isa_dma = TRUE;
  12834. share_irq = 0;
  12835. break;
  12836. }
  12837. /*
  12838. * NOTE: AscInitGetConfig() may change the board's
  12839. * bus_type value. The bus_type value should no
  12840. * longer be used. If the bus_type field must be
  12841. * referenced only use the bit-wise AND operator "&".
  12842. */
  12843. ASC_DBG(2, "advansys_board_found: AscInitGetConfig()\n");
  12844. err_code = AscInitGetConfig(boardp);
  12845. } else {
  12846. #ifdef CONFIG_PCI
  12847. /*
  12848. * For Wide boards set PCI information before calling
  12849. * AdvInitGetConfig().
  12850. */
  12851. shost->irq = adv_dvc_varp->irq_no = pdev->irq;
  12852. shost->unchecked_isa_dma = FALSE;
  12853. share_irq = IRQF_SHARED;
  12854. ASC_DBG(2, "advansys_board_found: AdvInitGetConfig()\n");
  12855. err_code = AdvInitGetConfig(pdev, boardp);
  12856. #endif /* CONFIG_PCI */
  12857. }
  12858. if (err_code != 0)
  12859. goto err_free_proc;
  12860. /*
  12861. * Save the EEPROM configuration so that it can be displayed
  12862. * from /proc/scsi/advansys/[0...].
  12863. */
  12864. if (ASC_NARROW_BOARD(boardp)) {
  12865. ASCEEP_CONFIG *ep;
  12866. /*
  12867. * Set the adapter's target id bit in the 'init_tidmask' field.
  12868. */
  12869. boardp->init_tidmask |=
  12870. ADV_TID_TO_TIDMASK(asc_dvc_varp->cfg->chip_scsi_id);
  12871. /*
  12872. * Save EEPROM settings for the board.
  12873. */
  12874. ep = &boardp->eep_config.asc_eep;
  12875. ep->init_sdtr = asc_dvc_varp->cfg->sdtr_enable;
  12876. ep->disc_enable = asc_dvc_varp->cfg->disc_enable;
  12877. ep->use_cmd_qng = asc_dvc_varp->cfg->cmd_qng_enabled;
  12878. ASC_EEP_SET_DMA_SPD(ep, asc_dvc_varp->cfg->isa_dma_speed);
  12879. ep->start_motor = asc_dvc_varp->start_motor;
  12880. ep->cntl = asc_dvc_varp->dvc_cntl;
  12881. ep->no_scam = asc_dvc_varp->no_scam;
  12882. ep->max_total_qng = asc_dvc_varp->max_total_qng;
  12883. ASC_EEP_SET_CHIP_ID(ep, asc_dvc_varp->cfg->chip_scsi_id);
  12884. /* 'max_tag_qng' is set to the same value for every device. */
  12885. ep->max_tag_qng = asc_dvc_varp->cfg->max_tag_qng[0];
  12886. ep->adapter_info[0] = asc_dvc_varp->cfg->adapter_info[0];
  12887. ep->adapter_info[1] = asc_dvc_varp->cfg->adapter_info[1];
  12888. ep->adapter_info[2] = asc_dvc_varp->cfg->adapter_info[2];
  12889. ep->adapter_info[3] = asc_dvc_varp->cfg->adapter_info[3];
  12890. ep->adapter_info[4] = asc_dvc_varp->cfg->adapter_info[4];
  12891. ep->adapter_info[5] = asc_dvc_varp->cfg->adapter_info[5];
  12892. /*
  12893. * Modify board configuration.
  12894. */
  12895. ASC_DBG(2, "advansys_board_found: AscInitSetConfig()\n");
  12896. err_code = AscInitSetConfig(pdev, boardp);
  12897. if (err_code)
  12898. goto err_free_proc;
  12899. /*
  12900. * Finish initializing the 'Scsi_Host' structure.
  12901. */
  12902. /* AscInitSetConfig() will set the IRQ for non-PCI boards. */
  12903. if ((asc_dvc_varp->bus_type & ASC_IS_PCI) == 0) {
  12904. shost->irq = asc_dvc_varp->irq_no;
  12905. }
  12906. } else {
  12907. ADVEEP_3550_CONFIG *ep_3550;
  12908. ADVEEP_38C0800_CONFIG *ep_38C0800;
  12909. ADVEEP_38C1600_CONFIG *ep_38C1600;
  12910. /*
  12911. * Save Wide EEP Configuration Information.
  12912. */
  12913. if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
  12914. ep_3550 = &boardp->eep_config.adv_3550_eep;
  12915. ep_3550->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
  12916. ep_3550->max_host_qng = adv_dvc_varp->max_host_qng;
  12917. ep_3550->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  12918. ep_3550->termination = adv_dvc_varp->cfg->termination;
  12919. ep_3550->disc_enable = adv_dvc_varp->cfg->disc_enable;
  12920. ep_3550->bios_ctrl = adv_dvc_varp->bios_ctrl;
  12921. ep_3550->wdtr_able = adv_dvc_varp->wdtr_able;
  12922. ep_3550->sdtr_able = adv_dvc_varp->sdtr_able;
  12923. ep_3550->ultra_able = adv_dvc_varp->ultra_able;
  12924. ep_3550->tagqng_able = adv_dvc_varp->tagqng_able;
  12925. ep_3550->start_motor = adv_dvc_varp->start_motor;
  12926. ep_3550->scsi_reset_delay =
  12927. adv_dvc_varp->scsi_reset_wait;
  12928. ep_3550->serial_number_word1 =
  12929. adv_dvc_varp->cfg->serial1;
  12930. ep_3550->serial_number_word2 =
  12931. adv_dvc_varp->cfg->serial2;
  12932. ep_3550->serial_number_word3 =
  12933. adv_dvc_varp->cfg->serial3;
  12934. } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
  12935. ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
  12936. ep_38C0800->adapter_scsi_id =
  12937. adv_dvc_varp->chip_scsi_id;
  12938. ep_38C0800->max_host_qng = adv_dvc_varp->max_host_qng;
  12939. ep_38C0800->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  12940. ep_38C0800->termination_lvd =
  12941. adv_dvc_varp->cfg->termination;
  12942. ep_38C0800->disc_enable =
  12943. adv_dvc_varp->cfg->disc_enable;
  12944. ep_38C0800->bios_ctrl = adv_dvc_varp->bios_ctrl;
  12945. ep_38C0800->wdtr_able = adv_dvc_varp->wdtr_able;
  12946. ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
  12947. ep_38C0800->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
  12948. ep_38C0800->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
  12949. ep_38C0800->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
  12950. ep_38C0800->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
  12951. ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
  12952. ep_38C0800->start_motor = adv_dvc_varp->start_motor;
  12953. ep_38C0800->scsi_reset_delay =
  12954. adv_dvc_varp->scsi_reset_wait;
  12955. ep_38C0800->serial_number_word1 =
  12956. adv_dvc_varp->cfg->serial1;
  12957. ep_38C0800->serial_number_word2 =
  12958. adv_dvc_varp->cfg->serial2;
  12959. ep_38C0800->serial_number_word3 =
  12960. adv_dvc_varp->cfg->serial3;
  12961. } else {
  12962. ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
  12963. ep_38C1600->adapter_scsi_id =
  12964. adv_dvc_varp->chip_scsi_id;
  12965. ep_38C1600->max_host_qng = adv_dvc_varp->max_host_qng;
  12966. ep_38C1600->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
  12967. ep_38C1600->termination_lvd =
  12968. adv_dvc_varp->cfg->termination;
  12969. ep_38C1600->disc_enable =
  12970. adv_dvc_varp->cfg->disc_enable;
  12971. ep_38C1600->bios_ctrl = adv_dvc_varp->bios_ctrl;
  12972. ep_38C1600->wdtr_able = adv_dvc_varp->wdtr_able;
  12973. ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
  12974. ep_38C1600->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
  12975. ep_38C1600->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
  12976. ep_38C1600->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
  12977. ep_38C1600->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
  12978. ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
  12979. ep_38C1600->start_motor = adv_dvc_varp->start_motor;
  12980. ep_38C1600->scsi_reset_delay =
  12981. adv_dvc_varp->scsi_reset_wait;
  12982. ep_38C1600->serial_number_word1 =
  12983. adv_dvc_varp->cfg->serial1;
  12984. ep_38C1600->serial_number_word2 =
  12985. adv_dvc_varp->cfg->serial2;
  12986. ep_38C1600->serial_number_word3 =
  12987. adv_dvc_varp->cfg->serial3;
  12988. }
  12989. /*
  12990. * Set the adapter's target id bit in the 'init_tidmask' field.
  12991. */
  12992. boardp->init_tidmask |=
  12993. ADV_TID_TO_TIDMASK(adv_dvc_varp->chip_scsi_id);
  12994. }
  12995. /*
  12996. * Channels are numbered beginning with 0. For AdvanSys one host
  12997. * structure supports one channel. Multi-channel boards have a
  12998. * separate host structure for each channel.
  12999. */
  13000. shost->max_channel = 0;
  13001. if (ASC_NARROW_BOARD(boardp)) {
  13002. shost->max_id = ASC_MAX_TID + 1;
  13003. shost->max_lun = ASC_MAX_LUN + 1;
  13004. shost->max_cmd_len = ASC_MAX_CDB_LEN;
  13005. shost->io_port = asc_dvc_varp->iop_base;
  13006. boardp->asc_n_io_port = ASC_IOADR_GAP;
  13007. shost->this_id = asc_dvc_varp->cfg->chip_scsi_id;
  13008. /* Set maximum number of queues the adapter can handle. */
  13009. shost->can_queue = asc_dvc_varp->max_total_qng;
  13010. } else {
  13011. shost->max_id = ADV_MAX_TID + 1;
  13012. shost->max_lun = ADV_MAX_LUN + 1;
  13013. shost->max_cmd_len = ADV_MAX_CDB_LEN;
  13014. /*
  13015. * Save the I/O Port address and length even though
  13016. * I/O ports are not used to access Wide boards.
  13017. * Instead the Wide boards are accessed with
  13018. * PCI Memory Mapped I/O.
  13019. */
  13020. shost->io_port = iop;
  13021. shost->this_id = adv_dvc_varp->chip_scsi_id;
  13022. /* Set maximum number of queues the adapter can handle. */
  13023. shost->can_queue = adv_dvc_varp->max_host_qng;
  13024. }
  13025. /*
  13026. * Following v1.3.89, 'cmd_per_lun' is no longer needed
  13027. * and should be set to zero.
  13028. *
  13029. * But because of a bug introduced in v1.3.89 if the driver is
  13030. * compiled as a module and 'cmd_per_lun' is zero, the Mid-Level
  13031. * SCSI function 'allocate_device' will panic. To allow the driver
  13032. * to work as a module in these kernels set 'cmd_per_lun' to 1.
  13033. *
  13034. * Note: This is wrong. cmd_per_lun should be set to the depth
  13035. * you want on untagged devices always.
  13036. #ifdef MODULE
  13037. */
  13038. shost->cmd_per_lun = 1;
  13039. /* #else
  13040. shost->cmd_per_lun = 0;
  13041. #endif */
  13042. /*
  13043. * Set the maximum number of scatter-gather elements the
  13044. * adapter can handle.
  13045. */
  13046. if (ASC_NARROW_BOARD(boardp)) {
  13047. /*
  13048. * Allow two commands with 'sg_tablesize' scatter-gather
  13049. * elements to be executed simultaneously. This value is
  13050. * the theoretical hardware limit. It may be decreased
  13051. * below.
  13052. */
  13053. shost->sg_tablesize =
  13054. (((asc_dvc_varp->max_total_qng - 2) / 2) *
  13055. ASC_SG_LIST_PER_Q) + 1;
  13056. } else {
  13057. shost->sg_tablesize = ADV_MAX_SG_LIST;
  13058. }
  13059. /*
  13060. * The value of 'sg_tablesize' can not exceed the SCSI
  13061. * mid-level driver definition of SG_ALL. SG_ALL also
  13062. * must not be exceeded, because it is used to define the
  13063. * size of the scatter-gather table in 'struct asc_sg_head'.
  13064. */
  13065. if (shost->sg_tablesize > SG_ALL) {
  13066. shost->sg_tablesize = SG_ALL;
  13067. }
  13068. ASC_DBG1(1, "advansys_board_found: sg_tablesize: %d\n", shost->sg_tablesize);
  13069. /* BIOS start address. */
  13070. if (ASC_NARROW_BOARD(boardp)) {
  13071. shost->base = AscGetChipBiosAddress(asc_dvc_varp->iop_base,
  13072. asc_dvc_varp->bus_type);
  13073. } else {
  13074. /*
  13075. * Fill-in BIOS board variables. The Wide BIOS saves
  13076. * information in LRAM that is used by the driver.
  13077. */
  13078. AdvReadWordLram(adv_dvc_varp->iop_base,
  13079. BIOS_SIGNATURE, boardp->bios_signature);
  13080. AdvReadWordLram(adv_dvc_varp->iop_base,
  13081. BIOS_VERSION, boardp->bios_version);
  13082. AdvReadWordLram(adv_dvc_varp->iop_base,
  13083. BIOS_CODESEG, boardp->bios_codeseg);
  13084. AdvReadWordLram(adv_dvc_varp->iop_base,
  13085. BIOS_CODELEN, boardp->bios_codelen);
  13086. ASC_DBG2(1,
  13087. "advansys_board_found: bios_signature 0x%x, bios_version 0x%x\n",
  13088. boardp->bios_signature, boardp->bios_version);
  13089. ASC_DBG2(1,
  13090. "advansys_board_found: bios_codeseg 0x%x, bios_codelen 0x%x\n",
  13091. boardp->bios_codeseg, boardp->bios_codelen);
  13092. /*
  13093. * If the BIOS saved a valid signature, then fill in
  13094. * the BIOS code segment base address.
  13095. */
  13096. if (boardp->bios_signature == 0x55AA) {
  13097. /*
  13098. * Convert x86 realmode code segment to a linear
  13099. * address by shifting left 4.
  13100. */
  13101. shost->base = ((ulong)boardp->bios_codeseg << 4);
  13102. } else {
  13103. shost->base = 0;
  13104. }
  13105. }
  13106. /*
  13107. * Register Board Resources - I/O Port, DMA, IRQ
  13108. */
  13109. /* Register DMA Channel for Narrow boards. */
  13110. shost->dma_channel = NO_ISA_DMA; /* Default to no ISA DMA. */
  13111. #ifdef CONFIG_ISA
  13112. if (ASC_NARROW_BOARD(boardp)) {
  13113. /* Register DMA channel for ISA bus. */
  13114. if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
  13115. shost->dma_channel = asc_dvc_varp->cfg->isa_dma_channel;
  13116. ret = request_dma(shost->dma_channel, DRV_NAME);
  13117. if (ret) {
  13118. ASC_PRINT3
  13119. ("advansys_board_found: board %d: request_dma() %d failed %d\n",
  13120. boardp->id, shost->dma_channel, ret);
  13121. goto err_free_proc;
  13122. }
  13123. AscEnableIsaDma(shost->dma_channel);
  13124. }
  13125. }
  13126. #endif /* CONFIG_ISA */
  13127. /* Register IRQ Number. */
  13128. ASC_DBG1(2, "advansys_board_found: request_irq() %d\n", shost->irq);
  13129. ret = request_irq(shost->irq, advansys_interrupt, share_irq,
  13130. DRV_NAME, shost);
  13131. if (ret) {
  13132. if (ret == -EBUSY) {
  13133. ASC_PRINT2
  13134. ("advansys_board_found: board %d: request_irq(): IRQ 0x%x already in use.\n",
  13135. boardp->id, shost->irq);
  13136. } else if (ret == -EINVAL) {
  13137. ASC_PRINT2
  13138. ("advansys_board_found: board %d: request_irq(): IRQ 0x%x not valid.\n",
  13139. boardp->id, shost->irq);
  13140. } else {
  13141. ASC_PRINT3
  13142. ("advansys_board_found: board %d: request_irq(): IRQ 0x%x failed with %d\n",
  13143. boardp->id, shost->irq, ret);
  13144. }
  13145. goto err_free_dma;
  13146. }
  13147. /*
  13148. * Initialize board RISC chip and enable interrupts.
  13149. */
  13150. if (ASC_NARROW_BOARD(boardp)) {
  13151. ASC_DBG(2, "advansys_board_found: AscInitAsc1000Driver()\n");
  13152. warn_code = AscInitAsc1000Driver(asc_dvc_varp);
  13153. err_code = asc_dvc_varp->err_code;
  13154. if (warn_code || err_code) {
  13155. ASC_PRINT4
  13156. ("advansys_board_found: board %d error: init_state 0x%x, warn 0x%x, error 0x%x\n",
  13157. boardp->id,
  13158. asc_dvc_varp->init_state, warn_code, err_code);
  13159. }
  13160. } else {
  13161. err_code = advansys_wide_init_chip(boardp, adv_dvc_varp);
  13162. }
  13163. if (err_code != 0)
  13164. goto err_free_wide_mem;
  13165. ASC_DBG_PRT_SCSI_HOST(2, shost);
  13166. ret = scsi_add_host(shost, dev);
  13167. if (ret)
  13168. goto err_free_wide_mem;
  13169. scsi_scan_host(shost);
  13170. return shost;
  13171. err_free_wide_mem:
  13172. advansys_wide_free_mem(boardp);
  13173. free_irq(shost->irq, shost);
  13174. err_free_dma:
  13175. if (shost->dma_channel != NO_ISA_DMA)
  13176. free_dma(shost->dma_channel);
  13177. err_free_proc:
  13178. kfree(boardp->prtbuf);
  13179. err_unmap:
  13180. if (boardp->ioremap_addr)
  13181. iounmap(boardp->ioremap_addr);
  13182. err_shost:
  13183. scsi_host_put(shost);
  13184. return NULL;
  13185. }
  13186. /*
  13187. * advansys_release()
  13188. *
  13189. * Release resources allocated for a single AdvanSys adapter.
  13190. */
  13191. static int advansys_release(struct Scsi_Host *shost)
  13192. {
  13193. asc_board_t *boardp;
  13194. ASC_DBG(1, "advansys_release: begin\n");
  13195. scsi_remove_host(shost);
  13196. boardp = ASC_BOARDP(shost);
  13197. free_irq(shost->irq, shost);
  13198. if (shost->dma_channel != NO_ISA_DMA) {
  13199. ASC_DBG(1, "advansys_release: free_dma()\n");
  13200. free_dma(shost->dma_channel);
  13201. }
  13202. if (ASC_WIDE_BOARD(boardp)) {
  13203. iounmap(boardp->ioremap_addr);
  13204. advansys_wide_free_mem(boardp);
  13205. }
  13206. kfree(boardp->prtbuf);
  13207. scsi_host_put(shost);
  13208. ASC_DBG(1, "advansys_release: end\n");
  13209. return 0;
  13210. }
  13211. #define ASC_IOADR_TABLE_MAX_IX 11
  13212. static PortAddr _asc_def_iop_base[ASC_IOADR_TABLE_MAX_IX] __devinitdata = {
  13213. 0x100, 0x0110, 0x120, 0x0130, 0x140, 0x0150, 0x0190,
  13214. 0x0210, 0x0230, 0x0250, 0x0330
  13215. };
  13216. static int __devinit advansys_isa_probe(struct device *dev, unsigned int id)
  13217. {
  13218. PortAddr iop_base = _asc_def_iop_base[id];
  13219. struct Scsi_Host *shost;
  13220. if (!request_region(iop_base, ASC_IOADR_GAP, DRV_NAME)) {
  13221. ASC_DBG1(1, "advansys_isa_match: I/O port 0x%x busy\n",
  13222. iop_base);
  13223. return -ENODEV;
  13224. }
  13225. ASC_DBG1(1, "advansys_isa_match: probing I/O port 0x%x\n", iop_base);
  13226. if (!AscFindSignature(iop_base))
  13227. goto nodev;
  13228. if (!(AscGetChipVersion(iop_base, ASC_IS_ISA) & ASC_CHIP_VER_ISA_BIT))
  13229. goto nodev;
  13230. shost = advansys_board_found(iop_base, dev, ASC_IS_ISA);
  13231. if (!shost)
  13232. goto nodev;
  13233. dev_set_drvdata(dev, shost);
  13234. return 0;
  13235. nodev:
  13236. release_region(iop_base, ASC_IOADR_GAP);
  13237. return -ENODEV;
  13238. }
  13239. static int __devexit advansys_isa_remove(struct device *dev, unsigned int id)
  13240. {
  13241. int ioport = _asc_def_iop_base[id];
  13242. advansys_release(dev_get_drvdata(dev));
  13243. release_region(ioport, ASC_IOADR_GAP);
  13244. return 0;
  13245. }
  13246. static struct isa_driver advansys_isa_driver = {
  13247. .probe = advansys_isa_probe,
  13248. .remove = __devexit_p(advansys_isa_remove),
  13249. .driver = {
  13250. .owner = THIS_MODULE,
  13251. .name = DRV_NAME,
  13252. },
  13253. };
  13254. static int __devinit advansys_vlb_probe(struct device *dev, unsigned int id)
  13255. {
  13256. PortAddr iop_base = _asc_def_iop_base[id];
  13257. struct Scsi_Host *shost;
  13258. if (!request_region(iop_base, ASC_IOADR_GAP, DRV_NAME)) {
  13259. ASC_DBG1(1, "advansys_vlb_match: I/O port 0x%x busy\n",
  13260. iop_base);
  13261. return -ENODEV;
  13262. }
  13263. ASC_DBG1(1, "advansys_vlb_match: probing I/O port 0x%x\n", iop_base);
  13264. if (!AscFindSignature(iop_base))
  13265. goto nodev;
  13266. /*
  13267. * I don't think this condition can actually happen, but the old
  13268. * driver did it, and the chances of finding a VLB setup in 2007
  13269. * to do testing with is slight to none.
  13270. */
  13271. if (AscGetChipVersion(iop_base, ASC_IS_VL) > ASC_CHIP_MAX_VER_VL)
  13272. goto nodev;
  13273. shost = advansys_board_found(iop_base, dev, ASC_IS_VL);
  13274. if (!shost)
  13275. goto nodev;
  13276. dev_set_drvdata(dev, shost);
  13277. return 0;
  13278. nodev:
  13279. release_region(iop_base, ASC_IOADR_GAP);
  13280. return -ENODEV;
  13281. }
  13282. static struct isa_driver advansys_vlb_driver = {
  13283. .probe = advansys_vlb_probe,
  13284. .remove = __devexit_p(advansys_isa_remove),
  13285. .driver = {
  13286. .owner = THIS_MODULE,
  13287. .name = "advansys_vlb",
  13288. },
  13289. };
  13290. static struct eisa_device_id advansys_eisa_table[] __devinitdata = {
  13291. { "ABP7401" },
  13292. { "ABP7501" },
  13293. { "" }
  13294. };
  13295. MODULE_DEVICE_TABLE(eisa, advansys_eisa_table);
  13296. /*
  13297. * EISA is a little more tricky than PCI; each EISA device may have two
  13298. * channels, and this driver is written to make each channel its own Scsi_Host
  13299. */
  13300. struct eisa_scsi_data {
  13301. struct Scsi_Host *host[2];
  13302. };
  13303. static int __devinit advansys_eisa_probe(struct device *dev)
  13304. {
  13305. int i, ioport;
  13306. int err;
  13307. struct eisa_device *edev = to_eisa_device(dev);
  13308. struct eisa_scsi_data *data;
  13309. err = -ENOMEM;
  13310. data = kzalloc(sizeof(*data), GFP_KERNEL);
  13311. if (!data)
  13312. goto fail;
  13313. ioport = edev->base_addr + 0xc30;
  13314. err = -ENODEV;
  13315. for (i = 0; i < 2; i++, ioport += 0x20) {
  13316. if (!request_region(ioport, ASC_IOADR_GAP, DRV_NAME)) {
  13317. printk(KERN_WARNING "Region %x-%x busy\n", ioport,
  13318. ioport + ASC_IOADR_GAP - 1);
  13319. continue;
  13320. }
  13321. if (!AscFindSignature(ioport)) {
  13322. release_region(ioport, ASC_IOADR_GAP);
  13323. continue;
  13324. }
  13325. /*
  13326. * I don't know why we need to do this for EISA chips, but
  13327. * not for any others. It looks to be equivalent to
  13328. * AscGetChipCfgMsw, but I may have overlooked something,
  13329. * so I'm not converting it until I get an EISA board to
  13330. * test with.
  13331. */
  13332. inw(ioport + 4);
  13333. data->host[i] = advansys_board_found(ioport, dev, ASC_IS_EISA);
  13334. if (data->host[i]) {
  13335. err = 0;
  13336. } else {
  13337. release_region(ioport, ASC_IOADR_GAP);
  13338. }
  13339. }
  13340. if (err) {
  13341. kfree(data);
  13342. } else {
  13343. dev_set_drvdata(dev, data);
  13344. }
  13345. fail:
  13346. return err;
  13347. }
  13348. static __devexit int advansys_eisa_remove(struct device *dev)
  13349. {
  13350. int i;
  13351. struct eisa_scsi_data *data = dev_get_drvdata(dev);
  13352. for (i = 0; i < 2; i++) {
  13353. int ioport;
  13354. struct Scsi_Host *shost = data->host[i];
  13355. if (!shost)
  13356. continue;
  13357. ioport = shost->io_port;
  13358. advansys_release(shost);
  13359. release_region(ioport, ASC_IOADR_GAP);
  13360. }
  13361. kfree(data);
  13362. return 0;
  13363. }
  13364. static struct eisa_driver advansys_eisa_driver = {
  13365. .id_table = advansys_eisa_table,
  13366. .driver = {
  13367. .name = DRV_NAME,
  13368. .probe = advansys_eisa_probe,
  13369. .remove = __devexit_p(advansys_eisa_remove),
  13370. }
  13371. };
  13372. /* PCI Devices supported by this driver */
  13373. static struct pci_device_id advansys_pci_tbl[] __devinitdata = {
  13374. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_1200A,
  13375. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13376. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940,
  13377. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13378. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940U,
  13379. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13380. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940UW,
  13381. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13382. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C0800_REV1,
  13383. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13384. {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C1600_REV1,
  13385. PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
  13386. {}
  13387. };
  13388. MODULE_DEVICE_TABLE(pci, advansys_pci_tbl);
  13389. static void __devinit advansys_set_latency(struct pci_dev *pdev)
  13390. {
  13391. if ((pdev->device == PCI_DEVICE_ID_ASP_1200A) ||
  13392. (pdev->device == PCI_DEVICE_ID_ASP_ABP940)) {
  13393. pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0);
  13394. } else {
  13395. u8 latency;
  13396. pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency);
  13397. if (latency < 0x20)
  13398. pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x20);
  13399. }
  13400. }
  13401. static int __devinit
  13402. advansys_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  13403. {
  13404. int err, ioport;
  13405. struct Scsi_Host *shost;
  13406. err = pci_enable_device(pdev);
  13407. if (err)
  13408. goto fail;
  13409. err = pci_request_regions(pdev, DRV_NAME);
  13410. if (err)
  13411. goto disable_device;
  13412. pci_set_master(pdev);
  13413. advansys_set_latency(pdev);
  13414. if (pci_resource_len(pdev, 0) == 0)
  13415. goto nodev;
  13416. ioport = pci_resource_start(pdev, 0);
  13417. shost = advansys_board_found(ioport, &pdev->dev, ASC_IS_PCI);
  13418. if (!shost)
  13419. goto nodev;
  13420. pci_set_drvdata(pdev, shost);
  13421. return 0;
  13422. nodev:
  13423. err = -ENODEV;
  13424. pci_release_regions(pdev);
  13425. disable_device:
  13426. pci_disable_device(pdev);
  13427. fail:
  13428. return err;
  13429. }
  13430. static void __devexit advansys_pci_remove(struct pci_dev *pdev)
  13431. {
  13432. advansys_release(pci_get_drvdata(pdev));
  13433. pci_release_regions(pdev);
  13434. pci_disable_device(pdev);
  13435. }
  13436. static struct pci_driver advansys_pci_driver = {
  13437. .name = DRV_NAME,
  13438. .id_table = advansys_pci_tbl,
  13439. .probe = advansys_pci_probe,
  13440. .remove = __devexit_p(advansys_pci_remove),
  13441. };
  13442. static int __init advansys_init(void)
  13443. {
  13444. int error;
  13445. error = isa_register_driver(&advansys_isa_driver,
  13446. ASC_IOADR_TABLE_MAX_IX);
  13447. if (error)
  13448. goto fail;
  13449. error = isa_register_driver(&advansys_vlb_driver,
  13450. ASC_IOADR_TABLE_MAX_IX);
  13451. if (error)
  13452. goto unregister_isa;
  13453. error = eisa_driver_register(&advansys_eisa_driver);
  13454. if (error)
  13455. goto unregister_vlb;
  13456. error = pci_register_driver(&advansys_pci_driver);
  13457. if (error)
  13458. goto unregister_eisa;
  13459. return 0;
  13460. unregister_eisa:
  13461. eisa_driver_unregister(&advansys_eisa_driver);
  13462. unregister_vlb:
  13463. isa_unregister_driver(&advansys_vlb_driver);
  13464. unregister_isa:
  13465. isa_unregister_driver(&advansys_isa_driver);
  13466. fail:
  13467. return error;
  13468. }
  13469. static void __exit advansys_exit(void)
  13470. {
  13471. pci_unregister_driver(&advansys_pci_driver);
  13472. eisa_driver_unregister(&advansys_eisa_driver);
  13473. isa_unregister_driver(&advansys_vlb_driver);
  13474. isa_unregister_driver(&advansys_isa_driver);
  13475. }
  13476. module_init(advansys_init);
  13477. module_exit(advansys_exit);
  13478. MODULE_LICENSE("GPL");