grub.400-nic_update2.patch 1.6 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480
  1. Submitted By: Jim Gifford (patches at jg555 dot com)
  2. Date: 2005-08-31
  3. Initial Package Version: 0.97
  4. Origin: OpenSolaris, Joe Ciccone, Jim Gifford
  5. Upstream Status: N/A
  6. Description: Adds support for Forcedeth and other NIC's
  7. Fixes for GCC 4.x
  8. Removal of bad network drivers
  9. diff -Naur grub-0.97.orig/configure grub-0.97/configure
  10. --- grub-0.97.orig/configure 2005-05-08 02:48:12.000000000 +0000
  11. +++ grub-0.97/configure 2005-09-01 00:15:48.000000000 +0000
  12. @@ -872,47 +872,32 @@
  13. --disable-packet-retransmission
  14. turn off packet retransmission
  15. --enable-pci-direct access PCI directly instead of using BIOS
  16. - --enable-3c509 enable 3Com509 driver
  17. - --enable-3c529 enable 3Com529 driver
  18. --enable-3c595 enable 3Com595 driver
  19. --enable-3c90x enable 3Com90x driver
  20. - --enable-cs89x0 enable CS89x0 driver
  21. --enable-davicom enable Davicom driver
  22. - --enable-depca enable DEPCA and EtherWORKS driver
  23. - --enable-eepro enable Etherexpress Pro/10 driver
  24. + --enable-e1000 enable Etherexpress Pro/1000 driver
  25. --enable-eepro100 enable Etherexpress Pro/100 driver
  26. --enable-epic100 enable SMC 83c170 EPIC/100 driver
  27. - --enable-3c507 enable 3Com507 driver
  28. - --enable-exos205 enable EXOS205 driver
  29. - --enable-ni5210 enable Racal-Interlan NI5210 driver
  30. - --enable-lance enable Lance PCI PCNet/32 driver
  31. - --enable-ne2100 enable Novell NE2100 driver
  32. - --enable-ni6510 enable Racal-Interlan NI6510 driver
  33. + --enable-forcedeth enable Nvidia Geforce driver
  34. --enable-natsemi enable NatSemi DP8381x driver
  35. - --enable-ni5010 enable Racal-Interlan NI5010 driver
  36. - --enable-3c503 enable 3Com503 driver
  37. - --enable-ne enable NE1000/2000 ISA driver
  38. + --enable-ns83820 enable NS83820 driver
  39. --enable-ns8390 enable NE2000 PCI driver
  40. - --enable-wd enable WD8003/8013, SMC8216/8416 driver
  41. - --enable-otulip enable old Tulip driver
  42. + --enable-pcnet32 enable AMD Lance/PCI PCNet/32 driver
  43. + --enable-pnic enable Bochs Pseudo Nic driver
  44. --enable-rtl8139 enable Realtek 8139 driver
  45. + --enable-r8169 enable Realtek 8169 driver
  46. --enable-sis900 enable SIS 900 and SIS 7016 driver
  47. - --enable-sk-g16 enable Schneider and Koch G16 driver
  48. - --enable-smc9000 enable SMC9000 driver
  49. - --enable-tiara enable Tiara driver
  50. + --enable-tg3 enable Broadcom Tigon3 driver
  51. --enable-tulip enable Tulip driver
  52. + --enable-tlan enable TI ThunderLAN driver
  53. + --enable-undi enable PXE UNDI driver
  54. --enable-via-rhine enable Rhine-I/II driver
  55. - --enable-w89c840 enable Winbond W89c840, Compex RL100-ATX driver
  56. - --enable-3c503-shmem use 3c503 shared memory mode
  57. - --enable-3c503-aui use AUI by default on 3c503 cards
  58. + --enable-w89c840 enable Winbond W89c840 driver
  59. --enable-compex-rl2000-fix
  60. specify this if you have a Compex RL2000 PCI
  61. - --enable-smc9000-scan=LIST
  62. - probe for SMC9000 I/O addresses using LIST
  63. --enable-ne-scan=LIST probe for NE base address using LIST
  64. --enable-wd-default-mem=MEM
  65. set the default memory location for WD/SMC
  66. - --enable-cs-scan=LIST probe for CS89x0 base address using LIST
  67. --enable-diskless enable diskless support
  68. --disable-hercules disable hercules terminal support
  69. --disable-serial disable serial terminal support
  70. @@ -5559,7 +5544,7 @@
  71. fi;
  72. if test "x$enable_packet_retransmission" != xno; then
  73. - NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DCONGESTED=1"
  74. + NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DCONGESTED=1 -DCONFIG_PCI"
  75. fi
  76. # Check whether --enable-pci-direct or --disable-pci-direct was given.
  77. @@ -5571,26 +5556,6 @@
  78. NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DCONFIG_PCI_DIRECT=1"
  79. fi
  80. -# Check whether --enable-3c509 or --disable-3c509 was given.
  81. -if test "${enable_3c509+set}" = set; then
  82. - enableval="$enable_3c509"
  83. -
  84. -fi;
  85. -if test "x$enable_3c509" = xyes; then
  86. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_3C509"
  87. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS 3c509.o"
  88. -fi
  89. -
  90. -# Check whether --enable-3c529 or --disable-3c529 was given.
  91. -if test "${enable_3c529+set}" = set; then
  92. - enableval="$enable_3c529"
  93. -
  94. -fi;
  95. -if test "x$enable_3c529" = xyes; then
  96. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_3C529=1"
  97. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS 3c529.o"
  98. -fi
  99. -
  100. # Check whether --enable-3c595 or --disable-3c595 was given.
  101. if test "${enable_3c595+set}" = set; then
  102. enableval="$enable_3c595"
  103. @@ -5611,16 +5576,6 @@
  104. NETBOOT_DRIVERS="$NETBOOT_DRIVERS 3c90x.o"
  105. fi
  106. -# Check whether --enable-cs89x0 or --disable-cs89x0 was given.
  107. -if test "${enable_cs89x0+set}" = set; then
  108. - enableval="$enable_cs89x0"
  109. -
  110. -fi;
  111. -if test "x$enable_cs89x0" = xyes; then
  112. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_CS89X0=1"
  113. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS cs89x0.o"
  114. -fi
  115. -
  116. # Check whether --enable-davicom or --disable-davicom was given.
  117. if test "${enable_davicom+set}" = set; then
  118. enableval="$enable_davicom"
  119. @@ -5631,24 +5586,14 @@
  120. NETBOOT_DRIVERS="$NETBOOT_DRIVERS davicom.o"
  121. fi
  122. -# Check whether --enable-depca or --disable-depca was given.
  123. -if test "${enable_depca+set}" = set; then
  124. - enableval="$enable_depca"
  125. +# Check whether --enable-e1000 or --disable-e1000 was given.
  126. +if test "${enable_e1000+set}" = set; then
  127. + enableval="$enable_e1000"
  128. fi;
  129. -if test "x$enable_depca" = xyes; then
  130. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_DEPCA=1"
  131. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS depca.o"
  132. -fi
  133. -
  134. -# Check whether --enable-eepro or --disable-eepro was given.
  135. -if test "${enable_eepro+set}" = set; then
  136. - enableval="$enable_eepro"
  137. -
  138. -fi;
  139. -if test "x$enable_eepro" = xyes; then
  140. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_EEPRO=1"
  141. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS eepro.o"
  142. +if test "x$enable_e1000" = xyes; then
  143. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_E1000=1"
  144. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS e1000.o"
  145. fi
  146. # Check whether --enable-eepro100 or --disable-eepro100 was given.
  147. @@ -5671,64 +5616,14 @@
  148. NETBOOT_DRIVERS="$NETBOOT_DRIVERS epic100.o"
  149. fi
  150. -# Check whether --enable-3c507 or --disable-3c507 was given.
  151. -if test "${enable_3c507+set}" = set; then
  152. - enableval="$enable_3c507"
  153. -
  154. -fi;
  155. -if test "x$enable_3c507" = xyes; then
  156. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_3C507=1"
  157. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS 3c507.o"
  158. -fi
  159. -
  160. -# Check whether --enable-exos205 or --disable-exos205 was given.
  161. -if test "${enable_exos205+set}" = set; then
  162. - enableval="$enable_exos205"
  163. -
  164. -fi;
  165. -if test "x$enable_exos205" = xyes; then
  166. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_EXOS205=1"
  167. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS exos205.o"
  168. -fi
  169. -
  170. -# Check whether --enable-ni5210 or --disable-ni5210 was given.
  171. -if test "${enable_ni5210+set}" = set; then
  172. - enableval="$enable_ni5210"
  173. -
  174. -fi;
  175. -if test "x$enable_ni5210" = xyes; then
  176. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NI5210=1"
  177. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS ni5210.o"
  178. -fi
  179. -
  180. -# Check whether --enable-lance or --disable-lance was given.
  181. -if test "${enable_lance+set}" = set; then
  182. - enableval="$enable_lance"
  183. -
  184. -fi;
  185. -if test "x$enable_lance" = xyes; then
  186. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_LANCE=1"
  187. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS lance.o"
  188. -fi
  189. -
  190. -# Check whether --enable-ne2100 or --disable-ne2100 was given.
  191. -if test "${enable_ne2100+set}" = set; then
  192. - enableval="$enable_ne2100"
  193. -
  194. -fi;
  195. -if test "x$enable_ne2100" = xyes; then
  196. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NE2100=1"
  197. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS ne2100.o"
  198. -fi
  199. -
  200. -# Check whether --enable-ni6510 or --disable-ni6510 was given.
  201. -if test "${enable_ni6510+set}" = set; then
  202. - enableval="$enable_ni6510"
  203. +# Check whether --enable-forcedeth or --disable-forcedeth was given.
  204. +if test "${enable_forcedeth+set}" = set; then
  205. + enableval="$enable_forcedeth"
  206. fi;
  207. -if test "x$enable_ni6510" = xyes; then
  208. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NI6510=1"
  209. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS ni6510.o"
  210. +if test "x$enable_forcedeth" = xyes; then
  211. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_FORCEDETH=1"
  212. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS forcedeth.o"
  213. fi
  214. # Check whether --enable-natsemi or --disable-natsemi was given.
  215. @@ -5741,34 +5636,14 @@
  216. NETBOOT_DRIVERS="$NETBOOT_DRIVERS natsemi.o"
  217. fi
  218. -# Check whether --enable-ni5010 or --disable-ni5010 was given.
  219. -if test "${enable_ni5010+set}" = set; then
  220. - enableval="$enable_ni5010"
  221. +# Check whether --enable-ns83820 or --disable-ns83820 was given.
  222. +if test "${enable_ns83820+set}" = set; then
  223. + enableval="$enable_ns83820"
  224. fi;
  225. -if test "x$enable_ni5010" = xyes; then
  226. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NI5010=1"
  227. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS ni5010.o"
  228. -fi
  229. -
  230. -# Check whether --enable-3c503 or --disable-3c503 was given.
  231. -if test "${enable_3c503+set}" = set; then
  232. - enableval="$enable_3c503"
  233. -
  234. -fi;
  235. -if test "x$enable_3c503" = xyes; then
  236. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_3C503=1"
  237. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS 3c503.o"
  238. -fi
  239. -
  240. -# Check whether --enable-ne or --disable-ne was given.
  241. -if test "${enable_ne+set}" = set; then
  242. - enableval="$enable_ne"
  243. -
  244. -fi;
  245. -if test "x$enable_ne" = xyes; then
  246. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NE=1"
  247. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS ne.o"
  248. +if test "x$enable_ns83820" = xyes; then
  249. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NS83820=1"
  250. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS ns83820.o"
  251. fi
  252. # Check whether --enable-ns8390 or --disable-ns8390 was given.
  253. @@ -5781,24 +5656,24 @@
  254. NETBOOT_DRIVERS="$NETBOOT_DRIVERS ns8390.o"
  255. fi
  256. -# Check whether --enable-wd or --disable-wd was given.
  257. -if test "${enable_wd+set}" = set; then
  258. - enableval="$enable_wd"
  259. +# Check whether --enable-pcnet32 or --disable-pcnet32 was given.
  260. +if test "${enable_pcnet32+set}" = set; then
  261. + enableval="$enable_pcnet32"
  262. fi;
  263. -if test "x$enable_wd" = xyes; then
  264. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_WD=1"
  265. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS wd.o"
  266. +if test "x$enable_pcnet32" = xyes; then
  267. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_PCNET32=1"
  268. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS pcnet32.o"
  269. fi
  270. -# Check whether --enable-otulip or --disable-otulip was given.
  271. -if test "${enable_otulip+set}" = set; then
  272. - enableval="$enable_otulip"
  273. +# Check whether --enable-pnic or --disable-pnic was given.
  274. +if test "${enable_pnic+set}" = set; then
  275. + enableval="$enable_pnic"
  276. fi;
  277. -if test "x$enable_otulip" = xyes; then
  278. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_OTULIP=1"
  279. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS otulip.o"
  280. +if test "x$enable_pnic" = xyes; then
  281. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_PNIC=1"
  282. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS pnic.o"
  283. fi
  284. # Check whether --enable-rtl8139 or --disable-rtl8139 was given.
  285. @@ -5811,6 +5686,16 @@
  286. NETBOOT_DRIVERS="$NETBOOT_DRIVERS rtl8139.o"
  287. fi
  288. +# Check whether --enable-r8169 or --disable-r8169 was given.
  289. +if test "${enable_r8169+set}" = set; then
  290. + enableval="$enable_r8169"
  291. +
  292. +fi;
  293. +if test "x$enable_r8169" = xyes; then
  294. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_R8169=1"
  295. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS r8169.o"
  296. +fi
  297. +
  298. # Check whether --enable-sis900 or --disable-sis900 was given.
  299. if test "${enable_sis900+set}" = set; then
  300. enableval="$enable_sis900"
  301. @@ -5821,34 +5706,14 @@
  302. NETBOOT_DRIVERS="$NETBOOT_DRIVERS sis900.o"
  303. fi
  304. -# Check whether --enable-sk-g16 or --disable-sk-g16 was given.
  305. -if test "${enable_sk_g16+set}" = set; then
  306. - enableval="$enable_sk_g16"
  307. -
  308. -fi;
  309. -if test "x$enable_sk_g16" = xyes; then
  310. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_SK_G16=1"
  311. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS sk_g16.o"
  312. -fi
  313. -
  314. -# Check whether --enable-smc9000 or --disable-smc9000 was given.
  315. -if test "${enable_smc9000+set}" = set; then
  316. - enableval="$enable_smc9000"
  317. -
  318. -fi;
  319. -if test "x$enable_smc9000" = xyes; then
  320. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_SMC9000=1"
  321. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS smc9000.o"
  322. -fi
  323. -
  324. -# Check whether --enable-tiara or --disable-tiara was given.
  325. -if test "${enable_tiara+set}" = set; then
  326. - enableval="$enable_tiara"
  327. +# Check whether --enable-tg3 or --disable-tg3 was given.
  328. +if test "${enable_tg3+set}" = set; then
  329. + enableval="$enable_tg3"
  330. fi;
  331. -if test "x$enable_tiara" = xyes; then
  332. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_TIARA=1"
  333. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS tiara.o"
  334. +if test "x$enable_tg3" = xyes; then
  335. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_TG3=1"
  336. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS tg3.o"
  337. fi
  338. # Check whether --enable-tulip or --disable-tulip was given.
  339. @@ -5861,6 +5726,16 @@
  340. NETBOOT_DRIVERS="$NETBOOT_DRIVERS tulip.o"
  341. fi
  342. +# Check whether --enable-tlan or --disable-tlan was given.
  343. +if test "${enable_tlan+set}" = set; then
  344. + enableval="$enable_tlan"
  345. +
  346. +fi;
  347. +if test "x$enable_tlan" = xyes; then
  348. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_TLAN=1"
  349. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS tlan.o"
  350. +fi
  351. +
  352. # Check whether --enable-via-rhine or --disable-via-rhine was given.
  353. if test "${enable_via_rhine+set}" = set; then
  354. enableval="$enable_via_rhine"
  355. @@ -5895,24 +5770,6 @@
  356. FSYS_CFLAGS="$FSYS_CFLAGS -DFSYS_TFTP=1"
  357. fi
  358. -# Check whether --enable-3c503-shmem or --disable-3c503-shmem was given.
  359. -if test "${enable_3c503_shmem+set}" = set; then
  360. - enableval="$enable_3c503_shmem"
  361. -
  362. -fi;
  363. -if test "x$enable_3c503_shmem" = xyes; then
  364. - NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DT503_SHMEM=1"
  365. -fi
  366. -
  367. -# Check whether --enable-3c503-aui or --disable-3c503-aui was given.
  368. -if test "${enable_3c503_aui+set}" = set; then
  369. - enableval="$enable_3c503_aui"
  370. -
  371. -fi;
  372. -if test "x$enable_3c503_aui" = xyes; then
  373. - NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DT503_AUI=1"
  374. -fi
  375. -
  376. # Check whether --enable-compex-rl2000-fix or --disable-compex-rl2000-fix was given.
  377. if test "${enable_compex_rl2000_fix+set}" = set; then
  378. enableval="$enable_compex_rl2000_fix"
  379. @@ -5922,12 +5779,6 @@
  380. NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DCOMPEX_RL2000_FIX=1"
  381. fi
  382. -# Check whether --enable-smc9000-scan or --disable-smc9000-scan was given.
  383. -if test "${enable_smc9000_scan+set}" = set; then
  384. - enableval="$enable_smc9000_scan"
  385. - NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DSMC9000_SCAN=$enable_smc9000_scan"
  386. -fi;
  387. -
  388. # Check whether --enable-ne-scan or --disable-ne-scan was given.
  389. if test "${enable_ne_scan+set}" = set; then
  390. enableval="$enable_ne_scan"
  391. @@ -5944,12 +5795,6 @@
  392. NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DWD_DEFAULT_MEM=0xCC000"
  393. fi;
  394. -# Check whether --enable-cs-scan or --disable-cs-scan was given.
  395. -if test "${enable_cs_scan+set}" = set; then
  396. - enableval="$enable_cs_scan"
  397. - NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DCS_SCAN=$enable_cs_scan"
  398. -fi;
  399. -
  400. # Check whether --enable-diskless or --disable-diskless was given.
  401. if test "${enable_diskless+set}" = set; then
  402. enableval="$enable_diskless"
  403. diff -Naur grub-0.97.orig/configure.ac grub-0.97/configure.ac
  404. --- grub-0.97.orig/configure.ac 2005-05-08 02:36:03.000000000 +0000
  405. +++ grub-0.97/configure.ac 2005-09-01 00:16:05.000000000 +0000
  406. @@ -317,7 +317,7 @@
  407. [ --disable-packet-retransmission
  408. turn off packet retransmission])
  409. if test "x$enable_packet_retransmission" != xno; then
  410. - NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DCONGESTED=1"
  411. + NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DCONGESTED=1 -DCONFIG_PCI"
  412. fi
  413. AC_ARG_ENABLE(pci-direct,
  414. @@ -327,20 +327,6 @@
  415. fi
  416. dnl Device drivers.
  417. -AC_ARG_ENABLE(3c509,
  418. - [ --enable-3c509 enable 3Com509 driver])
  419. -if test "x$enable_3c509" = xyes; then
  420. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_3C509"
  421. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS 3c509.o"
  422. -fi
  423. -
  424. -AC_ARG_ENABLE(3c529,
  425. - [ --enable-3c529 enable 3Com529 driver])
  426. -if test "x$enable_3c529" = xyes; then
  427. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_3C529=1"
  428. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS 3c529.o"
  429. -fi
  430. -
  431. AC_ARG_ENABLE(3c595,
  432. [ --enable-3c595 enable 3Com595 driver])
  433. if test "x$enable_3c595" = xyes; then
  434. @@ -355,13 +341,6 @@
  435. NETBOOT_DRIVERS="$NETBOOT_DRIVERS 3c90x.o"
  436. fi
  437. -AC_ARG_ENABLE(cs89x0,
  438. - [ --enable-cs89x0 enable CS89x0 driver])
  439. -if test "x$enable_cs89x0" = xyes; then
  440. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_CS89X0=1"
  441. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS cs89x0.o"
  442. -fi
  443. -
  444. AC_ARG_ENABLE(davicom,
  445. [ --enable-davicom enable Davicom driver])
  446. if test "x$enable_davicom" = xyes; then
  447. @@ -369,18 +348,11 @@
  448. NETBOOT_DRIVERS="$NETBOOT_DRIVERS davicom.o"
  449. fi
  450. -AC_ARG_ENABLE(depca,
  451. - [ --enable-depca enable DEPCA and EtherWORKS driver])
  452. -if test "x$enable_depca" = xyes; then
  453. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_DEPCA=1"
  454. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS depca.o"
  455. -fi
  456. -
  457. -AC_ARG_ENABLE(eepro,
  458. - [ --enable-eepro enable Etherexpress Pro/10 driver])
  459. -if test "x$enable_eepro" = xyes; then
  460. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_EEPRO=1"
  461. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS eepro.o"
  462. +AC_ARG_ENABLE(e1000,
  463. + [ --enable-e1000 enable Etherexpress Pro/1000 driver])
  464. +if test "x$enable_e1000" = xyes; then
  465. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_E1000=1"
  466. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS e1000.o"
  467. fi
  468. AC_ARG_ENABLE(eepro100,
  469. @@ -397,46 +369,11 @@
  470. NETBOOT_DRIVERS="$NETBOOT_DRIVERS epic100.o"
  471. fi
  472. -AC_ARG_ENABLE(3c507,
  473. - [ --enable-3c507 enable 3Com507 driver])
  474. -if test "x$enable_3c507" = xyes; then
  475. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_3C507=1"
  476. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS 3c507.o"
  477. -fi
  478. -
  479. -AC_ARG_ENABLE(exos205,
  480. - [ --enable-exos205 enable EXOS205 driver])
  481. -if test "x$enable_exos205" = xyes; then
  482. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_EXOS205=1"
  483. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS exos205.o"
  484. -fi
  485. -
  486. -AC_ARG_ENABLE(ni5210,
  487. - [ --enable-ni5210 enable Racal-Interlan NI5210 driver])
  488. -if test "x$enable_ni5210" = xyes; then
  489. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NI5210=1"
  490. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS ni5210.o"
  491. -fi
  492. -
  493. -AC_ARG_ENABLE(lance,
  494. - [ --enable-lance enable Lance PCI PCNet/32 driver])
  495. -if test "x$enable_lance" = xyes; then
  496. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_LANCE=1"
  497. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS lance.o"
  498. -fi
  499. -
  500. -AC_ARG_ENABLE(ne2100,
  501. - [ --enable-ne2100 enable Novell NE2100 driver])
  502. -if test "x$enable_ne2100" = xyes; then
  503. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NE2100=1"
  504. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS ne2100.o"
  505. -fi
  506. -
  507. -AC_ARG_ENABLE(ni6510,
  508. - [ --enable-ni6510 enable Racal-Interlan NI6510 driver])
  509. -if test "x$enable_ni6510" = xyes; then
  510. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NI6510=1"
  511. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS ni6510.o"
  512. +AC_ARG_ENABLE(forcedeth,
  513. + [ --enable-forcedeth enable Nvidia Geforce driver])
  514. +if test "x$enable_forcedeth" = xyes; then
  515. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_FORCEDETH=1"
  516. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS forcedeth.o"
  517. fi
  518. AC_ARG_ENABLE(natsemi,
  519. @@ -446,25 +383,11 @@
  520. NETBOOT_DRIVERS="$NETBOOT_DRIVERS natsemi.o"
  521. fi
  522. -AC_ARG_ENABLE(ni5010,
  523. - [ --enable-ni5010 enable Racal-Interlan NI5010 driver])
  524. -if test "x$enable_ni5010" = xyes; then
  525. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NI5010=1"
  526. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS ni5010.o"
  527. -fi
  528. -
  529. -AC_ARG_ENABLE(3c503,
  530. - [ --enable-3c503 enable 3Com503 driver])
  531. -if test "x$enable_3c503" = xyes; then
  532. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_3C503=1"
  533. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS 3c503.o"
  534. -fi
  535. -
  536. -AC_ARG_ENABLE(ne,
  537. - [ --enable-ne enable NE1000/2000 ISA driver])
  538. -if test "x$enable_ne" = xyes; then
  539. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NE=1"
  540. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS ne.o"
  541. +AC_ARG_ENABLE(ns83820,
  542. + [ --enable-ns83820 enable NS83820 driver])
  543. +if test "x$enable_ns83820" = xyes; then
  544. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_NS83820=1"
  545. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS ns83820.o"
  546. fi
  547. AC_ARG_ENABLE(ns8390,
  548. @@ -474,18 +397,18 @@
  549. NETBOOT_DRIVERS="$NETBOOT_DRIVERS ns8390.o"
  550. fi
  551. -AC_ARG_ENABLE(wd,
  552. - [ --enable-wd enable WD8003/8013, SMC8216/8416 driver])
  553. -if test "x$enable_wd" = xyes; then
  554. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_WD=1"
  555. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS wd.o"
  556. +AC_ARG_ENABLE(pcnet32,
  557. + [ --enable-pcnet32 enable AMD Lance/PCI PCNet/32 driver])
  558. +if test "x$enable_pcnet32" = xyes; then
  559. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_PCNET32=1"
  560. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS pcnet32.o"
  561. fi
  562. -AC_ARG_ENABLE(otulip,
  563. - [ --enable-otulip enable old Tulip driver])
  564. -if test "x$enable_otulip" = xyes; then
  565. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_OTULIP=1"
  566. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS otulip.o"
  567. +AC_ARG_ENABLE(pnic,
  568. + [ --enable-pnic enable Bochs Pseudo Nic driver])
  569. +if test "x$enable_pnic" = xyes; then
  570. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_PNIC=1"
  571. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS pnic.o"
  572. fi
  573. AC_ARG_ENABLE(rtl8139,
  574. @@ -495,6 +418,13 @@
  575. NETBOOT_DRIVERS="$NETBOOT_DRIVERS rtl8139.o"
  576. fi
  577. +AC_ARG_ENABLE(r8169,
  578. + [ --enable-r8169 enable Realtek 8169 driver])
  579. +if test "x$enable_r8169" = xyes; then
  580. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_R8169=1"
  581. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS r8169.o"
  582. +fi
  583. +
  584. AC_ARG_ENABLE(sis900,
  585. [ --enable-sis900 enable SIS 900 and SIS 7016 driver])
  586. if test "x$enable_sis900" = xyes; then
  587. @@ -502,25 +432,11 @@
  588. NETBOOT_DRIVERS="$NETBOOT_DRIVERS sis900.o"
  589. fi
  590. -AC_ARG_ENABLE(sk-g16,
  591. - [ --enable-sk-g16 enable Schneider and Koch G16 driver])
  592. -if test "x$enable_sk_g16" = xyes; then
  593. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_SK_G16=1"
  594. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS sk_g16.o"
  595. -fi
  596. -
  597. -AC_ARG_ENABLE(smc9000,
  598. - [ --enable-smc9000 enable SMC9000 driver])
  599. -if test "x$enable_smc9000" = xyes; then
  600. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_SMC9000=1"
  601. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS smc9000.o"
  602. -fi
  603. -
  604. -AC_ARG_ENABLE(tiara,
  605. - [ --enable-tiara enable Tiara driver])
  606. -if test "x$enable_tiara" = xyes; then
  607. - NET_CFLAGS="$NET_CFLAGS -DINCLUDE_TIARA=1"
  608. - NETBOOT_DRIVERS="$NETBOOT_DRIVERS tiara.o"
  609. +AC_ARG_ENABLE(tg3,
  610. + [ --enable-tg3 enable Broadcom Tigon3 driver])
  611. +if test "x$enable_tg3" = xyes; then
  612. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_TG3=1"
  613. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS tg3.o"
  614. fi
  615. AC_ARG_ENABLE(tulip,
  616. @@ -530,6 +446,13 @@
  617. NETBOOT_DRIVERS="$NETBOOT_DRIVERS tulip.o"
  618. fi
  619. +AC_ARG_ENABLE(tlan,
  620. + [ --enable-tlan enable TI ThunderLAN driver])
  621. +if test "x$enable_tlan" = xyes; then
  622. + NET_CFLAGS="$NET_CFLAGS -DINCLUDE_TLAN=1"
  623. + NETBOOT_DRIVERS="$NETBOOT_DRIVERS tlan.o"
  624. +fi
  625. +
  626. AC_ARG_ENABLE(via-rhine,
  627. [ --enable-via-rhine enable Rhine-I/II driver])
  628. if test "x$enable_via_rhine" = xyes; then
  629. @@ -538,7 +461,7 @@
  630. fi
  631. AC_ARG_ENABLE(w89c840,
  632. - [ --enable-w89c840 enable Winbond W89c840, Compex RL100-ATX driver])
  633. + [ --enable-w89c840 enable Winbond W89c840 driver])
  634. if test "x$enable_w89c840" = xyes; then
  635. NET_CFLAGS="$NET_CFLAGS -DINCLUDE_W89C840=1"
  636. NETBOOT_DRIVERS="$NETBOOT_DRIVERS w89c840.o"
  637. @@ -550,19 +473,7 @@
  638. FSYS_CFLAGS="$FSYS_CFLAGS -DFSYS_TFTP=1"
  639. fi
  640. -dnl Extra options.
  641. -AC_ARG_ENABLE(3c503-shmem,
  642. - [ --enable-3c503-shmem use 3c503 shared memory mode])
  643. -if test "x$enable_3c503_shmem" = xyes; then
  644. - NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DT503_SHMEM=1"
  645. -fi
  646. -
  647. -AC_ARG_ENABLE(3c503-aui,
  648. - [ --enable-3c503-aui use AUI by default on 3c503 cards])
  649. -if test "x$enable_3c503_aui" = xyes; then
  650. - NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DT503_AUI=1"
  651. -fi
  652. -
  653. +dnl extra flag for ns8390.c
  654. AC_ARG_ENABLE(compex-rl2000-fix,
  655. [ --enable-compex-rl2000-fix
  656. specify this if you have a Compex RL2000 PCI])
  657. @@ -570,11 +481,6 @@
  658. NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DCOMPEX_RL2000_FIX=1"
  659. fi
  660. -AC_ARG_ENABLE(smc9000-scan,
  661. - [ --enable-smc9000-scan=LIST
  662. - probe for SMC9000 I/O addresses using LIST],
  663. - [NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DSMC9000_SCAN=$enable_smc9000_scan"])
  664. -
  665. AC_ARG_ENABLE(ne-scan,
  666. [ --enable-ne-scan=LIST probe for NE base address using LIST],
  667. [NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DNE_SCAN=$enable_ne_scan"],
  668. @@ -586,10 +492,6 @@
  669. [NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DWD_DEFAULT_MEM=$enable_wd_default_mem"],
  670. [NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DWD_DEFAULT_MEM=0xCC000"])
  671. -AC_ARG_ENABLE(cs-scan,
  672. - [ --enable-cs-scan=LIST probe for CS89x0 base address using LIST],
  673. - [NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DCS_SCAN=$enable_cs_scan"])
  674. -
  675. dnl Diskless
  676. AC_ARG_ENABLE(diskless,
  677. [ --enable-diskless enable diskless support])
  678. diff -Naur grub-0.97.orig/netboot/3c509.h grub-0.97/netboot/3c509.h
  679. --- grub-0.97.orig/netboot/3c509.h 2003-07-09 11:45:37.000000000 +0000
  680. +++ grub-0.97/netboot/3c509.h 1970-01-01 00:00:00.000000000 +0000
  681. @@ -1,397 +0,0 @@
  682. -/*
  683. - * Copyright (c) 1993 Herb Peyerl (hpeyerl@novatel.ca) All rights reserved.
  684. - *
  685. - * Redistribution and use in source and binary forms, with or without
  686. - * modification, are permitted provided that the following conditions are
  687. - * met: 1. Redistributions of source code must retain the above copyright
  688. - * notice, this list of conditions and the following disclaimer. 2. The name
  689. - * of the author may not be used to endorse or promote products derived from
  690. - * this software withough specific prior written permission
  691. - *
  692. - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  693. - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  694. - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  695. - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  696. - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
  697. - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  698. - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  699. - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  700. - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  701. - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  702. - *
  703. - * if_epreg.h,v 1.4 1994/11/13 10:12:37 gibbs Exp Modified by:
  704. - *
  705. - October 2, 1994
  706. -
  707. - Modified by: Andres Vega Garcia
  708. -
  709. - INRIA - Sophia Antipolis, France
  710. - e-mail: avega@sophia.inria.fr
  711. - finger: avega@pax.inria.fr
  712. -
  713. - */
  714. -
  715. -/*
  716. - * Ethernet software status per interface.
  717. - */
  718. -/*
  719. - * Some global constants
  720. - */
  721. -
  722. -#define TX_INIT_RATE 16
  723. -#define TX_INIT_MAX_RATE 64
  724. -#define RX_INIT_LATENCY 64
  725. -#define RX_INIT_EARLY_THRESH 64
  726. -#define MIN_RX_EARLY_THRESHF 16 /* not less than ether_header */
  727. -#define MIN_RX_EARLY_THRESHL 4
  728. -
  729. -#define EEPROMSIZE 0x40
  730. -#define MAX_EEPROMBUSY 1000
  731. -#define EP_LAST_TAG 0xd7
  732. -#define EP_MAX_BOARDS 16
  733. -#define EP_ID_PORT 0x100
  734. -
  735. -/*
  736. - * some macros to acces long named fields
  737. - */
  738. -#define IS_BASE (eth_nic_base)
  739. -#define BASE (eth_nic_base)
  740. -
  741. -/*
  742. - * Commands to read/write EEPROM trough EEPROM command register (Window 0,
  743. - * Offset 0xa)
  744. - */
  745. -#define EEPROM_CMD_RD 0x0080 /* Read: Address required (5 bits) */
  746. -#define EEPROM_CMD_WR 0x0040 /* Write: Address required (5 bits) */
  747. -#define EEPROM_CMD_ERASE 0x00c0 /* Erase: Address required (5 bits) */
  748. -#define EEPROM_CMD_EWEN 0x0030 /* Erase/Write Enable: No data required */
  749. -
  750. -#define EEPROM_BUSY (1<<15)
  751. -#define EEPROM_TST_MODE (1<<14)
  752. -
  753. -/*
  754. - * Some short functions, worth to let them be a macro
  755. - */
  756. -#define is_eeprom_busy(b) (inw((b)+EP_W0_EEPROM_COMMAND)&EEPROM_BUSY)
  757. -#define GO_WINDOW(x) outw(WINDOW_SELECT|(x), BASE+EP_COMMAND)
  758. -
  759. -/**************************************************************************
  760. - *
  761. - * These define the EEPROM data structure. They are used in the probe
  762. - * function to verify the existance of the adapter after having sent
  763. - * the ID_Sequence.
  764. - *
  765. - * There are others but only the ones we use are defined here.
  766. - *
  767. - **************************************************************************/
  768. -
  769. -#define EEPROM_NODE_ADDR_0 0x0 /* Word */
  770. -#define EEPROM_NODE_ADDR_1 0x1 /* Word */
  771. -#define EEPROM_NODE_ADDR_2 0x2 /* Word */
  772. -#define EEPROM_PROD_ID 0x3 /* 0x9[0-f]50 */
  773. -#define EEPROM_MFG_ID 0x7 /* 0x6d50 */
  774. -#define EEPROM_ADDR_CFG 0x8 /* Base addr */
  775. -#define EEPROM_RESOURCE_CFG 0x9 /* IRQ. Bits 12-15 */
  776. -
  777. -/**************************************************************************
  778. - *
  779. - * These are the registers for the 3Com 3c509 and their bit patterns when
  780. - * applicable. They have been taken out the the "EtherLink III Parallel
  781. - * Tasking EISA and ISA Technical Reference" "Beta Draft 10/30/92" manual
  782. - * from 3com.
  783. - *
  784. - **************************************************************************/
  785. -
  786. -#define EP_COMMAND 0x0e /* Write. BASE+0x0e is always a
  787. - * command reg. */
  788. -#define EP_STATUS 0x0e /* Read. BASE+0x0e is always status
  789. - * reg. */
  790. -#define EP_WINDOW 0x0f /* Read. BASE+0x0f is always window
  791. - * reg. */
  792. -/*
  793. - * Window 0 registers. Setup.
  794. - */
  795. -/* Write */
  796. -#define EP_W0_EEPROM_DATA 0x0c
  797. -#define EP_W0_EEPROM_COMMAND 0x0a
  798. -#define EP_W0_RESOURCE_CFG 0x08
  799. -#define EP_W0_ADDRESS_CFG 0x06
  800. -#define EP_W0_CONFIG_CTRL 0x04
  801. -/* Read */
  802. -#define EP_W0_PRODUCT_ID 0x02
  803. -#define EP_W0_MFG_ID 0x00
  804. -
  805. -/*
  806. - * Window 1 registers. Operating Set.
  807. - */
  808. -/* Write */
  809. -#define EP_W1_TX_PIO_WR_2 0x02
  810. -#define EP_W1_TX_PIO_WR_1 0x00
  811. -/* Read */
  812. -#define EP_W1_FREE_TX 0x0c
  813. -#define EP_W1_TX_STATUS 0x0b /* byte */
  814. -#define EP_W1_TIMER 0x0a /* byte */
  815. -#define EP_W1_RX_STATUS 0x08
  816. -#define EP_W1_RX_PIO_RD_2 0x02
  817. -#define EP_W1_RX_PIO_RD_1 0x00
  818. -
  819. -/*
  820. - * Window 2 registers. Station Address Setup/Read
  821. - */
  822. -/* Read/Write */
  823. -#define EP_W2_ADDR_5 0x05
  824. -#define EP_W2_ADDR_4 0x04
  825. -#define EP_W2_ADDR_3 0x03
  826. -#define EP_W2_ADDR_2 0x02
  827. -#define EP_W2_ADDR_1 0x01
  828. -#define EP_W2_ADDR_0 0x00
  829. -
  830. -/*
  831. - * Window 3 registers. FIFO Management.
  832. - */
  833. -/* Read */
  834. -#define EP_W3_FREE_TX 0x0c
  835. -#define EP_W3_FREE_RX 0x0a
  836. -
  837. -/*
  838. - * Window 4 registers. Diagnostics.
  839. - */
  840. -/* Read/Write */
  841. -#define EP_W4_MEDIA_TYPE 0x0a
  842. -#define EP_W4_CTRLR_STATUS 0x08
  843. -#define EP_W4_NET_DIAG 0x06
  844. -#define EP_W4_FIFO_DIAG 0x04
  845. -#define EP_W4_HOST_DIAG 0x02
  846. -#define EP_W4_TX_DIAG 0x00
  847. -
  848. -/*
  849. - * Window 5 Registers. Results and Internal status.
  850. - */
  851. -/* Read */
  852. -#define EP_W5_READ_0_MASK 0x0c
  853. -#define EP_W5_INTR_MASK 0x0a
  854. -#define EP_W5_RX_FILTER 0x08
  855. -#define EP_W5_RX_EARLY_THRESH 0x06
  856. -#define EP_W5_TX_AVAIL_THRESH 0x02
  857. -#define EP_W5_TX_START_THRESH 0x00
  858. -
  859. -/*
  860. - * Window 6 registers. Statistics.
  861. - */
  862. -/* Read/Write */
  863. -#define TX_TOTAL_OK 0x0c
  864. -#define RX_TOTAL_OK 0x0a
  865. -#define TX_DEFERRALS 0x08
  866. -#define RX_FRAMES_OK 0x07
  867. -#define TX_FRAMES_OK 0x06
  868. -#define RX_OVERRUNS 0x05
  869. -#define TX_COLLISIONS 0x04
  870. -#define TX_AFTER_1_COLLISION 0x03
  871. -#define TX_AFTER_X_COLLISIONS 0x02
  872. -#define TX_NO_SQE 0x01
  873. -#define TX_CD_LOST 0x00
  874. -
  875. -/****************************************
  876. - *
  877. - * Register definitions.
  878. - *
  879. - ****************************************/
  880. -
  881. -/*
  882. - * Command register. All windows.
  883. - *
  884. - * 16 bit register.
  885. - * 15-11: 5-bit code for command to be executed.
  886. - * 10-0: 11-bit arg if any. For commands with no args;
  887. - * this can be set to anything.
  888. - */
  889. -#define GLOBAL_RESET (unsigned short) 0x0000 /* Wait at least 1ms
  890. - * after issuing */
  891. -#define WINDOW_SELECT (unsigned short) (0x1<<11)
  892. -#define START_TRANSCEIVER (unsigned short) (0x2<<11) /* Read ADDR_CFG reg to
  893. - * determine whether
  894. - * this is needed. If
  895. - * so; wait 800 uSec
  896. - * before using trans-
  897. - * ceiver. */
  898. -#define RX_DISABLE (unsigned short) (0x3<<11) /* state disabled on
  899. - * power-up */
  900. -#define RX_ENABLE (unsigned short) (0x4<<11)
  901. -#define RX_RESET (unsigned short) (0x5<<11)
  902. -#define RX_DISCARD_TOP_PACK (unsigned short) (0x8<<11)
  903. -#define TX_ENABLE (unsigned short) (0x9<<11)
  904. -#define TX_DISABLE (unsigned short) (0xa<<11)
  905. -#define TX_RESET (unsigned short) (0xb<<11)
  906. -#define REQ_INTR (unsigned short) (0xc<<11)
  907. -#define SET_INTR_MASK (unsigned short) (0xe<<11)
  908. -#define SET_RD_0_MASK (unsigned short) (0xf<<11)
  909. -#define SET_RX_FILTER (unsigned short) (0x10<<11)
  910. -#define FIL_INDIVIDUAL (unsigned short) (0x1)
  911. -#define FIL_GROUP (unsigned short) (0x2)
  912. -#define FIL_BRDCST (unsigned short) (0x4)
  913. -#define FIL_ALL (unsigned short) (0x8)
  914. -#define SET_RX_EARLY_THRESH (unsigned short) (0x11<<11)
  915. -#define SET_TX_AVAIL_THRESH (unsigned short) (0x12<<11)
  916. -#define SET_TX_START_THRESH (unsigned short) (0x13<<11)
  917. -#define STATS_ENABLE (unsigned short) (0x15<<11)
  918. -#define STATS_DISABLE (unsigned short) (0x16<<11)
  919. -#define STOP_TRANSCEIVER (unsigned short) (0x17<<11)
  920. -/*
  921. - * The following C_* acknowledge the various interrupts. Some of them don't
  922. - * do anything. See the manual.
  923. - */
  924. -#define ACK_INTR (unsigned short) (0x6800)
  925. -#define C_INTR_LATCH (unsigned short) (ACK_INTR|0x1)
  926. -#define C_CARD_FAILURE (unsigned short) (ACK_INTR|0x2)
  927. -#define C_TX_COMPLETE (unsigned short) (ACK_INTR|0x4)
  928. -#define C_TX_AVAIL (unsigned short) (ACK_INTR|0x8)
  929. -#define C_RX_COMPLETE (unsigned short) (ACK_INTR|0x10)
  930. -#define C_RX_EARLY (unsigned short) (ACK_INTR|0x20)
  931. -#define C_INT_RQD (unsigned short) (ACK_INTR|0x40)
  932. -#define C_UPD_STATS (unsigned short) (ACK_INTR|0x80)
  933. -
  934. -/*
  935. - * Status register. All windows.
  936. - *
  937. - * 15-13: Window number(0-7).
  938. - * 12: Command_in_progress.
  939. - * 11: reserved.
  940. - * 10: reserved.
  941. - * 9: reserved.
  942. - * 8: reserved.
  943. - * 7: Update Statistics.
  944. - * 6: Interrupt Requested.
  945. - * 5: RX Early.
  946. - * 4: RX Complete.
  947. - * 3: TX Available.
  948. - * 2: TX Complete.
  949. - * 1: Adapter Failure.
  950. - * 0: Interrupt Latch.
  951. - */
  952. -#define S_INTR_LATCH (unsigned short) (0x1)
  953. -#define S_CARD_FAILURE (unsigned short) (0x2)
  954. -#define S_TX_COMPLETE (unsigned short) (0x4)
  955. -#define S_TX_AVAIL (unsigned short) (0x8)
  956. -#define S_RX_COMPLETE (unsigned short) (0x10)
  957. -#define S_RX_EARLY (unsigned short) (0x20)
  958. -#define S_INT_RQD (unsigned short) (0x40)
  959. -#define S_UPD_STATS (unsigned short) (0x80)
  960. -#define S_5_INTS (S_CARD_FAILURE|S_TX_COMPLETE|\
  961. - S_TX_AVAIL|S_RX_COMPLETE|S_RX_EARLY)
  962. -#define S_COMMAND_IN_PROGRESS (unsigned short) (0x1000)
  963. -
  964. -/*
  965. - * FIFO Registers.
  966. - * RX Status. Window 1/Port 08
  967. - *
  968. - * 15: Incomplete or FIFO empty.
  969. - * 14: 1: Error in RX Packet 0: Incomplete or no error.
  970. - * 13-11: Type of error.
  971. - * 1000 = Overrun.
  972. - * 1011 = Run Packet Error.
  973. - * 1100 = Alignment Error.
  974. - * 1101 = CRC Error.
  975. - * 1001 = Oversize Packet Error (>1514 bytes)
  976. - * 0010 = Dribble Bits.
  977. - * (all other error codes, no errors.)
  978. - *
  979. - * 10-0: RX Bytes (0-1514)
  980. - */
  981. -#define ERR_RX_INCOMPLETE (unsigned short) (0x1<<15)
  982. -#define ERR_RX (unsigned short) (0x1<<14)
  983. -#define ERR_RX_OVERRUN (unsigned short) (0x8<<11)
  984. -#define ERR_RX_RUN_PKT (unsigned short) (0xb<<11)
  985. -#define ERR_RX_ALIGN (unsigned short) (0xc<<11)
  986. -#define ERR_RX_CRC (unsigned short) (0xd<<11)
  987. -#define ERR_RX_OVERSIZE (unsigned short) (0x9<<11)
  988. -#define ERR_RX_DRIBBLE (unsigned short) (0x2<<11)
  989. -
  990. -/*
  991. - * FIFO Registers.
  992. - * TX Status. Window 1/Port 0B
  993. - *
  994. - * Reports the transmit status of a completed transmission. Writing this
  995. - * register pops the transmit completion stack.
  996. - *
  997. - * Window 1/Port 0x0b.
  998. - *
  999. - * 7: Complete
  1000. - * 6: Interrupt on successful transmission requested.
  1001. - * 5: Jabber Error (TP Only, TX Reset required. )
  1002. - * 4: Underrun (TX Reset required. )
  1003. - * 3: Maximum Collisions.
  1004. - * 2: TX Status Overflow.
  1005. - * 1-0: Undefined.
  1006. - *
  1007. - */
  1008. -#define TXS_COMPLETE 0x80
  1009. -#define TXS_SUCCES_INTR_REQ 0x40
  1010. -#define TXS_JABBER 0x20
  1011. -#define TXS_UNDERRUN 0x10
  1012. -#define TXS_MAX_COLLISION 0x8
  1013. -#define TXS_STATUS_OVERFLOW 0x4
  1014. -
  1015. -/*
  1016. - * Configuration control register.
  1017. - * Window 0/Port 04
  1018. - */
  1019. -/* Read */
  1020. -#define IS_AUI (1<<13)
  1021. -#define IS_BNC (1<<12)
  1022. -#define IS_UTP (1<<9)
  1023. -/* Write */
  1024. -#define ENABLE_DRQ_IRQ 0x0001
  1025. -#define W0_P4_CMD_RESET_ADAPTER 0x4
  1026. -#define W0_P4_CMD_ENABLE_ADAPTER 0x1
  1027. -/*
  1028. - * Media type and status.
  1029. - * Window 4/Port 0A
  1030. - */
  1031. -#define ENABLE_UTP 0xc0
  1032. -#define DISABLE_UTP 0x0
  1033. -
  1034. -/*
  1035. - * Resource control register
  1036. - */
  1037. -
  1038. -#define SET_IRQ(i) ( ((i)<<12) | 0xF00) /* set IRQ i */
  1039. -
  1040. -/*
  1041. - * Receive status register
  1042. - */
  1043. -
  1044. -#define RX_BYTES_MASK (unsigned short) (0x07ff)
  1045. -#define RX_ERROR 0x4000
  1046. -#define RX_INCOMPLETE 0x8000
  1047. -
  1048. -
  1049. -/*
  1050. - * Misc defines for various things.
  1051. - */
  1052. -#define ACTIVATE_ADAPTER_TO_CONFIG 0xff /* to the id_port */
  1053. -#define MFG_ID 0x6d50 /* in EEPROM and W0 ADDR_CONFIG */
  1054. -#define PROD_ID 0x9150
  1055. -
  1056. -#define AUI 0x1
  1057. -#define BNC 0x2
  1058. -#define UTP 0x4
  1059. -
  1060. -#define RX_BYTES_MASK (unsigned short) (0x07ff)
  1061. -
  1062. - /* EISA support */
  1063. -#define EP_EISA_START 0x1000
  1064. -#define EP_EISA_W0 0x0c80
  1065. -
  1066. -#ifdef INCLUDE_3C529
  1067. - /* MCA support */
  1068. -#define MCA_MOTHERBOARD_SETUP_REG 0x94
  1069. -#define MCA_ADAPTER_SETUP_REG 0x96
  1070. -#define MCA_MAX_SLOT_NR 8
  1071. -#define MCA_POS_REG(n) (0x100+(n))
  1072. -#endif
  1073. -
  1074. -/*
  1075. - * Local variables:
  1076. - * c-basic-offset: 8
  1077. - * End:
  1078. - */
  1079. diff -Naur grub-0.97.orig/netboot/3c595.c grub-0.97/netboot/3c595.c
  1080. --- grub-0.97.orig/netboot/3c595.c 2003-07-09 11:45:37.000000000 +0000
  1081. +++ grub-0.97/netboot/3c595.c 2005-08-31 19:03:35.000000000 +0000
  1082. @@ -20,6 +20,7 @@
  1083. *
  1084. * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca>
  1085. *
  1086. +* timlegge 08-24-2003 Add Multicast Support
  1087. */
  1088. /* #define EDEBUG */
  1089. @@ -30,7 +31,7 @@
  1090. #include "3c595.h"
  1091. #include "timer.h"
  1092. -static unsigned short eth_nic_base, eth_asic_base;
  1093. +static unsigned short eth_nic_base;
  1094. static unsigned short vx_connector, vx_connectors;
  1095. static struct connector_entry {
  1096. @@ -57,14 +58,12 @@
  1097. static void vxgetlink(void);
  1098. static void vxsetlink(void);
  1099. -#define udelay(n) waiton_timer2(((n)*TICKS_PER_MS)/1000)
  1100. -
  1101. /**************************************************************************
  1102. ETH_RESET - Reset adapter
  1103. ***************************************************************************/
  1104. static void t595_reset(struct nic *nic)
  1105. {
  1106. - int i, j;
  1107. + int i;
  1108. /***********************************************************
  1109. Reset 3Com 595 card
  1110. @@ -133,7 +132,7 @@
  1111. outw(ACK_INTR | 0xff, BASE + VX_COMMAND);
  1112. outw(SET_RX_FILTER | FIL_INDIVIDUAL |
  1113. - FIL_BRDCST, BASE + VX_COMMAND);
  1114. + FIL_BRDCST|FIL_MULTICAST, BASE + VX_COMMAND);
  1115. vxsetlink();
  1116. /*{
  1117. @@ -225,10 +224,9 @@
  1118. /**************************************************************************
  1119. ETH_POLL - Wait for a frame
  1120. ***************************************************************************/
  1121. -static int t595_poll(struct nic *nic)
  1122. +static int t595_poll(struct nic *nic, int retrieve)
  1123. {
  1124. /* common variables */
  1125. - unsigned short type = 0; /* used by EDEBUG */
  1126. /* variables for 3C595 */
  1127. short status, cst;
  1128. register short rx_fifo;
  1129. @@ -262,6 +260,8 @@
  1130. if (rx_fifo==0)
  1131. return 0;
  1132. + if ( ! retrieve ) return 1;
  1133. +
  1134. /* read packet */
  1135. #ifdef EDEBUG
  1136. printf("[l=%d",rx_fifo);
  1137. @@ -300,12 +300,15 @@
  1138. outw(RX_DISCARD_TOP_PACK, BASE + VX_COMMAND);
  1139. while (inw(BASE + VX_STATUS) & S_COMMAND_IN_PROGRESS);
  1140. #ifdef EDEBUG
  1141. +{
  1142. + unsigned short type = 0; /* used by EDEBUG */
  1143. type = (nic->packet[12]<<8) | nic->packet[13];
  1144. if(nic->packet[0]+nic->packet[1]+nic->packet[2]+nic->packet[3]+nic->packet[4]+
  1145. nic->packet[5] == 0xFF*ETH_ALEN)
  1146. printf(",t=%hX,b]",type);
  1147. else
  1148. printf(",t=%hX]",type);
  1149. +}
  1150. #endif
  1151. return 1;
  1152. }
  1153. @@ -382,9 +385,8 @@
  1154. static void
  1155. vxsetlink(void)
  1156. {
  1157. - int i, j, k;
  1158. + int i, j;
  1159. char *reason, *warning;
  1160. - static short prev_flags;
  1161. static char prev_conn = -1;
  1162. if (prev_conn == -1) {
  1163. @@ -438,28 +440,47 @@
  1164. GO_WINDOW(1);
  1165. }
  1166. -static void t595_disable(struct nic *nic)
  1167. +static void t595_disable(struct dev *dev)
  1168. {
  1169. - outw(STOP_TRANSCEIVER, BASE + VX_COMMAND);
  1170. - udelay(8000);
  1171. - GO_WINDOW(4);
  1172. - outw(0, BASE + VX_W4_MEDIA_TYPE);
  1173. - GO_WINDOW(1);
  1174. + struct nic *nic = (struct nic *)dev;
  1175. + t595_reset(nic);
  1176. +
  1177. + outw(STOP_TRANSCEIVER, BASE + VX_COMMAND);
  1178. + udelay(8000);
  1179. + GO_WINDOW(4);
  1180. + outw(0, BASE + VX_W4_MEDIA_TYPE);
  1181. + GO_WINDOW(1);
  1182. +}
  1183. +
  1184. +static void t595_irq(struct nic *nic __unused, irq_action_t action __unused)
  1185. +{
  1186. + switch ( action ) {
  1187. + case DISABLE :
  1188. + break;
  1189. + case ENABLE :
  1190. + break;
  1191. + case FORCE :
  1192. + break;
  1193. + }
  1194. }
  1195. /**************************************************************************
  1196. ETH_PROBE - Look for an adapter
  1197. ***************************************************************************/
  1198. -struct nic *t595_probe(struct nic *nic, unsigned short *probeaddrs, struct pci_device *pci)
  1199. +static int t595_probe(struct dev *dev, struct pci_device *pci)
  1200. {
  1201. + struct nic *nic = (struct nic *)dev;
  1202. int i;
  1203. unsigned short *p;
  1204. - if (probeaddrs == 0 || probeaddrs[0] == 0)
  1205. + if (pci->ioaddr == 0)
  1206. return 0;
  1207. /* eth_nic_base = probeaddrs[0] & ~3; */
  1208. eth_nic_base = pci->ioaddr;
  1209. + nic->irqno = 0;
  1210. + nic->ioaddr = pci->ioaddr & ~3;
  1211. +
  1212. GO_WINDOW(0);
  1213. outw(GLOBAL_RESET, BASE + VX_COMMAND);
  1214. VX_BUSY_WAIT;
  1215. @@ -487,14 +508,40 @@
  1216. printf("Ethernet address: %!\n", nic->node_addr);
  1217. t595_reset(nic);
  1218. - nic->reset = t595_reset;
  1219. - nic->poll = t595_poll;
  1220. + dev->disable = t595_disable;
  1221. + nic->poll = t595_poll;
  1222. nic->transmit = t595_transmit;
  1223. - nic->disable = t595_disable;
  1224. - return nic;
  1225. + nic->irq = t595_irq;
  1226. + return 1;
  1227. }
  1228. +static struct pci_id t595_nics[] = {
  1229. +PCI_ROM(0x10b7, 0x5900, "3c590", "3Com590"), /* Vortex 10Mbps */
  1230. +PCI_ROM(0x10b7, 0x5950, "3c595", "3Com595"), /* Vortex 100baseTx */
  1231. +PCI_ROM(0x10b7, 0x5951, "3c595-1", "3Com595"), /* Vortex 100baseT4 */
  1232. +PCI_ROM(0x10b7, 0x5952, "3c595-2", "3Com595"), /* Vortex 100base-MII */
  1233. +PCI_ROM(0x10b7, 0x9000, "3c900-tpo", "3Com900-TPO"), /* 10 Base TPO */
  1234. +PCI_ROM(0x10b7, 0x9001, "3c900-t4", "3Com900-Combo"), /* 10/100 T4 */
  1235. +PCI_ROM(0x10b7, 0x9004, "3c900b-tpo", "3Com900B-TPO"), /* 10 Base TPO */
  1236. +PCI_ROM(0x10b7, 0x9005, "3c900b-combo", "3Com900B-Combo"), /* 10 Base Combo */
  1237. +PCI_ROM(0x10b7, 0x9006, "3c900b-tpb2", "3Com900B-2/T"), /* 10 Base TP and Base2 */
  1238. +PCI_ROM(0x10b7, 0x900a, "3c900b-fl", "3Com900B-FL"), /* 10 Base F */
  1239. +PCI_ROM(0x10b7, 0x9800, "3c980-cyclone-1", "3Com980-Cyclone"), /* Cyclone */
  1240. +PCI_ROM(0x10b7, 0x9805, "3c9805-1", "3Com9805"), /* Dual Port Server Cyclone */
  1241. +PCI_ROM(0x10b7, 0x7646, "3csoho100-tx-1", "3CSOHO100-TX"), /* Hurricane */
  1242. +PCI_ROM(0x10b7, 0x4500, "3c450-1", "3Com450 HomePNA Tornado"),
  1243. +};
  1244. +
  1245. +struct pci_driver t595_driver = {
  1246. + .type = NIC_DRIVER,
  1247. + .name = "3C595",
  1248. + .probe = t595_probe,
  1249. + .ids = t595_nics,
  1250. + .id_count = sizeof(t595_nics)/sizeof(t595_nics[0]),
  1251. + .class = 0,
  1252. +};
  1253. +
  1254. /*
  1255. * Local variables:
  1256. * c-basic-offset: 8
  1257. diff -Naur grub-0.97.orig/netboot/3c90x.c grub-0.97/netboot/3c90x.c
  1258. --- grub-0.97.orig/netboot/3c90x.c 2003-07-09 11:45:37.000000000 +0000
  1259. +++ grub-0.97/netboot/3c90x.c 2005-08-31 19:03:35.000000000 +0000
  1260. @@ -1,7 +1,7 @@
  1261. /*
  1262. * 3c90x.c -- This file implements the 3c90x driver for etherboot. Written
  1263. * by Greg Beeley, Greg.Beeley@LightSys.org. Modified by Steve Smith,
  1264. - * Steve.Smith@Juno.Com
  1265. + * Steve.Smith@Juno.Com. Alignment bug fix Neil Newell (nn@icenoir.net).
  1266. *
  1267. * This program Copyright (C) 1999 LightSys Technology Services, Inc.
  1268. * Portions Copyright (C) 1999 Steve Smith
  1269. @@ -31,13 +31,15 @@
  1270. * Re-wrote poll and transmit for
  1271. * better error recovery and heavy
  1272. * network traffic operation
  1273. + * v2.01 5-26-2003 NN Fixed driver alignment issue which
  1274. + * caused system lockups if driver structures
  1275. + * not 8-byte aligned.
  1276. *
  1277. */
  1278. #include "etherboot.h"
  1279. #include "nic.h"
  1280. #include "pci.h"
  1281. -#include "cards.h"
  1282. #include "timer.h"
  1283. #define XCVR_MAGIC (0x5A00)
  1284. @@ -47,9 +49,6 @@
  1285. **/
  1286. #define XMIT_RETRIES 250
  1287. -#undef virt_to_bus
  1288. -#define virt_to_bus(x) ((unsigned long)x)
  1289. -
  1290. /*** Register definitions for the 3c905 ***/
  1291. enum Registers
  1292. {
  1293. @@ -225,7 +224,7 @@
  1294. unsigned int DataAddr;
  1295. unsigned int DataLength;
  1296. }
  1297. - TXD;
  1298. + TXD __attribute__ ((aligned(8))); /* 64-bit aligned for bus mastering */
  1299. /*** RX descriptor ***/
  1300. typedef struct
  1301. @@ -235,7 +234,7 @@
  1302. unsigned int DataAddr;
  1303. unsigned int DataLength;
  1304. }
  1305. - RXD;
  1306. + RXD __attribute__ ((aligned(8))); /* 64-bit aligned for bus mastering */
  1307. /*** Global variables ***/
  1308. static struct
  1309. @@ -311,6 +310,7 @@
  1310. }
  1311. +#if 0
  1312. /*** a3c90x_internal_WriteEepromWord - write a physical word of
  1313. *** data to the onboard serial eeprom (not the BIOS prom, but the
  1314. *** nvram in the card that stores, among other things, the MAC
  1315. @@ -344,8 +344,9 @@
  1316. return 0;
  1317. }
  1318. +#endif
  1319. -
  1320. +#if 0
  1321. /*** a3c90x_internal_WriteEeprom - write data to the serial eeprom,
  1322. *** and re-compute the eeprom checksum.
  1323. ***/
  1324. @@ -384,8 +385,7 @@
  1325. return 0;
  1326. }
  1327. -
  1328. -
  1329. +#endif
  1330. /*** a3c90x_reset: exported function that resets the card to its default
  1331. *** state. This is so the Linux driver can re-set the card up the way
  1332. @@ -393,12 +393,10 @@
  1333. *** not alter the selected transceiver that we used to download the boot
  1334. *** image.
  1335. ***/
  1336. -static void
  1337. -a3c90x_reset(struct nic *nic)
  1338. +static void a3c90x_reset(void)
  1339. {
  1340. - int cfg;
  1341. -
  1342. #ifdef CFG_3C90X_PRESERVE_XCVR
  1343. + int cfg;
  1344. /** Read the current InternalConfig value. **/
  1345. a3c90x_internal_SetWindow(INF_3C90X.IOAddr, winTxRxOptions3);
  1346. cfg = inl(INF_3C90X.IOAddr + regInternalConfig_3_l);
  1347. @@ -473,7 +471,7 @@
  1348. *** p - the pointer to the packet data itself.
  1349. ***/
  1350. static void
  1351. -a3c90x_transmit(struct nic *nic, const char *d, unsigned int t,
  1352. +a3c90x_transmit(struct nic *nic __unused, const char *d, unsigned int t,
  1353. unsigned int s, const char *p)
  1354. {
  1355. @@ -553,7 +551,7 @@
  1356. if (status & 0x02)
  1357. {
  1358. printf("3C90X: Tx Reclaim Error (%hhX)\n", status);
  1359. - a3c90x_reset(NULL);
  1360. + a3c90x_reset();
  1361. }
  1362. else if (status & 0x04)
  1363. {
  1364. @@ -572,18 +570,18 @@
  1365. else if (status & 0x10)
  1366. {
  1367. printf("3C90X: Tx Underrun (%hhX)\n", status);
  1368. - a3c90x_reset(NULL);
  1369. + a3c90x_reset();
  1370. }
  1371. else if (status & 0x20)
  1372. {
  1373. printf("3C90X: Tx Jabber (%hhX)\n", status);
  1374. - a3c90x_reset(NULL);
  1375. + a3c90x_reset();
  1376. }
  1377. else if ((status & 0x80) != 0x80)
  1378. {
  1379. printf("3C90X: Internal Error - Incomplete Transmission (%hhX)\n",
  1380. status);
  1381. - a3c90x_reset(NULL);
  1382. + a3c90x_reset();
  1383. }
  1384. }
  1385. @@ -601,7 +599,7 @@
  1386. *** in nic->packetlen. Return 1 if a packet was found.
  1387. ***/
  1388. static int
  1389. -a3c90x_poll(struct nic *nic)
  1390. +a3c90x_poll(struct nic *nic, int retrieve)
  1391. {
  1392. int i, errcode;
  1393. @@ -610,6 +608,8 @@
  1394. return 0;
  1395. }
  1396. + if ( ! retrieve ) return 1;
  1397. +
  1398. /** we don't need to acknowledge rxComplete -- the upload engine
  1399. ** does it for us.
  1400. **/
  1401. @@ -663,34 +663,51 @@
  1402. *** [Ken]
  1403. ***/
  1404. static void
  1405. -a3c90x_disable(struct nic *nic)
  1406. - {
  1407. +a3c90x_disable(struct dev *dev __unused)
  1408. +{
  1409. + /* reset and disable merge */
  1410. + a3c90x_reset();
  1411. /* Disable the receiver and transmitter. */
  1412. outw(cmdRxDisable, INF_3C90X.IOAddr + regCommandIntStatus_w);
  1413. outw(cmdTxDisable, INF_3C90X.IOAddr + regCommandIntStatus_w);
  1414. - }
  1415. -
  1416. +}
  1417. +static void a3c90x_irq(struct nic *nic __unused, irq_action_t action __unused)
  1418. +{
  1419. + switch ( action ) {
  1420. + case DISABLE :
  1421. + break;
  1422. + case ENABLE :
  1423. + break;
  1424. + case FORCE :
  1425. + break;
  1426. + }
  1427. +}
  1428. /*** a3c90x_probe: exported routine to probe for the 3c905 card and perform
  1429. *** initialization. If this routine is called, the pci functions did find the
  1430. *** card. We just have to init it here.
  1431. ***/
  1432. -struct nic*
  1433. -a3c90x_probe(struct nic *nic, unsigned short *probeaddrs, struct pci_device *pci)
  1434. - {
  1435. +static int a3c90x_probe(struct dev *dev, struct pci_device *pci)
  1436. +{
  1437. + struct nic *nic = (struct nic *)dev;
  1438. int i, c;
  1439. unsigned short eeprom[0x21];
  1440. unsigned int cfg;
  1441. unsigned int mopt;
  1442. + unsigned int mstat;
  1443. unsigned short linktype;
  1444. +#define HWADDR_OFFSET 10
  1445. - if (probeaddrs == 0 || probeaddrs[0] == 0)
  1446. + if (pci->ioaddr == 0)
  1447. return 0;
  1448. adjust_pci_device(pci);
  1449. - INF_3C90X.IOAddr = probeaddrs[0] & ~3;
  1450. + nic->ioaddr = pci->ioaddr & ~3;
  1451. + nic->irqno = 0;
  1452. +
  1453. + INF_3C90X.IOAddr = pci->ioaddr & ~3;
  1454. INF_3C90X.CurrentWindow = 255;
  1455. switch (a3c90x_internal_ReadEeprom(INF_3C90X.IOAddr, 0x03))
  1456. {
  1457. @@ -756,30 +773,45 @@
  1458. "Copyright 1999 LightSys Technology Services, Inc.\n"
  1459. "Portions Copyright 1999 Steve Smith\n");
  1460. printf("Provided with ABSOLUTELY NO WARRANTY.\n");
  1461. +#ifdef CFG_3C90X_BOOTROM_FIX
  1462. + if (INF_3C90X.isBrev)
  1463. + {
  1464. + printf("NOTE: 3c905b bootrom fix enabled; has side "
  1465. + "effects. See 3c90x.txt for info.\n");
  1466. + }
  1467. +#endif
  1468. printf("-------------------------------------------------------"
  1469. "------------------------\n");
  1470. /** Retrieve the Hardware address and print it on the screen. **/
  1471. - INF_3C90X.HWAddr[0] = eeprom[0]>>8;
  1472. - INF_3C90X.HWAddr[1] = eeprom[0]&0xFF;
  1473. - INF_3C90X.HWAddr[2] = eeprom[1]>>8;
  1474. - INF_3C90X.HWAddr[3] = eeprom[1]&0xFF;
  1475. - INF_3C90X.HWAddr[4] = eeprom[2]>>8;
  1476. - INF_3C90X.HWAddr[5] = eeprom[2]&0xFF;
  1477. + INF_3C90X.HWAddr[0] = eeprom[HWADDR_OFFSET + 0]>>8;
  1478. + INF_3C90X.HWAddr[1] = eeprom[HWADDR_OFFSET + 0]&0xFF;
  1479. + INF_3C90X.HWAddr[2] = eeprom[HWADDR_OFFSET + 1]>>8;
  1480. + INF_3C90X.HWAddr[3] = eeprom[HWADDR_OFFSET + 1]&0xFF;
  1481. + INF_3C90X.HWAddr[4] = eeprom[HWADDR_OFFSET + 2]>>8;
  1482. + INF_3C90X.HWAddr[5] = eeprom[HWADDR_OFFSET + 2]&0xFF;
  1483. printf("MAC Address = %!\n", INF_3C90X.HWAddr);
  1484. + /* Test if the link is good, if not continue */
  1485. + a3c90x_internal_SetWindow(INF_3C90X.IOAddr, winDiagnostics4);
  1486. + mstat = inw(INF_3C90X.IOAddr + regMediaStatus_4_w);
  1487. + if((mstat & (1<<11)) == 0) {
  1488. + printf("Valid link not established\n");
  1489. + return 0;
  1490. + }
  1491. +
  1492. /** Program the MAC address into the station address registers **/
  1493. a3c90x_internal_SetWindow(INF_3C90X.IOAddr, winAddressing2);
  1494. - outw(htons(eeprom[0]), INF_3C90X.IOAddr + regStationAddress_2_3w);
  1495. - outw(htons(eeprom[1]), INF_3C90X.IOAddr + regStationAddress_2_3w+2);
  1496. - outw(htons(eeprom[2]), INF_3C90X.IOAddr + regStationAddress_2_3w+4);
  1497. + outw(htons(eeprom[HWADDR_OFFSET + 0]), INF_3C90X.IOAddr + regStationAddress_2_3w);
  1498. + outw(htons(eeprom[HWADDR_OFFSET + 1]), INF_3C90X.IOAddr + regStationAddress_2_3w+2);
  1499. + outw(htons(eeprom[HWADDR_OFFSET + 2]), INF_3C90X.IOAddr + regStationAddress_2_3w+4);
  1500. outw(0, INF_3C90X.IOAddr + regStationMask_2_3w+0);
  1501. outw(0, INF_3C90X.IOAddr + regStationMask_2_3w+2);
  1502. outw(0, INF_3C90X.IOAddr + regStationMask_2_3w+4);
  1503. /** Fill in our entry in the etherboot arp table **/
  1504. for(i=0;i<ETH_ALEN;i++)
  1505. - nic->node_addr[i] = (eeprom[i/2] >> (8*((i&1)^1))) & 0xff;
  1506. + nic->node_addr[i] = (eeprom[HWADDR_OFFSET + i/2] >> (8*((i&1)^1))) & 0xff;
  1507. /** Read the media options register, print a message and set default
  1508. ** xcvr.
  1509. @@ -903,8 +935,8 @@
  1510. while (inw(INF_3C90X.IOAddr + regCommandIntStatus_w) & INT_CMDINPROGRESS)
  1511. ;
  1512. - /** Set the RX filter = receive only individual pkts & bcast. **/
  1513. - a3c90x_internal_IssueCommand(INF_3C90X.IOAddr, cmdSetRxFilter, 0x01 + 0x04);
  1514. + /** Set the RX filter = receive only individual pkts & multicast & bcast. **/
  1515. + a3c90x_internal_IssueCommand(INF_3C90X.IOAddr, cmdSetRxFilter, 0x01 + 0x02 + 0x04);
  1516. a3c90x_internal_IssueCommand(INF_3C90X.IOAddr, cmdRxEnable, 0);
  1517. @@ -918,12 +950,46 @@
  1518. cmdAcknowledgeInterrupt, 0x661);
  1519. /** Set our exported functions **/
  1520. - nic->reset = a3c90x_reset;
  1521. + dev->disable = a3c90x_disable;
  1522. nic->poll = a3c90x_poll;
  1523. nic->transmit = a3c90x_transmit;
  1524. - nic->disable = a3c90x_disable;
  1525. + nic->irq = a3c90x_irq;
  1526. - return nic;
  1527. - }
  1528. + return 1;
  1529. +}
  1530. +static struct pci_id a3c90x_nics[] = {
  1531. +/* Original 90x revisions: */
  1532. +PCI_ROM(0x10b7, 0x9000, "3c905-tpo", "3Com900-TPO"), /* 10 Base TPO */
  1533. +PCI_ROM(0x10b7, 0x9001, "3c905-t4", "3Com900-Combo"), /* 10/100 T4 */
  1534. +PCI_ROM(0x10b7, 0x9050, "3c905-tpo100", "3Com905-TX"), /* 100 Base TX / 10/100 TPO */
  1535. +PCI_ROM(0x10b7, 0x9051, "3c905-combo", "3Com905-T4"), /* 100 Base T4 / 10 Base Combo */
  1536. +/* Newer 90xB revisions: */
  1537. +PCI_ROM(0x10b7, 0x9004, "3c905b-tpo", "3Com900B-TPO"), /* 10 Base TPO */
  1538. +PCI_ROM(0x10b7, 0x9005, "3c905b-combo", "3Com900B-Combo"), /* 10 Base Combo */
  1539. +PCI_ROM(0x10b7, 0x9006, "3c905b-tpb2", "3Com900B-2/T"), /* 10 Base TP and Base2 */
  1540. +PCI_ROM(0x10b7, 0x900a, "3c905b-fl", "3Com900B-FL"), /* 10 Base FL */
  1541. +PCI_ROM(0x10b7, 0x9055, "3c905b-tpo100", "3Com905B-TX"), /* 10/100 TPO */
  1542. +PCI_ROM(0x10b7, 0x9056, "3c905b-t4", "3Com905B-T4"), /* 10/100 T4 */
  1543. +PCI_ROM(0x10b7, 0x9058, "3c905b-9058", "3Com905B-9058"), /* Cyclone 10/100/BNC */
  1544. +PCI_ROM(0x10b7, 0x905a, "3c905b-fx", "3Com905B-FL"), /* 100 Base FX / 10 Base FX */
  1545. +/* Newer 90xC revision: */
  1546. +PCI_ROM(0x10b7, 0x9200, "3c905c-tpo", "3Com905C-TXM"), /* 10/100 TPO (3C905C-TXM) */
  1547. +PCI_ROM(0x10b7, 0x9210, "3c920b-emb-wnm","3Com20B-EMB WNM"),
  1548. +PCI_ROM(0x10b7, 0x9800, "3c980", "3Com980-Cyclone"), /* Cyclone */
  1549. +PCI_ROM(0x10b7, 0x9805, "3c9805", "3Com9805"), /* Dual Port Server Cyclone */
  1550. +PCI_ROM(0x10b7, 0x7646, "3csoho100-tx", "3CSOHO100-TX"), /* Hurricane */
  1551. +PCI_ROM(0x10b7, 0x4500, "3c450", "3Com450 HomePNA Tornado"),
  1552. +PCI_ROM(0x10b7, 0x1201, "3c982a", "3Com982A"),
  1553. +PCI_ROM(0x10b7, 0x1202, "3c982b", "3Com982B"),
  1554. +};
  1555. +
  1556. +struct pci_driver a3c90x_driver = {
  1557. + .type = NIC_DRIVER,
  1558. + .name = "3C90X",
  1559. + .probe = a3c90x_probe,
  1560. + .ids = a3c90x_nics,
  1561. + .id_count = sizeof(a3c90x_nics)/sizeof(a3c90x_nics[0]),
  1562. + .class = 0,
  1563. +};
  1564. diff -Naur grub-0.97.orig/netboot/3c90x.txt grub-0.97/netboot/3c90x.txt
  1565. --- grub-0.97.orig/netboot/3c90x.txt 2003-07-09 11:45:37.000000000 +0000
  1566. +++ grub-0.97/netboot/3c90x.txt 1970-01-01 00:00:00.000000000 +0000
  1567. @@ -1,307 +0,0 @@
  1568. -
  1569. - Instructions for use of the 3C90X driver for EtherBoot
  1570. -
  1571. - Original 3C905B support by:
  1572. - Greg Beeley (Greg.Beeley@LightSys.org),
  1573. - LightSys Technology Services, Inc.
  1574. - February 11, 1999
  1575. -
  1576. - Updates for 3C90X family by:
  1577. - Steve Smith (steve.smith@juno.com)
  1578. - October 1, 1999
  1579. -
  1580. - Minor documentation updates by
  1581. - Greg Beeley (Greg.Beeley@LightSys.org)
  1582. - March 29, 2000
  1583. -
  1584. --------------------------------------------------------------------------------
  1585. -
  1586. -I OVERVIEW
  1587. -
  1588. - The 3c90X series ethernet cards are a group of high-performance busmaster
  1589. - DMA cards from 3Com. This particular driver supports both the 3c90x and
  1590. - the 3c90xB revision cards. 3C90xC family support has been tested to some
  1591. - degree but not extensively.
  1592. -
  1593. - Here's the licensing information:
  1594. -
  1595. - This program Copyright (C) 1999 LightSys Technology Services, Inc.
  1596. - Portions Copyright (C) 1999 Steve Smith.
  1597. -
  1598. - This program may be re-distributed in source or binary form, modified,
  1599. - sold, or copied for any purpose, provided that the above copyright message
  1600. - and this text are included with all source copies or derivative works, and
  1601. - provided that the above copyright message and this text are included in the
  1602. - documentation of any binary-only distributions. This program is
  1603. - distributed WITHOUT ANY WARRANTY, without even the warranty of FITNESS FOR
  1604. - A PARTICULAR PURPOSE or MERCHANTABILITY. Please read the associated
  1605. - documentation "3c90x.txt" before compiling and using this driver.
  1606. -
  1607. -
  1608. -II FLASH PROMS
  1609. -
  1610. - The 3c90xB cards, according to the 3Com documentation, only accept the
  1611. - following flash memory chips:
  1612. -
  1613. - Atmel AT29C512 (64 kilobyte)
  1614. - Atmel AT29C010 (128 kilobyte)
  1615. -
  1616. - The 3c90x cards, according to the 3Com documentation, accept the
  1617. - following flash memory chips capacities:
  1618. -
  1619. - 64 kb (8 kB)
  1620. - 128 kb (16 kB)
  1621. - 256 kb (32 kB) and
  1622. - 512 kb (64 kB)
  1623. -
  1624. - Atmel AT29C512 (64 kilobyte) chips are specifically listed for both
  1625. - adapters, but flashing on the 3c905b cards would only be supported
  1626. - through the Atmel parts. Any device, of the supported size, should
  1627. - be supported when programmed by a dedicated PROM programmer (e.g.
  1628. - not the card).
  1629. -
  1630. - To use this driver in such a PROM, visit Atmel's web site and download
  1631. - their .PDF file containing a list of their distributors. Contact the
  1632. - distributors for pricing information. The prices are quite reasonable
  1633. - (about $3 US each for the 64 kB part), and are comparable to what one would
  1634. - expect for similarly sized standard EPROMs. And, the flash chips are much
  1635. - easier to work with, as they don't need to be UV-erased to be reprogrammed.
  1636. - The 3C905B card actually provides a method to program the flash memory
  1637. - while it is resident on board the card itself; if someone would like to
  1638. - write a small DOS program to do the programming, I can provide the
  1639. - information about the registers and so forth.
  1640. -
  1641. - A utility program, 3c90xutil, is provided with Etherboot in the 'contrib'
  1642. - directory that allows for the on-board flashing of the ROM while Linux
  1643. - is running. The program has been successfully used under Linux, but I
  1644. - have heard problem reports of its use under FreeBSD. Anyone willing to
  1645. - make it work under FreeBSD is more than welcome to do so!
  1646. -
  1647. - You also have the option of using EPROM chips - the 3C905B-TX-NM has been
  1648. - successfully tested with 27C256 (32kB) and 27C512 (64kB) chips with a
  1649. - specified access time of 100ns and faster.
  1650. -
  1651. -
  1652. -III GENERAL USE
  1653. -
  1654. - Normally, the basic procedure for using this driver is as follows:
  1655. -
  1656. - 1. Run the 3c90xcfg program on the driver diskette to enable the
  1657. - boot PROM and set it to 64k or 128k, as appropriate.
  1658. - 2. Build the appropriate 3c90x.fd0 or 3c90x.fd0 floppy image with
  1659. - possibly the value CFG_3C90X_XCVR defined to the transceiver type that
  1660. - you want to use (i.e., 10/100 rj45, AUI, coax, MII).
  1661. - 3. Run the floppy image on the PC to be network booted, to get
  1662. - it configured, and to verify that it will boot properly.
  1663. - 4. Build the 3c90x.rom or 3c90x.lzrom PROM image and program
  1664. - it into the flash or EPROM memory chip.
  1665. - 5. Put the PROM in the ethernet card, boot and enable 'boot from
  1666. - network first' in the system BIOS, save and reboot.
  1667. -
  1668. - Here are some issues to be aware of:
  1669. -
  1670. - 1. If you experience crashes or different behaviour when using the
  1671. - boot PROM, add the setting CFG_3C90X_BOOTROM_FIX and go through the
  1672. - steps 2-5 above. This works around a bug in some 3c905B cards (see
  1673. - below), but has some side-effects which may not be desirable.
  1674. - Please note that you have to boot off a floppy (not PROM!) once for
  1675. - this fix to take effect.
  1676. - 2. The possible need to manually set the CFG_3C90X_XCVR value to
  1677. - configure the transceiver type. Values are listed below.
  1678. - 3. The possible need to define CFG_3C90X_PRESERVE_XCVR for use in
  1679. - operating systems that don't intelligently determine the
  1680. - transceiver type.
  1681. -
  1682. - Some things that are on the 'To-Do' list, perhaps for me, but perhaps
  1683. - for any other volunteers out there:
  1684. -
  1685. - 1. Extend the driver to fully implement the auto-select
  1686. - algorithm if the card has multiple media ports.
  1687. - 2. Fix any bugs in the code <grin>....
  1688. - 3. Extend the driver to support the 3c905c revision cards
  1689. - "officially". Right now, the support has been primarily empirical
  1690. - and not based on 3c905C documentation.
  1691. -
  1692. - Now for the details....
  1693. -
  1694. - This driver has been tested on roughly 300 systems. The main two
  1695. - configuration issues to contend with are:
  1696. -
  1697. - 1. Ensure that PCI Busmastering is enabled for the adapter (configured
  1698. - in the CMOS setup)
  1699. - 2. Some systems don't work properly with the adapter when plug and
  1700. - play OS is enabled; I always set it to "No" or "Disabled" -- this makes
  1701. - it easier and really doesn't adversely affect anything.
  1702. -
  1703. - Roughly 95% of the systems worked when configured properly. A few
  1704. - have issues with booting locally once the boot PROM has been installed
  1705. - (this number has been less than 2%). Other configuration issues that
  1706. - to check:
  1707. -
  1708. - 1. Newer BIOS's actually work correctly with the network boot order.
  1709. - Set the network adapter first. Most older BIOS's automatically go to
  1710. - the network boot PROM first.
  1711. - 2. For systems where the adapter was already installed and is just
  1712. - having the PROM installed, try setting the "reset configuration data"
  1713. - to yes in the CMOS setup if the BIOS isn't seen at first. If your BIOS
  1714. - doesn't have this option, remove the card, start the system, shut down,
  1715. - install the card and restart (or switch to a different PCI slot).
  1716. - 3. Make sure the CMOS security settings aren't preventing a boot.
  1717. -
  1718. - The 3c905B cards have a significant 'bug' that relates to the flash prom:
  1719. - unless the card is set internally to the MII transceiver, it will only
  1720. - read the first 8k of the PROM image. Don't ask why -- it seems really
  1721. - obscure, but it has to do with the way they mux'd the address lines
  1722. - from the PCI bus to the ROM. Unfortunately, most of us are not using
  1723. - MII transceivers, and even the .lzrom image ends up being just a little
  1724. - bit larger than 8k. Note that the workaround for this is disabled by
  1725. - default, because the Windows NT 4.0 driver does not like it (no packets
  1726. - are transmitted).
  1727. -
  1728. - So, the solution that I've used is to internally set the card's nvram
  1729. - configuration to use MII when it boots. The 3c905b driver does this
  1730. - automatically. This way, the 16k prom image can be loaded into memory,
  1731. - and then the 3c905b driver can set the temporary configuration of the
  1732. - card to an appropriate value, either configurable by the user or chosen
  1733. - by the driver.
  1734. -
  1735. - To enable the 3c905B bugfix, which is necessary for these cards when
  1736. - booting from the Flash ROM, define -DCFG_3C90X_BOOTROM_FIX when building,
  1737. - create a floppy image and boot it once.
  1738. - Thereafter, the card should accept the larger prom image.
  1739. -
  1740. - The driver should choose an appropriate transceiver on the card. However,
  1741. - if it doesn't on your card or if you need to, for instance, set your
  1742. - card to 10mbps when connected to an unmanaged 10/100 hub, you can specify
  1743. - which transceiver you want to use. To do this, build the 3c905b.fd0
  1744. - image with -DCFG_3C90X_XCVR=x, where 'x' is one of the following
  1745. - values:
  1746. -
  1747. - 0 10Base-T
  1748. - 1 10mbps AUI
  1749. - 3 10Base-2 (thinnet/coax)
  1750. - 4 100Base-TX
  1751. - 5 100Base-FX
  1752. - 6 MII
  1753. - 8 Auto-negotiation 10Base-T / 100Base-TX (usually the default)
  1754. - 9 MII External MAC Mode
  1755. - 255 Allow driver to choose an 'appropriate' media port.
  1756. -
  1757. - Then proceed from step 2 in the above 'general use' instructions. The
  1758. - .rom image can be built with CFG_3C90X_XCVR set to a value, but you
  1759. - normally don't want to do this, since it is easier to change the
  1760. - transceiver type by rebuilding a new floppy, changing the BIOS to floppy
  1761. - boot, booting, and then changing the BIOS back to network boot. If
  1762. - CFG_3C90X_XCVR is not set in a particular build, it just uses the
  1763. - current configuration (either its 'best guess' or whatever the stored
  1764. - CFG_3C90X_XCVR value was from the last time it was set).
  1765. -
  1766. - [[ Note for the more technically inclined: The CFG_3C90X_XCVR value is
  1767. - programmed into a register in the card's NVRAM that was reserved for
  1768. - LanWorks PROM images to use. When the driver boots, the card comes
  1769. - up in MII mode, and the driver checks the LanWorks register to find
  1770. - out if the user specified a transceiver type. If it finds that
  1771. - information, it uses that, otherwise it picks a transceiver that the
  1772. - card has based on the 3c905b's MediaOptions register. This driver isn't
  1773. - quite smart enough to always determine which media port is actually
  1774. - _connected_; maybe someone else would like to take on that task (it
  1775. - actually involves sending a self-directed packet and seeing if it
  1776. - comes back. IF it does, that port is connected). ]]
  1777. -
  1778. - Another issue to keep in mind is that it is possible that some OS'es
  1779. - might not be happy with the way I've handled the PROM-image hack with
  1780. - setting MII mode on bootup. Linux 2.0.35 does not have this problem.
  1781. - Behavior of other systems may vary. The 3com documentation specifically
  1782. - says that, at least with the card that I have, the device driver in the
  1783. - OS should auto-select the media port, so other drivers should work fine
  1784. - with this 'hack'. However, if yours doesn't seem to, you can try defining
  1785. - CFG_3C90X_PRESERVE_XCVR when building to cause Etherboot to keep the
  1786. - working setting (that allowed the bootp/tftp process) across the eth_reset
  1787. - operation.
  1788. -
  1789. -
  1790. -IV FOR DEVELOPERS....
  1791. -
  1792. - If you would like to fix/extend/etc. this driver, feel free to do so; just
  1793. - be sure you can test the modified version on the 3c905B-TX cards that the
  1794. - driver was originally designed for. This section of this document gives
  1795. - some information that might be relevant to a programmer.
  1796. -
  1797. - A. Main Entry Point
  1798. -
  1799. - a3c90x_probe is the main entry point for this driver. It is referred
  1800. - to in an array in 'config.c'.
  1801. -
  1802. - B. Other Important Functions
  1803. -
  1804. - The functions a3c90x_transmit, a3c90x_poll, a3c90x_reset, and
  1805. - a3c90x_disable are static functions that EtherBoot finds out about
  1806. - as a result of a3c90x_probe setting entries in the nic structure
  1807. - for them. The EtherBoot framework does not use interrupts. It is
  1808. - polled. All transmit and receive operations are initiated by the
  1809. - etherboot framework, not by an interrupt or by the driver.
  1810. -
  1811. - C. Internal Functions
  1812. -
  1813. - The following functions are internal to the driver:
  1814. -
  1815. - a3c90x_internal_IssueCommand - sends a command to the 3c905b card.
  1816. - a3c90x_internal_SetWindow - shifts between one of eight register
  1817. - windows onboard the 3c90x. The bottom 16 bytes of the card's
  1818. - I/O space are multiplexed among 128 bytes, only 16 of which are
  1819. - visible at any one time. This SetWindow function selects one of
  1820. - the eight sets.
  1821. - a3c90x_internal_ReadEeprom - reads a word (16 bits) from the
  1822. - card's onboard nvram. This is NOT the BIOS boot rom. This is
  1823. - where the card stores such things as its hardware address.
  1824. - a3c90x_internal_WriteEeprom - writes a word (16 bits) to the
  1825. - card's nvram, and recomputes the eeprom checksum.
  1826. - a3c90x_internal_WriteEepromWord - writes a word (16 bits) to the
  1827. - card's nvram. Used by the above routine.
  1828. - a3c90x_internal_WriteEepromWord - writes a word (16 bits) to the
  1829. - card's nvram. Used by the above routine.
  1830. -
  1831. - D. Globals
  1832. -
  1833. - All global variables are inside a global structure named INF_3C90X.
  1834. - So, wherever you see that structure referenced, you know the variable
  1835. - is a global. Just keeps things a little neater.
  1836. -
  1837. - E. Enumerations
  1838. -
  1839. - There are quite a few enumerated type definitions for registers and
  1840. - so forth, many for registers that I didn't even touch in the driver.
  1841. - Register types start with 'reg', window numbers (for SetWindow)
  1842. - start with 'win', and commands (for IssueCommand) start with 'cmd'.
  1843. - Register offsets also include an indication in the name as to the
  1844. - size of the register (_b = byte, _w = word, _l = long), and which
  1845. - window the register is in, if it is windowed (0-7).
  1846. -
  1847. - F. Why the 'a3c90x' name?
  1848. -
  1849. - I had to come up with a letter at the beginning of all of the
  1850. - identifiers, since 3com so conveniently had their name start with a
  1851. - number. Another driver used 't' (for 'three'?); I chose 'a' for
  1852. - no reason at all.
  1853. -
  1854. -Addendum by Jorge L. deLyra <delyra@latt.if.usp.br>, 22Nov2000 re
  1855. -working around the 3C905 hardware bug mentioned above:
  1856. -
  1857. -Use this floppy to fix any 3COM model 3C905B PCI 10/100 Ethernet cards
  1858. -that fail to load and run the boot program the first time around. If
  1859. -they have a "Lucent" rather than a "Broadcom" chipset these cards have
  1860. -a configuration bug that causes a hang when trying to load the boot
  1861. -program from the PROM, if you try to use them right out of the box.
  1862. -
  1863. -The boot program in this floppy is the file named 3c905b-tpo100.rom
  1864. -from Etherboot version 4.6.10, compiled with the bugfix parameter
  1865. -
  1866. - CFG_3C90X_BOOTROM_FIX
  1867. -
  1868. -You have to take the chip off the card and boot the system once using
  1869. -this floppy. Once loaded from the floppy, the boot program will access
  1870. -the card and change some setting in it, correcting the problem. After
  1871. -that you may use either this boot program or the normal one, compiled
  1872. -without this bugfix parameter, to boot the machine from the PROM chip.
  1873. -
  1874. -[Any recent Etherboot version should do, not just 4.6.10 - Ed.]
  1875. diff -Naur grub-0.97.orig/netboot/Makefile.am grub-0.97/netboot/Makefile.am
  1876. --- grub-0.97.orig/netboot/Makefile.am 2003-07-09 11:45:37.000000000 +0000
  1877. +++ grub-0.97/netboot/Makefile.am 2005-08-31 19:03:35.000000000 +0000
  1878. @@ -10,58 +10,72 @@
  1879. noinst_LIBRARIES = $(LIBDRIVERS)
  1880. -libdrivers_a_SOURCES = cards.h config.c etherboot.h \
  1881. - fsys_tftp.c linux-asm-io.h linux-asm-string.h \
  1882. - main.c misc.c nic.h osdep.h pci.c pci.h timer.c timer.h
  1883. -EXTRA_libdrivers_a_SOURCES = 3c509.c 3c509.h 3c595.c 3c595.h 3c90x.c \
  1884. - cs89x0.c cs89x0.h davicom.c depca.c eepro.c eepro100.c \
  1885. - epic100.c epic100.h fa311.c i82586.c lance.c natsemi.c \
  1886. - ni5010.c ns8390.c ns8390.h otulip.c otulip.h rtl8139.c \
  1887. - sis900.c sis900.h sk_g16.c sk_g16.h smc9000.c smc9000.h \
  1888. - tiara.c tlan.c tulip.c via-rhine.c w89c840.c
  1889. +libdrivers_a_SOURCES = big_bswap.h bootp.h byteswap.h config.c cpu.h \
  1890. + dev.h elf.h endian.h etherboot.h fsys_tftp.c grub.h \
  1891. + i386_byteswap.h i386_elf.h i386_endian.h i386_timer.c \
  1892. + if_arp.h if_ether.h igmp.h in.h io.h ip.h isa.h latch.h \
  1893. + little_bswap.h misc.c nic.c nic.h osdep.h pci.c pci.h \
  1894. + pci_ids.h pci_io.c stdint.h tftp.h timer.c timer.h \
  1895. + types.h udp.h mii.h pic8259.c pic8259.h pxe.h basemem.c segoff.h
  1896. +EXTRA_libdrivers_a_SOURCES = 3c595.c 3c595.h 3c90x.c davicom.c \
  1897. + e1000.c e1000_hw.h eepro100.c epic100.c epic100.h natsemi.c \
  1898. + ns8390.c ns8390.h pcnet32.c rtl8139.c sis900.c sis900.h \
  1899. + sundance.c tg3.c tg3.h tlan.c tlan.h tulip.c via-rhine.c \
  1900. + w89c840.c r8169.c forcedeth.c ns83820.c pnic.c pnic_api.c \
  1901. + undi.c undi.h
  1902. libdrivers_a_CFLAGS = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  1903. -DFSYS_TFTP=1 $(NET_CFLAGS) $(NET_EXTRAFLAGS)
  1904. # Filled by configure.
  1905. libdrivers_a_LIBADD = @NETBOOT_DRIVERS@
  1906. libdrivers_a_DEPENDENCIES = $(libdrivers_a_LIBADD)
  1907. -EXTRA_DIST = README.netboot 3c90x.txt cs89x0.txt sis900.txt tulip.txt
  1908. +EXTRA_DIST = README.netboot
  1909. # These below are several special rules for the device drivers.
  1910. # We cannot use a simple rule for them...
  1911. # What objects are derived from a driver?
  1912. -3c509_drivers = 3c509.o 3c529.o
  1913. +#3c509_drivers = 3c509.o 3c529.o
  1914. 3c595_drivers = 3c595.o
  1915. 3c90x_drivers = 3c90x.o
  1916. -cs89x0_drivers = cs89x0.o
  1917. +#cs89x0_drivers = cs89x0.o
  1918. davicom_drivers = davicom.o
  1919. -depca_drivers = depca.o
  1920. -eepro_drivers = eepro.o
  1921. +#depca_drivers = depca.o
  1922. +#eepro_drivers = eepro.o
  1923. +e1000_drivers = e1000.o
  1924. eepro100_drivers = eepro100.o
  1925. epic100_drivers = epic100.o
  1926. #fa311_drivers = fa311.o
  1927. -i82586_drivers = 3c507.o exos205.o ni5210.o
  1928. -lance_drivers = lance.o ne2100.o ni6510.o
  1929. +forcedeth_drivers = forcedeth.o
  1930. +#i82586_drivers = 3c507.o exos205.o ni5210.o
  1931. +#lance_drivers = lance.o ne2100.o ni6510.o
  1932. natsemi_drivers = natsemi.o
  1933. -ni5010_drivers = ni5010.o
  1934. +#ni5010_drivers = ni5010.o
  1935. +ns83820_drivers = ns83820.o
  1936. ns8390_drivers = 3c503.o ne.o ns8390.o wd.o
  1937. -otulip_drivers = otulip.o
  1938. +#otulip_drivers = otulip.o
  1939. +pcnet32_drivers = pcnet32.o
  1940. +pnic_drivers = pnic.o
  1941. +r8169_drivers = r8169.o
  1942. rtl8139_drivers = rtl8139.o
  1943. sis900_drivers = sis900.o
  1944. -sk_g16_drivers = sk_g16.o
  1945. -smc9000_drivers = smc9000.o
  1946. -tiara_drivers = tiara.o
  1947. -#tlan_drivers = tlan.o
  1948. +#sk_g16_drivers = sk_g16.o
  1949. +sundance_driver = sundance.o
  1950. +#smc9000_drivers = smc9000.o
  1951. +tg3_drivers = tg3.o
  1952. +#tiara_drivers = tiara.o
  1953. +tlan_drivers = tlan.o
  1954. tulip_drivers = tulip.o
  1955. +undi_drivers = undi.o
  1956. via_rhine_drivers = via_rhine.o
  1957. w89c840_drivers = w89c840.o
  1958. +
  1959. # Is it really necessary to specify dependecies explicitly?
  1960. -$(3c509_drivers): 3c509.c 3c509.h
  1961. -$(3c509_drivers): %.o: 3c509.c
  1962. - $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  1963. - $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  1964. +#$(3c509_drivers): 3c509.c 3c509.h
  1965. +#$(3c509_drivers): %.o: 3c509.c
  1966. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  1967. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  1968. $(3c595_drivers): 3c595.c 3c595.h
  1969. $(3c595_drivers): %.o: 3c595.c
  1970. @@ -73,23 +87,28 @@
  1971. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  1972. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  1973. -$(cs89x0_drivers): cs89x0.c cs89x0.h
  1974. -$(cs89x0_drivers): %.o: cs89x0.c
  1975. - $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  1976. - $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  1977. +#$(cs89x0_drivers): cs89x0.c cs89x0.h
  1978. +#$(cs89x0_drivers): %.o: cs89x0.c
  1979. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  1980. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  1981. $(davicom_drivers): davicom.c
  1982. $(davicom_drivers): %.o: davicom.c
  1983. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  1984. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  1985. -$(depca_drivers): depca.c
  1986. -$(depca_drivers): %.o: depca.c
  1987. - $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  1988. - $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  1989. +#$(depca_drivers): depca.c
  1990. +#$(depca_drivers): %.o: depca.c
  1991. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  1992. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  1993. +
  1994. +#$(eepro_drivers): eepro.c
  1995. +#$(eepro_drivers): %.o: eepro.c
  1996. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  1997. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  1998. -$(eepro_drivers): eepro.c
  1999. -$(eepro_drivers): %.o: eepro.c
  2000. +$(e1000_drivers): e1000.c e1000_hw.h
  2001. +$(e1000_drivers): %.o: e1000.c
  2002. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2003. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2004. @@ -103,28 +122,38 @@
  2005. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2006. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2007. +$(forcedeth_drivers): forcedeth.c
  2008. +$(forcedeth_drivers): %.o: forcedeth.c
  2009. + $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2010. + $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2011. +
  2012. #$(fa311_drivers): fa311.c
  2013. #$(fa311_drivers): %.o: fa311.c
  2014. # $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2015. # $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2016. -$(i82586_drivers): i82586.c
  2017. -$(i82586_drivers): %.o: i82586.c
  2018. - $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2019. - $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2020. +#$(i82586_drivers): i82586.c
  2021. +#$(i82586_drivers): %.o: i82586.c
  2022. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2023. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2024. -$(lance_drivers): lance.c
  2025. -$(lance_drivers): %.o: lance.c
  2026. - $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2027. - $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2028. +#$(lance_drivers): lance.c
  2029. +#$(lance_drivers): %.o: lance.c
  2030. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2031. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2032. $(natsemi_drivers): natsemi.c
  2033. $(natsemi_drivers): %.o: natsemi.c
  2034. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2035. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2036. -$(ni5010_drivers): ni5010.c
  2037. -$(ni5010_drivers): %.o: ni5010.c
  2038. +#$(ni5010_drivers): ni5010.c
  2039. +#$(ni5010_drivers): %.o: ni5010.c
  2040. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2041. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2042. +
  2043. +$(ns83820_drivers): ns83820.c
  2044. +$(ns83820_drivers): %.o: ns83820.c
  2045. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2046. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2047. @@ -133,8 +162,18 @@
  2048. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2049. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2050. -$(otulip_drivers): otulip.c otulip.h
  2051. -$(otulip_drivers): %.o: otulip.c
  2052. +#$(otulip_drivers): otulip.c otulip.h
  2053. +#$(otulip_drivers): %.o: otulip.c
  2054. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2055. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2056. +
  2057. +$(pcnet32_drivers): pcnet32.c
  2058. +$(pcnet32_drivers): %.o: pcnet32.c
  2059. + $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2060. + $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2061. +
  2062. +$(pnic_drivers): pnic.c
  2063. +$(pnic_drivers): %.o: pnic.c pnic_api.h
  2064. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2065. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2066. @@ -143,36 +182,56 @@
  2067. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2068. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2069. -$(sis900_drivers): sis900.c
  2070. -$(sis900_drivers): %.o: sis900.c sis900.h
  2071. +$(r8169_drivers): r8169.c
  2072. +$(r8169_drivers): %.o: r8169.c
  2073. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2074. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2075. -$(sk_g16_drivers): sk_g16.c sk_g16.h
  2076. -$(sk_g16_drivers): %.o: sk_g16.c
  2077. +$(sis900_drivers): sis900.c sis900.h
  2078. +$(sis900_drivers): %.o: sis900.c
  2079. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2080. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2081. -$(smc9000_drivers): smc9000.c smc9000.h
  2082. -$(smc9000_drivers): %.o: smc9000.c
  2083. +#$(sk_g16_drivers): sk_g16.c sk_g16.h
  2084. +#$(sk_g16_drivers): %.o: sk_g16.c
  2085. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2086. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2087. +
  2088. +#$(smc9000_drivers): smc9000.c smc9000.h
  2089. +#$(smc9000_drivers): %.o: smc9000.c
  2090. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2091. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2092. +
  2093. +$(sundance_drivers): sundance.c
  2094. +$(sundance_drivers): %.o: sundance.c
  2095. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2096. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2097. -$(tiara_drivers): tiara.c
  2098. -$(tiara_drivers): %.o: tiara.c
  2099. +$(tg3_drivers): tg3.c tg3.h
  2100. +$(tg3_drivers): %.o: tg3.c
  2101. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2102. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2103. -#$(tlan_drivers): tlan.c
  2104. -#$(tlan_drivers): %.o: tlan.c
  2105. +#$(tiara_drivers): tiara.c
  2106. +#$(tiara_drivers): %.o: tiara.c
  2107. # $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2108. # $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2109. +$(tlan_drivers): tlan.c tlan.h
  2110. +$(tlan_drivers): %.o: tlan.c
  2111. + $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2112. + $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2113. +
  2114. $(tulip_drivers): tulip.c
  2115. $(tulip_drivers): %.o: tulip.c
  2116. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2117. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2118. +$(undi_drivers): undi.c undi.h
  2119. +$(undi_drivers): %.o: undi.c
  2120. + $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2121. + $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2122. +
  2123. $(via_rhine_drivers): via-rhine.c
  2124. $(via_rhine_drivers): %.o: via-rhine.c
  2125. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2126. @@ -184,36 +243,45 @@
  2127. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  2128. # Per-object flags.
  2129. -3c509_o_CFLAGS = -DINCLUDE_3C509=1
  2130. -3c529_o_CFLAGS = -DINCLUDE_3C529=1
  2131. +#3c509_o_CFLAGS = -DINCLUDE_3C509=1
  2132. +#3c529_o_CFLAGS = -DINCLUDE_3C529=1
  2133. 3c595_o_CFLAGS = -DINCLUDE_3C595=1
  2134. 3c90x_o_CFLAGS = -DINCLUDE_3C90X=1
  2135. -cs89x0_o_CFLAGS = -DINCLUDE_CS89X0=1
  2136. +#cs89x0_o_CFLAGS = -DINCLUDE_CS89X0=1
  2137. davicom_o_CFLAGS = -DINCLUDE_DAVICOM=1
  2138. -depca_o_CFLAGS = -DINCLUDE_DEPCA=1
  2139. -eepro_o_CFLAGS = -DINCLUDE_EEPRO=1
  2140. +#depca_o_CFLAGS = -DINCLUDE_DEPCA=1
  2141. +#eepro_o_CFLAGS = -DINCLUDE_EEPRO=1
  2142. +e1000_o_CFLAGS = -DINCLUDE_E1000=1
  2143. eepro100_o_CFLAGS = -DINCLUDE_EEPRO100=1
  2144. epic100_o_CFLAGS = -DINCLUDE_EPIC100=1
  2145. #fa311_o_CFLAGS = -DINCLUDE_FA311=1
  2146. -3c507_o_CFLAGS = -DINCLUDE_3C507=1
  2147. -exos205_o_CFLAGS = -DINCLUDE_EXOS205=1
  2148. -ni5210_o_CFLAGS = -DINCLUDE_NI5210=1
  2149. -lance_o_CFLAGS = -DINCLUDE_LANCE=1
  2150. -ne2100_o_CFLAGS = -DINCLUDE_NE2100=1
  2151. -ni6510_o_CFLAGS = -DINCLUDE_NI6510=1
  2152. +forcedeth_o_CFLAGS = -DINCLUDE_FORCEDETH=1
  2153. +#3c507_o_CFLAGS = -DINCLUDE_3C507=1
  2154. +#exos205_o_CFLAGS = -DINCLUDE_EXOS205=1
  2155. +#ni5210_o_CFLAGS = -DINCLUDE_NI5210=1
  2156. +#lance_o_CFLAGS = -DINCLUDE_LANCE=1
  2157. +#ne2100_o_CFLAGS = -DINCLUDE_NE2100=1
  2158. +#ni6510_o_CFLAGS = -DINCLUDE_NI6510=1
  2159. natsemi_o_CFLAGS = -DINCLUDE_NATSEMI=1
  2160. -ni5010_o_CFLAGS = -DINCLUDE_NI5010=1
  2161. -3c503_o_CFLAGS = -DINCLUDE_3C503=1
  2162. -ne_o_CFLAGS = -DINCLUDE_NE=1
  2163. +#ni5010_o_CFLAGS = -DINCLUDE_NI5010=1
  2164. +#3c503_o_CFLAGS = -DINCLUDE_3C503=1
  2165. +#ne_o_CFLAGS = -DINCLUDE_NE=1
  2166. +ns83820_o_CFLAGS = -DINCLUDE_NS83820=1
  2167. ns8390_o_CFLAGS = -DINCLUDE_NS8390=1
  2168. -wd_o_CFLAGS = -DINCLUDE_WD=1
  2169. -otulip_o_CFLAGS = -DINCLUDE_OTULIP=1
  2170. +#wd_o_CFLAGS = -DINCLUDE_WD=1
  2171. +#otulip_o_CFLAGS = -DINCLUDE_OTULIP=1
  2172. +pcnet32_o_CFLAGS = -DINCLUDE_PCNET32=1
  2173. +pnic_o_CFLAGS = -DINCLUDE_PNIC=1
  2174. +r8169_o_CFLAGS = -DINCLUDE_R8169=1
  2175. rtl8139_o_CFLAGS = -DINCLUDE_RTL8139=1
  2176. sis900_o_CFLAGS = -DINCLUDE_SIS900=1
  2177. -sk_g16_o_CFLAGS = -DINCLUDE_SK_G16=1
  2178. -smc9000_o_CFLAGS = -DINCLUDE_SMC9000=1
  2179. -tiara_o_CFLAGS = -DINCLUDE_TIARA=1
  2180. -#tlan_o_CFLAGS = -DINCLUDE_TLAN=1
  2181. +#sk_g16_o_CFLAGS = -DINCLUDE_SK_G16=1
  2182. +#smc9000_o_CFLAGS = -DINCLUDE_SMC9000=1
  2183. +sundance_o_CFLAGS = -DINCLUDE_SUNDANCE=1
  2184. +#tiara_o_CFLAGS = -DINCLUDE_TIARA=1
  2185. +tg3_o_CFLAGS = -DINCLUDE_TG3=1
  2186. +tlan_o_CFLAGS = -DINCLUDE_TLAN=1
  2187. tulip_o_CFLAGS = -DINCLUDE_TULIP=1
  2188. +undi_o_CFLAGS = -DINCLUDE_UNDI=1
  2189. via_rhine_o_CFLAGS = -DINCLUDE_VIA_RHINE=1
  2190. w89c840_o_CFLAGS = -DINCLUDE_W89C840=1
  2191. diff -Naur grub-0.97.orig/netboot/Makefile.in grub-0.97/netboot/Makefile.in
  2192. --- grub-0.97.orig/netboot/Makefile.in 2005-05-08 02:42:35.000000000 +0000
  2193. +++ grub-0.97/netboot/Makefile.in 2005-09-01 00:14:15.000000000 +0000
  2194. @@ -48,18 +47,51 @@
  2195. mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
  2196. CONFIG_HEADER = $(top_builddir)/config.h
  2197. CONFIG_CLEAN_FILES =
  2198. -LIBRARIES = $(noinst_LIBRARIES)
  2199. AR = ar
  2200. ARFLAGS = cru
  2201. +LIBRARIES = $(noinst_LIBRARIES)
  2202. libdrivers_a_AR = $(AR) $(ARFLAGS)
  2203. am_libdrivers_a_OBJECTS = libdrivers_a-config.$(OBJEXT) \
  2204. - libdrivers_a-fsys_tftp.$(OBJEXT) libdrivers_a-main.$(OBJEXT) \
  2205. - libdrivers_a-misc.$(OBJEXT) libdrivers_a-pci.$(OBJEXT) \
  2206. - libdrivers_a-timer.$(OBJEXT)
  2207. + libdrivers_a-fsys_tftp.$(OBJEXT) \
  2208. + libdrivers_a-i386_timer.$(OBJEXT) libdrivers_a-misc.$(OBJEXT) \
  2209. + libdrivers_a-nic.$(OBJEXT) libdrivers_a-pci.$(OBJEXT) \
  2210. + libdrivers_a-pci_io.$(OBJEXT) libdrivers_a-timer.$(OBJEXT) \
  2211. + libdrivers_a-pic8259.$(OBJEXT) libdrivers_a-basemem.$(OBJEXT)
  2212. libdrivers_a_OBJECTS = $(am_libdrivers_a_OBJECTS)
  2213. DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
  2214. depcomp = $(SHELL) $(top_srcdir)/depcomp
  2215. am__depfiles_maybe = depfiles
  2216. +@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/libdrivers_a-3c595.Po \
  2217. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-3c90x.Po \
  2218. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-basemem.Po \
  2219. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-config.Po \
  2220. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-davicom.Po \
  2221. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-e1000.Po \
  2222. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-eepro100.Po \
  2223. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-epic100.Po \
  2224. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-forcedeth.Po \
  2225. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-fsys_tftp.Po \
  2226. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-i386_timer.Po \
  2227. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-misc.Po \
  2228. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-natsemi.Po \
  2229. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-nic.Po \
  2230. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-ns83820.Po \
  2231. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-ns8390.Po \
  2232. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-pci.Po \
  2233. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-pci_io.Po \
  2234. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-pcnet32.Po \
  2235. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-pic8259.Po \
  2236. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-pnic.Po \
  2237. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-pnic_api.Po \
  2238. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-r8169.Po \
  2239. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-rtl8139.Po \
  2240. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-sis900.Po \
  2241. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-tg3.Po \
  2242. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-timer.Po \
  2243. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-tlan.Po \
  2244. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-tulip.Po \
  2245. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-via-rhine.Po \
  2246. +@AMDEP_TRUE@ ./$(DEPDIR)/libdrivers_a-w89c840.Po
  2247. COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
  2248. $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
  2249. CCLD = $(CC)
  2250. @@ -148,8 +180,6 @@
  2251. am__include = @am__include@
  2252. am__leading_dot = @am__leading_dot@
  2253. am__quote = @am__quote@
  2254. -am__tar = @am__tar@
  2255. -am__untar = @am__untar@
  2256. bindir = @bindir@
  2257. build = @build@
  2258. build_alias = @build_alias@
  2259. @@ -186,16 +216,19 @@
  2260. # Don't build the netboot support by default.
  2261. @NETBOOT_SUPPORT_TRUE@LIBDRIVERS = libdrivers.a
  2262. noinst_LIBRARIES = $(LIBDRIVERS)
  2263. -libdrivers_a_SOURCES = cards.h config.c etherboot.h \
  2264. - fsys_tftp.c linux-asm-io.h linux-asm-string.h \
  2265. - main.c misc.c nic.h osdep.h pci.c pci.h timer.c timer.h
  2266. -
  2267. -EXTRA_libdrivers_a_SOURCES = 3c509.c 3c509.h 3c595.c 3c595.h 3c90x.c \
  2268. - cs89x0.c cs89x0.h davicom.c depca.c eepro.c eepro100.c \
  2269. - epic100.c epic100.h fa311.c i82586.c lance.c natsemi.c \
  2270. - ni5010.c ns8390.c ns8390.h otulip.c otulip.h rtl8139.c \
  2271. - sis900.c sis900.h sk_g16.c sk_g16.h smc9000.c smc9000.h \
  2272. - tiara.c tlan.c tulip.c via-rhine.c w89c840.c
  2273. +libdrivers_a_SOURCES = big_bswap.h bootp.h byteswap.h config.c cpu.h \
  2274. + dev.h elf.h endian.h etherboot.h fsys_tftp.c grub.h \
  2275. + i386_byteswap.h i386_elf.h i386_endian.h i386_timer.c \
  2276. + if_arp.h if_ether.h igmp.h in.h io.h ip.h isa.h latch.h \
  2277. + little_bswap.h misc.c nic.c nic.h osdep.h pci.c pci.h \
  2278. + pci_ids.h pci_io.c stdint.h tftp.h timer.c timer.h \
  2279. + types.h udp.h mii.h pic8259.c pic8259.h pxe.h basemem.c segoff.h
  2280. +
  2281. +EXTRA_libdrivers_a_SOURCES = 3c595.c 3c595.h 3c90x.c davicom.c \
  2282. + e1000.c e1000_hw.h eepro100.c epic100.c epic100.h natsemi.c \
  2283. + ns8390.c ns8390.h pcnet32.c rtl8139.c sis900.c sis900.h \
  2284. + tg3.c tg3.h tlan.c tlan.h tulip.c via-rhine.c \
  2285. + w89c840.c r8169.c forcedeth.c ns83820.c pnic.c pnic_api.c
  2286. libdrivers_a_CFLAGS = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  2287. -DFSYS_TFTP=1 $(NET_CFLAGS) $(NET_EXTRAFLAGS)
  2288. @@ -203,69 +236,83 @@
  2289. # Filled by configure.
  2290. libdrivers_a_LIBADD = @NETBOOT_DRIVERS@
  2291. libdrivers_a_DEPENDENCIES = $(libdrivers_a_LIBADD)
  2292. -EXTRA_DIST = README.netboot 3c90x.txt cs89x0.txt sis900.txt tulip.txt
  2293. +EXTRA_DIST = README.netboot
  2294. # These below are several special rules for the device drivers.
  2295. # We cannot use a simple rule for them...
  2296. # What objects are derived from a driver?
  2297. -3c509_drivers = 3c509.o 3c529.o
  2298. +#3c509_drivers = 3c509.o 3c529.o
  2299. 3c595_drivers = 3c595.o
  2300. 3c90x_drivers = 3c90x.o
  2301. -cs89x0_drivers = cs89x0.o
  2302. +#cs89x0_drivers = cs89x0.o
  2303. davicom_drivers = davicom.o
  2304. -depca_drivers = depca.o
  2305. -eepro_drivers = eepro.o
  2306. +#depca_drivers = depca.o
  2307. +#eepro_drivers = eepro.o
  2308. +e1000_drivers = e1000.o
  2309. eepro100_drivers = eepro100.o
  2310. epic100_drivers = epic100.o
  2311. #fa311_drivers = fa311.o
  2312. -i82586_drivers = 3c507.o exos205.o ni5210.o
  2313. -lance_drivers = lance.o ne2100.o ni6510.o
  2314. +forcedeth_drivers = forcedeth.o
  2315. +#i82586_drivers = 3c507.o exos205.o ni5210.o
  2316. +#lance_drivers = lance.o ne2100.o ni6510.o
  2317. natsemi_drivers = natsemi.o
  2318. -ni5010_drivers = ni5010.o
  2319. +#ni5010_drivers = ni5010.o
  2320. +ns83820_drivers = ns83820.o
  2321. ns8390_drivers = 3c503.o ne.o ns8390.o wd.o
  2322. -otulip_drivers = otulip.o
  2323. +#otulip_drivers = otulip.o
  2324. +pcnet32_drivers = pcnet32.o
  2325. +pnic_drivers = pnic.o
  2326. +r8169_drivers = r8169.o
  2327. rtl8139_drivers = rtl8139.o
  2328. sis900_drivers = sis900.o
  2329. -sk_g16_drivers = sk_g16.o
  2330. -smc9000_drivers = smc9000.o
  2331. -tiara_drivers = tiara.o
  2332. -#tlan_drivers = tlan.o
  2333. +#sk_g16_drivers = sk_g16.o
  2334. +#smc9000_drivers = smc9000.o
  2335. +tg3_drivers = tg3.o
  2336. +#tiara_drivers = tiara.o
  2337. +tlan_drivers = tlan.o
  2338. tulip_drivers = tulip.o
  2339. via_rhine_drivers = via_rhine.o
  2340. w89c840_drivers = w89c840.o
  2341. # Per-object flags.
  2342. -3c509_o_CFLAGS = -DINCLUDE_3C509=1
  2343. -3c529_o_CFLAGS = -DINCLUDE_3C529=1
  2344. +#3c509_o_CFLAGS = -DINCLUDE_3C509=1
  2345. +#3c529_o_CFLAGS = -DINCLUDE_3C529=1
  2346. 3c595_o_CFLAGS = -DINCLUDE_3C595=1
  2347. 3c90x_o_CFLAGS = -DINCLUDE_3C90X=1
  2348. -cs89x0_o_CFLAGS = -DINCLUDE_CS89X0=1
  2349. +#cs89x0_o_CFLAGS = -DINCLUDE_CS89X0=1
  2350. davicom_o_CFLAGS = -DINCLUDE_DAVICOM=1
  2351. -depca_o_CFLAGS = -DINCLUDE_DEPCA=1
  2352. -eepro_o_CFLAGS = -DINCLUDE_EEPRO=1
  2353. +#depca_o_CFLAGS = -DINCLUDE_DEPCA=1
  2354. +#eepro_o_CFLAGS = -DINCLUDE_EEPRO=1
  2355. +e1000_o_CFLAGS = -DINCLUDE_E1000=1
  2356. eepro100_o_CFLAGS = -DINCLUDE_EEPRO100=1
  2357. epic100_o_CFLAGS = -DINCLUDE_EPIC100=1
  2358. #fa311_o_CFLAGS = -DINCLUDE_FA311=1
  2359. -3c507_o_CFLAGS = -DINCLUDE_3C507=1
  2360. -exos205_o_CFLAGS = -DINCLUDE_EXOS205=1
  2361. -ni5210_o_CFLAGS = -DINCLUDE_NI5210=1
  2362. -lance_o_CFLAGS = -DINCLUDE_LANCE=1
  2363. -ne2100_o_CFLAGS = -DINCLUDE_NE2100=1
  2364. -ni6510_o_CFLAGS = -DINCLUDE_NI6510=1
  2365. +forcedeth_o_CFLAGS = -DINCLUDE_FORCEDETH=1
  2366. +#3c507_o_CFLAGS = -DINCLUDE_3C507=1
  2367. +#exos205_o_CFLAGS = -DINCLUDE_EXOS205=1
  2368. +#ni5210_o_CFLAGS = -DINCLUDE_NI5210=1
  2369. +#lance_o_CFLAGS = -DINCLUDE_LANCE=1
  2370. +#ne2100_o_CFLAGS = -DINCLUDE_NE2100=1
  2371. +#ni6510_o_CFLAGS = -DINCLUDE_NI6510=1
  2372. natsemi_o_CFLAGS = -DINCLUDE_NATSEMI=1
  2373. -ni5010_o_CFLAGS = -DINCLUDE_NI5010=1
  2374. -3c503_o_CFLAGS = -DINCLUDE_3C503=1
  2375. -ne_o_CFLAGS = -DINCLUDE_NE=1
  2376. +#ni5010_o_CFLAGS = -DINCLUDE_NI5010=1
  2377. +#3c503_o_CFLAGS = -DINCLUDE_3C503=1
  2378. +#ne_o_CFLAGS = -DINCLUDE_NE=1
  2379. +ns83820_o_CFLAGS = -DINCLUDE_NS83820=1
  2380. ns8390_o_CFLAGS = -DINCLUDE_NS8390=1
  2381. -wd_o_CFLAGS = -DINCLUDE_WD=1
  2382. -otulip_o_CFLAGS = -DINCLUDE_OTULIP=1
  2383. +#wd_o_CFLAGS = -DINCLUDE_WD=1
  2384. +#otulip_o_CFLAGS = -DINCLUDE_OTULIP=1
  2385. +pcnet32_o_CFLAGS = -DINCLUDE_PCNET32=1
  2386. +pnic_o_CFLAGS = -DINCLUDE_PNIC=1
  2387. +r8169_o_CFLAGS = -DINCLUDE_R8169=1
  2388. rtl8139_o_CFLAGS = -DINCLUDE_RTL8139=1
  2389. sis900_o_CFLAGS = -DINCLUDE_SIS900=1
  2390. -sk_g16_o_CFLAGS = -DINCLUDE_SK_G16=1
  2391. -smc9000_o_CFLAGS = -DINCLUDE_SMC9000=1
  2392. -tiara_o_CFLAGS = -DINCLUDE_TIARA=1
  2393. -#tlan_o_CFLAGS = -DINCLUDE_TLAN=1
  2394. +#sk_g16_o_CFLAGS = -DINCLUDE_SK_G16=1
  2395. +#smc9000_o_CFLAGS = -DINCLUDE_SMC9000=1
  2396. +#tiara_o_CFLAGS = -DINCLUDE_TIARA=1
  2397. +tg3_o_CFLAGS = -DINCLUDE_TG3=1
  2398. +tlan_o_CFLAGS = -DINCLUDE_TLAN=1
  2399. tulip_o_CFLAGS = -DINCLUDE_TULIP=1
  2400. via_rhine_o_CFLAGS = -DINCLUDE_VIA_RHINE=1
  2401. w89c840_o_CFLAGS = -DINCLUDE_W89C840=1
  2402. @@ -316,32 +363,32 @@
  2403. distclean-compile:
  2404. -rm -f *.tab.c
  2405. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-3c509.Po@am__quote@
  2406. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-3c595.Po@am__quote@
  2407. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-3c90x.Po@am__quote@
  2408. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-basemem.Po@am__quote@
  2409. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-config.Po@am__quote@
  2410. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-cs89x0.Po@am__quote@
  2411. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-davicom.Po@am__quote@
  2412. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-depca.Po@am__quote@
  2413. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-eepro.Po@am__quote@
  2414. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-e1000.Po@am__quote@
  2415. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-eepro100.Po@am__quote@
  2416. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-epic100.Po@am__quote@
  2417. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-fa311.Po@am__quote@
  2418. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-forcedeth.Po@am__quote@
  2419. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-fsys_tftp.Po@am__quote@
  2420. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-i82586.Po@am__quote@
  2421. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-lance.Po@am__quote@
  2422. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-main.Po@am__quote@
  2423. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-i386_timer.Po@am__quote@
  2424. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-misc.Po@am__quote@
  2425. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-natsemi.Po@am__quote@
  2426. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-ni5010.Po@am__quote@
  2427. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-nic.Po@am__quote@
  2428. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-ns83820.Po@am__quote@
  2429. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-ns8390.Po@am__quote@
  2430. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-otulip.Po@am__quote@
  2431. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-pci.Po@am__quote@
  2432. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-pci_io.Po@am__quote@
  2433. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-pcnet32.Po@am__quote@
  2434. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-pic8259.Po@am__quote@
  2435. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-pnic.Po@am__quote@
  2436. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-pnic_api.Po@am__quote@
  2437. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-r8169.Po@am__quote@
  2438. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-rtl8139.Po@am__quote@
  2439. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-sis900.Po@am__quote@
  2440. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-sk_g16.Po@am__quote@
  2441. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-smc9000.Po@am__quote@
  2442. -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-tiara.Po@am__quote@
  2443. +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-tg3.Po@am__quote@
  2444. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-timer.Po@am__quote@
  2445. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-tlan.Po@am__quote@
  2446. @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdrivers_a-tulip.Po@am__quote@
  2447. @@ -352,450 +399,513 @@
  2448. @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
  2449. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
  2450. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
  2451. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2452. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
  2453. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2454. @am__fastdepCC_FALSE@ $(COMPILE) -c $<
  2455. .c.obj:
  2456. @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
  2457. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
  2458. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
  2459. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2460. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
  2461. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2462. @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
  2463. libdrivers_a-config.o: config.c
  2464. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-config.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-config.Tpo" -c -o libdrivers_a-config.o `test -f 'config.c' || echo '$(srcdir)/'`config.c; \
  2465. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-config.Tpo" "$(DEPDIR)/libdrivers_a-config.Po"; else rm -f "$(DEPDIR)/libdrivers_a-config.Tpo"; exit 1; fi
  2466. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='config.c' object='libdrivers_a-config.o' libtool=no @AMDEPBACKSLASH@
  2467. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2468. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-config.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-config.TPo' @AMDEPBACKSLASH@
  2469. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2470. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-config.o `test -f 'config.c' || echo '$(srcdir)/'`config.c
  2471. libdrivers_a-config.obj: config.c
  2472. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-config.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-config.Tpo" -c -o libdrivers_a-config.obj `if test -f 'config.c'; then $(CYGPATH_W) 'config.c'; else $(CYGPATH_W) '$(srcdir)/config.c'; fi`; \
  2473. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-config.Tpo" "$(DEPDIR)/libdrivers_a-config.Po"; else rm -f "$(DEPDIR)/libdrivers_a-config.Tpo"; exit 1; fi
  2474. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='config.c' object='libdrivers_a-config.obj' libtool=no @AMDEPBACKSLASH@
  2475. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2476. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-config.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-config.TPo' @AMDEPBACKSLASH@
  2477. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2478. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-config.obj `if test -f 'config.c'; then $(CYGPATH_W) 'config.c'; else $(CYGPATH_W) '$(srcdir)/config.c'; fi`
  2479. libdrivers_a-fsys_tftp.o: fsys_tftp.c
  2480. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-fsys_tftp.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-fsys_tftp.Tpo" -c -o libdrivers_a-fsys_tftp.o `test -f 'fsys_tftp.c' || echo '$(srcdir)/'`fsys_tftp.c; \
  2481. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-fsys_tftp.Tpo" "$(DEPDIR)/libdrivers_a-fsys_tftp.Po"; else rm -f "$(DEPDIR)/libdrivers_a-fsys_tftp.Tpo"; exit 1; fi
  2482. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='fsys_tftp.c' object='libdrivers_a-fsys_tftp.o' libtool=no @AMDEPBACKSLASH@
  2483. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2484. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-fsys_tftp.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-fsys_tftp.TPo' @AMDEPBACKSLASH@
  2485. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2486. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-fsys_tftp.o `test -f 'fsys_tftp.c' || echo '$(srcdir)/'`fsys_tftp.c
  2487. libdrivers_a-fsys_tftp.obj: fsys_tftp.c
  2488. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-fsys_tftp.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-fsys_tftp.Tpo" -c -o libdrivers_a-fsys_tftp.obj `if test -f 'fsys_tftp.c'; then $(CYGPATH_W) 'fsys_tftp.c'; else $(CYGPATH_W) '$(srcdir)/fsys_tftp.c'; fi`; \
  2489. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-fsys_tftp.Tpo" "$(DEPDIR)/libdrivers_a-fsys_tftp.Po"; else rm -f "$(DEPDIR)/libdrivers_a-fsys_tftp.Tpo"; exit 1; fi
  2490. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='fsys_tftp.c' object='libdrivers_a-fsys_tftp.obj' libtool=no @AMDEPBACKSLASH@
  2491. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2492. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-fsys_tftp.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-fsys_tftp.TPo' @AMDEPBACKSLASH@
  2493. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2494. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-fsys_tftp.obj `if test -f 'fsys_tftp.c'; then $(CYGPATH_W) 'fsys_tftp.c'; else $(CYGPATH_W) '$(srcdir)/fsys_tftp.c'; fi`
  2495. -libdrivers_a-main.o: main.c
  2496. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-main.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-main.Tpo" -c -o libdrivers_a-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c; \
  2497. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-main.Tpo" "$(DEPDIR)/libdrivers_a-main.Po"; else rm -f "$(DEPDIR)/libdrivers_a-main.Tpo"; exit 1; fi
  2498. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='main.c' object='libdrivers_a-main.o' libtool=no @AMDEPBACKSLASH@
  2499. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2500. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c
  2501. -
  2502. -libdrivers_a-main.obj: main.c
  2503. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-main.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-main.Tpo" -c -o libdrivers_a-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi`; \
  2504. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-main.Tpo" "$(DEPDIR)/libdrivers_a-main.Po"; else rm -f "$(DEPDIR)/libdrivers_a-main.Tpo"; exit 1; fi
  2505. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='main.c' object='libdrivers_a-main.obj' libtool=no @AMDEPBACKSLASH@
  2506. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2507. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi`
  2508. +libdrivers_a-i386_timer.o: i386_timer.c
  2509. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-i386_timer.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-i386_timer.Tpo" -c -o libdrivers_a-i386_timer.o `test -f 'i386_timer.c' || echo '$(srcdir)/'`i386_timer.c; \
  2510. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-i386_timer.Tpo" "$(DEPDIR)/libdrivers_a-i386_timer.Po"; else rm -f "$(DEPDIR)/libdrivers_a-i386_timer.Tpo"; exit 1; fi
  2511. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='i386_timer.c' object='libdrivers_a-i386_timer.o' libtool=no @AMDEPBACKSLASH@
  2512. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-i386_timer.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-i386_timer.TPo' @AMDEPBACKSLASH@
  2513. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2514. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-i386_timer.o `test -f 'i386_timer.c' || echo '$(srcdir)/'`i386_timer.c
  2515. +
  2516. +libdrivers_a-i386_timer.obj: i386_timer.c
  2517. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-i386_timer.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-i386_timer.Tpo" -c -o libdrivers_a-i386_timer.obj `if test -f 'i386_timer.c'; then $(CYGPATH_W) 'i386_timer.c'; else $(CYGPATH_W) '$(srcdir)/i386_timer.c'; fi`; \
  2518. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-i386_timer.Tpo" "$(DEPDIR)/libdrivers_a-i386_timer.Po"; else rm -f "$(DEPDIR)/libdrivers_a-i386_timer.Tpo"; exit 1; fi
  2519. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='i386_timer.c' object='libdrivers_a-i386_timer.obj' libtool=no @AMDEPBACKSLASH@
  2520. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-i386_timer.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-i386_timer.TPo' @AMDEPBACKSLASH@
  2521. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2522. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-i386_timer.obj `if test -f 'i386_timer.c'; then $(CYGPATH_W) 'i386_timer.c'; else $(CYGPATH_W) '$(srcdir)/i386_timer.c'; fi`
  2523. libdrivers_a-misc.o: misc.c
  2524. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-misc.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-misc.Tpo" -c -o libdrivers_a-misc.o `test -f 'misc.c' || echo '$(srcdir)/'`misc.c; \
  2525. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-misc.Tpo" "$(DEPDIR)/libdrivers_a-misc.Po"; else rm -f "$(DEPDIR)/libdrivers_a-misc.Tpo"; exit 1; fi
  2526. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='misc.c' object='libdrivers_a-misc.o' libtool=no @AMDEPBACKSLASH@
  2527. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2528. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-misc.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-misc.TPo' @AMDEPBACKSLASH@
  2529. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2530. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-misc.o `test -f 'misc.c' || echo '$(srcdir)/'`misc.c
  2531. libdrivers_a-misc.obj: misc.c
  2532. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-misc.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-misc.Tpo" -c -o libdrivers_a-misc.obj `if test -f 'misc.c'; then $(CYGPATH_W) 'misc.c'; else $(CYGPATH_W) '$(srcdir)/misc.c'; fi`; \
  2533. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-misc.Tpo" "$(DEPDIR)/libdrivers_a-misc.Po"; else rm -f "$(DEPDIR)/libdrivers_a-misc.Tpo"; exit 1; fi
  2534. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='misc.c' object='libdrivers_a-misc.obj' libtool=no @AMDEPBACKSLASH@
  2535. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2536. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-misc.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-misc.TPo' @AMDEPBACKSLASH@
  2537. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2538. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-misc.obj `if test -f 'misc.c'; then $(CYGPATH_W) 'misc.c'; else $(CYGPATH_W) '$(srcdir)/misc.c'; fi`
  2539. +libdrivers_a-nic.o: nic.c
  2540. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-nic.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-nic.Tpo" -c -o libdrivers_a-nic.o `test -f 'nic.c' || echo '$(srcdir)/'`nic.c; \
  2541. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-nic.Tpo" "$(DEPDIR)/libdrivers_a-nic.Po"; else rm -f "$(DEPDIR)/libdrivers_a-nic.Tpo"; exit 1; fi
  2542. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nic.c' object='libdrivers_a-nic.o' libtool=no @AMDEPBACKSLASH@
  2543. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-nic.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-nic.TPo' @AMDEPBACKSLASH@
  2544. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2545. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-nic.o `test -f 'nic.c' || echo '$(srcdir)/'`nic.c
  2546. +
  2547. +libdrivers_a-nic.obj: nic.c
  2548. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-nic.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-nic.Tpo" -c -o libdrivers_a-nic.obj `if test -f 'nic.c'; then $(CYGPATH_W) 'nic.c'; else $(CYGPATH_W) '$(srcdir)/nic.c'; fi`; \
  2549. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-nic.Tpo" "$(DEPDIR)/libdrivers_a-nic.Po"; else rm -f "$(DEPDIR)/libdrivers_a-nic.Tpo"; exit 1; fi
  2550. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='nic.c' object='libdrivers_a-nic.obj' libtool=no @AMDEPBACKSLASH@
  2551. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-nic.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-nic.TPo' @AMDEPBACKSLASH@
  2552. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2553. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-nic.obj `if test -f 'nic.c'; then $(CYGPATH_W) 'nic.c'; else $(CYGPATH_W) '$(srcdir)/nic.c'; fi`
  2554. +
  2555. libdrivers_a-pci.o: pci.c
  2556. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-pci.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-pci.Tpo" -c -o libdrivers_a-pci.o `test -f 'pci.c' || echo '$(srcdir)/'`pci.c; \
  2557. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-pci.Tpo" "$(DEPDIR)/libdrivers_a-pci.Po"; else rm -f "$(DEPDIR)/libdrivers_a-pci.Tpo"; exit 1; fi
  2558. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pci.c' object='libdrivers_a-pci.o' libtool=no @AMDEPBACKSLASH@
  2559. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2560. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-pci.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-pci.TPo' @AMDEPBACKSLASH@
  2561. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2562. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-pci.o `test -f 'pci.c' || echo '$(srcdir)/'`pci.c
  2563. libdrivers_a-pci.obj: pci.c
  2564. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-pci.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-pci.Tpo" -c -o libdrivers_a-pci.obj `if test -f 'pci.c'; then $(CYGPATH_W) 'pci.c'; else $(CYGPATH_W) '$(srcdir)/pci.c'; fi`; \
  2565. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-pci.Tpo" "$(DEPDIR)/libdrivers_a-pci.Po"; else rm -f "$(DEPDIR)/libdrivers_a-pci.Tpo"; exit 1; fi
  2566. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pci.c' object='libdrivers_a-pci.obj' libtool=no @AMDEPBACKSLASH@
  2567. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2568. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-pci.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-pci.TPo' @AMDEPBACKSLASH@
  2569. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2570. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-pci.obj `if test -f 'pci.c'; then $(CYGPATH_W) 'pci.c'; else $(CYGPATH_W) '$(srcdir)/pci.c'; fi`
  2571. +libdrivers_a-pci_io.o: pci_io.c
  2572. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-pci_io.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-pci_io.Tpo" -c -o libdrivers_a-pci_io.o `test -f 'pci_io.c' || echo '$(srcdir)/'`pci_io.c; \
  2573. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-pci_io.Tpo" "$(DEPDIR)/libdrivers_a-pci_io.Po"; else rm -f "$(DEPDIR)/libdrivers_a-pci_io.Tpo"; exit 1; fi
  2574. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pci_io.c' object='libdrivers_a-pci_io.o' libtool=no @AMDEPBACKSLASH@
  2575. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-pci_io.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-pci_io.TPo' @AMDEPBACKSLASH@
  2576. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2577. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-pci_io.o `test -f 'pci_io.c' || echo '$(srcdir)/'`pci_io.c
  2578. +
  2579. +libdrivers_a-pci_io.obj: pci_io.c
  2580. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-pci_io.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-pci_io.Tpo" -c -o libdrivers_a-pci_io.obj `if test -f 'pci_io.c'; then $(CYGPATH_W) 'pci_io.c'; else $(CYGPATH_W) '$(srcdir)/pci_io.c'; fi`; \
  2581. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-pci_io.Tpo" "$(DEPDIR)/libdrivers_a-pci_io.Po"; else rm -f "$(DEPDIR)/libdrivers_a-pci_io.Tpo"; exit 1; fi
  2582. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pci_io.c' object='libdrivers_a-pci_io.obj' libtool=no @AMDEPBACKSLASH@
  2583. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-pci_io.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-pci_io.TPo' @AMDEPBACKSLASH@
  2584. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2585. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-pci_io.obj `if test -f 'pci_io.c'; then $(CYGPATH_W) 'pci_io.c'; else $(CYGPATH_W) '$(srcdir)/pci_io.c'; fi`
  2586. +
  2587. libdrivers_a-timer.o: timer.c
  2588. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-timer.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-timer.Tpo" -c -o libdrivers_a-timer.o `test -f 'timer.c' || echo '$(srcdir)/'`timer.c; \
  2589. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-timer.Tpo" "$(DEPDIR)/libdrivers_a-timer.Po"; else rm -f "$(DEPDIR)/libdrivers_a-timer.Tpo"; exit 1; fi
  2590. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='timer.c' object='libdrivers_a-timer.o' libtool=no @AMDEPBACKSLASH@
  2591. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2592. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-timer.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-timer.TPo' @AMDEPBACKSLASH@
  2593. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2594. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-timer.o `test -f 'timer.c' || echo '$(srcdir)/'`timer.c
  2595. libdrivers_a-timer.obj: timer.c
  2596. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-timer.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-timer.Tpo" -c -o libdrivers_a-timer.obj `if test -f 'timer.c'; then $(CYGPATH_W) 'timer.c'; else $(CYGPATH_W) '$(srcdir)/timer.c'; fi`; \
  2597. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-timer.Tpo" "$(DEPDIR)/libdrivers_a-timer.Po"; else rm -f "$(DEPDIR)/libdrivers_a-timer.Tpo"; exit 1; fi
  2598. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='timer.c' object='libdrivers_a-timer.obj' libtool=no @AMDEPBACKSLASH@
  2599. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2600. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-timer.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-timer.TPo' @AMDEPBACKSLASH@
  2601. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2602. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-timer.obj `if test -f 'timer.c'; then $(CYGPATH_W) 'timer.c'; else $(CYGPATH_W) '$(srcdir)/timer.c'; fi`
  2603. -libdrivers_a-3c509.o: 3c509.c
  2604. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-3c509.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-3c509.Tpo" -c -o libdrivers_a-3c509.o `test -f '3c509.c' || echo '$(srcdir)/'`3c509.c; \
  2605. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-3c509.Tpo" "$(DEPDIR)/libdrivers_a-3c509.Po"; else rm -f "$(DEPDIR)/libdrivers_a-3c509.Tpo"; exit 1; fi
  2606. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='3c509.c' object='libdrivers_a-3c509.o' libtool=no @AMDEPBACKSLASH@
  2607. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2608. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-3c509.o `test -f '3c509.c' || echo '$(srcdir)/'`3c509.c
  2609. -
  2610. -libdrivers_a-3c509.obj: 3c509.c
  2611. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-3c509.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-3c509.Tpo" -c -o libdrivers_a-3c509.obj `if test -f '3c509.c'; then $(CYGPATH_W) '3c509.c'; else $(CYGPATH_W) '$(srcdir)/3c509.c'; fi`; \
  2612. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-3c509.Tpo" "$(DEPDIR)/libdrivers_a-3c509.Po"; else rm -f "$(DEPDIR)/libdrivers_a-3c509.Tpo"; exit 1; fi
  2613. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='3c509.c' object='libdrivers_a-3c509.obj' libtool=no @AMDEPBACKSLASH@
  2614. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2615. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-3c509.obj `if test -f '3c509.c'; then $(CYGPATH_W) '3c509.c'; else $(CYGPATH_W) '$(srcdir)/3c509.c'; fi`
  2616. +libdrivers_a-pic8259.o: pic8259.c
  2617. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-pic8259.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-pic8259.Tpo" -c -o libdrivers_a-pic8259.o `test -f 'pic8259.c' || echo '$(srcdir)/'`pic8259.c; \
  2618. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-pic8259.Tpo" "$(DEPDIR)/libdrivers_a-pic8259.Po"; else rm -f "$(DEPDIR)/libdrivers_a-pic8259.Tpo"; exit 1; fi
  2619. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pic8259.c' object='libdrivers_a-pic8259.o' libtool=no @AMDEPBACKSLASH@
  2620. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-pic8259.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-pic8259.TPo' @AMDEPBACKSLASH@
  2621. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2622. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-pic8259.o `test -f 'pic8259.c' || echo '$(srcdir)/'`pic8259.c
  2623. +
  2624. +libdrivers_a-pic8259.obj: pic8259.c
  2625. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-pic8259.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-pic8259.Tpo" -c -o libdrivers_a-pic8259.obj `if test -f 'pic8259.c'; then $(CYGPATH_W) 'pic8259.c'; else $(CYGPATH_W) '$(srcdir)/pic8259.c'; fi`; \
  2626. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-pic8259.Tpo" "$(DEPDIR)/libdrivers_a-pic8259.Po"; else rm -f "$(DEPDIR)/libdrivers_a-pic8259.Tpo"; exit 1; fi
  2627. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pic8259.c' object='libdrivers_a-pic8259.obj' libtool=no @AMDEPBACKSLASH@
  2628. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-pic8259.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-pic8259.TPo' @AMDEPBACKSLASH@
  2629. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2630. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-pic8259.obj `if test -f 'pic8259.c'; then $(CYGPATH_W) 'pic8259.c'; else $(CYGPATH_W) '$(srcdir)/pic8259.c'; fi`
  2631. +
  2632. +libdrivers_a-basemem.o: basemem.c
  2633. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-basemem.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-basemem.Tpo" -c -o libdrivers_a-basemem.o `test -f 'basemem.c' || echo '$(srcdir)/'`basemem.c; \
  2634. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-basemem.Tpo" "$(DEPDIR)/libdrivers_a-basemem.Po"; else rm -f "$(DEPDIR)/libdrivers_a-basemem.Tpo"; exit 1; fi
  2635. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='basemem.c' object='libdrivers_a-basemem.o' libtool=no @AMDEPBACKSLASH@
  2636. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-basemem.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-basemem.TPo' @AMDEPBACKSLASH@
  2637. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2638. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-basemem.o `test -f 'basemem.c' || echo '$(srcdir)/'`basemem.c
  2639. +
  2640. +libdrivers_a-basemem.obj: basemem.c
  2641. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-basemem.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-basemem.Tpo" -c -o libdrivers_a-basemem.obj `if test -f 'basemem.c'; then $(CYGPATH_W) 'basemem.c'; else $(CYGPATH_W) '$(srcdir)/basemem.c'; fi`; \
  2642. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-basemem.Tpo" "$(DEPDIR)/libdrivers_a-basemem.Po"; else rm -f "$(DEPDIR)/libdrivers_a-basemem.Tpo"; exit 1; fi
  2643. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='basemem.c' object='libdrivers_a-basemem.obj' libtool=no @AMDEPBACKSLASH@
  2644. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-basemem.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-basemem.TPo' @AMDEPBACKSLASH@
  2645. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2646. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-basemem.obj `if test -f 'basemem.c'; then $(CYGPATH_W) 'basemem.c'; else $(CYGPATH_W) '$(srcdir)/basemem.c'; fi`
  2647. libdrivers_a-3c595.o: 3c595.c
  2648. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-3c595.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-3c595.Tpo" -c -o libdrivers_a-3c595.o `test -f '3c595.c' || echo '$(srcdir)/'`3c595.c; \
  2649. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-3c595.Tpo" "$(DEPDIR)/libdrivers_a-3c595.Po"; else rm -f "$(DEPDIR)/libdrivers_a-3c595.Tpo"; exit 1; fi
  2650. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='3c595.c' object='libdrivers_a-3c595.o' libtool=no @AMDEPBACKSLASH@
  2651. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2652. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-3c595.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-3c595.TPo' @AMDEPBACKSLASH@
  2653. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2654. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-3c595.o `test -f '3c595.c' || echo '$(srcdir)/'`3c595.c
  2655. libdrivers_a-3c595.obj: 3c595.c
  2656. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-3c595.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-3c595.Tpo" -c -o libdrivers_a-3c595.obj `if test -f '3c595.c'; then $(CYGPATH_W) '3c595.c'; else $(CYGPATH_W) '$(srcdir)/3c595.c'; fi`; \
  2657. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-3c595.Tpo" "$(DEPDIR)/libdrivers_a-3c595.Po"; else rm -f "$(DEPDIR)/libdrivers_a-3c595.Tpo"; exit 1; fi
  2658. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='3c595.c' object='libdrivers_a-3c595.obj' libtool=no @AMDEPBACKSLASH@
  2659. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2660. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-3c595.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-3c595.TPo' @AMDEPBACKSLASH@
  2661. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2662. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-3c595.obj `if test -f '3c595.c'; then $(CYGPATH_W) '3c595.c'; else $(CYGPATH_W) '$(srcdir)/3c595.c'; fi`
  2663. libdrivers_a-3c90x.o: 3c90x.c
  2664. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-3c90x.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-3c90x.Tpo" -c -o libdrivers_a-3c90x.o `test -f '3c90x.c' || echo '$(srcdir)/'`3c90x.c; \
  2665. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-3c90x.Tpo" "$(DEPDIR)/libdrivers_a-3c90x.Po"; else rm -f "$(DEPDIR)/libdrivers_a-3c90x.Tpo"; exit 1; fi
  2666. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='3c90x.c' object='libdrivers_a-3c90x.o' libtool=no @AMDEPBACKSLASH@
  2667. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2668. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-3c90x.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-3c90x.TPo' @AMDEPBACKSLASH@
  2669. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2670. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-3c90x.o `test -f '3c90x.c' || echo '$(srcdir)/'`3c90x.c
  2671. libdrivers_a-3c90x.obj: 3c90x.c
  2672. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-3c90x.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-3c90x.Tpo" -c -o libdrivers_a-3c90x.obj `if test -f '3c90x.c'; then $(CYGPATH_W) '3c90x.c'; else $(CYGPATH_W) '$(srcdir)/3c90x.c'; fi`; \
  2673. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-3c90x.Tpo" "$(DEPDIR)/libdrivers_a-3c90x.Po"; else rm -f "$(DEPDIR)/libdrivers_a-3c90x.Tpo"; exit 1; fi
  2674. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='3c90x.c' object='libdrivers_a-3c90x.obj' libtool=no @AMDEPBACKSLASH@
  2675. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2676. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-3c90x.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-3c90x.TPo' @AMDEPBACKSLASH@
  2677. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2678. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-3c90x.obj `if test -f '3c90x.c'; then $(CYGPATH_W) '3c90x.c'; else $(CYGPATH_W) '$(srcdir)/3c90x.c'; fi`
  2679. -libdrivers_a-cs89x0.o: cs89x0.c
  2680. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-cs89x0.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-cs89x0.Tpo" -c -o libdrivers_a-cs89x0.o `test -f 'cs89x0.c' || echo '$(srcdir)/'`cs89x0.c; \
  2681. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-cs89x0.Tpo" "$(DEPDIR)/libdrivers_a-cs89x0.Po"; else rm -f "$(DEPDIR)/libdrivers_a-cs89x0.Tpo"; exit 1; fi
  2682. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cs89x0.c' object='libdrivers_a-cs89x0.o' libtool=no @AMDEPBACKSLASH@
  2683. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2684. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-cs89x0.o `test -f 'cs89x0.c' || echo '$(srcdir)/'`cs89x0.c
  2685. -
  2686. -libdrivers_a-cs89x0.obj: cs89x0.c
  2687. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-cs89x0.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-cs89x0.Tpo" -c -o libdrivers_a-cs89x0.obj `if test -f 'cs89x0.c'; then $(CYGPATH_W) 'cs89x0.c'; else $(CYGPATH_W) '$(srcdir)/cs89x0.c'; fi`; \
  2688. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-cs89x0.Tpo" "$(DEPDIR)/libdrivers_a-cs89x0.Po"; else rm -f "$(DEPDIR)/libdrivers_a-cs89x0.Tpo"; exit 1; fi
  2689. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cs89x0.c' object='libdrivers_a-cs89x0.obj' libtool=no @AMDEPBACKSLASH@
  2690. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2691. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-cs89x0.obj `if test -f 'cs89x0.c'; then $(CYGPATH_W) 'cs89x0.c'; else $(CYGPATH_W) '$(srcdir)/cs89x0.c'; fi`
  2692. -
  2693. libdrivers_a-davicom.o: davicom.c
  2694. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-davicom.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-davicom.Tpo" -c -o libdrivers_a-davicom.o `test -f 'davicom.c' || echo '$(srcdir)/'`davicom.c; \
  2695. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-davicom.Tpo" "$(DEPDIR)/libdrivers_a-davicom.Po"; else rm -f "$(DEPDIR)/libdrivers_a-davicom.Tpo"; exit 1; fi
  2696. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='davicom.c' object='libdrivers_a-davicom.o' libtool=no @AMDEPBACKSLASH@
  2697. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2698. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-davicom.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-davicom.TPo' @AMDEPBACKSLASH@
  2699. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2700. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-davicom.o `test -f 'davicom.c' || echo '$(srcdir)/'`davicom.c
  2701. libdrivers_a-davicom.obj: davicom.c
  2702. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-davicom.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-davicom.Tpo" -c -o libdrivers_a-davicom.obj `if test -f 'davicom.c'; then $(CYGPATH_W) 'davicom.c'; else $(CYGPATH_W) '$(srcdir)/davicom.c'; fi`; \
  2703. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-davicom.Tpo" "$(DEPDIR)/libdrivers_a-davicom.Po"; else rm -f "$(DEPDIR)/libdrivers_a-davicom.Tpo"; exit 1; fi
  2704. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='davicom.c' object='libdrivers_a-davicom.obj' libtool=no @AMDEPBACKSLASH@
  2705. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2706. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-davicom.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-davicom.TPo' @AMDEPBACKSLASH@
  2707. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2708. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-davicom.obj `if test -f 'davicom.c'; then $(CYGPATH_W) 'davicom.c'; else $(CYGPATH_W) '$(srcdir)/davicom.c'; fi`
  2709. -libdrivers_a-depca.o: depca.c
  2710. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-depca.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-depca.Tpo" -c -o libdrivers_a-depca.o `test -f 'depca.c' || echo '$(srcdir)/'`depca.c; \
  2711. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-depca.Tpo" "$(DEPDIR)/libdrivers_a-depca.Po"; else rm -f "$(DEPDIR)/libdrivers_a-depca.Tpo"; exit 1; fi
  2712. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='depca.c' object='libdrivers_a-depca.o' libtool=no @AMDEPBACKSLASH@
  2713. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2714. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-depca.o `test -f 'depca.c' || echo '$(srcdir)/'`depca.c
  2715. -
  2716. -libdrivers_a-depca.obj: depca.c
  2717. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-depca.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-depca.Tpo" -c -o libdrivers_a-depca.obj `if test -f 'depca.c'; then $(CYGPATH_W) 'depca.c'; else $(CYGPATH_W) '$(srcdir)/depca.c'; fi`; \
  2718. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-depca.Tpo" "$(DEPDIR)/libdrivers_a-depca.Po"; else rm -f "$(DEPDIR)/libdrivers_a-depca.Tpo"; exit 1; fi
  2719. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='depca.c' object='libdrivers_a-depca.obj' libtool=no @AMDEPBACKSLASH@
  2720. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2721. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-depca.obj `if test -f 'depca.c'; then $(CYGPATH_W) 'depca.c'; else $(CYGPATH_W) '$(srcdir)/depca.c'; fi`
  2722. -
  2723. -libdrivers_a-eepro.o: eepro.c
  2724. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-eepro.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-eepro.Tpo" -c -o libdrivers_a-eepro.o `test -f 'eepro.c' || echo '$(srcdir)/'`eepro.c; \
  2725. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-eepro.Tpo" "$(DEPDIR)/libdrivers_a-eepro.Po"; else rm -f "$(DEPDIR)/libdrivers_a-eepro.Tpo"; exit 1; fi
  2726. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='eepro.c' object='libdrivers_a-eepro.o' libtool=no @AMDEPBACKSLASH@
  2727. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2728. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-eepro.o `test -f 'eepro.c' || echo '$(srcdir)/'`eepro.c
  2729. -
  2730. -libdrivers_a-eepro.obj: eepro.c
  2731. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-eepro.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-eepro.Tpo" -c -o libdrivers_a-eepro.obj `if test -f 'eepro.c'; then $(CYGPATH_W) 'eepro.c'; else $(CYGPATH_W) '$(srcdir)/eepro.c'; fi`; \
  2732. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-eepro.Tpo" "$(DEPDIR)/libdrivers_a-eepro.Po"; else rm -f "$(DEPDIR)/libdrivers_a-eepro.Tpo"; exit 1; fi
  2733. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='eepro.c' object='libdrivers_a-eepro.obj' libtool=no @AMDEPBACKSLASH@
  2734. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2735. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-eepro.obj `if test -f 'eepro.c'; then $(CYGPATH_W) 'eepro.c'; else $(CYGPATH_W) '$(srcdir)/eepro.c'; fi`
  2736. +libdrivers_a-e1000.o: e1000.c
  2737. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-e1000.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-e1000.Tpo" -c -o libdrivers_a-e1000.o `test -f 'e1000.c' || echo '$(srcdir)/'`e1000.c; \
  2738. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-e1000.Tpo" "$(DEPDIR)/libdrivers_a-e1000.Po"; else rm -f "$(DEPDIR)/libdrivers_a-e1000.Tpo"; exit 1; fi
  2739. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='e1000.c' object='libdrivers_a-e1000.o' libtool=no @AMDEPBACKSLASH@
  2740. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-e1000.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-e1000.TPo' @AMDEPBACKSLASH@
  2741. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2742. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-e1000.o `test -f 'e1000.c' || echo '$(srcdir)/'`e1000.c
  2743. +
  2744. +libdrivers_a-e1000.obj: e1000.c
  2745. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-e1000.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-e1000.Tpo" -c -o libdrivers_a-e1000.obj `if test -f 'e1000.c'; then $(CYGPATH_W) 'e1000.c'; else $(CYGPATH_W) '$(srcdir)/e1000.c'; fi`; \
  2746. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-e1000.Tpo" "$(DEPDIR)/libdrivers_a-e1000.Po"; else rm -f "$(DEPDIR)/libdrivers_a-e1000.Tpo"; exit 1; fi
  2747. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='e1000.c' object='libdrivers_a-e1000.obj' libtool=no @AMDEPBACKSLASH@
  2748. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-e1000.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-e1000.TPo' @AMDEPBACKSLASH@
  2749. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2750. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-e1000.obj `if test -f 'e1000.c'; then $(CYGPATH_W) 'e1000.c'; else $(CYGPATH_W) '$(srcdir)/e1000.c'; fi`
  2751. libdrivers_a-eepro100.o: eepro100.c
  2752. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-eepro100.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-eepro100.Tpo" -c -o libdrivers_a-eepro100.o `test -f 'eepro100.c' || echo '$(srcdir)/'`eepro100.c; \
  2753. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-eepro100.Tpo" "$(DEPDIR)/libdrivers_a-eepro100.Po"; else rm -f "$(DEPDIR)/libdrivers_a-eepro100.Tpo"; exit 1; fi
  2754. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='eepro100.c' object='libdrivers_a-eepro100.o' libtool=no @AMDEPBACKSLASH@
  2755. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2756. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-eepro100.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-eepro100.TPo' @AMDEPBACKSLASH@
  2757. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2758. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-eepro100.o `test -f 'eepro100.c' || echo '$(srcdir)/'`eepro100.c
  2759. libdrivers_a-eepro100.obj: eepro100.c
  2760. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-eepro100.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-eepro100.Tpo" -c -o libdrivers_a-eepro100.obj `if test -f 'eepro100.c'; then $(CYGPATH_W) 'eepro100.c'; else $(CYGPATH_W) '$(srcdir)/eepro100.c'; fi`; \
  2761. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-eepro100.Tpo" "$(DEPDIR)/libdrivers_a-eepro100.Po"; else rm -f "$(DEPDIR)/libdrivers_a-eepro100.Tpo"; exit 1; fi
  2762. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='eepro100.c' object='libdrivers_a-eepro100.obj' libtool=no @AMDEPBACKSLASH@
  2763. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2764. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-eepro100.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-eepro100.TPo' @AMDEPBACKSLASH@
  2765. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2766. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-eepro100.obj `if test -f 'eepro100.c'; then $(CYGPATH_W) 'eepro100.c'; else $(CYGPATH_W) '$(srcdir)/eepro100.c'; fi`
  2767. libdrivers_a-epic100.o: epic100.c
  2768. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-epic100.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-epic100.Tpo" -c -o libdrivers_a-epic100.o `test -f 'epic100.c' || echo '$(srcdir)/'`epic100.c; \
  2769. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-epic100.Tpo" "$(DEPDIR)/libdrivers_a-epic100.Po"; else rm -f "$(DEPDIR)/libdrivers_a-epic100.Tpo"; exit 1; fi
  2770. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='epic100.c' object='libdrivers_a-epic100.o' libtool=no @AMDEPBACKSLASH@
  2771. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2772. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-epic100.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-epic100.TPo' @AMDEPBACKSLASH@
  2773. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2774. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-epic100.o `test -f 'epic100.c' || echo '$(srcdir)/'`epic100.c
  2775. libdrivers_a-epic100.obj: epic100.c
  2776. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-epic100.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-epic100.Tpo" -c -o libdrivers_a-epic100.obj `if test -f 'epic100.c'; then $(CYGPATH_W) 'epic100.c'; else $(CYGPATH_W) '$(srcdir)/epic100.c'; fi`; \
  2777. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-epic100.Tpo" "$(DEPDIR)/libdrivers_a-epic100.Po"; else rm -f "$(DEPDIR)/libdrivers_a-epic100.Tpo"; exit 1; fi
  2778. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='epic100.c' object='libdrivers_a-epic100.obj' libtool=no @AMDEPBACKSLASH@
  2779. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2780. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-epic100.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-epic100.TPo' @AMDEPBACKSLASH@
  2781. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2782. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-epic100.obj `if test -f 'epic100.c'; then $(CYGPATH_W) 'epic100.c'; else $(CYGPATH_W) '$(srcdir)/epic100.c'; fi`
  2783. -libdrivers_a-fa311.o: fa311.c
  2784. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-fa311.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-fa311.Tpo" -c -o libdrivers_a-fa311.o `test -f 'fa311.c' || echo '$(srcdir)/'`fa311.c; \
  2785. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-fa311.Tpo" "$(DEPDIR)/libdrivers_a-fa311.Po"; else rm -f "$(DEPDIR)/libdrivers_a-fa311.Tpo"; exit 1; fi
  2786. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='fa311.c' object='libdrivers_a-fa311.o' libtool=no @AMDEPBACKSLASH@
  2787. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2788. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-fa311.o `test -f 'fa311.c' || echo '$(srcdir)/'`fa311.c
  2789. -
  2790. -libdrivers_a-fa311.obj: fa311.c
  2791. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-fa311.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-fa311.Tpo" -c -o libdrivers_a-fa311.obj `if test -f 'fa311.c'; then $(CYGPATH_W) 'fa311.c'; else $(CYGPATH_W) '$(srcdir)/fa311.c'; fi`; \
  2792. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-fa311.Tpo" "$(DEPDIR)/libdrivers_a-fa311.Po"; else rm -f "$(DEPDIR)/libdrivers_a-fa311.Tpo"; exit 1; fi
  2793. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='fa311.c' object='libdrivers_a-fa311.obj' libtool=no @AMDEPBACKSLASH@
  2794. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2795. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-fa311.obj `if test -f 'fa311.c'; then $(CYGPATH_W) 'fa311.c'; else $(CYGPATH_W) '$(srcdir)/fa311.c'; fi`
  2796. -
  2797. -libdrivers_a-i82586.o: i82586.c
  2798. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-i82586.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-i82586.Tpo" -c -o libdrivers_a-i82586.o `test -f 'i82586.c' || echo '$(srcdir)/'`i82586.c; \
  2799. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-i82586.Tpo" "$(DEPDIR)/libdrivers_a-i82586.Po"; else rm -f "$(DEPDIR)/libdrivers_a-i82586.Tpo"; exit 1; fi
  2800. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='i82586.c' object='libdrivers_a-i82586.o' libtool=no @AMDEPBACKSLASH@
  2801. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2802. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-i82586.o `test -f 'i82586.c' || echo '$(srcdir)/'`i82586.c
  2803. -
  2804. -libdrivers_a-i82586.obj: i82586.c
  2805. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-i82586.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-i82586.Tpo" -c -o libdrivers_a-i82586.obj `if test -f 'i82586.c'; then $(CYGPATH_W) 'i82586.c'; else $(CYGPATH_W) '$(srcdir)/i82586.c'; fi`; \
  2806. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-i82586.Tpo" "$(DEPDIR)/libdrivers_a-i82586.Po"; else rm -f "$(DEPDIR)/libdrivers_a-i82586.Tpo"; exit 1; fi
  2807. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='i82586.c' object='libdrivers_a-i82586.obj' libtool=no @AMDEPBACKSLASH@
  2808. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2809. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-i82586.obj `if test -f 'i82586.c'; then $(CYGPATH_W) 'i82586.c'; else $(CYGPATH_W) '$(srcdir)/i82586.c'; fi`
  2810. -
  2811. -libdrivers_a-lance.o: lance.c
  2812. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-lance.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-lance.Tpo" -c -o libdrivers_a-lance.o `test -f 'lance.c' || echo '$(srcdir)/'`lance.c; \
  2813. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-lance.Tpo" "$(DEPDIR)/libdrivers_a-lance.Po"; else rm -f "$(DEPDIR)/libdrivers_a-lance.Tpo"; exit 1; fi
  2814. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='lance.c' object='libdrivers_a-lance.o' libtool=no @AMDEPBACKSLASH@
  2815. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2816. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-lance.o `test -f 'lance.c' || echo '$(srcdir)/'`lance.c
  2817. -
  2818. -libdrivers_a-lance.obj: lance.c
  2819. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-lance.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-lance.Tpo" -c -o libdrivers_a-lance.obj `if test -f 'lance.c'; then $(CYGPATH_W) 'lance.c'; else $(CYGPATH_W) '$(srcdir)/lance.c'; fi`; \
  2820. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-lance.Tpo" "$(DEPDIR)/libdrivers_a-lance.Po"; else rm -f "$(DEPDIR)/libdrivers_a-lance.Tpo"; exit 1; fi
  2821. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='lance.c' object='libdrivers_a-lance.obj' libtool=no @AMDEPBACKSLASH@
  2822. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2823. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-lance.obj `if test -f 'lance.c'; then $(CYGPATH_W) 'lance.c'; else $(CYGPATH_W) '$(srcdir)/lance.c'; fi`
  2824. -
  2825. libdrivers_a-natsemi.o: natsemi.c
  2826. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-natsemi.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-natsemi.Tpo" -c -o libdrivers_a-natsemi.o `test -f 'natsemi.c' || echo '$(srcdir)/'`natsemi.c; \
  2827. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-natsemi.Tpo" "$(DEPDIR)/libdrivers_a-natsemi.Po"; else rm -f "$(DEPDIR)/libdrivers_a-natsemi.Tpo"; exit 1; fi
  2828. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='natsemi.c' object='libdrivers_a-natsemi.o' libtool=no @AMDEPBACKSLASH@
  2829. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2830. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-natsemi.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-natsemi.TPo' @AMDEPBACKSLASH@
  2831. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2832. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-natsemi.o `test -f 'natsemi.c' || echo '$(srcdir)/'`natsemi.c
  2833. libdrivers_a-natsemi.obj: natsemi.c
  2834. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-natsemi.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-natsemi.Tpo" -c -o libdrivers_a-natsemi.obj `if test -f 'natsemi.c'; then $(CYGPATH_W) 'natsemi.c'; else $(CYGPATH_W) '$(srcdir)/natsemi.c'; fi`; \
  2835. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-natsemi.Tpo" "$(DEPDIR)/libdrivers_a-natsemi.Po"; else rm -f "$(DEPDIR)/libdrivers_a-natsemi.Tpo"; exit 1; fi
  2836. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='natsemi.c' object='libdrivers_a-natsemi.obj' libtool=no @AMDEPBACKSLASH@
  2837. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2838. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-natsemi.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-natsemi.TPo' @AMDEPBACKSLASH@
  2839. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2840. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-natsemi.obj `if test -f 'natsemi.c'; then $(CYGPATH_W) 'natsemi.c'; else $(CYGPATH_W) '$(srcdir)/natsemi.c'; fi`
  2841. -libdrivers_a-ni5010.o: ni5010.c
  2842. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-ni5010.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-ni5010.Tpo" -c -o libdrivers_a-ni5010.o `test -f 'ni5010.c' || echo '$(srcdir)/'`ni5010.c; \
  2843. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-ni5010.Tpo" "$(DEPDIR)/libdrivers_a-ni5010.Po"; else rm -f "$(DEPDIR)/libdrivers_a-ni5010.Tpo"; exit 1; fi
  2844. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ni5010.c' object='libdrivers_a-ni5010.o' libtool=no @AMDEPBACKSLASH@
  2845. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2846. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-ni5010.o `test -f 'ni5010.c' || echo '$(srcdir)/'`ni5010.c
  2847. -
  2848. -libdrivers_a-ni5010.obj: ni5010.c
  2849. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-ni5010.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-ni5010.Tpo" -c -o libdrivers_a-ni5010.obj `if test -f 'ni5010.c'; then $(CYGPATH_W) 'ni5010.c'; else $(CYGPATH_W) '$(srcdir)/ni5010.c'; fi`; \
  2850. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-ni5010.Tpo" "$(DEPDIR)/libdrivers_a-ni5010.Po"; else rm -f "$(DEPDIR)/libdrivers_a-ni5010.Tpo"; exit 1; fi
  2851. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ni5010.c' object='libdrivers_a-ni5010.obj' libtool=no @AMDEPBACKSLASH@
  2852. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2853. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-ni5010.obj `if test -f 'ni5010.c'; then $(CYGPATH_W) 'ni5010.c'; else $(CYGPATH_W) '$(srcdir)/ni5010.c'; fi`
  2854. -
  2855. libdrivers_a-ns8390.o: ns8390.c
  2856. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-ns8390.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-ns8390.Tpo" -c -o libdrivers_a-ns8390.o `test -f 'ns8390.c' || echo '$(srcdir)/'`ns8390.c; \
  2857. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-ns8390.Tpo" "$(DEPDIR)/libdrivers_a-ns8390.Po"; else rm -f "$(DEPDIR)/libdrivers_a-ns8390.Tpo"; exit 1; fi
  2858. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ns8390.c' object='libdrivers_a-ns8390.o' libtool=no @AMDEPBACKSLASH@
  2859. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2860. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-ns8390.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-ns8390.TPo' @AMDEPBACKSLASH@
  2861. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2862. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-ns8390.o `test -f 'ns8390.c' || echo '$(srcdir)/'`ns8390.c
  2863. libdrivers_a-ns8390.obj: ns8390.c
  2864. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-ns8390.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-ns8390.Tpo" -c -o libdrivers_a-ns8390.obj `if test -f 'ns8390.c'; then $(CYGPATH_W) 'ns8390.c'; else $(CYGPATH_W) '$(srcdir)/ns8390.c'; fi`; \
  2865. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-ns8390.Tpo" "$(DEPDIR)/libdrivers_a-ns8390.Po"; else rm -f "$(DEPDIR)/libdrivers_a-ns8390.Tpo"; exit 1; fi
  2866. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ns8390.c' object='libdrivers_a-ns8390.obj' libtool=no @AMDEPBACKSLASH@
  2867. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2868. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-ns8390.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-ns8390.TPo' @AMDEPBACKSLASH@
  2869. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2870. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-ns8390.obj `if test -f 'ns8390.c'; then $(CYGPATH_W) 'ns8390.c'; else $(CYGPATH_W) '$(srcdir)/ns8390.c'; fi`
  2871. -libdrivers_a-otulip.o: otulip.c
  2872. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-otulip.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-otulip.Tpo" -c -o libdrivers_a-otulip.o `test -f 'otulip.c' || echo '$(srcdir)/'`otulip.c; \
  2873. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-otulip.Tpo" "$(DEPDIR)/libdrivers_a-otulip.Po"; else rm -f "$(DEPDIR)/libdrivers_a-otulip.Tpo"; exit 1; fi
  2874. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='otulip.c' object='libdrivers_a-otulip.o' libtool=no @AMDEPBACKSLASH@
  2875. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2876. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-otulip.o `test -f 'otulip.c' || echo '$(srcdir)/'`otulip.c
  2877. -
  2878. -libdrivers_a-otulip.obj: otulip.c
  2879. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-otulip.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-otulip.Tpo" -c -o libdrivers_a-otulip.obj `if test -f 'otulip.c'; then $(CYGPATH_W) 'otulip.c'; else $(CYGPATH_W) '$(srcdir)/otulip.c'; fi`; \
  2880. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-otulip.Tpo" "$(DEPDIR)/libdrivers_a-otulip.Po"; else rm -f "$(DEPDIR)/libdrivers_a-otulip.Tpo"; exit 1; fi
  2881. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='otulip.c' object='libdrivers_a-otulip.obj' libtool=no @AMDEPBACKSLASH@
  2882. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2883. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-otulip.obj `if test -f 'otulip.c'; then $(CYGPATH_W) 'otulip.c'; else $(CYGPATH_W) '$(srcdir)/otulip.c'; fi`
  2884. +libdrivers_a-pcnet32.o: pcnet32.c
  2885. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-pcnet32.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-pcnet32.Tpo" -c -o libdrivers_a-pcnet32.o `test -f 'pcnet32.c' || echo '$(srcdir)/'`pcnet32.c; \
  2886. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-pcnet32.Tpo" "$(DEPDIR)/libdrivers_a-pcnet32.Po"; else rm -f "$(DEPDIR)/libdrivers_a-pcnet32.Tpo"; exit 1; fi
  2887. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pcnet32.c' object='libdrivers_a-pcnet32.o' libtool=no @AMDEPBACKSLASH@
  2888. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-pcnet32.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-pcnet32.TPo' @AMDEPBACKSLASH@
  2889. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2890. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-pcnet32.o `test -f 'pcnet32.c' || echo '$(srcdir)/'`pcnet32.c
  2891. +
  2892. +libdrivers_a-pcnet32.obj: pcnet32.c
  2893. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-pcnet32.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-pcnet32.Tpo" -c -o libdrivers_a-pcnet32.obj `if test -f 'pcnet32.c'; then $(CYGPATH_W) 'pcnet32.c'; else $(CYGPATH_W) '$(srcdir)/pcnet32.c'; fi`; \
  2894. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-pcnet32.Tpo" "$(DEPDIR)/libdrivers_a-pcnet32.Po"; else rm -f "$(DEPDIR)/libdrivers_a-pcnet32.Tpo"; exit 1; fi
  2895. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pcnet32.c' object='libdrivers_a-pcnet32.obj' libtool=no @AMDEPBACKSLASH@
  2896. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-pcnet32.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-pcnet32.TPo' @AMDEPBACKSLASH@
  2897. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2898. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-pcnet32.obj `if test -f 'pcnet32.c'; then $(CYGPATH_W) 'pcnet32.c'; else $(CYGPATH_W) '$(srcdir)/pcnet32.c'; fi`
  2899. libdrivers_a-rtl8139.o: rtl8139.c
  2900. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-rtl8139.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-rtl8139.Tpo" -c -o libdrivers_a-rtl8139.o `test -f 'rtl8139.c' || echo '$(srcdir)/'`rtl8139.c; \
  2901. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-rtl8139.Tpo" "$(DEPDIR)/libdrivers_a-rtl8139.Po"; else rm -f "$(DEPDIR)/libdrivers_a-rtl8139.Tpo"; exit 1; fi
  2902. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rtl8139.c' object='libdrivers_a-rtl8139.o' libtool=no @AMDEPBACKSLASH@
  2903. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2904. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-rtl8139.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-rtl8139.TPo' @AMDEPBACKSLASH@
  2905. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2906. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-rtl8139.o `test -f 'rtl8139.c' || echo '$(srcdir)/'`rtl8139.c
  2907. libdrivers_a-rtl8139.obj: rtl8139.c
  2908. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-rtl8139.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-rtl8139.Tpo" -c -o libdrivers_a-rtl8139.obj `if test -f 'rtl8139.c'; then $(CYGPATH_W) 'rtl8139.c'; else $(CYGPATH_W) '$(srcdir)/rtl8139.c'; fi`; \
  2909. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-rtl8139.Tpo" "$(DEPDIR)/libdrivers_a-rtl8139.Po"; else rm -f "$(DEPDIR)/libdrivers_a-rtl8139.Tpo"; exit 1; fi
  2910. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rtl8139.c' object='libdrivers_a-rtl8139.obj' libtool=no @AMDEPBACKSLASH@
  2911. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2912. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-rtl8139.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-rtl8139.TPo' @AMDEPBACKSLASH@
  2913. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2914. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-rtl8139.obj `if test -f 'rtl8139.c'; then $(CYGPATH_W) 'rtl8139.c'; else $(CYGPATH_W) '$(srcdir)/rtl8139.c'; fi`
  2915. libdrivers_a-sis900.o: sis900.c
  2916. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-sis900.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-sis900.Tpo" -c -o libdrivers_a-sis900.o `test -f 'sis900.c' || echo '$(srcdir)/'`sis900.c; \
  2917. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-sis900.Tpo" "$(DEPDIR)/libdrivers_a-sis900.Po"; else rm -f "$(DEPDIR)/libdrivers_a-sis900.Tpo"; exit 1; fi
  2918. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sis900.c' object='libdrivers_a-sis900.o' libtool=no @AMDEPBACKSLASH@
  2919. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2920. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-sis900.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-sis900.TPo' @AMDEPBACKSLASH@
  2921. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2922. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-sis900.o `test -f 'sis900.c' || echo '$(srcdir)/'`sis900.c
  2923. libdrivers_a-sis900.obj: sis900.c
  2924. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-sis900.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-sis900.Tpo" -c -o libdrivers_a-sis900.obj `if test -f 'sis900.c'; then $(CYGPATH_W) 'sis900.c'; else $(CYGPATH_W) '$(srcdir)/sis900.c'; fi`; \
  2925. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-sis900.Tpo" "$(DEPDIR)/libdrivers_a-sis900.Po"; else rm -f "$(DEPDIR)/libdrivers_a-sis900.Tpo"; exit 1; fi
  2926. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sis900.c' object='libdrivers_a-sis900.obj' libtool=no @AMDEPBACKSLASH@
  2927. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2928. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-sis900.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-sis900.TPo' @AMDEPBACKSLASH@
  2929. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2930. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-sis900.obj `if test -f 'sis900.c'; then $(CYGPATH_W) 'sis900.c'; else $(CYGPATH_W) '$(srcdir)/sis900.c'; fi`
  2931. -libdrivers_a-sk_g16.o: sk_g16.c
  2932. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-sk_g16.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-sk_g16.Tpo" -c -o libdrivers_a-sk_g16.o `test -f 'sk_g16.c' || echo '$(srcdir)/'`sk_g16.c; \
  2933. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-sk_g16.Tpo" "$(DEPDIR)/libdrivers_a-sk_g16.Po"; else rm -f "$(DEPDIR)/libdrivers_a-sk_g16.Tpo"; exit 1; fi
  2934. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sk_g16.c' object='libdrivers_a-sk_g16.o' libtool=no @AMDEPBACKSLASH@
  2935. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2936. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-sk_g16.o `test -f 'sk_g16.c' || echo '$(srcdir)/'`sk_g16.c
  2937. -
  2938. -libdrivers_a-sk_g16.obj: sk_g16.c
  2939. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-sk_g16.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-sk_g16.Tpo" -c -o libdrivers_a-sk_g16.obj `if test -f 'sk_g16.c'; then $(CYGPATH_W) 'sk_g16.c'; else $(CYGPATH_W) '$(srcdir)/sk_g16.c'; fi`; \
  2940. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-sk_g16.Tpo" "$(DEPDIR)/libdrivers_a-sk_g16.Po"; else rm -f "$(DEPDIR)/libdrivers_a-sk_g16.Tpo"; exit 1; fi
  2941. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sk_g16.c' object='libdrivers_a-sk_g16.obj' libtool=no @AMDEPBACKSLASH@
  2942. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2943. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-sk_g16.obj `if test -f 'sk_g16.c'; then $(CYGPATH_W) 'sk_g16.c'; else $(CYGPATH_W) '$(srcdir)/sk_g16.c'; fi`
  2944. -
  2945. -libdrivers_a-smc9000.o: smc9000.c
  2946. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-smc9000.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-smc9000.Tpo" -c -o libdrivers_a-smc9000.o `test -f 'smc9000.c' || echo '$(srcdir)/'`smc9000.c; \
  2947. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-smc9000.Tpo" "$(DEPDIR)/libdrivers_a-smc9000.Po"; else rm -f "$(DEPDIR)/libdrivers_a-smc9000.Tpo"; exit 1; fi
  2948. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='smc9000.c' object='libdrivers_a-smc9000.o' libtool=no @AMDEPBACKSLASH@
  2949. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2950. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-smc9000.o `test -f 'smc9000.c' || echo '$(srcdir)/'`smc9000.c
  2951. -
  2952. -libdrivers_a-smc9000.obj: smc9000.c
  2953. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-smc9000.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-smc9000.Tpo" -c -o libdrivers_a-smc9000.obj `if test -f 'smc9000.c'; then $(CYGPATH_W) 'smc9000.c'; else $(CYGPATH_W) '$(srcdir)/smc9000.c'; fi`; \
  2954. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-smc9000.Tpo" "$(DEPDIR)/libdrivers_a-smc9000.Po"; else rm -f "$(DEPDIR)/libdrivers_a-smc9000.Tpo"; exit 1; fi
  2955. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='smc9000.c' object='libdrivers_a-smc9000.obj' libtool=no @AMDEPBACKSLASH@
  2956. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2957. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-smc9000.obj `if test -f 'smc9000.c'; then $(CYGPATH_W) 'smc9000.c'; else $(CYGPATH_W) '$(srcdir)/smc9000.c'; fi`
  2958. -
  2959. -libdrivers_a-tiara.o: tiara.c
  2960. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-tiara.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-tiara.Tpo" -c -o libdrivers_a-tiara.o `test -f 'tiara.c' || echo '$(srcdir)/'`tiara.c; \
  2961. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-tiara.Tpo" "$(DEPDIR)/libdrivers_a-tiara.Po"; else rm -f "$(DEPDIR)/libdrivers_a-tiara.Tpo"; exit 1; fi
  2962. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tiara.c' object='libdrivers_a-tiara.o' libtool=no @AMDEPBACKSLASH@
  2963. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2964. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-tiara.o `test -f 'tiara.c' || echo '$(srcdir)/'`tiara.c
  2965. -
  2966. -libdrivers_a-tiara.obj: tiara.c
  2967. -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-tiara.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-tiara.Tpo" -c -o libdrivers_a-tiara.obj `if test -f 'tiara.c'; then $(CYGPATH_W) 'tiara.c'; else $(CYGPATH_W) '$(srcdir)/tiara.c'; fi`; \
  2968. -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-tiara.Tpo" "$(DEPDIR)/libdrivers_a-tiara.Po"; else rm -f "$(DEPDIR)/libdrivers_a-tiara.Tpo"; exit 1; fi
  2969. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tiara.c' object='libdrivers_a-tiara.obj' libtool=no @AMDEPBACKSLASH@
  2970. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2971. -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-tiara.obj `if test -f 'tiara.c'; then $(CYGPATH_W) 'tiara.c'; else $(CYGPATH_W) '$(srcdir)/tiara.c'; fi`
  2972. +libdrivers_a-tg3.o: tg3.c
  2973. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-tg3.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-tg3.Tpo" -c -o libdrivers_a-tg3.o `test -f 'tg3.c' || echo '$(srcdir)/'`tg3.c; \
  2974. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-tg3.Tpo" "$(DEPDIR)/libdrivers_a-tg3.Po"; else rm -f "$(DEPDIR)/libdrivers_a-tg3.Tpo"; exit 1; fi
  2975. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tg3.c' object='libdrivers_a-tg3.o' libtool=no @AMDEPBACKSLASH@
  2976. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-tg3.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-tg3.TPo' @AMDEPBACKSLASH@
  2977. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2978. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-tg3.o `test -f 'tg3.c' || echo '$(srcdir)/'`tg3.c
  2979. +
  2980. +libdrivers_a-tg3.obj: tg3.c
  2981. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-tg3.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-tg3.Tpo" -c -o libdrivers_a-tg3.obj `if test -f 'tg3.c'; then $(CYGPATH_W) 'tg3.c'; else $(CYGPATH_W) '$(srcdir)/tg3.c'; fi`; \
  2982. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-tg3.Tpo" "$(DEPDIR)/libdrivers_a-tg3.Po"; else rm -f "$(DEPDIR)/libdrivers_a-tg3.Tpo"; exit 1; fi
  2983. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tg3.c' object='libdrivers_a-tg3.obj' libtool=no @AMDEPBACKSLASH@
  2984. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-tg3.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-tg3.TPo' @AMDEPBACKSLASH@
  2985. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2986. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-tg3.obj `if test -f 'tg3.c'; then $(CYGPATH_W) 'tg3.c'; else $(CYGPATH_W) '$(srcdir)/tg3.c'; fi`
  2987. libdrivers_a-tlan.o: tlan.c
  2988. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-tlan.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-tlan.Tpo" -c -o libdrivers_a-tlan.o `test -f 'tlan.c' || echo '$(srcdir)/'`tlan.c; \
  2989. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-tlan.Tpo" "$(DEPDIR)/libdrivers_a-tlan.Po"; else rm -f "$(DEPDIR)/libdrivers_a-tlan.Tpo"; exit 1; fi
  2990. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tlan.c' object='libdrivers_a-tlan.o' libtool=no @AMDEPBACKSLASH@
  2991. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2992. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-tlan.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-tlan.TPo' @AMDEPBACKSLASH@
  2993. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  2994. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-tlan.o `test -f 'tlan.c' || echo '$(srcdir)/'`tlan.c
  2995. libdrivers_a-tlan.obj: tlan.c
  2996. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-tlan.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-tlan.Tpo" -c -o libdrivers_a-tlan.obj `if test -f 'tlan.c'; then $(CYGPATH_W) 'tlan.c'; else $(CYGPATH_W) '$(srcdir)/tlan.c'; fi`; \
  2997. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-tlan.Tpo" "$(DEPDIR)/libdrivers_a-tlan.Po"; else rm -f "$(DEPDIR)/libdrivers_a-tlan.Tpo"; exit 1; fi
  2998. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tlan.c' object='libdrivers_a-tlan.obj' libtool=no @AMDEPBACKSLASH@
  2999. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3000. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-tlan.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-tlan.TPo' @AMDEPBACKSLASH@
  3001. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3002. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-tlan.obj `if test -f 'tlan.c'; then $(CYGPATH_W) 'tlan.c'; else $(CYGPATH_W) '$(srcdir)/tlan.c'; fi`
  3003. libdrivers_a-tulip.o: tulip.c
  3004. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-tulip.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-tulip.Tpo" -c -o libdrivers_a-tulip.o `test -f 'tulip.c' || echo '$(srcdir)/'`tulip.c; \
  3005. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-tulip.Tpo" "$(DEPDIR)/libdrivers_a-tulip.Po"; else rm -f "$(DEPDIR)/libdrivers_a-tulip.Tpo"; exit 1; fi
  3006. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tulip.c' object='libdrivers_a-tulip.o' libtool=no @AMDEPBACKSLASH@
  3007. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3008. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-tulip.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-tulip.TPo' @AMDEPBACKSLASH@
  3009. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3010. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-tulip.o `test -f 'tulip.c' || echo '$(srcdir)/'`tulip.c
  3011. libdrivers_a-tulip.obj: tulip.c
  3012. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-tulip.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-tulip.Tpo" -c -o libdrivers_a-tulip.obj `if test -f 'tulip.c'; then $(CYGPATH_W) 'tulip.c'; else $(CYGPATH_W) '$(srcdir)/tulip.c'; fi`; \
  3013. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-tulip.Tpo" "$(DEPDIR)/libdrivers_a-tulip.Po"; else rm -f "$(DEPDIR)/libdrivers_a-tulip.Tpo"; exit 1; fi
  3014. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tulip.c' object='libdrivers_a-tulip.obj' libtool=no @AMDEPBACKSLASH@
  3015. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3016. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-tulip.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-tulip.TPo' @AMDEPBACKSLASH@
  3017. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3018. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-tulip.obj `if test -f 'tulip.c'; then $(CYGPATH_W) 'tulip.c'; else $(CYGPATH_W) '$(srcdir)/tulip.c'; fi`
  3019. libdrivers_a-via-rhine.o: via-rhine.c
  3020. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-via-rhine.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-via-rhine.Tpo" -c -o libdrivers_a-via-rhine.o `test -f 'via-rhine.c' || echo '$(srcdir)/'`via-rhine.c; \
  3021. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-via-rhine.Tpo" "$(DEPDIR)/libdrivers_a-via-rhine.Po"; else rm -f "$(DEPDIR)/libdrivers_a-via-rhine.Tpo"; exit 1; fi
  3022. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='via-rhine.c' object='libdrivers_a-via-rhine.o' libtool=no @AMDEPBACKSLASH@
  3023. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3024. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-via-rhine.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-via-rhine.TPo' @AMDEPBACKSLASH@
  3025. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3026. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-via-rhine.o `test -f 'via-rhine.c' || echo '$(srcdir)/'`via-rhine.c
  3027. libdrivers_a-via-rhine.obj: via-rhine.c
  3028. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-via-rhine.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-via-rhine.Tpo" -c -o libdrivers_a-via-rhine.obj `if test -f 'via-rhine.c'; then $(CYGPATH_W) 'via-rhine.c'; else $(CYGPATH_W) '$(srcdir)/via-rhine.c'; fi`; \
  3029. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-via-rhine.Tpo" "$(DEPDIR)/libdrivers_a-via-rhine.Po"; else rm -f "$(DEPDIR)/libdrivers_a-via-rhine.Tpo"; exit 1; fi
  3030. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='via-rhine.c' object='libdrivers_a-via-rhine.obj' libtool=no @AMDEPBACKSLASH@
  3031. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3032. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-via-rhine.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-via-rhine.TPo' @AMDEPBACKSLASH@
  3033. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3034. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-via-rhine.obj `if test -f 'via-rhine.c'; then $(CYGPATH_W) 'via-rhine.c'; else $(CYGPATH_W) '$(srcdir)/via-rhine.c'; fi`
  3035. libdrivers_a-w89c840.o: w89c840.c
  3036. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-w89c840.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-w89c840.Tpo" -c -o libdrivers_a-w89c840.o `test -f 'w89c840.c' || echo '$(srcdir)/'`w89c840.c; \
  3037. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-w89c840.Tpo" "$(DEPDIR)/libdrivers_a-w89c840.Po"; else rm -f "$(DEPDIR)/libdrivers_a-w89c840.Tpo"; exit 1; fi
  3038. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='w89c840.c' object='libdrivers_a-w89c840.o' libtool=no @AMDEPBACKSLASH@
  3039. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3040. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-w89c840.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-w89c840.TPo' @AMDEPBACKSLASH@
  3041. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3042. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-w89c840.o `test -f 'w89c840.c' || echo '$(srcdir)/'`w89c840.c
  3043. libdrivers_a-w89c840.obj: w89c840.c
  3044. @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-w89c840.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-w89c840.Tpo" -c -o libdrivers_a-w89c840.obj `if test -f 'w89c840.c'; then $(CYGPATH_W) 'w89c840.c'; else $(CYGPATH_W) '$(srcdir)/w89c840.c'; fi`; \
  3045. @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-w89c840.Tpo" "$(DEPDIR)/libdrivers_a-w89c840.Po"; else rm -f "$(DEPDIR)/libdrivers_a-w89c840.Tpo"; exit 1; fi
  3046. @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='w89c840.c' object='libdrivers_a-w89c840.obj' libtool=no @AMDEPBACKSLASH@
  3047. -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3048. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-w89c840.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-w89c840.TPo' @AMDEPBACKSLASH@
  3049. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3050. @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-w89c840.obj `if test -f 'w89c840.c'; then $(CYGPATH_W) 'w89c840.c'; else $(CYGPATH_W) '$(srcdir)/w89c840.c'; fi`
  3051. -uninstall-info-am:
  3052. +
  3053. +libdrivers_a-r8169.o: r8169.c
  3054. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-r8169.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-r8169.Tpo" -c -o libdrivers_a-r8169.o `test -f 'r8169.c' || echo '$(srcdir)/'`r8169.c; \
  3055. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-r8169.Tpo" "$(DEPDIR)/libdrivers_a-r8169.Po"; else rm -f "$(DEPDIR)/libdrivers_a-r8169.Tpo"; exit 1; fi
  3056. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='r8169.c' object='libdrivers_a-r8169.o' libtool=no @AMDEPBACKSLASH@
  3057. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-r8169.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-r8169.TPo' @AMDEPBACKSLASH@
  3058. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3059. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-r8169.o `test -f 'r8169.c' || echo '$(srcdir)/'`r8169.c
  3060. +
  3061. +libdrivers_a-r8169.obj: r8169.c
  3062. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-r8169.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-r8169.Tpo" -c -o libdrivers_a-r8169.obj `if test -f 'r8169.c'; then $(CYGPATH_W) 'r8169.c'; else $(CYGPATH_W) '$(srcdir)/r8169.c'; fi`; \
  3063. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-r8169.Tpo" "$(DEPDIR)/libdrivers_a-r8169.Po"; else rm -f "$(DEPDIR)/libdrivers_a-r8169.Tpo"; exit 1; fi
  3064. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='r8169.c' object='libdrivers_a-r8169.obj' libtool=no @AMDEPBACKSLASH@
  3065. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-r8169.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-r8169.TPo' @AMDEPBACKSLASH@
  3066. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3067. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-r8169.obj `if test -f 'r8169.c'; then $(CYGPATH_W) 'r8169.c'; else $(CYGPATH_W) '$(srcdir)/r8169.c'; fi`
  3068. +
  3069. +libdrivers_a-forcedeth.o: forcedeth.c
  3070. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-forcedeth.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-forcedeth.Tpo" -c -o libdrivers_a-forcedeth.o `test -f 'forcedeth.c' || echo '$(srcdir)/'`forcedeth.c; \
  3071. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-forcedeth.Tpo" "$(DEPDIR)/libdrivers_a-forcedeth.Po"; else rm -f "$(DEPDIR)/libdrivers_a-forcedeth.Tpo"; exit 1; fi
  3072. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='forcedeth.c' object='libdrivers_a-forcedeth.o' libtool=no @AMDEPBACKSLASH@
  3073. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-forcedeth.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-forcedeth.TPo' @AMDEPBACKSLASH@
  3074. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3075. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-forcedeth.o `test -f 'forcedeth.c' || echo '$(srcdir)/'`forcedeth.c
  3076. +
  3077. +libdrivers_a-forcedeth.obj: forcedeth.c
  3078. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-forcedeth.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-forcedeth.Tpo" -c -o libdrivers_a-forcedeth.obj `if test -f 'forcedeth.c'; then $(CYGPATH_W) 'forcedeth.c'; else $(CYGPATH_W) '$(srcdir)/forcedeth.c'; fi`; \
  3079. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-forcedeth.Tpo" "$(DEPDIR)/libdrivers_a-forcedeth.Po"; else rm -f "$(DEPDIR)/libdrivers_a-forcedeth.Tpo"; exit 1; fi
  3080. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='forcedeth.c' object='libdrivers_a-forcedeth.obj' libtool=no @AMDEPBACKSLASH@
  3081. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-forcedeth.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-forcedeth.TPo' @AMDEPBACKSLASH@
  3082. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3083. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-forcedeth.obj `if test -f 'forcedeth.c'; then $(CYGPATH_W) 'forcedeth.c'; else $(CYGPATH_W) '$(srcdir)/forcedeth.c'; fi`
  3084. +
  3085. +libdrivers_a-ns83820.o: ns83820.c
  3086. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-ns83820.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-ns83820.Tpo" -c -o libdrivers_a-ns83820.o `test -f 'ns83820.c' || echo '$(srcdir)/'`ns83820.c; \
  3087. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-ns83820.Tpo" "$(DEPDIR)/libdrivers_a-ns83820.Po"; else rm -f "$(DEPDIR)/libdrivers_a-ns83820.Tpo"; exit 1; fi
  3088. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ns83820.c' object='libdrivers_a-ns83820.o' libtool=no @AMDEPBACKSLASH@
  3089. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-ns83820.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-ns83820.TPo' @AMDEPBACKSLASH@
  3090. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3091. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-ns83820.o `test -f 'ns83820.c' || echo '$(srcdir)/'`ns83820.c
  3092. +
  3093. +libdrivers_a-ns83820.obj: ns83820.c
  3094. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-ns83820.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-ns83820.Tpo" -c -o libdrivers_a-ns83820.obj `if test -f 'ns83820.c'; then $(CYGPATH_W) 'ns83820.c'; else $(CYGPATH_W) '$(srcdir)/ns83820.c'; fi`; \
  3095. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-ns83820.Tpo" "$(DEPDIR)/libdrivers_a-ns83820.Po"; else rm -f "$(DEPDIR)/libdrivers_a-ns83820.Tpo"; exit 1; fi
  3096. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ns83820.c' object='libdrivers_a-ns83820.obj' libtool=no @AMDEPBACKSLASH@
  3097. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-ns83820.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-ns83820.TPo' @AMDEPBACKSLASH@
  3098. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3099. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-ns83820.obj `if test -f 'ns83820.c'; then $(CYGPATH_W) 'ns83820.c'; else $(CYGPATH_W) '$(srcdir)/ns83820.c'; fi`
  3100. +
  3101. +libdrivers_a-pnic.o: pnic.c
  3102. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-pnic.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-pnic.Tpo" -c -o libdrivers_a-pnic.o `test -f 'pnic.c' || echo '$(srcdir)/'`pnic.c; \
  3103. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-pnic.Tpo" "$(DEPDIR)/libdrivers_a-pnic.Po"; else rm -f "$(DEPDIR)/libdrivers_a-pnic.Tpo"; exit 1; fi
  3104. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pnic.c' object='libdrivers_a-pnic.o' libtool=no @AMDEPBACKSLASH@
  3105. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-pnic.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-pnic.TPo' @AMDEPBACKSLASH@
  3106. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3107. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-pnic.o `test -f 'pnic.c' || echo '$(srcdir)/'`pnic.c
  3108. +
  3109. +libdrivers_a-pnic.obj: pnic.c
  3110. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-pnic.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-pnic.Tpo" -c -o libdrivers_a-pnic.obj `if test -f 'pnic.c'; then $(CYGPATH_W) 'pnic.c'; else $(CYGPATH_W) '$(srcdir)/pnic.c'; fi`; \
  3111. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-pnic.Tpo" "$(DEPDIR)/libdrivers_a-pnic.Po"; else rm -f "$(DEPDIR)/libdrivers_a-pnic.Tpo"; exit 1; fi
  3112. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pnic.c' object='libdrivers_a-pnic.obj' libtool=no @AMDEPBACKSLASH@
  3113. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-pnic.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-pnic.TPo' @AMDEPBACKSLASH@
  3114. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3115. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-pnic.obj `if test -f 'pnic.c'; then $(CYGPATH_W) 'pnic.c'; else $(CYGPATH_W) '$(srcdir)/pnic.c'; fi`
  3116. +
  3117. +libdrivers_a-pnic_api.o: pnic_api.c
  3118. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-pnic_api.o -MD -MP -MF "$(DEPDIR)/libdrivers_a-pnic_api.Tpo" -c -o libdrivers_a-pnic_api.o `test -f 'pnic_api.c' || echo '$(srcdir)/'`pnic_api.c; \
  3119. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-pnic_api.Tpo" "$(DEPDIR)/libdrivers_a-pnic_api.Po"; else rm -f "$(DEPDIR)/libdrivers_a-pnic_api.Tpo"; exit 1; fi
  3120. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pnic_api.c' object='libdrivers_a-pnic_api.o' libtool=no @AMDEPBACKSLASH@
  3121. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-pnic_api.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-pnic_api.TPo' @AMDEPBACKSLASH@
  3122. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3123. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-pnic_api.o `test -f 'pnic_api.c' || echo '$(srcdir)/'`pnic_api.c
  3124. +
  3125. +libdrivers_a-pnic_api.obj: pnic_api.c
  3126. +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -MT libdrivers_a-pnic_api.obj -MD -MP -MF "$(DEPDIR)/libdrivers_a-pnic_api.Tpo" -c -o libdrivers_a-pnic_api.obj `if test -f 'pnic_api.c'; then $(CYGPATH_W) 'pnic_api.c'; else $(CYGPATH_W) '$(srcdir)/pnic_api.c'; fi`; \
  3127. +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libdrivers_a-pnic_api.Tpo" "$(DEPDIR)/libdrivers_a-pnic_api.Po"; else rm -f "$(DEPDIR)/libdrivers_a-pnic_api.Tpo"; exit 1; fi
  3128. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pnic_api.c' object='libdrivers_a-pnic_api.obj' libtool=no @AMDEPBACKSLASH@
  3129. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/libdrivers_a-pnic_api.Po' tmpdepfile='$(DEPDIR)/libdrivers_a-pnic_api.TPo' @AMDEPBACKSLASH@
  3130. +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  3131. +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libdrivers_a_CFLAGS) $(CFLAGS) -c -o libdrivers_a-pnic_api.obj `if test -f 'pnic_api.c'; then $(CYGPATH_W) 'pnic_api.c'; else $(CYGPATH_W) '$(srcdir)/pnic_api.c'; fi`
  3132. ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
  3133. list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
  3134. @@ -817,11 +927,9 @@
  3135. done | \
  3136. $(AWK) ' { files[$$0] = 1; } \
  3137. END { for (i in files) print i; }'`; \
  3138. - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
  3139. - test -n "$$unique" || unique=$$empty_fix; \
  3140. - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
  3141. - $$tags $$unique; \
  3142. - fi
  3143. + test -z "$(ETAGS_ARGS)$$tags$$unique" \
  3144. + || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
  3145. + $$tags $$unique
  3146. ctags: CTAGS
  3147. CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
  3148. $(TAGS_FILES) $(LISP)
  3149. @@ -895,7 +1003,7 @@
  3150. clean-generic:
  3151. distclean-generic:
  3152. - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
  3153. + -rm -f $(CONFIG_CLEAN_FILES)
  3154. maintainer-clean-generic:
  3155. @echo "This command is intended for maintainers to use"
  3156. @@ -962,10 +1070,10 @@
  3157. # Is it really necessary to specify dependecies explicitly?
  3158. -$(3c509_drivers): 3c509.c 3c509.h
  3159. -$(3c509_drivers): %.o: 3c509.c
  3160. - $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3161. - $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3162. +#$(3c509_drivers): 3c509.c 3c509.h
  3163. +#$(3c509_drivers): %.o: 3c509.c
  3164. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3165. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3166. $(3c595_drivers): 3c595.c 3c595.h
  3167. $(3c595_drivers): %.o: 3c595.c
  3168. @@ -977,23 +1085,28 @@
  3169. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3170. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3171. -$(cs89x0_drivers): cs89x0.c cs89x0.h
  3172. -$(cs89x0_drivers): %.o: cs89x0.c
  3173. - $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3174. - $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3175. +#$(cs89x0_drivers): cs89x0.c cs89x0.h
  3176. +#$(cs89x0_drivers): %.o: cs89x0.c
  3177. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3178. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3179. $(davicom_drivers): davicom.c
  3180. $(davicom_drivers): %.o: davicom.c
  3181. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3182. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3183. -$(depca_drivers): depca.c
  3184. -$(depca_drivers): %.o: depca.c
  3185. - $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3186. - $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3187. +#$(depca_drivers): depca.c
  3188. +#$(depca_drivers): %.o: depca.c
  3189. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3190. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3191. -$(eepro_drivers): eepro.c
  3192. -$(eepro_drivers): %.o: eepro.c
  3193. +#$(eepro_drivers): eepro.c
  3194. +#$(eepro_drivers): %.o: eepro.c
  3195. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3196. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3197. +
  3198. +$(e1000_drivers): e1000.c e1000_hw.h
  3199. +$(e1000_drivers): %.o: e1000.c
  3200. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3201. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3202. @@ -1007,28 +1120,38 @@
  3203. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3204. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3205. +$(forcedeth_drivers): forcedeth.c
  3206. +$(forcedeth_drivers): %.o: forcedeth.c
  3207. + $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3208. + $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3209. +
  3210. #$(fa311_drivers): fa311.c
  3211. #$(fa311_drivers): %.o: fa311.c
  3212. # $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3213. # $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3214. -$(i82586_drivers): i82586.c
  3215. -$(i82586_drivers): %.o: i82586.c
  3216. - $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3217. - $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3218. +#$(i82586_drivers): i82586.c
  3219. +#$(i82586_drivers): %.o: i82586.c
  3220. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3221. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3222. -$(lance_drivers): lance.c
  3223. -$(lance_drivers): %.o: lance.c
  3224. - $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3225. - $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3226. +#$(lance_drivers): lance.c
  3227. +#$(lance_drivers): %.o: lance.c
  3228. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3229. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3230. $(natsemi_drivers): natsemi.c
  3231. $(natsemi_drivers): %.o: natsemi.c
  3232. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3233. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3234. -$(ni5010_drivers): ni5010.c
  3235. -$(ni5010_drivers): %.o: ni5010.c
  3236. +#$(ni5010_drivers): ni5010.c
  3237. +#$(ni5010_drivers): %.o: ni5010.c
  3238. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3239. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3240. +
  3241. +$(ns83820_drivers): ns83820.c
  3242. +$(ns83820_drivers): %.o: ns83820.c
  3243. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3244. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3245. @@ -1037,41 +1160,62 @@
  3246. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3247. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3248. -$(otulip_drivers): otulip.c otulip.h
  3249. -$(otulip_drivers): %.o: otulip.c
  3250. +#$(otulip_drivers): otulip.c otulip.h
  3251. +#$(otulip_drivers): %.o: otulip.c
  3252. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3253. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3254. +
  3255. +$(pcnet32_drivers): pcnet32.c
  3256. +$(pcnet32_drivers): %.o: pcnet32.c
  3257. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3258. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3259. -$(rtl8139_drivers): rtl8139.c
  3260. -$(rtl8139_drivers): %.o: rtl8139.c
  3261. +$(pnic_drivers): pnic.c
  3262. +$(pnic_drivers): %.o: pnic.c pnic_api.h
  3263. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3264. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3265. -$(sis900_drivers): sis900.c
  3266. -$(sis900_drivers): %.o: sis900.c sis900.h
  3267. +$(rtl8139_drivers): rtl8139.c
  3268. +$(rtl8139_drivers): %.o: rtl8139.c
  3269. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3270. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3271. -$(sk_g16_drivers): sk_g16.c sk_g16.h
  3272. -$(sk_g16_drivers): %.o: sk_g16.c
  3273. +$(r8169_drivers): r8169.c
  3274. +$(r8169_drivers): %.o: r8169.c
  3275. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3276. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3277. -$(smc9000_drivers): smc9000.c smc9000.h
  3278. -$(smc9000_drivers): %.o: smc9000.c
  3279. +$(sis900_drivers): sis900.c sis900.h
  3280. +$(sis900_drivers): %.o: sis900.c
  3281. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3282. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3283. -$(tiara_drivers): tiara.c
  3284. -$(tiara_drivers): %.o: tiara.c
  3285. +#$(sk_g16_drivers): sk_g16.c sk_g16.h
  3286. +#$(sk_g16_drivers): %.o: sk_g16.c
  3287. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3288. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3289. +
  3290. +#$(smc9000_drivers): smc9000.c smc9000.h
  3291. +#$(smc9000_drivers): %.o: smc9000.c
  3292. +# $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3293. +# $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3294. +
  3295. +
  3296. +$(tg3_drivers): tg3.c tg3.h
  3297. +$(tg3_drivers): %.o: tg3.c
  3298. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3299. $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3300. -#$(tlan_drivers): tlan.c
  3301. -#$(tlan_drivers): %.o: tlan.c
  3302. +#$(tiara_drivers): tiara.c
  3303. +#$(tiara_drivers): %.o: tiara.c
  3304. # $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3305. # $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3306. +$(tlan_drivers): tlan.c tlan.h
  3307. +$(tlan_drivers): %.o: tlan.c
  3308. + $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3309. + $(NET_EXTRAFLAGS) $($(basename $@)_o_CFLAGS) -o $@ -c $<
  3310. +
  3311. $(tulip_drivers): tulip.c
  3312. $(tulip_drivers): %.o: tulip.c
  3313. $(COMPILE) $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
  3314. diff -Naur grub-0.97.orig/netboot/basemem.c grub-0.97/netboot/basemem.c
  3315. --- grub-0.97.orig/netboot/basemem.c 1970-01-01 00:00:00.000000000 +0000
  3316. +++ grub-0.97/netboot/basemem.c 2005-08-31 19:24:28.000000000 +0000
  3317. @@ -0,0 +1,178 @@
  3318. +#include "etherboot.h"
  3319. +#define DEBUG_BASEMEM
  3320. +/* Routines to allocate base memory in a BIOS-compatible way, by
  3321. + * updating the Free Base Memory Size counter at 40:13h.
  3322. + *
  3323. + * Michael Brown <mbrown@fensystems.co.uk> (mcb30)
  3324. + * $Id: grub-0.95-diskless-patch-2-undi.patch,v 1.1.1.1 2005/06/14 08:18:50 wesolows Exp $
  3325. + */
  3326. +
  3327. +#define fbms ( ( uint16_t * ) phys_to_virt ( 0x413 ) )
  3328. +#define BASE_MEMORY_MAX ( 640 )
  3329. +#define FREE_BLOCK_MAGIC ( ('!'<<0) + ('F'<<8) + ('R'<<16) + ('E'<<24) )
  3330. +
  3331. +typedef struct free_base_memory_block {
  3332. + uint32_t magic;
  3333. + uint16_t size_kb;
  3334. +} free_base_memory_block_t;
  3335. +
  3336. +/* Return amount of free base memory in bytes
  3337. + */
  3338. +
  3339. +uint32_t get_free_base_memory ( void ) {
  3340. + return *fbms << 10;
  3341. +}
  3342. +
  3343. +/* Adjust the real mode stack pointer. We keep the real mode stack at
  3344. + * the top of free base memory, rather than allocating space for it.
  3345. + */
  3346. +
  3347. +inline void adjust_real_mode_stack ( void ) {
  3348. +/* real_mode_stack = ( *fbms << 10 ); */
  3349. +}
  3350. +
  3351. +/* Allocate N bytes of base memory. Amount allocated will be rounded
  3352. + * up to the nearest kB, since that's the granularity of the BIOS FBMS
  3353. + * counter. Returns NULL if memory cannot be allocated.
  3354. + */
  3355. +
  3356. +void * allot_base_memory ( size_t size ) {
  3357. + uint16_t size_kb = ( size + 1023 ) >> 10;
  3358. + void *ptr = NULL;
  3359. +
  3360. +#ifdef DEBUG_BASEMEM
  3361. + printf ( "Trying to allocate %d kB of base memory, %d kB free\n",
  3362. + size_kb, *fbms );
  3363. +#endif
  3364. +
  3365. + /* Free up any unused memory before we start */
  3366. + free_unused_base_memory();
  3367. +
  3368. + /* Check available base memory */
  3369. + if ( size_kb > *fbms ) { return NULL; }
  3370. +
  3371. + /* Reduce available base memory */
  3372. + *fbms -= size_kb;
  3373. +
  3374. + /* Calculate address of memory allocated */
  3375. + ptr = phys_to_virt ( *fbms << 10 );
  3376. +
  3377. +#ifdef DEBUG_BASEMEM
  3378. + /* Zero out memory. We do this so that allocation of
  3379. + * already-used space will show up in the form of a crash as
  3380. + * soon as possible.
  3381. + */
  3382. + memset ( ptr, 0, size_kb << 10 );
  3383. +#endif
  3384. +
  3385. + /* Adjust real mode stack pointer */
  3386. + adjust_real_mode_stack ();
  3387. +
  3388. + return ptr;
  3389. +}
  3390. +
  3391. +/* Free base memory allocated by allot_base_memory. The BIOS provides
  3392. + * nothing better than a LIFO mechanism for freeing memory (i.e. it
  3393. + * just has the single "total free memory" counter), but we improve
  3394. + * upon this slightly; as long as you free all the allotted blocks, it
  3395. + * doesn't matter what order you free them in. (This will only work
  3396. + * for blocks that are freed via forget_base_memory()).
  3397. + *
  3398. + * Yes, it's annoying that you have to remember the size of the blocks
  3399. + * you've allotted. However, since our granularity of allocation is
  3400. + * 1K, the alternative is to risk wasting the occasional kB of base
  3401. + * memory, which is a Bad Thing. Really, you should be using as
  3402. + * little base memory as possible, so consider the awkwardness of the
  3403. + * API to be a feature! :-)
  3404. + */
  3405. +
  3406. +void forget_base_memory ( void *ptr, size_t size ) {
  3407. + uint16_t remainder = virt_to_phys(ptr) & 1023;
  3408. + uint16_t size_kb = ( size + remainder + 1023 ) >> 10;
  3409. + free_base_memory_block_t *free_block =
  3410. + ( free_base_memory_block_t * ) ( ptr - remainder );
  3411. +
  3412. + if ( ( ptr == NULL ) || ( size == 0 ) ) { return; }
  3413. +
  3414. +#ifdef DEBUG_BASEMEM
  3415. + printf ( "Trying to free %d bytes base memory at 0x%x\n",
  3416. + size, virt_to_phys ( ptr ) );
  3417. + if ( remainder > 0 ) {
  3418. + printf ( "WARNING: destructively expanding free block "
  3419. + "downwards to 0x%x\n",
  3420. + virt_to_phys ( ptr - remainder ) );
  3421. + }
  3422. +#endif
  3423. +
  3424. + /* Mark every kilobyte within this block as free. This is
  3425. + * overkill for normal purposes, but helps when something has
  3426. + * allocated base memory with a granularity finer than the
  3427. + * BIOS granularity of 1kB. PXE ROMs tend to do this when
  3428. + * they allocate their own memory. This method allows us to
  3429. + * free their blocks (admittedly in a rather dangerous,
  3430. + * tread-on-anything-either-side sort of way, but there's no
  3431. + * other way to do it).
  3432. + *
  3433. + * Since we're marking every kB as free, there's actually no
  3434. + * need for recording the size of the blocks. However, we
  3435. + * keep this in so that debug messages are friendlier. It
  3436. + * probably adds around 8 bytes to the overall code size.
  3437. + */
  3438. + while ( size_kb > 0 ) {
  3439. + /* Mark this block as unused */
  3440. + free_block->magic = FREE_BLOCK_MAGIC;
  3441. + free_block->size_kb = size_kb;
  3442. + /* Move up by 1 kB */
  3443. + (void *)(free_block += ( 1 << 10 ));
  3444. + size_kb--;
  3445. + }
  3446. +
  3447. + /* Free up unused base memory */
  3448. + free_unused_base_memory();
  3449. +}
  3450. +
  3451. +/* Do the actual freeing of memory. This is split out from
  3452. + * forget_base_memory() so that it may be called separately. It
  3453. + * should be called whenever base memory is deallocated by an external
  3454. + * entity (if we can detect that it has done so) so that we get the
  3455. + * chance to free up our own blocks.
  3456. + */
  3457. +void free_unused_base_memory ( void ) {
  3458. + free_base_memory_block_t *free_block = NULL;
  3459. +
  3460. + /* Try to release memory back to the BIOS. Free all
  3461. + * consecutive blocks marked as free.
  3462. + */
  3463. + while ( 1 ) {
  3464. + /* Calculate address of next potential free block */
  3465. + free_block = ( free_base_memory_block_t * )
  3466. + phys_to_virt ( *fbms << 10 );
  3467. +
  3468. + /* Stop processing if we're all the way up to 640K or
  3469. + * if this is not a free block
  3470. + */
  3471. + if ( ( *fbms == BASE_MEMORY_MAX ) ||
  3472. + ( free_block->magic != FREE_BLOCK_MAGIC ) ) {
  3473. + break;
  3474. + }
  3475. +
  3476. + /* Return memory to BIOS */
  3477. + *fbms += free_block->size_kb;
  3478. +
  3479. +#ifdef DEBUG_BASEMEM
  3480. + printf ( "Freed %d kB base memory, %d kB now free\n",
  3481. + free_block->size_kb, *fbms );
  3482. +
  3483. + /* Zero out freed block. We do this in case
  3484. + * the block contained any structures that
  3485. + * might be located by scanning through
  3486. + * memory.
  3487. + */
  3488. + memset ( free_block, 0, free_block->size_kb << 10 );
  3489. +#endif
  3490. + }
  3491. +
  3492. + /* Adjust real mode stack pointer */
  3493. + adjust_real_mode_stack ();
  3494. +}
  3495. +
  3496. diff -Naur grub-0.97.orig/netboot/big_bswap.h grub-0.97/netboot/big_bswap.h
  3497. --- grub-0.97.orig/netboot/big_bswap.h 1970-01-01 00:00:00.000000000 +0000
  3498. +++ grub-0.97/netboot/big_bswap.h 2005-08-31 19:03:35.000000000 +0000
  3499. @@ -0,0 +1,17 @@
  3500. +#ifndef ETHERBOOT_BIG_BSWAP_H
  3501. +#define ETHERBOOT_BIG_BSWAP_H
  3502. +
  3503. +#define ntohl(x) (x)
  3504. +#define htonl(x) (x)
  3505. +#define ntohs(x) (x)
  3506. +#define htons(x) (x)
  3507. +#define cpu_to_le32(x) __bswap_32(x)
  3508. +#define cpu_to_le16(x) __bswap_16(x)
  3509. +#define cpu_to_be32(x) (x)
  3510. +#define cpu_to_be16(x) (x)
  3511. +#define le32_to_cpu(x) __bswap_32(x)
  3512. +#define le16_to_cpu(x) __bswap_16(x)
  3513. +#define be32_to_cpu(x) (x)
  3514. +#define be16_to_cpu(x) (x)
  3515. +
  3516. +#endif /* ETHERBOOT_BIG_BSWAP_H */
  3517. diff -Naur grub-0.97.orig/netboot/bootp.h grub-0.97/netboot/bootp.h
  3518. --- grub-0.97.orig/netboot/bootp.h 1970-01-01 00:00:00.000000000 +0000
  3519. +++ grub-0.97/netboot/bootp.h 2005-08-31 19:03:35.000000000 +0000
  3520. @@ -0,0 +1,182 @@
  3521. +#ifndef _BOOTP_H
  3522. +#define _BOOTP_H
  3523. +
  3524. +#include "if_ether.h"
  3525. +#include "ip.h"
  3526. +#include "udp.h"
  3527. +
  3528. +#ifndef MAX_BOOTP_RETRIES
  3529. +#define MAX_BOOTP_RETRIES 20
  3530. +#endif
  3531. +
  3532. +#ifdef ALTERNATE_DHCP_PORTS_1067_1068
  3533. +#undef NON_STANDARD_BOOTP_SERVER
  3534. +#define NON_STANDARD_BOOTP_SERVER 1067
  3535. +#undef NON_STANDARD_BOOTP_CLIENT
  3536. +#define NON_STANDARD_BOOTP_CLIENT 1068
  3537. +#endif
  3538. +
  3539. +#ifdef NON_STANDARD_BOOTP_SERVER
  3540. +#define BOOTP_SERVER NON_STANDARD_BOOTP_SERVER
  3541. +#else
  3542. +#define BOOTP_SERVER 67
  3543. +#endif
  3544. +#ifdef NON_STANDARD_BOOTP_CLIENT
  3545. +#define BOOTP_CLIENT NON_STANDARD_BOOTP_CLIENT
  3546. +#else
  3547. +#define BOOTP_CLIENT 68
  3548. +#endif
  3549. +
  3550. +#define BOOTP_REQUEST 1
  3551. +#define BOOTP_REPLY 2
  3552. +
  3553. +#define TAG_LEN(p) (*((p)+1))
  3554. +#define RFC1533_COOKIE 99, 130, 83, 99
  3555. +#define RFC1533_PAD 0
  3556. +#define RFC1533_NETMASK 1
  3557. +#define RFC1533_TIMEOFFSET 2
  3558. +#define RFC1533_GATEWAY 3
  3559. +#define RFC1533_TIMESERVER 4
  3560. +#define RFC1533_IEN116NS 5
  3561. +#define RFC1533_DNS 6
  3562. +#define RFC1533_LOGSERVER 7
  3563. +#define RFC1533_COOKIESERVER 8
  3564. +#define RFC1533_LPRSERVER 9
  3565. +#define RFC1533_IMPRESSSERVER 10
  3566. +#define RFC1533_RESOURCESERVER 11
  3567. +#define RFC1533_HOSTNAME 12
  3568. +#define RFC1533_BOOTFILESIZE 13
  3569. +#define RFC1533_MERITDUMPFILE 14
  3570. +#define RFC1533_DOMAINNAME 15
  3571. +#define RFC1533_SWAPSERVER 16
  3572. +#define RFC1533_ROOTPATH 17
  3573. +#define RFC1533_EXTENSIONPATH 18
  3574. +#define RFC1533_IPFORWARDING 19
  3575. +#define RFC1533_IPSOURCEROUTING 20
  3576. +#define RFC1533_IPPOLICYFILTER 21
  3577. +#define RFC1533_IPMAXREASSEMBLY 22
  3578. +#define RFC1533_IPTTL 23
  3579. +#define RFC1533_IPMTU 24
  3580. +#define RFC1533_IPMTUPLATEAU 25
  3581. +#define RFC1533_INTMTU 26
  3582. +#define RFC1533_INTLOCALSUBNETS 27
  3583. +#define RFC1533_INTBROADCAST 28
  3584. +#define RFC1533_INTICMPDISCOVER 29
  3585. +#define RFC1533_INTICMPRESPOND 30
  3586. +#define RFC1533_INTROUTEDISCOVER 31
  3587. +#define RFC1533_INTROUTESOLICIT 32
  3588. +#define RFC1533_INTSTATICROUTES 33
  3589. +#define RFC1533_LLTRAILERENCAP 34
  3590. +#define RFC1533_LLARPCACHETMO 35
  3591. +#define RFC1533_LLETHERNETENCAP 36
  3592. +#define RFC1533_TCPTTL 37
  3593. +#define RFC1533_TCPKEEPALIVETMO 38
  3594. +#define RFC1533_TCPKEEPALIVEGB 39
  3595. +#define RFC1533_NISDOMAIN 40
  3596. +#define RFC1533_NISSERVER 41
  3597. +#define RFC1533_NTPSERVER 42
  3598. +#define RFC1533_VENDOR 43
  3599. +#define RFC1533_NBNS 44
  3600. +#define RFC1533_NBDD 45
  3601. +#define RFC1533_NBNT 46
  3602. +#define RFC1533_NBSCOPE 47
  3603. +#define RFC1533_XFS 48
  3604. +#define RFC1533_XDM 49
  3605. +#ifndef NO_DHCP_SUPPORT
  3606. +#define RFC2132_REQ_ADDR 50
  3607. +#define RFC2132_MSG_TYPE 53
  3608. +#define RFC2132_SRV_ID 54
  3609. +#define RFC2132_PARAM_LIST 55
  3610. +#define RFC2132_MAX_SIZE 57
  3611. +#define RFC2132_VENDOR_CLASS_ID 60
  3612. +
  3613. +#define DHCPDISCOVER 1
  3614. +#define DHCPOFFER 2
  3615. +#define DHCPREQUEST 3
  3616. +#define DHCPACK 5
  3617. +#endif /* NO_DHCP_SUPPORT */
  3618. +
  3619. +#define RFC1533_VENDOR_MAJOR 0
  3620. +#define RFC1533_VENDOR_MINOR 0
  3621. +
  3622. +#define RFC1533_VENDOR_MAGIC 128
  3623. +#define RFC1533_VENDOR_ADDPARM 129
  3624. +#define RFC1533_VENDOR_ETHDEV 130
  3625. +#ifdef IMAGE_FREEBSD
  3626. +#define RFC1533_VENDOR_HOWTO 132
  3627. +#define RFC1533_VENDOR_KERNEL_ENV 133
  3628. +#endif
  3629. +#define RFC1533_VENDOR_ETHERBOOT_ENCAP 150
  3630. +#define RFC1533_VENDOR_MNUOPTS 160
  3631. +#define RFC1533_VENDOR_NIC_DEV_ID 175
  3632. +#define RFC1533_VENDOR_SELECTION 176
  3633. +#define RFC1533_VENDOR_ARCH 177
  3634. +#define RFC1533_VENDOR_MOTD 184
  3635. +#define RFC1533_VENDOR_NUMOFMOTD 8
  3636. +#define RFC1533_VENDOR_IMG 192
  3637. +#define RFC1533_VENDOR_NUMOFIMG 16
  3638. +
  3639. +#define RFC1533_VENDOR_CONFIGFILE 150
  3640. +
  3641. +#define RFC1533_END 255
  3642. +
  3643. +#define BOOTP_VENDOR_LEN 64
  3644. +
  3645. +#define DHCP_OPT_LEN 312
  3646. +
  3647. +/* Format of a bootp packet */
  3648. +struct bootp_t {
  3649. + uint8_t bp_op;
  3650. + uint8_t bp_htype;
  3651. + uint8_t bp_hlen;
  3652. + uint8_t bp_hops;
  3653. + uint32_t bp_xid;
  3654. + uint16_t bp_secs;
  3655. + uint16_t unused;
  3656. + in_addr bp_ciaddr;
  3657. + in_addr bp_yiaddr;
  3658. + in_addr bp_siaddr;
  3659. + in_addr bp_giaddr;
  3660. + uint8_t bp_hwaddr[16];
  3661. + uint8_t bp_sname[64];
  3662. + char bp_file[128];
  3663. + uint8_t bp_vend[BOOTP_VENDOR_LEN];
  3664. +};
  3665. +
  3666. +struct dhcp_t {
  3667. + uint8_t bp_op;
  3668. + uint8_t bp_htype;
  3669. + uint8_t bp_hlen;
  3670. + uint8_t bp_hops;
  3671. + uint32_t bp_xid;
  3672. + uint16_t bp_secs;
  3673. + uint16_t bp_flag;
  3674. + in_addr bp_ciaddr;
  3675. + in_addr bp_yiaddr;
  3676. + in_addr bp_siaddr;
  3677. + in_addr bp_giaddr;
  3678. + uint8_t bp_hwaddr[16];
  3679. + uint8_t bp_sname[64];
  3680. + char bp_file[128];
  3681. + uint8_t bp_vend[DHCP_OPT_LEN];
  3682. +};
  3683. +
  3684. +/* Format of a bootp IP packet */
  3685. +struct bootpip_t
  3686. +{
  3687. + struct iphdr ip;
  3688. + struct udphdr udp;
  3689. + struct bootp_t bp;
  3690. +};
  3691. +struct dhcpip_t
  3692. +{
  3693. + struct iphdr ip;
  3694. + struct udphdr udp;
  3695. + struct dhcp_t bp;
  3696. +};
  3697. +
  3698. +#define MAX_RFC1533_VENDLEN (ETH_MAX_MTU - sizeof(struct bootpip_t) + BOOTP_VENDOR_LEN)
  3699. +
  3700. +#define BOOTP_DATA_ADDR (&bootp_data)
  3701. +
  3702. +#endif /* _BOOTP_H */
  3703. diff -Naur grub-0.97.orig/netboot/byteswap.h grub-0.97/netboot/byteswap.h
  3704. --- grub-0.97.orig/netboot/byteswap.h 1970-01-01 00:00:00.000000000 +0000
  3705. +++ grub-0.97/netboot/byteswap.h 2005-08-31 19:03:35.000000000 +0000
  3706. @@ -0,0 +1,20 @@
  3707. +#ifndef ETHERBOOT_BYTESWAP_H
  3708. +#define ETHERBOOT_BYTESWAP_H
  3709. +
  3710. +#include "endian.h"
  3711. +#include "i386_byteswap.h"
  3712. +
  3713. +#if __BYTE_ORDER == __LITTLE_ENDIAN
  3714. +#include "little_bswap.h"
  3715. +#endif
  3716. +#if __BYTE_ORDER == __BIG_ENDIAN
  3717. +#include "big_bswap.h"
  3718. +#endif
  3719. +
  3720. +/* Make routines available to all */
  3721. +#define swap32(x) __bswap_32(x)
  3722. +#define swap16(x) __bswap_16(x)
  3723. +#define bswap_32(x) __bswap_32(x)
  3724. +#define bswap_16(x) __bswap_16(x)
  3725. +
  3726. +#endif /* ETHERBOOT_BYTESWAP_H */
  3727. diff -Naur grub-0.97.orig/netboot/cards.h grub-0.97/netboot/cards.h
  3728. --- grub-0.97.orig/netboot/cards.h 2003-07-09 11:45:37.000000000 +0000
  3729. +++ grub-0.97/netboot/cards.h 1970-01-01 00:00:00.000000000 +0000
  3730. @@ -1,183 +0,0 @@
  3731. -#ifndef CARDS_H
  3732. -#define CARDS_H
  3733. -
  3734. -/*
  3735. - * This program is free software; you can redistribute it and/or
  3736. - * modify it under the terms of the GNU General Public License as
  3737. - * published by the Free Software Foundation; either version 2, or (at
  3738. - * your option) any later version.
  3739. - */
  3740. -
  3741. -#include "nic.h"
  3742. -
  3743. -/* OK, this is how the PCI support hack works: if pci.h is included before
  3744. - * this file is included, assume that the driver supports PCI. This means that
  3745. - * this file is usually included last. */
  3746. -
  3747. -#ifdef PCI_H
  3748. -#define PCI_ARG(x) ,x
  3749. -#else
  3750. -#define PCI_ARG(x)
  3751. -#endif
  3752. -
  3753. -#ifdef INCLUDE_WD
  3754. -extern struct nic *wd_probe(struct nic *, unsigned short *
  3755. - PCI_ARG(struct pci_device *));
  3756. -#endif
  3757. -
  3758. -#ifdef INCLUDE_3C503
  3759. -extern struct nic *t503_probe(struct nic *, unsigned short *
  3760. - PCI_ARG(struct pci_device *));
  3761. -#endif
  3762. -
  3763. -#ifdef INCLUDE_VIA_RHINE
  3764. -extern struct nic *rhine_probe(struct nic *, unsigned short *
  3765. - PCI_ARG(struct pci_device *));
  3766. -#endif
  3767. -
  3768. -#ifdef INCLUDE_NE
  3769. -extern struct nic *ne_probe(struct nic *, unsigned short *
  3770. - PCI_ARG(struct pci_device *));
  3771. -#endif
  3772. -
  3773. -#ifdef INCLUDE_NS8390
  3774. -extern struct nic *nepci_probe(struct nic *, unsigned short *
  3775. - PCI_ARG(struct pci_device *));
  3776. -#endif
  3777. -
  3778. -#ifdef INCLUDE_3C509
  3779. -extern struct nic *t509_probe(struct nic *, unsigned short *
  3780. - PCI_ARG(struct pci_device *));
  3781. -#endif
  3782. -
  3783. -#ifdef INCLUDE_3C529
  3784. -extern struct nic *t529_probe(struct nic *, unsigned short *
  3785. - PCI_ARG(struct pci_device *));
  3786. -#endif
  3787. -
  3788. -#ifdef INCLUDE_3C595
  3789. -extern struct nic *t595_probe(struct nic *, unsigned short *
  3790. - PCI_ARG(struct pci_device *));
  3791. -#endif
  3792. -
  3793. -#ifdef INCLUDE_3C90X
  3794. -extern struct nic *a3c90x_probe(struct nic *, unsigned short *
  3795. - PCI_ARG(struct pci_device *));
  3796. -#endif
  3797. -
  3798. -#ifdef INCLUDE_EEPRO
  3799. -extern struct nic *eepro_probe(struct nic *, unsigned short *
  3800. - PCI_ARG(struct pci_device *));
  3801. -#endif
  3802. -
  3803. -#ifdef INCLUDE_EEPRO100
  3804. -extern struct nic *eepro100_probe(struct nic *, unsigned short *
  3805. - PCI_ARG(struct pci_device *));
  3806. -#endif
  3807. -
  3808. -#ifdef INCLUDE_EPIC100
  3809. -extern struct nic *epic100_probe(struct nic *, unsigned short *
  3810. - PCI_ARG(struct pci_device *));
  3811. -#endif
  3812. -
  3813. -#ifdef INCLUDE_OTULIP
  3814. -extern struct nic *otulip_probe(struct nic *, unsigned short *
  3815. - PCI_ARG(struct pci_device *));
  3816. -#endif
  3817. -
  3818. -#ifdef INCLUDE_TULIP
  3819. -extern struct nic *tulip_probe(struct nic *, unsigned short *
  3820. - PCI_ARG(struct pci_device *));
  3821. -#endif
  3822. -
  3823. -#ifdef INCLUDE_DAVICOM
  3824. -extern struct nic *davicom_probe(struct nic *, unsigned short *
  3825. - PCI_ARG(struct pci_device *));
  3826. -#endif
  3827. -
  3828. -#ifdef INCLUDE_CS89X0
  3829. -extern struct nic *cs89x0_probe(struct nic *, unsigned short *
  3830. - PCI_ARG(struct pci_device *));
  3831. -#endif
  3832. -
  3833. -#ifdef INCLUDE_LANCE
  3834. -extern struct nic *lancepci_probe(struct nic *, unsigned short *
  3835. - PCI_ARG(struct pci_device *));
  3836. -#endif
  3837. -
  3838. -#ifdef INCLUDE_NE2100
  3839. -extern struct nic *ne2100_probe(struct nic *, unsigned short *
  3840. - PCI_ARG(struct pci_device *));
  3841. -#endif
  3842. -
  3843. -#ifdef INCLUDE_NI6510
  3844. -extern struct nic *ni6510_probe(struct nic *, unsigned short *
  3845. - PCI_ARG(struct pci_device *));
  3846. -#endif
  3847. -
  3848. -#ifdef INCLUDE_SK_G16
  3849. -extern struct nic *SK_probe(struct nic *, unsigned short *
  3850. - PCI_ARG(struct pci_device *));
  3851. -#endif
  3852. -
  3853. -#ifdef INCLUDE_3C507
  3854. -extern struct nic *t507_probe(struct nic *, unsigned short *
  3855. - PCI_ARG(struct pci_device *));
  3856. -#endif
  3857. -
  3858. -#ifdef INCLUDE_NI5010
  3859. -extern struct nic *ni5010_probe(struct nic *, unsigned short *
  3860. - PCI_ARG(struct pci_device *));
  3861. -#endif
  3862. -
  3863. -#ifdef INCLUDE_NI5210
  3864. -extern struct nic *ni5210_probe(struct nic *, unsigned short *
  3865. - PCI_ARG(struct pci_device *));
  3866. -#endif
  3867. -
  3868. -#ifdef INCLUDE_EXOS205
  3869. -extern struct nic *exos205_probe(struct nic *, unsigned short *
  3870. - PCI_ARG(struct pci_device *));
  3871. -#endif
  3872. -
  3873. -#ifdef INCLUDE_SMC9000
  3874. -extern struct nic *smc9000_probe(struct nic *, unsigned short *
  3875. - PCI_ARG(struct pci_device *));
  3876. -#endif
  3877. -
  3878. -#ifdef INCLUDE_TIARA
  3879. -extern struct nic *tiara_probe(struct nic *, unsigned short *
  3880. - PCI_ARG(struct pci_device *));
  3881. -#endif
  3882. -
  3883. -#ifdef INCLUDE_DEPCA
  3884. -extern struct nic *depca_probe(struct nic *, unsigned short *
  3885. - PCI_ARG(struct pci_device *));
  3886. -#endif
  3887. -
  3888. -#ifdef INCLUDE_RTL8139
  3889. -extern struct nic *rtl8139_probe(struct nic *, unsigned short *
  3890. - PCI_ARG(struct pci_device *));
  3891. -#endif
  3892. -
  3893. -#ifdef INCLUDE_W89C840
  3894. -extern struct nic *w89c840_probe(struct nic *, unsigned short *
  3895. - PCI_ARG(struct pci_device *));
  3896. -#endif
  3897. -
  3898. -#ifdef INCLUDE_SIS900
  3899. -extern struct nic *sis900_probe(struct nic *, unsigned short *
  3900. - PCI_ARG(struct pci_device *));
  3901. -#endif
  3902. -
  3903. -#ifdef INCLUDE_NATSEMI
  3904. -extern struct nic *natsemi_probe(struct nic *, unsigned short *
  3905. - PCI_ARG(struct pci_device *));
  3906. -#endif
  3907. -
  3908. -#ifdef INCLUDE_TLAN
  3909. -extern struct nic *tlan_probe(struct nic *, unsigned short *
  3910. - PCI_ARG(struct pci_device *));
  3911. -#endif
  3912. -
  3913. -#endif /* CARDS_H */
  3914. diff -Naur grub-0.97.orig/netboot/config.c grub-0.97/netboot/config.c
  3915. --- grub-0.97.orig/netboot/config.c 2003-07-09 11:45:37.000000000 +0000
  3916. +++ grub-0.97/netboot/config.c 2005-08-31 19:03:35.000000000 +0000
  3917. @@ -1,598 +1,165 @@
  3918. /*
  3919. - * GRUB -- GRand Unified Bootloader
  3920. - * Copyright (C) 2001,2002 Free Software Foundation, Inc.
  3921. - *
  3922. - * This program is free software; you can redistribute it and/or modify
  3923. - * it under the terms of the GNU General Public License as published by
  3924. - * the Free Software Foundation; either version 2 of the License, or
  3925. - * (at your option) any later version.
  3926. - *
  3927. - * This program is distributed in the hope that it will be useful,
  3928. - * but WITHOUT ANY WARRANTY; without even the implied warranty of
  3929. - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3930. - * GNU General Public License for more details.
  3931. - *
  3932. - * You should have received a copy of the GNU General Public License
  3933. - * along with this program; if not, write to the Free Software
  3934. - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  3935. - */
  3936. -
  3937. -/* Based on "src/config.c" in etherboot-5.0.5. */
  3938. -
  3939. -/*
  3940. * This program is free software; you can redistribute it and/or
  3941. * modify it under the terms of the GNU General Public License as
  3942. * published by the Free Software Foundation; either version 2, or (at
  3943. * your option) any later version.
  3944. */
  3945. -#define GRUB 1
  3946. -#include <etherboot.h>
  3947. -#include <nic.h>
  3948. +#include "grub.h"
  3949. +#include "pci.h"
  3950. +#include "isa.h"
  3951. +#include "nic.h"
  3952. -#undef INCLUDE_PCI
  3953. -#if defined(INCLUDE_NS8390) || defined(INCLUDE_EEPRO100) || defined(INCLUDE_LANCE) || defined(INCLUDE_EPIC100) || defined(INCLUDE_TULIP) || defined(INCLUDE_OTULIP) || defined(INCLUDE_3C90X) || defined(INCLUDE_3C595) || defined(INCLUDE_RTL8139) || defined(INCLUDE_VIA_RHINE) || defined(INCLUDE_W89C840) || defined(INCLUDE_DAVICOM) || defined(INCLUDE_SIS900) || defined(INCLUDE_NATSEMI) || defined(INCLUDE_TLAN)
  3954. - /* || others later */
  3955. -# define INCLUDE_PCI
  3956. -# include <pci.h>
  3957. -static unsigned short pci_ioaddrs[16];
  3958. -
  3959. -static struct pci_device pci_nic_list[] =
  3960. +#ifdef CONFIG_PCI
  3961. +static int pci_probe(struct dev *dev, const char *type_name)
  3962. {
  3963. -#ifdef INCLUDE_NS8390
  3964. - { PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8029,
  3965. - "Realtek 8029", 0, 0, 0, 0},
  3966. - { PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_89C940,
  3967. - "Winbond NE2000-PCI", 0, 0, 0, 0},
  3968. - { PCI_VENDOR_ID_COMPEX, PCI_DEVICE_ID_COMPEX_RL2000,
  3969. - "Compex ReadyLink 2000", 0, 0, 0, 0},
  3970. - { PCI_VENDOR_ID_KTI, PCI_DEVICE_ID_KTI_ET32P2,
  3971. - "KTI ET32P2", 0, 0, 0, 0},
  3972. - { PCI_VENDOR_ID_NETVIN, PCI_DEVICE_ID_NETVIN_NV5000SC,
  3973. - "NetVin NV5000SC", 0, 0, 0, 0},
  3974. - { PCI_VENDOR_ID_HOLTEK, PCI_DEVICE_ID_HOLTEK_HT80232,
  3975. - "Holtek HT80232", 0, 0, 0, 0},
  3976. -#endif
  3977. -#ifdef INCLUDE_3C90X
  3978. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C900TPO,
  3979. - "3Com900-TPO", 0, 0, 0, 0},
  3980. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C900COMBO,
  3981. - "3Com900-Combo", 0, 0, 0, 0},
  3982. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C905TX,
  3983. - "3Com905-TX", 0, 0, 0, 0},
  3984. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C905T4,
  3985. - "3Com905-T4", 0, 0, 0, 0},
  3986. - { PCI_VENDOR_ID_3COM, 0x9004,
  3987. - "3Com900B-TPO", 0, 0, 0, 0},
  3988. - { PCI_VENDOR_ID_3COM, 0x9005,
  3989. - "3Com900B-Combo", 0, 0, 0, 0},
  3990. - { PCI_VENDOR_ID_3COM, 0x9006,
  3991. - "3Com900B-2/T", 0, 0, 0, 0},
  3992. - { PCI_VENDOR_ID_3COM, 0x900A,
  3993. - "3Com900B-FL", 0, 0, 0, 0},
  3994. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C905B_TX,
  3995. - "3Com905B-TX", 0, 0, 0, 0},
  3996. - { PCI_VENDOR_ID_3COM, 0x9056,
  3997. - "3Com905B-T4", 0, 0, 0, 0},
  3998. - { PCI_VENDOR_ID_3COM, 0x905A,
  3999. - "3Com905B-FL", 0, 0, 0, 0},
  4000. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C905C_TXM,
  4001. - "3Com905C-TXM", 0, 0, 0, 0},
  4002. - { PCI_VENDOR_ID_3COM, 0x9800,
  4003. - "3Com980-Cyclone", 0, 0, 0, 0},
  4004. - { PCI_VENDOR_ID_3COM, 0x9805,
  4005. - "3Com9805", 0, 0, 0, 0},
  4006. - { PCI_VENDOR_ID_3COM, 0x7646,
  4007. - "3CSOHO100-TX", 0, 0, 0, 0},
  4008. -#endif
  4009. -#ifdef INCLUDE_3C595
  4010. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C590,
  4011. - "3Com590", 0, 0, 0, 0},
  4012. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C595,
  4013. - "3Com595", 0, 0, 0, 0},
  4014. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C595_1,
  4015. - "3Com595", 0, 0, 0, 0},
  4016. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C595_2,
  4017. - "3Com595", 0, 0, 0, 0},
  4018. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C900TPO,
  4019. - "3Com900-TPO", 0, 0, 0, 0},
  4020. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C900COMBO,
  4021. - "3Com900-Combo", 0, 0, 0, 0},
  4022. - { PCI_VENDOR_ID_3COM, 0x9004,
  4023. - "3Com900B-TPO", 0, 0, 0, 0},
  4024. - { PCI_VENDOR_ID_3COM, 0x9005,
  4025. - "3Com900B-Combo", 0, 0, 0, 0},
  4026. - { PCI_VENDOR_ID_3COM, 0x9006,
  4027. - "3Com900B-2/T", 0, 0, 0, 0},
  4028. - { PCI_VENDOR_ID_3COM, 0x900A,
  4029. - "3Com900B-FL", 0, 0, 0, 0},
  4030. - { PCI_VENDOR_ID_3COM, 0x9800,
  4031. - "3Com980-Cyclone", 0, 0, 0, 0},
  4032. - { PCI_VENDOR_ID_3COM, 0x9805,
  4033. - "3Com9805", 0, 0, 0, 0},
  4034. - { PCI_VENDOR_ID_3COM, 0x7646,
  4035. - "3CSOHO100-TX", 0, 0, 0, 0},
  4036. -#endif
  4037. -#ifdef INCLUDE_EEPRO100
  4038. - { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557,
  4039. - "Intel EtherExpressPro100", 0, 0, 0, 0},
  4040. - { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559ER,
  4041. - "Intel EtherExpressPro100 82559ER", 0, 0, 0, 0},
  4042. - { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ID1029,
  4043. - "Intel EtherExpressPro100 ID1029", 0, 0, 0, 0},
  4044. - { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ID1030,
  4045. - "Intel Corporation 82559 InBusiness 10/100", 0, 0, 0, 0},
  4046. - { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82562,
  4047. - "Intel EtherExpressPro100 82562EM", 0, 0, 0, 0},
  4048. -#endif
  4049. -#ifdef INCLUDE_EPIC100
  4050. - { PCI_VENDOR_ID_SMC, PCI_DEVICE_ID_SMC_EPIC100,
  4051. - "SMC EtherPowerII", 0, 0, 0, 0},
  4052. -#endif
  4053. -#ifdef INCLUDE_LANCE
  4054. - { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LANCE,
  4055. - "AMD Lance/PCI", 0, 0, 0, 0},
  4056. - { PCI_VENDOR_ID_AMD_HOMEPNA, PCI_DEVICE_ID_AMD_HOMEPNA,
  4057. - "AMD Lance/HomePNA", 0, 0, 0, 0},
  4058. -#endif
  4059. -#ifdef INCLUDE_RTL8139
  4060. - { PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8139,
  4061. - "Realtek 8139", 0, 0, 0, 0},
  4062. - { PCI_VENDOR_ID_DLINK, PCI_DEVICE_ID_DFE530TXP,
  4063. - "DFE530TX+/DFE538TX", 0, 0, 0, 0},
  4064. - { PCI_VENDOR_ID_SMC_1211, PCI_DEVICE_ID_SMC_1211,
  4065. - "SMC EZ10/100", 0, 0, 0, 0},
  4066. -#endif
  4067. -#ifdef INCLUDE_OTULIP
  4068. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP,
  4069. - "Digital Tulip", 0, 0, 0, 0},
  4070. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_FAST,
  4071. - "Digital Tulip Fast", 0, 0, 0, 0},
  4072. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_PLUS,
  4073. - "Digital Tulip+", 0, 0, 0, 0},
  4074. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21142,
  4075. - "Digital Tulip 21142", 0, 0, 0, 0},
  4076. -#endif
  4077. -#ifdef INCLUDE_TULIP
  4078. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP,
  4079. - "Digital Tulip", 0, 0, 0, 0},
  4080. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_FAST,
  4081. - "Digital Tulip Fast", 0, 0, 0, 0},
  4082. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_PLUS,
  4083. - "Digital Tulip+", 0, 0, 0, 0},
  4084. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21142,
  4085. - "Digital Tulip 21142", 0, 0, 0, 0},
  4086. - { PCI_VENDOR_ID_MACRONIX, PCI_DEVICE_ID_MX987x5,
  4087. - "Macronix MX987x5", 0, 0, 0, 0},
  4088. - { PCI_VENDOR_ID_LINKSYS, PCI_DEVICE_ID_LC82C115,
  4089. - "LinkSys LNE100TX", 0, 0, 0, 0},
  4090. - { PCI_VENDOR_ID_LINKSYS, PCI_DEVICE_ID_DEC_TULIP,
  4091. - "Netgear FA310TX", 0, 0, 0, 0},
  4092. - { PCI_VENDOR_ID_DAVICOM, PCI_DEVICE_ID_DM9102,
  4093. - "Davicom 9102", 0, 0, 0, 0},
  4094. - { PCI_VENDOR_ID_DAVICOM, PCI_DEVICE_ID_DM9009,
  4095. - "Davicom 9009", 0, 0, 0, 0},
  4096. - { PCI_VENDOR_ID_ADMTEK, PCI_DEVICE_ID_ADMTEK_0985,
  4097. - "ADMtek Centaur-P", 0, 0, 0, 0},
  4098. - { PCI_VENDOR_ID_ADMTEK, 0x0981,
  4099. - "ADMtek AN981 Comet", 0, 0, 0, 0},
  4100. - { 0x125B, 0x1400,
  4101. - "ASIX AX88140", 0, 0, 0, 0 },
  4102. - { 0x11F6, 0x9881,
  4103. - "Compex RL100-TX", 0, 0, 0, 0 },
  4104. -#endif
  4105. -#ifdef INCLUDE_DAVICOM
  4106. - { PCI_VENDOR_ID_DAVICOM, PCI_DEVICE_ID_DM9102,
  4107. - "Davicom 9102", 0, 0, 0, 0},
  4108. - { PCI_VENDOR_ID_DAVICOM, PCI_DEVICE_ID_DM9009,
  4109. - "Davicom 9009", 0, 0, 0, 0},
  4110. -#endif
  4111. -#ifdef INCLUDE_VIA_RHINE
  4112. - { PCI_VENDOR_ID_VIATEC, PCI_DEVICE_ID_VIA_VT6102,
  4113. - "VIA 6102", 0, 0, 0, 0},
  4114. - { PCI_VENDOR_ID_VIATEC, PCI_DEVICE_ID_VIA_RHINE_I,
  4115. - "VIA 3043", 0, 0, 0, 0},
  4116. - { PCI_VENDOR_ID_VIATEC, PCI_DEVICE_ID_VIA_86C100A,
  4117. - "VIA 86C100A", 0, 0, 0, 0},
  4118. -#endif
  4119. -#ifdef INCLUDE_W89C840
  4120. - { PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_89C840,
  4121. - "Winbond W89C840F", 0, 0, 0, 0},
  4122. - { PCI_VENDOR_ID_COMPEX, PCI_DEVICE_ID_COMPEX_RL100ATX,
  4123. - "Compex RL100ATX", 0, 0, 0, 0},
  4124. -#endif
  4125. -#ifdef INCLUDE_SIS900
  4126. - { PCI_VENDOR_ID_SIS, PCI_DEVICE_ID_SIS900,
  4127. - "SIS900", 0, 0, 0, 0},
  4128. - { PCI_VENDOR_ID_SIS, PCI_DEVICE_ID_SIS7016,
  4129. - "SIS7016", 0, 0, 0, 0},
  4130. -#endif
  4131. -
  4132. -#ifdef INCLUDE_NATSEMI
  4133. - { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_DP83815,
  4134. - "DP83815", 0, 0, 0, 0},
  4135. -#endif
  4136. -
  4137. -#ifdef INCLUDE_TLAN
  4138. - { PCI_VENDOR_ID_OLICOM, PCI_DEVICE_ID_OLICOM_OC2326,
  4139. - "OC2326", 0, 0, 0, 0},
  4140. +/*
  4141. + * NIC probing is in pci device order, followed by the
  4142. + * link order of the drivers. A driver that matches
  4143. + * on vendor and device id will supersede a driver
  4144. + * that matches on pci class.
  4145. + *
  4146. + * If you want to probe for another device behind the same pci
  4147. + * device just increment index. And the previous probe call
  4148. + * will be repeated.
  4149. + */
  4150. + struct pci_probe_state *state = &dev->state.pci;
  4151. + printf("Probing pci %s...\n", type_name);
  4152. + if (dev->how_probe == PROBE_FIRST) {
  4153. + state->advance = 1;
  4154. + state->dev.driver = 0;
  4155. + state->dev.bus = 0;
  4156. + state->dev.devfn = 0;
  4157. + dev->index = -1;
  4158. + }
  4159. + for(;;) {
  4160. + if ((dev->how_probe != PROBE_AWAKE) && state->advance) {
  4161. + find_pci(dev->type, &state->dev);
  4162. + dev->index = -1;
  4163. + }
  4164. + state->advance = 1;
  4165. +
  4166. + if (state->dev.driver == 0)
  4167. + break;
  4168. +
  4169. +#if 0
  4170. + /* FIXME the romaddr code needs a total rethought to be useful */
  4171. + if (state->dev.romaddr != ((unsigned long) rom.rom_segment << 4)) {
  4172. + continue;
  4173. + }
  4174. +#endif
  4175. + if (dev->how_probe != PROBE_AWAKE) {
  4176. + dev->type_index++;
  4177. + }
  4178. + dev->devid.bus_type = PCI_BUS_TYPE;
  4179. + dev->devid.vendor_id = htons(state->dev.vendor);
  4180. + dev->devid.device_id = htons(state->dev.dev_id);
  4181. + /* FIXME how do I handle dev->index + PROBE_AGAIN?? */
  4182. +
  4183. + printf("[%s]", state->dev.name);
  4184. + if (state->dev.driver->probe(dev, &state->dev)) {
  4185. + state->advance = (dev->index == -1);
  4186. + return PROBE_WORKED;
  4187. + }
  4188. + putchar('\n');
  4189. + }
  4190. + return PROBE_FAILED;
  4191. +}
  4192. #endif
  4193. - /* other PCI NICs go here */
  4194. - {0, 0, NULL, 0, 0, 0, 0}
  4195. -};
  4196. -#endif /* INCLUDE_*PCI */
  4197. -
  4198. -#include <cards.h>
  4199. -
  4200. -#ifdef INCLUDE_PCI
  4201. -struct pci_dispatch_table
  4202. +#ifdef CONFIG_ISA
  4203. +static int isa_probe(struct dev *dev, const char *type_name)
  4204. {
  4205. - unsigned short vendor;
  4206. - unsigned short dev_id;
  4207. - struct nic *(*eth_probe) (struct nic *, unsigned short *,
  4208. - struct pci_device *);
  4209. -};
  4210. -
  4211. -static struct pci_dispatch_table PCI_NIC[] =
  4212. -{
  4213. -# ifdef INCLUDE_NS8390
  4214. - { PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8029, nepci_probe },
  4215. - { PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_89C940, nepci_probe },
  4216. - { PCI_VENDOR_ID_COMPEX, PCI_DEVICE_ID_COMPEX_RL2000, nepci_probe },
  4217. - { PCI_VENDOR_ID_KTI, PCI_DEVICE_ID_KTI_ET32P2, nepci_probe },
  4218. - { PCI_VENDOR_ID_NETVIN, PCI_DEVICE_ID_NETVIN_NV5000SC, nepci_probe },
  4219. - { PCI_VENDOR_ID_HOLTEK, PCI_DEVICE_ID_HOLTEK_HT80232, nepci_probe },
  4220. -# endif /* INCLUDE_NS8390 */
  4221. -# ifdef INCLUDE_3C90X
  4222. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C900TPO, a3c90x_probe },
  4223. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C900COMBO, a3c90x_probe },
  4224. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C905TX, a3c90x_probe },
  4225. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C905T4, a3c90x_probe },
  4226. - { PCI_VENDOR_ID_3COM, 0x9004, a3c90x_probe },
  4227. - { PCI_VENDOR_ID_3COM, 0x9005, a3c90x_probe },
  4228. - { PCI_VENDOR_ID_3COM, 0x9006, a3c90x_probe },
  4229. - { PCI_VENDOR_ID_3COM, 0x900A, a3c90x_probe },
  4230. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C905B_TX, a3c90x_probe },
  4231. - { PCI_VENDOR_ID_3COM, 0x9056, a3c90x_probe },
  4232. - { PCI_VENDOR_ID_3COM, 0x905A, a3c90x_probe },
  4233. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C905C_TXM, a3c90x_probe },
  4234. - { PCI_VENDOR_ID_3COM, 0x9800, a3c90x_probe },
  4235. - { PCI_VENDOR_ID_3COM, 0x9805, a3c90x_probe },
  4236. - { PCI_VENDOR_ID_3COM, 0x7646, a3c90x_probe },
  4237. -# endif /* INCLUDE_3C90X */
  4238. -# ifdef INCLUDE_3C595
  4239. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C590, t595_probe },
  4240. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C595, t595_probe },
  4241. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C595_1, t595_probe },
  4242. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C595_2, t595_probe },
  4243. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C900TPO, t595_probe },
  4244. - { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C900COMBO, t595_probe },
  4245. - { PCI_VENDOR_ID_3COM, 0x9004, t595_probe },
  4246. - { PCI_VENDOR_ID_3COM, 0x9005, t595_probe },
  4247. - { PCI_VENDOR_ID_3COM, 0x9006, t595_probe },
  4248. - { PCI_VENDOR_ID_3COM, 0x900A, t595_probe },
  4249. - { PCI_VENDOR_ID_3COM, 0x9800, t595_probe },
  4250. - { PCI_VENDOR_ID_3COM, 0x9805, t595_probe },
  4251. - { PCI_VENDOR_ID_3COM, 0x7646, t595_probe },
  4252. -# endif /* INCLUDE_3C595 */
  4253. -# ifdef INCLUDE_EEPRO100
  4254. - { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82557, eepro100_probe },
  4255. - { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82559ER, eepro100_probe },
  4256. - { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ID1029, eepro100_probe },
  4257. - { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ID1030, eepro100_probe },
  4258. - { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82562, eepro100_probe },
  4259. -# endif /* INCLUDE_EEPRO100 */
  4260. -# ifdef INCLUDE_EPIC100
  4261. - { PCI_VENDOR_ID_SMC, PCI_DEVICE_ID_SMC_EPIC100, epic100_probe },
  4262. -# endif /* INCLUDE_EPIC100 */
  4263. -# ifdef INCLUDE_LANCE
  4264. - { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LANCE, lancepci_probe },
  4265. - { PCI_VENDOR_ID_AMD_HOMEPNA, PCI_DEVICE_ID_AMD_HOMEPNA, lancepci_probe },
  4266. -# endif /* INCLUDE_LANCE */
  4267. -# ifdef INCLUDE_RTL8139
  4268. - { PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8139, rtl8139_probe },
  4269. - { PCI_VENDOR_ID_DLINK, PCI_DEVICE_ID_DFE530TXP, rtl8139_probe },
  4270. - { PCI_VENDOR_ID_SMC_1211, PCI_DEVICE_ID_SMC_1211, rtl8139_probe },
  4271. -# endif /* INCLUDE_RTL8139 */
  4272. -# ifdef INCLUDE_OTULIP
  4273. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP, otulip_probe },
  4274. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_FAST, otulip_probe },
  4275. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_PLUS, otulip_probe },
  4276. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21142, otulip_probe },
  4277. -# endif /* INCLUDE_OTULIP */
  4278. -# ifdef INCLUDE_TULIP
  4279. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP, tulip_probe },
  4280. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_FAST, tulip_probe },
  4281. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_PLUS, tulip_probe },
  4282. - { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21142, tulip_probe },
  4283. - { PCI_VENDOR_ID_MACRONIX, PCI_DEVICE_ID_MX987x5, tulip_probe },
  4284. - { PCI_VENDOR_ID_LINKSYS, PCI_DEVICE_ID_LC82C115, tulip_probe },
  4285. - { PCI_VENDOR_ID_LINKSYS, PCI_DEVICE_ID_DEC_TULIP, tulip_probe },
  4286. - { PCI_VENDOR_ID_DAVICOM, PCI_DEVICE_ID_DM9102, tulip_probe },
  4287. - { PCI_VENDOR_ID_DAVICOM, PCI_DEVICE_ID_DM9009, tulip_probe },
  4288. - { PCI_VENDOR_ID_ADMTEK, PCI_DEVICE_ID_ADMTEK_0985, tulip_probe },
  4289. - { PCI_VENDOR_ID_ADMTEK, 0x0981, tulip_probe },
  4290. - { 0x125B, 0x1400, tulip_probe },
  4291. - { 0x11F6, 0x9881, tulip_probe },
  4292. -# endif /* INCLUDE_TULIP */
  4293. -# ifdef INCLUDE_DAVICOM
  4294. - { PCI_VENDOR_ID_DAVICOM, PCI_DEVICE_ID_DM9102, davicom_probe },
  4295. - { PCI_VENDOR_ID_DAVICOM, PCI_DEVICE_ID_DM9009, davicom_probe },
  4296. -# endif /* INCLUDE_DAVICOM */
  4297. -# ifdef INCLUDE_VIA_RHINE
  4298. - { PCI_VENDOR_ID_VIATEC, PCI_DEVICE_ID_VIA_VT6102, rhine_probe },
  4299. - { PCI_VENDOR_ID_VIATEC, PCI_DEVICE_ID_VIA_RHINE_I, rhine_probe },
  4300. - { PCI_VENDOR_ID_VIATEC, PCI_DEVICE_ID_VIA_86C100A, rhine_probe },
  4301. -# endif /* INCLUDE_VIA_RHINE */
  4302. -# ifdef INCLUDE_W89C840
  4303. - { PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_89C840, w89c840_probe },
  4304. - { PCI_VENDOR_ID_COMPEX, PCI_DEVICE_ID_COMPEX_RL100ATX, w89c840_probe },
  4305. -# endif /* INCLUDE_W89C840 */
  4306. -# ifdef INCLUDE_SIS900
  4307. - { PCI_VENDOR_ID_SIS, PCI_DEVICE_ID_SIS900, sis900_probe },
  4308. - { PCI_VENDOR_ID_SIS, PCI_DEVICE_ID_SIS7016, sis900_probe },
  4309. -# endif /* INCLUDE_SIS900 */
  4310. -# ifdef INCLUDE_NATSEMI
  4311. - { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_DP83815, natsemi_probe },
  4312. -# endif /* INCLUDE_NATSEMI */
  4313. -# ifdef INCLUDE_TLAN
  4314. - { PCI_VENDOR_ID_OLICOM, PCI_DEVICE_ID_OLICOM_OC2326, tlan_probe },
  4315. -# endif /* INCLUDE_TLAN */
  4316. - { 0, 0, 0 }
  4317. -};
  4318. -#endif /* GRUB && INCLUDE_PCI */
  4319. -
  4320. -struct dispatch_table
  4321. -{
  4322. - const char *nic_name;
  4323. -#ifdef INCLUDE_PCI
  4324. - struct nic *(*eth_probe) (struct nic *, unsigned short *,
  4325. - struct pci_device *);
  4326. -#else
  4327. - struct nic *(*eth_probe) (struct nic *, unsigned short *);
  4328. -#endif /* INCLUDE_PCI */
  4329. - unsigned short *probe_ioaddrs; /* for probe overrides */
  4330. -};
  4331. -
  4332. /*
  4333. - * NIC probing is in order of appearance in this table.
  4334. + * NIC probing is in the order the drivers were linked togeter.
  4335. * If for some reason you want to change the order,
  4336. - * just rearrange the entries (bracketed by the #ifdef/#endif)
  4337. + * just change the order you list the drivers in.
  4338. */
  4339. -static struct dispatch_table NIC[] =
  4340. -{
  4341. -#ifdef INCLUDE_RTL8139
  4342. - { "RTL8139", rtl8139_probe, pci_ioaddrs },
  4343. -#endif
  4344. -#ifdef INCLUDE_SIS900
  4345. - { "SIS900", sis900_probe, pci_ioaddrs },
  4346. -#endif
  4347. -#ifdef INCLUDE_NATSEMI
  4348. - { "NATSEMI", natsemi_probe, pci_ioaddrs },
  4349. -#endif
  4350. -#ifdef INCLUDE_WD
  4351. - { "WD", wd_probe, 0 },
  4352. -#endif
  4353. -#ifdef INCLUDE_3C503
  4354. - { "3C503", t503_probe, 0 },
  4355. -#endif
  4356. -#ifdef INCLUDE_NE
  4357. - { "NE*000", ne_probe, 0 },
  4358. -#endif
  4359. -#ifdef INCLUDE_3C509
  4360. - { "3C5x9", t509_probe, 0 },
  4361. -#endif
  4362. -#ifdef INCLUDE_3C529
  4363. - { "3C5x9", t529_probe, 0 },
  4364. -#endif
  4365. -#ifdef INCLUDE_3C595
  4366. - { "3C595", t595_probe, pci_ioaddrs },
  4367. -#endif
  4368. -#ifdef INCLUDE_3C90X
  4369. - { "3C90X", a3c90x_probe, pci_ioaddrs },
  4370. -#endif
  4371. -#ifdef INCLUDE_EEPRO
  4372. - { "EEPRO", eepro_probe, 0 },
  4373. -#endif
  4374. -#ifdef INCLUDE_EEPRO100
  4375. - { "EEPRO100", eepro100_probe, pci_ioaddrs },
  4376. -#endif
  4377. -#ifdef INCLUDE_EPIC100
  4378. - { "EPIC100", epic100_probe, pci_ioaddrs },
  4379. -#endif
  4380. -#ifdef INCLUDE_OTULIP
  4381. - { "OTulip", otulip_probe, pci_ioaddrs },
  4382. -#endif
  4383. -#ifdef INCLUDE_TULIP
  4384. - { "Tulip", tulip_probe, pci_ioaddrs },
  4385. -#endif
  4386. -#ifdef INCLUDE_DAVICOM
  4387. - { "DAVICOM", davicom_probe, pci_ioaddrs },
  4388. -#endif
  4389. -#ifdef INCLUDE_CS89X0
  4390. - { "CS89x0", cs89x0_probe, 0 },
  4391. -#endif
  4392. -#ifdef INCLUDE_NE2100
  4393. - { "NE2100", ne2100_probe, 0 },
  4394. -#endif
  4395. -#ifdef INCLUDE_NI6510
  4396. - { "NI6510", ni6510_probe, 0 },
  4397. -#endif
  4398. -#ifdef INCLUDE_SK_G16
  4399. - { "SK_G16", SK_probe, 0 },
  4400. -#endif
  4401. -#ifdef INCLUDE_3C507
  4402. - { "3C507", t507_probe, 0 },
  4403. -#endif
  4404. -#ifdef INCLUDE_NI5010
  4405. - { "NI5010", ni5010_probe, 0 },
  4406. -#endif
  4407. -#ifdef INCLUDE_NI5210
  4408. - { "NI5210", ni5210_probe, 0 },
  4409. -#endif
  4410. -#ifdef INCLUDE_EXOS205
  4411. - { "EXOS205", exos205_probe, 0 },
  4412. -#endif
  4413. -#ifdef INCLUDE_SMC9000
  4414. - { "SMC9000", smc9000_probe, 0 },
  4415. -#endif
  4416. -#ifdef INCLUDE_TIARA
  4417. - { "TIARA", tiara_probe, 0 },
  4418. -#endif
  4419. -#ifdef INCLUDE_DEPCA
  4420. - { "DEPCA", depca_probe, 0 },
  4421. -#endif
  4422. -#ifdef INCLUDE_NS8390
  4423. - { "NE2000/PCI", nepci_probe, pci_ioaddrs },
  4424. -#endif
  4425. -#ifdef INCLUDE_LANCE
  4426. - { "LANCE/PCI", lancepci_probe, pci_ioaddrs },
  4427. -#endif
  4428. -#ifdef INCLUDE_VIA_RHINE
  4429. - { "VIA 86C100", rhine_probe, pci_ioaddrs },
  4430. -#endif
  4431. -#ifdef INCLUDE_W89C840
  4432. - { "W89C840F", w89c840_probe, pci_ioaddrs },
  4433. -#endif
  4434. -#ifdef INCLUDE_TLAN
  4435. - { "Olicom 2326", tlan_probe, pci_ioaddrs },
  4436. -#endif
  4437. - /* this entry must always be last to mark the end of list */
  4438. - { 0, 0, 0 }
  4439. -};
  4440. -
  4441. -#define NIC_TABLE_SIZE (sizeof (NIC) / sizeof (NIC[0]))
  4442. -
  4443. -static int
  4444. -eth_dummy (struct nic *dummy)
  4445. -{
  4446. - return 0;
  4447. + struct isa_probe_state *state = &dev->state.isa;
  4448. + printf("Probing isa %s...\n", type_name);
  4449. + if (dev->how_probe == PROBE_FIRST) {
  4450. + state->advance = 0;
  4451. + state->driver = isa_drivers;
  4452. + dev->index = -1;
  4453. + }
  4454. + for(;;)
  4455. + {
  4456. + if ((dev->how_probe != PROBE_AWAKE) && state->advance) {
  4457. + state->driver++;
  4458. + dev->index = -1;
  4459. + }
  4460. + state->advance = 1;
  4461. +
  4462. + if (state->driver >= isa_drivers_end)
  4463. + break;
  4464. +
  4465. + if (state->driver->type != dev->type)
  4466. + continue;
  4467. +
  4468. + if (dev->how_probe != PROBE_AWAKE) {
  4469. + dev->type_index++;
  4470. + }
  4471. + printf("[%s]", state->driver->name);
  4472. + dev->devid.bus_type = ISA_BUS_TYPE;
  4473. + /* FIXME how do I handle dev->index + PROBE_AGAIN?? */
  4474. + /* driver will fill in vendor and device IDs */
  4475. + if (state->driver->probe(dev, state->driver->ioaddrs)) {
  4476. + state->advance = (dev->index == -1);
  4477. + return PROBE_WORKED;
  4478. + }
  4479. + putchar('\n');
  4480. + }
  4481. + return PROBE_FAILED;
  4482. }
  4483. -
  4484. -static char packet[ETH_FRAME_LEN];
  4485. -
  4486. -struct nic nic =
  4487. -{
  4488. - (void (*) (struct nic *)) eth_dummy, /* reset */
  4489. - eth_dummy, /* poll */
  4490. - (void (*) (struct nic *, const char *,
  4491. - unsigned int, unsigned int,
  4492. - const char *)) eth_dummy, /* transmit */
  4493. - (void (*) (struct nic *)) eth_dummy, /* disable */
  4494. -#ifdef T503_AUI
  4495. - 1, /* aui */
  4496. #else
  4497. - 0, /* no aui */
  4498. +#define isa_probe(d,tn) (PROBE_FAILED)
  4499. #endif
  4500. - &rom, /* rom_info */
  4501. - arptable[ARP_CLIENT].node, /* node_addr */
  4502. - packet, /* packet */
  4503. - 0, /* packetlen */
  4504. - 0, /* priv_data */
  4505. +static const char *driver_name[] = {
  4506. + "nic",
  4507. + "disk",
  4508. + "floppy",
  4509. };
  4510. -
  4511. -void
  4512. -eth_reset (void)
  4513. +int probe(struct dev *dev)
  4514. {
  4515. - (*nic.reset) (&nic);
  4516. -}
  4517. + const char *type_name;
  4518. -int
  4519. -eth_probe (void)
  4520. -{
  4521. - struct pci_device *p;
  4522. - const struct dispatch_table *t;
  4523. - static int probed = 0;
  4524. + EnterFunction("probe");
  4525. - /* If already probed, don't try to probe it any longer. */
  4526. - if (probed)
  4527. - return 1;
  4528. -
  4529. - /* Clear the ready flag. */
  4530. - network_ready = 0;
  4531. - /* Clear the ARP table. */
  4532. - grub_memset ((char *) arptable, 0,
  4533. - MAX_ARP * sizeof (struct arptable_t));
  4534. -
  4535. - p = 0;
  4536. -
  4537. -#ifdef INCLUDE_PCI
  4538. - /* In GRUB, the ROM info is initialized here. */
  4539. - rom = *((struct rom_info *) ROM_INFO_LOCATION);
  4540. -
  4541. - eth_pci_init(pci_nic_list);
  4542. - pci_ioaddrs[0] = 0;
  4543. - pci_ioaddrs[1] = 0;
  4544. - /* at this point we have a list of possible PCI candidates
  4545. - we just pick the first one with a non-zero ioaddr */
  4546. - for (p = pci_nic_list; p->vendor != 0; ++p)
  4547. - {
  4548. - if (p->ioaddr != 0)
  4549. - {
  4550. - pci_ioaddrs[0] = p->ioaddr;
  4551. - break;
  4552. + type_name = "";
  4553. + if ((dev->type >= 0) &&
  4554. + (dev->type < sizeof(driver_name)/sizeof(driver_name[0]))) {
  4555. + type_name = driver_name[dev->type];
  4556. }
  4557. - }
  4558. -#endif
  4559. -
  4560. - etherboot_printf("Probing...");
  4561. -
  4562. -#ifdef INCLUDE_PCI
  4563. - if (p->vendor)
  4564. - {
  4565. - struct pci_dispatch_table *pt;
  4566. -
  4567. - for (pt = PCI_NIC; pt->eth_probe != 0; pt++)
  4568. - if (p->vendor == pt->vendor && p->dev_id == pt->dev_id)
  4569. - {
  4570. - etherboot_printf ("[%s]", p->name);
  4571. - if ((pt->eth_probe) (&nic, pci_ioaddrs, p))
  4572. - {
  4573. - probed = 1;
  4574. - return 1;
  4575. - }
  4576. - }
  4577. - }
  4578. -#endif /* INCLUDE_PCI */
  4579. -
  4580. - for (t = NIC; t->nic_name != 0; ++t)
  4581. - {
  4582. - etherboot_printf("[%s]", t->nic_name);
  4583. -#ifdef INCLUDE_PCI
  4584. - if ((*t->eth_probe) (&nic, t->probe_ioaddrs, p))
  4585. - {
  4586. - probed = 1;
  4587. - return 1;
  4588. + if (dev->how_probe == PROBE_FIRST) {
  4589. + dev->to_probe = PROBE_PCI;
  4590. + memset(&dev->state, 0, sizeof(dev->state));
  4591. }
  4592. -#else
  4593. - if ((*t->eth_probe) (&nic, t->probe_ioaddrs))
  4594. - {
  4595. - probed = 1;
  4596. - return 1;
  4597. + if (dev->to_probe == PROBE_PCI) {
  4598. + dev->how_probe = pci_probe(dev, type_name);
  4599. + if (dev->how_probe == PROBE_FAILED) {
  4600. + dev->to_probe = PROBE_ISA;
  4601. + }
  4602. + }
  4603. + if (dev->to_probe == PROBE_ISA) {
  4604. + dev->how_probe = isa_probe(dev, type_name);
  4605. + if (dev->how_probe == PROBE_FAILED) {
  4606. + dev->to_probe = PROBE_NONE;
  4607. + }
  4608. + }
  4609. + if ((dev->to_probe != PROBE_PCI) &&
  4610. + (dev->to_probe != PROBE_ISA)) {
  4611. + dev->how_probe = PROBE_FAILED;
  4612. +
  4613. }
  4614. -#endif /* INCLUDE_PCI */
  4615. - }
  4616. -
  4617. - return 0;
  4618. -}
  4619. -
  4620. -int
  4621. -eth_poll (void)
  4622. -{
  4623. - return ((*nic.poll) (&nic));
  4624. -}
  4625. -void
  4626. -eth_transmit (const char *d, unsigned int t, unsigned int s, const void *p)
  4627. -{
  4628. - (*nic.transmit) (&nic, d, t, s, p);
  4629. - if (t == IP)
  4630. - twiddle ();
  4631. + LeaveFunction("probe");
  4632. + return dev->how_probe;
  4633. }
  4634. -void
  4635. -eth_disable (void)
  4636. +void disable(struct dev *dev)
  4637. {
  4638. - (*nic.disable) (&nic);
  4639. + if (dev->disable) {
  4640. + dev->disable(dev);
  4641. + dev->disable = 0;
  4642. + }
  4643. }
  4644. diff -Naur grub-0.97.orig/netboot/cpu.h grub-0.97/netboot/cpu.h
  4645. --- grub-0.97.orig/netboot/cpu.h 1970-01-01 00:00:00.000000000 +0000
  4646. +++ grub-0.97/netboot/cpu.h 2005-08-31 19:03:35.000000000 +0000
  4647. @@ -0,0 +1,243 @@
  4648. +#ifndef I386_BITS_CPU_H
  4649. +#define I386_BITS_CPU_H
  4650. +
  4651. +
  4652. +/* Sample usage: CPU_FEATURE_P(cpu.x86_capability, FPU) */
  4653. +#define CPU_FEATURE_P(CAP, FEATURE) \
  4654. + (!!(CAP[(X86_FEATURE_##FEATURE)/32] & ((X86_FEATURE_##FEATURE) & 0x1f)))
  4655. +
  4656. +#define NCAPINTS 4 /* Currently we have 4 32-bit words worth of info */
  4657. +
  4658. +/* Intel-defined CPU features, CPUID level 0x00000001, word 0 */
  4659. +#define X86_FEATURE_FPU (0*32+ 0) /* Onboard FPU */
  4660. +#define X86_FEATURE_VME (0*32+ 1) /* Virtual Mode Extensions */
  4661. +#define X86_FEATURE_DE (0*32+ 2) /* Debugging Extensions */
  4662. +#define X86_FEATURE_PSE (0*32+ 3) /* Page Size Extensions */
  4663. +#define X86_FEATURE_TSC (0*32+ 4) /* Time Stamp Counter */
  4664. +#define X86_FEATURE_MSR (0*32+ 5) /* Model-Specific Registers, RDMSR, WRMSR */
  4665. +#define X86_FEATURE_PAE (0*32+ 6) /* Physical Address Extensions */
  4666. +#define X86_FEATURE_MCE (0*32+ 7) /* Machine Check Architecture */
  4667. +#define X86_FEATURE_CX8 (0*32+ 8) /* CMPXCHG8 instruction */
  4668. +#define X86_FEATURE_APIC (0*32+ 9) /* Onboard APIC */
  4669. +#define X86_FEATURE_SEP (0*32+11) /* SYSENTER/SYSEXIT */
  4670. +#define X86_FEATURE_MTRR (0*32+12) /* Memory Type Range Registers */
  4671. +#define X86_FEATURE_PGE (0*32+13) /* Page Global Enable */
  4672. +#define X86_FEATURE_MCA (0*32+14) /* Machine Check Architecture */
  4673. +#define X86_FEATURE_CMOV (0*32+15) /* CMOV instruction (FCMOVCC and FCOMI too if FPU present) */
  4674. +#define X86_FEATURE_PAT (0*32+16) /* Page Attribute Table */
  4675. +#define X86_FEATURE_PSE36 (0*32+17) /* 36-bit PSEs */
  4676. +#define X86_FEATURE_PN (0*32+18) /* Processor serial number */
  4677. +#define X86_FEATURE_CLFLSH (0*32+19) /* Supports the CLFLUSH instruction */
  4678. +#define X86_FEATURE_DTES (0*32+21) /* Debug Trace Store */
  4679. +#define X86_FEATURE_ACPI (0*32+22) /* ACPI via MSR */
  4680. +#define X86_FEATURE_MMX (0*32+23) /* Multimedia Extensions */
  4681. +#define X86_FEATURE_FXSR (0*32+24) /* FXSAVE and FXRSTOR instructions (fast save and restore */
  4682. + /* of FPU context), and CR4.OSFXSR available */
  4683. +#define X86_FEATURE_XMM (0*32+25) /* Streaming SIMD Extensions */
  4684. +#define X86_FEATURE_XMM2 (0*32+26) /* Streaming SIMD Extensions-2 */
  4685. +#define X86_FEATURE_SELFSNOOP (0*32+27) /* CPU self snoop */
  4686. +#define X86_FEATURE_HT (0*32+28) /* Hyper-Threading */
  4687. +#define X86_FEATURE_ACC (0*32+29) /* Automatic clock control */
  4688. +#define X86_FEATURE_IA64 (0*32+30) /* IA-64 processor */
  4689. +
  4690. +/* AMD-defined CPU features, CPUID level 0x80000001, word 1 */
  4691. +/* Don't duplicate feature flags which are redundant with Intel! */
  4692. +#define X86_FEATURE_SYSCALL (1*32+11) /* SYSCALL/SYSRET */
  4693. +#define X86_FEATURE_MMXEXT (1*32+22) /* AMD MMX extensions */
  4694. +#define X86_FEATURE_LM (1*32+29) /* Long Mode (x86-64) */
  4695. +#define X86_FEATURE_3DNOWEXT (1*32+30) /* AMD 3DNow! extensions */
  4696. +#define X86_FEATURE_3DNOW (1*32+31) /* 3DNow! */
  4697. +
  4698. +/* Transmeta-defined CPU features, CPUID level 0x80860001, word 2 */
  4699. +#define X86_FEATURE_RECOVERY (2*32+ 0) /* CPU in recovery mode */
  4700. +#define X86_FEATURE_LONGRUN (2*32+ 1) /* Longrun power control */
  4701. +#define X86_FEATURE_LRTI (2*32+ 3) /* LongRun table interface */
  4702. +
  4703. +/* Other features, Linux-defined mapping, word 3 */
  4704. +/* This range is used for feature bits which conflict or are synthesized */
  4705. +#define X86_FEATURE_CXMMX (3*32+ 0) /* Cyrix MMX extensions */
  4706. +#define X86_FEATURE_K6_MTRR (3*32+ 1) /* AMD K6 nonstandard MTRRs */
  4707. +#define X86_FEATURE_CYRIX_ARR (3*32+ 2) /* Cyrix ARRs (= MTRRs) */
  4708. +#define X86_FEATURE_CENTAUR_MCR (3*32+ 3) /* Centaur MCRs (= MTRRs) */
  4709. +
  4710. +#define MAX_X86_VENDOR_ID 16
  4711. +struct cpuinfo_x86 {
  4712. + uint8_t x86; /* CPU family */
  4713. + uint8_t x86_model;
  4714. + uint8_t x86_mask;
  4715. +
  4716. + int cpuid_level; /* Maximum supported CPUID level, -1=no CPUID */
  4717. + unsigned x86_capability[NCAPINTS];
  4718. + char x86_vendor_id[MAX_X86_VENDOR_ID];
  4719. +};
  4720. +
  4721. +
  4722. +#define X86_VENDOR_INTEL 0
  4723. +#define X86_VENDOR_CYRIX 1
  4724. +#define X86_VENDOR_AMD 2
  4725. +#define X86_VENDOR_UMC 3
  4726. +#define X86_VENDOR_NEXGEN 4
  4727. +#define X86_VENDOR_CENTAUR 5
  4728. +#define X86_VENDOR_RISE 6
  4729. +#define X86_VENDOR_TRANSMETA 7
  4730. +#define X86_VENDOR_NSC 8
  4731. +#define X86_VENDOR_UNKNOWN 0xff
  4732. +
  4733. +/*
  4734. + * EFLAGS bits
  4735. + */
  4736. +#define X86_EFLAGS_CF 0x00000001 /* Carry Flag */
  4737. +#define X86_EFLAGS_PF 0x00000004 /* Parity Flag */
  4738. +#define X86_EFLAGS_AF 0x00000010 /* Auxillary carry Flag */
  4739. +#define X86_EFLAGS_ZF 0x00000040 /* Zero Flag */
  4740. +#define X86_EFLAGS_SF 0x00000080 /* Sign Flag */
  4741. +#define X86_EFLAGS_TF 0x00000100 /* Trap Flag */
  4742. +#define X86_EFLAGS_IF 0x00000200 /* Interrupt Flag */
  4743. +#define X86_EFLAGS_DF 0x00000400 /* Direction Flag */
  4744. +#define X86_EFLAGS_OF 0x00000800 /* Overflow Flag */
  4745. +#define X86_EFLAGS_IOPL 0x00003000 /* IOPL mask */
  4746. +#define X86_EFLAGS_NT 0x00004000 /* Nested Task */
  4747. +#define X86_EFLAGS_RF 0x00010000 /* Resume Flag */
  4748. +#define X86_EFLAGS_VM 0x00020000 /* Virtual Mode */
  4749. +#define X86_EFLAGS_AC 0x00040000 /* Alignment Check */
  4750. +#define X86_EFLAGS_VIF 0x00080000 /* Virtual Interrupt Flag */
  4751. +#define X86_EFLAGS_VIP 0x00100000 /* Virtual Interrupt Pending */
  4752. +#define X86_EFLAGS_ID 0x00200000 /* CPUID detection flag */
  4753. +
  4754. +/*
  4755. + * Generic CPUID function
  4756. + */
  4757. +static inline void cpuid(int op,
  4758. + unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx)
  4759. +{
  4760. + __asm__("cpuid"
  4761. + : "=a" (*eax),
  4762. + "=b" (*ebx),
  4763. + "=c" (*ecx),
  4764. + "=d" (*edx)
  4765. + : "0" (op));
  4766. +}
  4767. +
  4768. +/*
  4769. + * CPUID functions returning a single datum
  4770. + */
  4771. +static inline unsigned int cpuid_eax(unsigned int op)
  4772. +{
  4773. + unsigned int eax;
  4774. +
  4775. + __asm__("cpuid"
  4776. + : "=a" (eax)
  4777. + : "0" (op)
  4778. + : "bx", "cx", "dx");
  4779. + return eax;
  4780. +}
  4781. +static inline unsigned int cpuid_ebx(unsigned int op)
  4782. +{
  4783. + unsigned int eax, ebx;
  4784. +
  4785. + __asm__("cpuid"
  4786. + : "=a" (eax), "=b" (ebx)
  4787. + : "0" (op)
  4788. + : "cx", "dx" );
  4789. + return ebx;
  4790. +}
  4791. +static inline unsigned int cpuid_ecx(unsigned int op)
  4792. +{
  4793. + unsigned int eax, ecx;
  4794. +
  4795. + __asm__("cpuid"
  4796. + : "=a" (eax), "=c" (ecx)
  4797. + : "0" (op)
  4798. + : "bx", "dx" );
  4799. + return ecx;
  4800. +}
  4801. +static inline unsigned int cpuid_edx(unsigned int op)
  4802. +{
  4803. + unsigned int eax, edx;
  4804. +
  4805. + __asm__("cpuid"
  4806. + : "=a" (eax), "=d" (edx)
  4807. + : "0" (op)
  4808. + : "bx", "cx");
  4809. + return edx;
  4810. +}
  4811. +
  4812. +/*
  4813. + * Intel CPU features in CR4
  4814. + */
  4815. +#define X86_CR4_VME 0x0001 /* enable vm86 extensions */
  4816. +#define X86_CR4_PVI 0x0002 /* virtual interrupts flag enable */
  4817. +#define X86_CR4_TSD 0x0004 /* disable time stamp at ipl 3 */
  4818. +#define X86_CR4_DE 0x0008 /* enable debugging extensions */
  4819. +#define X86_CR4_PSE 0x0010 /* enable page size extensions */
  4820. +#define X86_CR4_PAE 0x0020 /* enable physical address extensions */
  4821. +#define X86_CR4_MCE 0x0040 /* Machine check enable */
  4822. +#define X86_CR4_PGE 0x0080 /* enable global pages */
  4823. +#define X86_CR4_PCE 0x0100 /* enable performance counters at ipl 3 */
  4824. +#define X86_CR4_OSFXSR 0x0200 /* enable fast FPU save and restore */
  4825. +#define X86_CR4_OSXMMEXCPT 0x0400 /* enable unmasked SSE exceptions */
  4826. +
  4827. +
  4828. +#define MSR_K6_EFER 0xC0000080
  4829. +/* EFER bits: */
  4830. +#define _EFER_SCE 0 /* SYSCALL/SYSRET */
  4831. +#define _EFER_LME 8 /* Long mode enable */
  4832. +#define _EFER_LMA 10 /* Long mode active (read-only) */
  4833. +#define _EFER_NX 11 /* No execute enable */
  4834. +
  4835. +#define EFER_SCE (1<<_EFER_SCE)
  4836. +#define EFER_LME (1<<EFER_LME)
  4837. +#define EFER_LMA (1<<EFER_LMA)
  4838. +#define EFER_NX (1<<_EFER_NX)
  4839. +
  4840. +#define rdmsr(msr,val1,val2) \
  4841. + __asm__ __volatile__("rdmsr" \
  4842. + : "=a" (val1), "=d" (val2) \
  4843. + : "c" (msr))
  4844. +
  4845. +#define wrmsr(msr,val1,val2) \
  4846. + __asm__ __volatile__("wrmsr" \
  4847. + : /* no outputs */ \
  4848. + : "c" (msr), "a" (val1), "d" (val2))
  4849. +
  4850. +
  4851. +#define read_cr0() ({ \
  4852. + unsigned int __dummy; \
  4853. + __asm__( \
  4854. + "movl %%cr0, %0\n\t" \
  4855. + :"=r" (__dummy)); \
  4856. + __dummy; \
  4857. +})
  4858. +#define write_cr0(x) \
  4859. + __asm__("movl %0,%%cr0": :"r" (x));
  4860. +
  4861. +#define read_cr3() ({ \
  4862. + unsigned int __dummy; \
  4863. + __asm__( \
  4864. + "movl %%cr3, %0\n\t" \
  4865. + :"=r" (__dummy)); \
  4866. + __dummy; \
  4867. +})
  4868. +#define write_cr3x(x) \
  4869. + __asm__("movl %0,%%cr3": :"r" (x));
  4870. +
  4871. +
  4872. +#define read_cr4() ({ \
  4873. + unsigned int __dummy; \
  4874. + __asm__( \
  4875. + "movl %%cr4, %0\n\t" \
  4876. + :"=r" (__dummy)); \
  4877. + __dummy; \
  4878. +})
  4879. +#define write_cr4x(x) \
  4880. + __asm__("movl %0,%%cr4": :"r" (x));
  4881. +
  4882. +
  4883. +extern struct cpuinfo_x86 cpu_info;
  4884. +#ifdef CONFIG_X86_64
  4885. +extern void cpu_setup(void);
  4886. +#else
  4887. +#define cpu_setup() do {} while(0)
  4888. +#endif
  4889. +
  4890. +#endif /* I386_BITS_CPU_H */
  4891. diff -Naur grub-0.97.orig/netboot/cs89x0.c grub-0.97/netboot/cs89x0.c
  4892. --- grub-0.97.orig/netboot/cs89x0.c 2003-07-09 11:45:37.000000000 +0000
  4893. +++ grub-0.97/netboot/cs89x0.c 1970-01-01 00:00:00.000000000 +0000
  4894. @@ -1,659 +0,0 @@
  4895. -/* cs89x0.c: A Crystal Semiconductor CS89[02]0 driver for etherboot. */
  4896. -/*
  4897. - Permission is granted to distribute the enclosed cs89x0.[ch] driver
  4898. - only in conjunction with the Etherboot package. The code is
  4899. - ordinarily distributed under the GPL.
  4900. -
  4901. - Russ Nelson, January 2000
  4902. -
  4903. - ChangeLog:
  4904. -
  4905. - Thu Dec 6 22:40:00 1996 Markus Gutschke <gutschk@math.uni-muenster.de>
  4906. -
  4907. - * disabled all "advanced" features; this should make the code more reliable
  4908. -
  4909. - * reorganized the reset function
  4910. -
  4911. - * always reset the address port, so that autoprobing will continue working
  4912. -
  4913. - * some cosmetic changes
  4914. -
  4915. - * 2.5
  4916. -
  4917. - Thu Dec 5 21:00:00 1996 Markus Gutschke <gutschk@math.uni-muenster.de>
  4918. -
  4919. - * tested the code against a CS8900 card
  4920. -
  4921. - * lots of minor bug fixes and adjustments
  4922. -
  4923. - * this is the first release, that actually works! it still requires some
  4924. - changes in order to be more tolerant to different environments
  4925. -
  4926. - * 4
  4927. -
  4928. - Fri Nov 22 23:00:00 1996 Markus Gutschke <gutschk@math.uni-muenster.de>
  4929. -
  4930. - * read the manuals for the CS89x0 chipsets and took note of all the
  4931. - changes that will be neccessary in order to adapt Russel Nelson's code
  4932. - to the requirements of a BOOT-Prom
  4933. -
  4934. - * 6
  4935. -
  4936. - Thu Nov 19 22:00:00 1996 Markus Gutschke <gutschk@math.uni-muenster.de>
  4937. -
  4938. - * Synched with Russel Nelson's current code (v1.00)
  4939. -
  4940. - * 2
  4941. -
  4942. - Thu Nov 12 18:00:00 1996 Markus Gutschke <gutschk@math.uni-muenster.de>
  4943. -
  4944. - * Cleaned up some of the code and tried to optimize the code size.
  4945. -
  4946. - * 1.5
  4947. -
  4948. - Sun Nov 10 16:30:00 1996 Markus Gutschke <gutschk@math.uni-muenster.de>
  4949. -
  4950. - * First experimental release. This code compiles fine, but I
  4951. - have no way of testing whether it actually works.
  4952. -
  4953. - * I did not (yet) bother to make the code 16bit aware, so for
  4954. - the time being, it will only work for Etherboot/32.
  4955. -
  4956. - * 12
  4957. -
  4958. - */
  4959. -
  4960. -#include "etherboot.h"
  4961. -#include "nic.h"
  4962. -#include "cards.h"
  4963. -#include "cs89x0.h"
  4964. -
  4965. -static unsigned short eth_nic_base;
  4966. -static unsigned long eth_mem_start;
  4967. -static unsigned short eth_irq;
  4968. -static unsigned short eth_cs_type; /* one of: CS8900, CS8920, CS8920M */
  4969. -static unsigned short eth_auto_neg_cnf;
  4970. -static unsigned short eth_adapter_cnf;
  4971. -static unsigned short eth_linectl;
  4972. -
  4973. -/*************************************************************************
  4974. - CS89x0 - specific routines
  4975. -**************************************************************************/
  4976. -
  4977. -static inline int readreg(int portno)
  4978. -{
  4979. - outw(portno, eth_nic_base + ADD_PORT);
  4980. - return inw(eth_nic_base + DATA_PORT);
  4981. -}
  4982. -
  4983. -static inline void writereg(int portno, int value)
  4984. -{
  4985. - outw(portno, eth_nic_base + ADD_PORT);
  4986. - outw(value, eth_nic_base + DATA_PORT);
  4987. - return;
  4988. -}
  4989. -
  4990. -/*************************************************************************
  4991. -EEPROM access
  4992. -**************************************************************************/
  4993. -
  4994. -static int wait_eeprom_ready(void)
  4995. -{
  4996. - unsigned long tmo = currticks() + 4*TICKS_PER_SEC;
  4997. -
  4998. - /* check to see if the EEPROM is ready, a timeout is used -
  4999. - just in case EEPROM is ready when SI_BUSY in the
  5000. - PP_SelfST is clear */
  5001. - while(readreg(PP_SelfST) & SI_BUSY) {
  5002. - if (currticks() >= tmo)
  5003. - return -1; }
  5004. - return 0;
  5005. -}
  5006. -
  5007. -static int get_eeprom_data(int off, int len, unsigned short *buffer)
  5008. -{
  5009. - int i;
  5010. -
  5011. -#ifdef EDEBUG
  5012. - printf("\ncs: EEPROM data from %hX for %hX:",off,len);
  5013. -#endif
  5014. - for (i = 0; i < len; i++) {
  5015. - if (wait_eeprom_ready() < 0)
  5016. - return -1;
  5017. - /* Now send the EEPROM read command and EEPROM location
  5018. - to read */
  5019. - writereg(PP_EECMD, (off + i) | EEPROM_READ_CMD);
  5020. - if (wait_eeprom_ready() < 0)
  5021. - return -1;
  5022. - buffer[i] = readreg(PP_EEData);
  5023. -#ifdef EDEBUG
  5024. - if (!(i%10))
  5025. - printf("\ncs: ");
  5026. - printf("%hX ", buffer[i]);
  5027. -#endif
  5028. - }
  5029. -#ifdef EDEBUG
  5030. - putchar('\n');
  5031. -#endif
  5032. -
  5033. - return(0);
  5034. -}
  5035. -
  5036. -static int get_eeprom_chksum(int off, int len, unsigned short *buffer)
  5037. -{
  5038. - int i, cksum;
  5039. -
  5040. - cksum = 0;
  5041. - for (i = 0; i < len; i++)
  5042. - cksum += buffer[i];
  5043. - cksum &= 0xffff;
  5044. - if (cksum == 0)
  5045. - return 0;
  5046. - return -1;
  5047. -}
  5048. -
  5049. -/*************************************************************************
  5050. -Activate all of the available media and probe for network
  5051. -**************************************************************************/
  5052. -
  5053. -static void clrline(void)
  5054. -{
  5055. - int i;
  5056. -
  5057. - putchar('\r');
  5058. - for (i = 79; i--; ) putchar(' ');
  5059. - printf("\rcs: ");
  5060. - return;
  5061. -}
  5062. -
  5063. -static void control_dc_dc(int on_not_off)
  5064. -{
  5065. - unsigned int selfcontrol;
  5066. - unsigned long tmo = currticks() + TICKS_PER_SEC;
  5067. -
  5068. - /* control the DC to DC convertor in the SelfControl register. */
  5069. - selfcontrol = HCB1_ENBL; /* Enable the HCB1 bit as an output */
  5070. - if (((eth_adapter_cnf & A_CNF_DC_DC_POLARITY) != 0) ^ on_not_off)
  5071. - selfcontrol |= HCB1;
  5072. - else
  5073. - selfcontrol &= ~HCB1;
  5074. - writereg(PP_SelfCTL, selfcontrol);
  5075. -
  5076. - /* Wait for the DC/DC converter to power up - 1000ms */
  5077. - while (currticks() < tmo);
  5078. -
  5079. - return;
  5080. -}
  5081. -
  5082. -static int detect_tp(void)
  5083. -{
  5084. - unsigned long tmo;
  5085. -
  5086. - /* Turn on the chip auto detection of 10BT/ AUI */
  5087. -
  5088. - clrline(); printf("attempting %s:","TP");
  5089. -
  5090. - /* If connected to another full duplex capable 10-Base-T card
  5091. - the link pulses seem to be lost when the auto detect bit in
  5092. - the LineCTL is set. To overcome this the auto detect bit
  5093. - will be cleared whilst testing the 10-Base-T interface.
  5094. - This would not be necessary for the sparrow chip but is
  5095. - simpler to do it anyway. */
  5096. - writereg(PP_LineCTL, eth_linectl &~ AUI_ONLY);
  5097. - control_dc_dc(0);
  5098. -
  5099. - /* Delay for the hardware to work out if the TP cable is
  5100. - present - 150ms */
  5101. - for (tmo = currticks() + 4; currticks() < tmo; );
  5102. -
  5103. - if ((readreg(PP_LineST) & LINK_OK) == 0)
  5104. - return 0;
  5105. -
  5106. - if (eth_cs_type != CS8900) {
  5107. -
  5108. - writereg(PP_AutoNegCTL, eth_auto_neg_cnf & AUTO_NEG_MASK);
  5109. -
  5110. - if ((eth_auto_neg_cnf & AUTO_NEG_BITS) == AUTO_NEG_ENABLE) {
  5111. - printf(" negotiating duplex... ");
  5112. - while (readreg(PP_AutoNegST) & AUTO_NEG_BUSY) {
  5113. - if (currticks() - tmo > 40*TICKS_PER_SEC) {
  5114. - printf("time out ");
  5115. - break;
  5116. - }
  5117. - }
  5118. - }
  5119. - if (readreg(PP_AutoNegST) & FDX_ACTIVE)
  5120. - printf("using full duplex");
  5121. - else
  5122. - printf("using half duplex");
  5123. - }
  5124. -
  5125. - return A_CNF_MEDIA_10B_T;
  5126. -}
  5127. -
  5128. -/* send a test packet - return true if carrier bits are ok */
  5129. -static int send_test_pkt(struct nic *nic)
  5130. -{
  5131. - static unsigned char testpacket[] = { 0,0,0,0,0,0, 0,0,0,0,0,0,
  5132. - 0, 46, /*A 46 in network order */
  5133. - 0, 0, /*DSAP=0 & SSAP=0 fields */
  5134. - 0xf3,0 /*Control (Test Req+P bit set)*/ };
  5135. - unsigned long tmo;
  5136. -
  5137. - writereg(PP_LineCTL, readreg(PP_LineCTL) | SERIAL_TX_ON);
  5138. -
  5139. - memcpy(testpacket, nic->node_addr, ETH_ALEN);
  5140. - memcpy(testpacket+ETH_ALEN, nic->node_addr, ETH_ALEN);
  5141. -
  5142. - outw(TX_AFTER_ALL, eth_nic_base + TX_CMD_PORT);
  5143. - outw(ETH_ZLEN, eth_nic_base + TX_LEN_PORT);
  5144. -
  5145. - /* Test to see if the chip has allocated memory for the packet */
  5146. - for (tmo = currticks() + 2;
  5147. - (readreg(PP_BusST) & READY_FOR_TX_NOW) == 0; )
  5148. - if (currticks() >= tmo)
  5149. - return(0);
  5150. -
  5151. - /* Write the contents of the packet */
  5152. - outsw(eth_nic_base + TX_FRAME_PORT, testpacket,
  5153. - (ETH_ZLEN+1)>>1);
  5154. -
  5155. - printf(" sending test packet ");
  5156. - /* wait a couple of timer ticks for packet to be received */
  5157. - for (tmo = currticks() + 2; currticks() < tmo; );
  5158. -
  5159. - if ((readreg(PP_TxEvent) & TX_SEND_OK_BITS) == TX_OK) {
  5160. - printf("succeeded");
  5161. - return 1;
  5162. - }
  5163. - printf("failed");
  5164. - return 0;
  5165. -}
  5166. -
  5167. -
  5168. -static int detect_aui(struct nic *nic)
  5169. -{
  5170. - clrline(); printf("attempting %s:","AUI");
  5171. - control_dc_dc(0);
  5172. -
  5173. - writereg(PP_LineCTL, (eth_linectl & ~AUTO_AUI_10BASET) | AUI_ONLY);
  5174. -
  5175. - if (send_test_pkt(nic)) {
  5176. - return A_CNF_MEDIA_AUI; }
  5177. - else
  5178. - return 0;
  5179. -}
  5180. -
  5181. -static int detect_bnc(struct nic *nic)
  5182. -{
  5183. - clrline(); printf("attempting %s:","BNC");
  5184. - control_dc_dc(1);
  5185. -
  5186. - writereg(PP_LineCTL, (eth_linectl & ~AUTO_AUI_10BASET) | AUI_ONLY);
  5187. -
  5188. - if (send_test_pkt(nic)) {
  5189. - return A_CNF_MEDIA_10B_2; }
  5190. - else
  5191. - return 0;
  5192. -}
  5193. -
  5194. -/**************************************************************************
  5195. -ETH_RESET - Reset adapter
  5196. -***************************************************************************/
  5197. -
  5198. -static void cs89x0_reset(struct nic *nic)
  5199. -{
  5200. - int i;
  5201. - unsigned long reset_tmo;
  5202. -
  5203. - writereg(PP_SelfCTL, readreg(PP_SelfCTL) | POWER_ON_RESET);
  5204. -
  5205. - /* wait for two ticks; that is 2*55ms */
  5206. - for (reset_tmo = currticks() + 2; currticks() < reset_tmo; );
  5207. -
  5208. - if (eth_cs_type != CS8900) {
  5209. - /* Hardware problem requires PNP registers to be reconfigured
  5210. - after a reset */
  5211. - if (eth_irq != 0xFFFF) {
  5212. - outw(PP_CS8920_ISAINT, eth_nic_base + ADD_PORT);
  5213. - outb(eth_irq, eth_nic_base + DATA_PORT);
  5214. - outb(0, eth_nic_base + DATA_PORT + 1); }
  5215. -
  5216. - if (eth_mem_start) {
  5217. - outw(PP_CS8920_ISAMemB, eth_nic_base + ADD_PORT);
  5218. - outb((eth_mem_start >> 8) & 0xff, eth_nic_base + DATA_PORT);
  5219. - outb((eth_mem_start >> 24) & 0xff, eth_nic_base + DATA_PORT + 1); } }
  5220. -
  5221. - /* Wait until the chip is reset */
  5222. - for (reset_tmo = currticks() + 2;
  5223. - (readreg(PP_SelfST) & INIT_DONE) == 0 &&
  5224. - currticks() < reset_tmo; );
  5225. -
  5226. - /* disable interrupts and memory accesses */
  5227. - writereg(PP_BusCTL, 0);
  5228. -
  5229. - /* set the ethernet address */
  5230. - for (i=0; i < ETH_ALEN/2; i++)
  5231. - writereg(PP_IA+i*2,
  5232. - nic->node_addr[i*2] |
  5233. - (nic->node_addr[i*2+1] << 8));
  5234. -
  5235. - /* receive only error free packets addressed to this card */
  5236. - writereg(PP_RxCTL, DEF_RX_ACCEPT);
  5237. -
  5238. - /* do not generate any interrupts on receive operations */
  5239. - writereg(PP_RxCFG, 0);
  5240. -
  5241. - /* do not generate any interrupts on transmit operations */
  5242. - writereg(PP_TxCFG, 0);
  5243. -
  5244. - /* do not generate any interrupts on buffer operations */
  5245. - writereg(PP_BufCFG, 0);
  5246. -
  5247. - /* reset address port, so that autoprobing will keep working */
  5248. - outw(PP_ChipID, eth_nic_base + ADD_PORT);
  5249. -
  5250. - return;
  5251. -}
  5252. -
  5253. -/**************************************************************************
  5254. -ETH_TRANSMIT - Transmit a frame
  5255. -***************************************************************************/
  5256. -
  5257. -static void cs89x0_transmit(
  5258. - struct nic *nic,
  5259. - const char *d, /* Destination */
  5260. - unsigned int t, /* Type */
  5261. - unsigned int s, /* size */
  5262. - const char *p) /* Packet */
  5263. -{
  5264. - unsigned long tmo;
  5265. - int sr;
  5266. -
  5267. - /* does this size have to be rounded??? please,
  5268. - somebody have a look in the specs */
  5269. - if ((sr = ((s + ETH_HLEN + 1)&~1)) < ETH_ZLEN)
  5270. - sr = ETH_ZLEN;
  5271. -
  5272. -retry:
  5273. - /* initiate a transmit sequence */
  5274. - outw(TX_AFTER_ALL, eth_nic_base + TX_CMD_PORT);
  5275. - outw(sr, eth_nic_base + TX_LEN_PORT);
  5276. -
  5277. - /* Test to see if the chip has allocated memory for the packet */
  5278. - if ((readreg(PP_BusST) & READY_FOR_TX_NOW) == 0) {
  5279. - /* Oops... this should not happen! */
  5280. - printf("cs: unable to send packet; retrying...\n");
  5281. - for (tmo = currticks() + 5*TICKS_PER_SEC; currticks() < tmo; );
  5282. - cs89x0_reset(nic);
  5283. - goto retry; }
  5284. -
  5285. - /* Write the contents of the packet */
  5286. - outsw(eth_nic_base + TX_FRAME_PORT, d, ETH_ALEN/2);
  5287. - outsw(eth_nic_base + TX_FRAME_PORT, nic->node_addr,
  5288. - ETH_ALEN/2);
  5289. - outw(((t >> 8)&0xFF)|(t << 8), eth_nic_base + TX_FRAME_PORT);
  5290. - outsw(eth_nic_base + TX_FRAME_PORT, p, (s+1)/2);
  5291. - for (sr = sr/2 - (s+1)/2 - ETH_ALEN - 1; sr-- > 0;
  5292. - outw(0, eth_nic_base + TX_FRAME_PORT));
  5293. -
  5294. - /* wait for transfer to succeed */
  5295. - for (tmo = currticks()+5*TICKS_PER_SEC;
  5296. - (s = readreg(PP_TxEvent)&~0x1F) == 0 && currticks() < tmo;)
  5297. - /* nothing */ ;
  5298. - if ((s & TX_SEND_OK_BITS) != TX_OK) {
  5299. - printf("\ntransmission error %#hX\n", s);
  5300. - }
  5301. -
  5302. - return;
  5303. -}
  5304. -
  5305. -/**************************************************************************
  5306. -ETH_POLL - Wait for a frame
  5307. -***************************************************************************/
  5308. -
  5309. -static int cs89x0_poll(struct nic *nic)
  5310. -{
  5311. - int status;
  5312. -
  5313. - status = readreg(PP_RxEvent);
  5314. -
  5315. - if ((status & RX_OK) == 0)
  5316. - return(0);
  5317. -
  5318. - status = inw(eth_nic_base + RX_FRAME_PORT);
  5319. - nic->packetlen = inw(eth_nic_base + RX_FRAME_PORT);
  5320. - insw(eth_nic_base + RX_FRAME_PORT, nic->packet, nic->packetlen >> 1);
  5321. - if (nic->packetlen & 1)
  5322. - nic->packet[nic->packetlen-1] = inw(eth_nic_base + RX_FRAME_PORT);
  5323. - return 1;
  5324. -}
  5325. -
  5326. -static void cs89x0_disable(struct nic *nic)
  5327. -{
  5328. - cs89x0_reset(nic);
  5329. -}
  5330. -
  5331. -/**************************************************************************
  5332. -ETH_PROBE - Look for an adapter
  5333. -***************************************************************************/
  5334. -
  5335. -struct nic *cs89x0_probe(struct nic *nic, unsigned short *probe_addrs)
  5336. -{
  5337. - static const unsigned int netcard_portlist[] = {
  5338. -#ifdef CS_SCAN
  5339. - CS_SCAN,
  5340. -#else /* use "conservative" default values for autoprobing */
  5341. - 0x300,0x320,0x340,0x200,0x220,0x240,
  5342. - 0x260,0x280,0x2a0,0x2c0,0x2e0,
  5343. - /* if that did not work, then be more aggressive */
  5344. - 0x301,0x321,0x341,0x201,0x221,0x241,
  5345. - 0x261,0x281,0x2a1,0x2c1,0x2e1,
  5346. -#endif
  5347. - 0};
  5348. -
  5349. - int i, result = -1;
  5350. - unsigned rev_type = 0, ioaddr, ioidx, isa_cnf, cs_revision;
  5351. - unsigned short eeprom_buff[CHKSUM_LEN];
  5352. -
  5353. -
  5354. - for (ioidx = 0; (ioaddr=netcard_portlist[ioidx++]) != 0; ) {
  5355. - /* if they give us an odd I/O address, then do ONE write to
  5356. - the address port, to get it back to address zero, where we
  5357. - expect to find the EISA signature word. */
  5358. - if (ioaddr & 1) {
  5359. - ioaddr &= ~1;
  5360. - if ((inw(ioaddr + ADD_PORT) & ADD_MASK) != ADD_SIG)
  5361. - continue;
  5362. - outw(PP_ChipID, ioaddr + ADD_PORT);
  5363. - }
  5364. -
  5365. - if (inw(ioaddr + DATA_PORT) != CHIP_EISA_ID_SIG)
  5366. - continue;
  5367. - eth_nic_base = ioaddr;
  5368. -
  5369. - /* get the chip type */
  5370. - rev_type = readreg(PRODUCT_ID_ADD);
  5371. - eth_cs_type = rev_type &~ REVISON_BITS;
  5372. - cs_revision = ((rev_type & REVISON_BITS) >> 8) + 'A';
  5373. -
  5374. - printf("\ncs: cs89%c0%s rev %c, base %#hX",
  5375. - eth_cs_type==CS8900?'0':'2',
  5376. - eth_cs_type==CS8920M?"M":"",
  5377. - cs_revision,
  5378. - eth_nic_base);
  5379. -
  5380. - /* First check to see if an EEPROM is attached*/
  5381. - if ((readreg(PP_SelfST) & EEPROM_PRESENT) == 0) {
  5382. - printf("\ncs: no EEPROM...\n");
  5383. - outw(PP_ChipID, eth_nic_base + ADD_PORT);
  5384. - continue; }
  5385. - else if (get_eeprom_data(START_EEPROM_DATA,CHKSUM_LEN,
  5386. - eeprom_buff) < 0) {
  5387. - printf("\ncs: EEPROM read failed...\n");
  5388. - outw(PP_ChipID, eth_nic_base + ADD_PORT);
  5389. - continue; }
  5390. - else if (get_eeprom_chksum(START_EEPROM_DATA,CHKSUM_LEN,
  5391. - eeprom_buff) < 0) {
  5392. - printf("\ncs: EEPROM checksum bad...\n");
  5393. - outw(PP_ChipID, eth_nic_base + ADD_PORT);
  5394. - continue; }
  5395. -
  5396. - /* get transmission control word but keep the
  5397. - autonegotiation bits */
  5398. - eth_auto_neg_cnf = eeprom_buff[AUTO_NEG_CNF_OFFSET/2];
  5399. - /* Store adapter configuration */
  5400. - eth_adapter_cnf = eeprom_buff[ADAPTER_CNF_OFFSET/2];
  5401. - /* Store ISA configuration */
  5402. - isa_cnf = eeprom_buff[ISA_CNF_OFFSET/2];
  5403. -
  5404. - /* store the initial memory base address */
  5405. - eth_mem_start = eeprom_buff[PACKET_PAGE_OFFSET/2] << 8;
  5406. -
  5407. - printf("%s%s%s, addr ",
  5408. - (eth_adapter_cnf & A_CNF_10B_T)?", RJ-45":"",
  5409. - (eth_adapter_cnf & A_CNF_AUI)?", AUI":"",
  5410. - (eth_adapter_cnf & A_CNF_10B_2)?", BNC":"");
  5411. -
  5412. - /* If this is a CS8900 then no pnp soft */
  5413. - if (eth_cs_type != CS8900 &&
  5414. - /* Check if the ISA IRQ has been set */
  5415. - (i = readreg(PP_CS8920_ISAINT) & 0xff,
  5416. - (i != 0 && i < CS8920_NO_INTS)))
  5417. - eth_irq = i;
  5418. - else {
  5419. - i = isa_cnf & INT_NO_MASK;
  5420. - if (eth_cs_type == CS8900) {
  5421. - /* the table that follows is dependent
  5422. - upon how you wired up your cs8900
  5423. - in your system. The table is the
  5424. - same as the cs8900 engineering demo
  5425. - board. irq_map also depends on the
  5426. - contents of the table. Also see
  5427. - write_irq, which is the reverse
  5428. - mapping of the table below. */
  5429. - if (i < 4) i = "\012\013\014\005"[i];
  5430. - else printf("\ncs: BUG: isa_config is %d\n", i); }
  5431. - eth_irq = i; }
  5432. -
  5433. - /* Retrieve and print the ethernet address. */
  5434. - for (i=0; i<ETH_ALEN; i++) {
  5435. - nic->node_addr[i] = ((unsigned char *)eeprom_buff)[i];
  5436. - }
  5437. - printf("%!\n", nic->node_addr);
  5438. -
  5439. - /* Set the LineCTL quintuplet based on adapter
  5440. - configuration read from EEPROM */
  5441. - if ((eth_adapter_cnf & A_CNF_EXTND_10B_2) &&
  5442. - (eth_adapter_cnf & A_CNF_LOW_RX_SQUELCH))
  5443. - eth_linectl = LOW_RX_SQUELCH;
  5444. - else
  5445. - eth_linectl = 0;
  5446. -
  5447. - /* check to make sure that they have the "right"
  5448. - hardware available */
  5449. - switch(eth_adapter_cnf & A_CNF_MEDIA_TYPE) {
  5450. - case A_CNF_MEDIA_10B_T: result = eth_adapter_cnf & A_CNF_10B_T;
  5451. - break;
  5452. - case A_CNF_MEDIA_AUI: result = eth_adapter_cnf & A_CNF_AUI;
  5453. - break;
  5454. - case A_CNF_MEDIA_10B_2: result = eth_adapter_cnf & A_CNF_10B_2;
  5455. - break;
  5456. - default: result = eth_adapter_cnf & (A_CNF_10B_T | A_CNF_AUI |
  5457. - A_CNF_10B_2);
  5458. - }
  5459. - if (!result) {
  5460. - printf("cs: EEPROM is configured for unavailable media\n");
  5461. - error:
  5462. - writereg(PP_LineCTL, readreg(PP_LineCTL) &
  5463. - ~(SERIAL_TX_ON | SERIAL_RX_ON));
  5464. - outw(PP_ChipID, eth_nic_base + ADD_PORT);
  5465. - continue;
  5466. - }
  5467. -
  5468. - /* Initialize the card for probing of the attached media */
  5469. - cs89x0_reset(nic);
  5470. -
  5471. - /* set the hardware to the configured choice */
  5472. - switch(eth_adapter_cnf & A_CNF_MEDIA_TYPE) {
  5473. - case A_CNF_MEDIA_10B_T:
  5474. - result = detect_tp();
  5475. - if (!result) {
  5476. - clrline();
  5477. - printf("10Base-T (RJ-45%s",
  5478. - ") has no cable\n"); }
  5479. - /* check "ignore missing media" bit */
  5480. - if (eth_auto_neg_cnf & IMM_BIT)
  5481. - /* Yes! I don't care if I see a link pulse */
  5482. - result = A_CNF_MEDIA_10B_T;
  5483. - break;
  5484. - case A_CNF_MEDIA_AUI:
  5485. - result = detect_aui(nic);
  5486. - if (!result) {
  5487. - clrline();
  5488. - printf("10Base-5 (AUI%s",
  5489. - ") has no cable\n"); }
  5490. - /* check "ignore missing media" bit */
  5491. - if (eth_auto_neg_cnf & IMM_BIT)
  5492. - /* Yes! I don't care if I see a carrrier */
  5493. - result = A_CNF_MEDIA_AUI;
  5494. - break;
  5495. - case A_CNF_MEDIA_10B_2:
  5496. - result = detect_bnc(nic);
  5497. - if (!result) {
  5498. - clrline();
  5499. - printf("10Base-2 (BNC%s",
  5500. - ") has no cable\n"); }
  5501. - /* check "ignore missing media" bit */
  5502. - if (eth_auto_neg_cnf & IMM_BIT)
  5503. - /* Yes! I don't care if I can xmit a packet */
  5504. - result = A_CNF_MEDIA_10B_2;
  5505. - break;
  5506. - case A_CNF_MEDIA_AUTO:
  5507. - writereg(PP_LineCTL, eth_linectl | AUTO_AUI_10BASET);
  5508. - if (eth_adapter_cnf & A_CNF_10B_T)
  5509. - if ((result = detect_tp()) != 0)
  5510. - break;
  5511. - if (eth_adapter_cnf & A_CNF_AUI)
  5512. - if ((result = detect_aui(nic)) != 0)
  5513. - break;
  5514. - if (eth_adapter_cnf & A_CNF_10B_2)
  5515. - if ((result = detect_bnc(nic)) != 0)
  5516. - break;
  5517. - clrline(); printf("no media detected\n");
  5518. - goto error;
  5519. - }
  5520. - clrline();
  5521. - switch(result) {
  5522. - case 0: printf("no network cable attached to configured media\n");
  5523. - goto error;
  5524. - case A_CNF_MEDIA_10B_T: printf("using 10Base-T (RJ-45)\n");
  5525. - break;
  5526. - case A_CNF_MEDIA_AUI: printf("using 10Base-5 (AUI)\n");
  5527. - break;
  5528. - case A_CNF_MEDIA_10B_2: printf("using 10Base-2 (BNC)\n");
  5529. - break;
  5530. - }
  5531. -
  5532. - /* Turn on both receive and transmit operations */
  5533. - writereg(PP_LineCTL, readreg(PP_LineCTL) | SERIAL_RX_ON |
  5534. - SERIAL_TX_ON);
  5535. -
  5536. - break;
  5537. - }
  5538. -
  5539. - if (ioaddr == 0)
  5540. - return (0);
  5541. - nic->reset = cs89x0_reset;
  5542. - nic->poll = cs89x0_poll;
  5543. - nic->transmit = cs89x0_transmit;
  5544. - nic->disable = cs89x0_disable;
  5545. - return (nic);
  5546. -}
  5547. -
  5548. -/*
  5549. - * Local variables:
  5550. - * c-basic-offset: 8
  5551. - * End:
  5552. - */
  5553. -
  5554. diff -Naur grub-0.97.orig/netboot/cs89x0.h grub-0.97/netboot/cs89x0.h
  5555. --- grub-0.97.orig/netboot/cs89x0.h 2003-07-09 11:45:37.000000000 +0000
  5556. +++ grub-0.97/netboot/cs89x0.h 1970-01-01 00:00:00.000000000 +0000
  5557. @@ -1,461 +0,0 @@
  5558. -/* Copyright, 1988-1992, Russell Nelson, Crynwr Software
  5559. -
  5560. - This program is free software; you can redistribute it and/or modify
  5561. - it under the terms of the GNU General Public License as published by
  5562. - the Free Software Foundation, version 1.
  5563. -
  5564. - This program is distributed in the hope that it will be useful,
  5565. - but WITHOUT ANY WARRANTY; without even the implied warranty of
  5566. - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5567. - GNU General Public License for more details.
  5568. -
  5569. - You should have received a copy of the GNU General Public License
  5570. - along with this program; if not, write to the Free Software
  5571. - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
  5572. -
  5573. -#define PP_ChipID 0x0000 /* offset 0h -> Corp -ID */
  5574. - /* offset 2h -> Model/Product Number */
  5575. - /* offset 3h -> Chip Revision Number */
  5576. -
  5577. -#define PP_ISAIOB 0x0020 /* IO base address */
  5578. -#define PP_CS8900_ISAINT 0x0022 /* ISA interrupt select */
  5579. -#define PP_CS8920_ISAINT 0x0370 /* ISA interrupt select */
  5580. -#define PP_CS8900_ISADMA 0x0024 /* ISA Rec DMA channel */
  5581. -#define PP_CS8920_ISADMA 0x0374 /* ISA Rec DMA channel */
  5582. -#define PP_ISASOF 0x0026 /* ISA DMA offset */
  5583. -#define PP_DmaFrameCnt 0x0028 /* ISA DMA Frame count */
  5584. -#define PP_DmaByteCnt 0x002A /* ISA DMA Byte count */
  5585. -#define PP_CS8900_ISAMemB 0x002C /* Memory base */
  5586. -#define PP_CS8920_ISAMemB 0x0348 /* */
  5587. -
  5588. -#define PP_ISABootBase 0x0030 /* Boot Prom base */
  5589. -#define PP_ISABootMask 0x0034 /* Boot Prom Mask */
  5590. -
  5591. -/* EEPROM data and command registers */
  5592. -#define PP_EECMD 0x0040 /* NVR Interface Command register */
  5593. -#define PP_EEData 0x0042 /* NVR Interface Data Register */
  5594. -#define PP_DebugReg 0x0044 /* Debug Register */
  5595. -
  5596. -#define PP_RxCFG 0x0102 /* Rx Bus config */
  5597. -#define PP_RxCTL 0x0104 /* Receive Control Register */
  5598. -#define PP_TxCFG 0x0106 /* Transmit Config Register */
  5599. -#define PP_TxCMD 0x0108 /* Transmit Command Register */
  5600. -#define PP_BufCFG 0x010A /* Bus configuration Register */
  5601. -#define PP_LineCTL 0x0112 /* Line Config Register */
  5602. -#define PP_SelfCTL 0x0114 /* Self Command Register */
  5603. -#define PP_BusCTL 0x0116 /* ISA bus control Register */
  5604. -#define PP_TestCTL 0x0118 /* Test Register */
  5605. -#define PP_AutoNegCTL 0x011C /* Auto Negotiation Ctrl */
  5606. -
  5607. -#define PP_ISQ 0x0120 /* Interrupt Status */
  5608. -#define PP_RxEvent 0x0124 /* Rx Event Register */
  5609. -#define PP_TxEvent 0x0128 /* Tx Event Register */
  5610. -#define PP_BufEvent 0x012C /* Bus Event Register */
  5611. -#define PP_RxMiss 0x0130 /* Receive Miss Count */
  5612. -#define PP_TxCol 0x0132 /* Transmit Collision Count */
  5613. -#define PP_LineST 0x0134 /* Line State Register */
  5614. -#define PP_SelfST 0x0136 /* Self State register */
  5615. -#define PP_BusST 0x0138 /* Bus Status */
  5616. -#define PP_TDR 0x013C /* Time Domain Reflectometry */
  5617. -#define PP_AutoNegST 0x013E /* Auto Neg Status */
  5618. -#define PP_TxCommand 0x0144 /* Tx Command */
  5619. -#define PP_TxLength 0x0146 /* Tx Length */
  5620. -#define PP_LAF 0x0150 /* Hash Table */
  5621. -#define PP_IA 0x0158 /* Physical Address Register */
  5622. -
  5623. -#define PP_RxStatus 0x0400 /* Receive start of frame */
  5624. -#define PP_RxLength 0x0402 /* Receive Length of frame */
  5625. -#define PP_RxFrame 0x0404 /* Receive frame pointer */
  5626. -#define PP_TxFrame 0x0A00 /* Transmit frame pointer */
  5627. -
  5628. -/* Primary I/O Base Address. If no I/O base is supplied by the user, then this */
  5629. -/* can be used as the default I/O base to access the PacketPage Area. */
  5630. -#define DEFAULTIOBASE 0x0300
  5631. -#define FIRST_IO 0x020C /* First I/O port to check */
  5632. -#define LAST_IO 0x037C /* Last I/O port to check (+10h) */
  5633. -#define ADD_MASK 0x3000 /* Mask it use of the ADD_PORT register */
  5634. -#define ADD_SIG 0x3000 /* Expected ID signature */
  5635. -
  5636. -#define CHIP_EISA_ID_SIG 0x630E /* Product ID Code for Crystal Chip (CS8900 spec 4.3) */
  5637. -
  5638. -#ifdef IBMEIPKT
  5639. -#define EISA_ID_SIG 0x4D24 /* IBM */
  5640. -#define PART_NO_SIG 0x1010 /* IBM */
  5641. -#define MONGOOSE_BIT 0x0000 /* IBM */
  5642. -#else
  5643. -#define EISA_ID_SIG 0x630E /* PnP Vendor ID (same as chip id for Crystal board) */
  5644. -#define PART_NO_SIG 0x4000 /* ID code CS8920 board (PnP Vendor Product code) */
  5645. -#define MONGOOSE_BIT 0x2000 /* PART_NO_SIG + MONGOOSE_BUT => ID of mongoose */
  5646. -#endif
  5647. -
  5648. -#define PRODUCT_ID_ADD 0x0002 /* Address of product ID */
  5649. -
  5650. -/* Mask to find out the types of registers */
  5651. -#define REG_TYPE_MASK 0x001F
  5652. -
  5653. -/* Eeprom Commands */
  5654. -#define ERSE_WR_ENBL 0x00F0
  5655. -#define ERSE_WR_DISABLE 0x0000
  5656. -
  5657. -/* Defines Control/Config register quintuplet numbers */
  5658. -#define RX_BUF_CFG 0x0003
  5659. -#define RX_CONTROL 0x0005
  5660. -#define TX_CFG 0x0007
  5661. -#define TX_COMMAND 0x0009
  5662. -#define BUF_CFG 0x000B
  5663. -#define LINE_CONTROL 0x0013
  5664. -#define SELF_CONTROL 0x0015
  5665. -#define BUS_CONTROL 0x0017
  5666. -#define TEST_CONTROL 0x0019
  5667. -
  5668. -/* Defines Status/Count registers quintuplet numbers */
  5669. -#define RX_EVENT 0x0004
  5670. -#define TX_EVENT 0x0008
  5671. -#define BUF_EVENT 0x000C
  5672. -#define RX_MISS_COUNT 0x0010
  5673. -#define TX_COL_COUNT 0x0012
  5674. -#define LINE_STATUS 0x0014
  5675. -#define SELF_STATUS 0x0016
  5676. -#define BUS_STATUS 0x0018
  5677. -#define TDR 0x001C
  5678. -
  5679. -/* PP_RxCFG - Receive Configuration and Interrupt Mask bit definition - Read/write */
  5680. -#define SKIP_1 0x0040
  5681. -#define RX_STREAM_ENBL 0x0080
  5682. -#define RX_OK_ENBL 0x0100
  5683. -#define RX_DMA_ONLY 0x0200
  5684. -#define AUTO_RX_DMA 0x0400
  5685. -#define BUFFER_CRC 0x0800
  5686. -#define RX_CRC_ERROR_ENBL 0x1000
  5687. -#define RX_RUNT_ENBL 0x2000
  5688. -#define RX_EXTRA_DATA_ENBL 0x4000
  5689. -
  5690. -/* PP_RxCTL - Receive Control bit definition - Read/write */
  5691. -#define RX_IA_HASH_ACCEPT 0x0040
  5692. -#define RX_PROM_ACCEPT 0x0080
  5693. -#define RX_OK_ACCEPT 0x0100
  5694. -#define RX_MULTCAST_ACCEPT 0x0200
  5695. -#define RX_IA_ACCEPT 0x0400
  5696. -#define RX_BROADCAST_ACCEPT 0x0800
  5697. -#define RX_BAD_CRC_ACCEPT 0x1000
  5698. -#define RX_RUNT_ACCEPT 0x2000
  5699. -#define RX_EXTRA_DATA_ACCEPT 0x4000
  5700. -#define RX_ALL_ACCEPT (RX_PROM_ACCEPT|RX_BAD_CRC_ACCEPT|RX_RUNT_ACCEPT|RX_EXTRA_DATA_ACCEPT)
  5701. -/* Default receive mode - individually addressed, broadcast, and error free */
  5702. -#define DEF_RX_ACCEPT (RX_IA_ACCEPT | RX_BROADCAST_ACCEPT | RX_OK_ACCEPT)
  5703. -
  5704. -/* PP_TxCFG - Transmit Configuration Interrupt Mask bit definition - Read/write */
  5705. -#define TX_LOST_CRS_ENBL 0x0040
  5706. -#define TX_SQE_ERROR_ENBL 0x0080
  5707. -#define TX_OK_ENBL 0x0100
  5708. -#define TX_LATE_COL_ENBL 0x0200
  5709. -#define TX_JBR_ENBL 0x0400
  5710. -#define TX_ANY_COL_ENBL 0x0800
  5711. -#define TX_16_COL_ENBL 0x8000
  5712. -
  5713. -/* PP_TxCMD - Transmit Command bit definition - Read-only */
  5714. -#define TX_START_4_BYTES 0x0000
  5715. -#define TX_START_64_BYTES 0x0040
  5716. -#define TX_START_128_BYTES 0x0080
  5717. -#define TX_START_ALL_BYTES 0x00C0
  5718. -#define TX_FORCE 0x0100
  5719. -#define TX_ONE_COL 0x0200
  5720. -#define TX_TWO_PART_DEFF_DISABLE 0x0400
  5721. -#define TX_NO_CRC 0x1000
  5722. -#define TX_RUNT 0x2000
  5723. -
  5724. -/* PP_BufCFG - Buffer Configuration Interrupt Mask bit definition - Read/write */
  5725. -#define GENERATE_SW_INTERRUPT 0x0040
  5726. -#define RX_DMA_ENBL 0x0080
  5727. -#define READY_FOR_TX_ENBL 0x0100
  5728. -#define TX_UNDERRUN_ENBL 0x0200
  5729. -#define RX_MISS_ENBL 0x0400
  5730. -#define RX_128_BYTE_ENBL 0x0800
  5731. -#define TX_COL_COUNT_OVRFLOW_ENBL 0x1000
  5732. -#define RX_MISS_COUNT_OVRFLOW_ENBL 0x2000
  5733. -#define RX_DEST_MATCH_ENBL 0x8000
  5734. -
  5735. -/* PP_LineCTL - Line Control bit definition - Read/write */
  5736. -#define SERIAL_RX_ON 0x0040
  5737. -#define SERIAL_TX_ON 0x0080
  5738. -#define AUI_ONLY 0x0100
  5739. -#define AUTO_AUI_10BASET 0x0200
  5740. -#define MODIFIED_BACKOFF 0x0800
  5741. -#define NO_AUTO_POLARITY 0x1000
  5742. -#define TWO_PART_DEFDIS 0x2000
  5743. -#define LOW_RX_SQUELCH 0x4000
  5744. -
  5745. -/* PP_SelfCTL - Software Self Control bit definition - Read/write */
  5746. -#define POWER_ON_RESET 0x0040
  5747. -#define SW_STOP 0x0100
  5748. -#define SLEEP_ON 0x0200
  5749. -#define AUTO_WAKEUP 0x0400
  5750. -#define HCB0_ENBL 0x1000
  5751. -#define HCB1_ENBL 0x2000
  5752. -#define HCB0 0x4000
  5753. -#define HCB1 0x8000
  5754. -
  5755. -/* PP_BusCTL - ISA Bus Control bit definition - Read/write */
  5756. -#define RESET_RX_DMA 0x0040
  5757. -#define MEMORY_ON 0x0400
  5758. -#define DMA_BURST_MODE 0x0800
  5759. -#define IO_CHANNEL_READY_ON 0x1000
  5760. -#define RX_DMA_SIZE_64K 0x2000
  5761. -#define ENABLE_IRQ 0x8000
  5762. -
  5763. -/* PP_TestCTL - Test Control bit definition - Read/write */
  5764. -#define LINK_OFF 0x0080
  5765. -#define ENDEC_LOOPBACK 0x0200
  5766. -#define AUI_LOOPBACK 0x0400
  5767. -#define BACKOFF_OFF 0x0800
  5768. -#define FAST_TEST 0x8000
  5769. -
  5770. -/* PP_RxEvent - Receive Event Bit definition - Read-only */
  5771. -#define RX_IA_HASHED 0x0040
  5772. -#define RX_DRIBBLE 0x0080
  5773. -#define RX_OK 0x0100
  5774. -#define RX_HASHED 0x0200
  5775. -#define RX_IA 0x0400
  5776. -#define RX_BROADCAST 0x0800
  5777. -#define RX_CRC_ERROR 0x1000
  5778. -#define RX_RUNT 0x2000
  5779. -#define RX_EXTRA_DATA 0x4000
  5780. -
  5781. -#define HASH_INDEX_MASK 0x0FC00
  5782. -
  5783. -/* PP_TxEvent - Transmit Event Bit definition - Read-only */
  5784. -#define TX_LOST_CRS 0x0040
  5785. -#define TX_SQE_ERROR 0x0080
  5786. -#define TX_OK 0x0100
  5787. -#define TX_LATE_COL 0x0200
  5788. -#define TX_JBR 0x0400
  5789. -#define TX_16_COL 0x8000
  5790. -#define TX_SEND_OK_BITS (TX_OK|TX_LOST_CRS)
  5791. -#define TX_COL_COUNT_MASK 0x7800
  5792. -
  5793. -/* PP_BufEvent - Buffer Event Bit definition - Read-only */
  5794. -#define SW_INTERRUPT 0x0040
  5795. -#define RX_DMA 0x0080
  5796. -#define READY_FOR_TX 0x0100
  5797. -#define TX_UNDERRUN 0x0200
  5798. -#define RX_MISS 0x0400
  5799. -#define RX_128_BYTE 0x0800
  5800. -#define TX_COL_OVRFLW 0x1000
  5801. -#define RX_MISS_OVRFLW 0x2000
  5802. -#define RX_DEST_MATCH 0x8000
  5803. -
  5804. -/* PP_LineST - Ethernet Line Status bit definition - Read-only */
  5805. -#define LINK_OK 0x0080
  5806. -#define AUI_ON 0x0100
  5807. -#define TENBASET_ON 0x0200
  5808. -#define POLARITY_OK 0x1000
  5809. -#define CRS_OK 0x4000
  5810. -
  5811. -/* PP_SelfST - Chip Software Status bit definition */
  5812. -#define ACTIVE_33V 0x0040
  5813. -#define INIT_DONE 0x0080
  5814. -#define SI_BUSY 0x0100
  5815. -#define EEPROM_PRESENT 0x0200
  5816. -#define EEPROM_OK 0x0400
  5817. -#define EL_PRESENT 0x0800
  5818. -#define EE_SIZE_64 0x1000
  5819. -
  5820. -/* PP_BusST - ISA Bus Status bit definition */
  5821. -#define TX_BID_ERROR 0x0080
  5822. -#define READY_FOR_TX_NOW 0x0100
  5823. -
  5824. -/* PP_AutoNegCTL - Auto Negotiation Control bit definition */
  5825. -#define RE_NEG_NOW 0x0040
  5826. -#define ALLOW_FDX 0x0080
  5827. -#define AUTO_NEG_ENABLE 0x0100
  5828. -#define NLP_ENABLE 0x0200
  5829. -#define FORCE_FDX 0x8000
  5830. -#define AUTO_NEG_BITS (FORCE_FDX|NLP_ENABLE|AUTO_NEG_ENABLE)
  5831. -#define AUTO_NEG_MASK (FORCE_FDX|NLP_ENABLE|AUTO_NEG_ENABLE|ALLOW_FDX|RE_NEG_NOW)
  5832. -
  5833. -/* PP_AutoNegST - Auto Negotiation Status bit definition */
  5834. -#define AUTO_NEG_BUSY 0x0080
  5835. -#define FLP_LINK 0x0100
  5836. -#define FLP_LINK_GOOD 0x0800
  5837. -#define LINK_FAULT 0x1000
  5838. -#define HDX_ACTIVE 0x4000
  5839. -#define FDX_ACTIVE 0x8000
  5840. -
  5841. -/* The following block defines the ISQ event types */
  5842. -#define ISQ_RECEIVER_EVENT 0x04
  5843. -#define ISQ_TRANSMITTER_EVENT 0x08
  5844. -#define ISQ_BUFFER_EVENT 0x0c
  5845. -#define ISQ_RX_MISS_EVENT 0x10
  5846. -#define ISQ_TX_COL_EVENT 0x12
  5847. -
  5848. -#define ISQ_EVENT_MASK 0x003F /* ISQ mask to find out type of event */
  5849. -#define ISQ_HIST 16 /* small history buffer */
  5850. -#define AUTOINCREMENT 0x8000 /* Bit mask to set bit-15 for autoincrement */
  5851. -
  5852. -#define TXRXBUFSIZE 0x0600
  5853. -#define RXDMABUFSIZE 0x8000
  5854. -#define RXDMASIZE 0x4000
  5855. -#define TXRX_LENGTH_MASK 0x07FF
  5856. -
  5857. -/* rx options bits */
  5858. -#define RCV_WITH_RXON 1 /* Set SerRx ON */
  5859. -#define RCV_COUNTS 2 /* Use Framecnt1 */
  5860. -#define RCV_PONG 4 /* Pong respondent */
  5861. -#define RCV_DONG 8 /* Dong operation */
  5862. -#define RCV_POLLING 0x10 /* Poll RxEvent */
  5863. -#define RCV_ISQ 0x20 /* Use ISQ, int */
  5864. -#define RCV_AUTO_DMA 0x100 /* Set AutoRxDMAE */
  5865. -#define RCV_DMA 0x200 /* Set RxDMA only */
  5866. -#define RCV_DMA_ALL 0x400 /* Copy all DMA'ed */
  5867. -#define RCV_FIXED_DATA 0x800 /* Every frame same */
  5868. -#define RCV_IO 0x1000 /* Use ISA IO only */
  5869. -#define RCV_MEMORY 0x2000 /* Use ISA Memory */
  5870. -
  5871. -#define RAM_SIZE 0x1000 /* The card has 4k bytes or RAM */
  5872. -#define PKT_START PP_TxFrame /* Start of packet RAM */
  5873. -
  5874. -#define RX_FRAME_PORT 0x0000
  5875. -#define TX_FRAME_PORT RX_FRAME_PORT
  5876. -#define TX_CMD_PORT 0x0004
  5877. -#define TX_NOW 0x0000 /* Tx packet after 5 bytes copied */
  5878. -#define TX_AFTER_381 0x0020 /* Tx packet after 381 bytes copied */
  5879. -#define TX_AFTER_ALL 0x0060 /* Tx packet after all bytes copied */
  5880. -#define TX_LEN_PORT 0x0006
  5881. -#define ISQ_PORT 0x0008
  5882. -#define ADD_PORT 0x000A
  5883. -#define DATA_PORT 0x000C
  5884. -
  5885. -#define EEPROM_WRITE_EN 0x00F0
  5886. -#define EEPROM_WRITE_DIS 0x0000
  5887. -#define EEPROM_WRITE_CMD 0x0100
  5888. -#define EEPROM_READ_CMD 0x0200
  5889. -
  5890. -/* Receive Header */
  5891. -/* Description of header of each packet in receive area of memory */
  5892. -#define RBUF_EVENT_LOW 0 /* Low byte of RxEvent - status of received frame */
  5893. -#define RBUF_EVENT_HIGH 1 /* High byte of RxEvent - status of received frame */
  5894. -#define RBUF_LEN_LOW 2 /* Length of received data - low byte */
  5895. -#define RBUF_LEN_HI 3 /* Length of received data - high byte */
  5896. -#define RBUF_HEAD_LEN 4 /* Length of this header */
  5897. -
  5898. -#define CHIP_READ 0x1 /* Used to mark state of the repins code (chip or dma) */
  5899. -#define DMA_READ 0x2 /* Used to mark state of the repins code (chip or dma) */
  5900. -
  5901. -/* for bios scan */
  5902. -/* */
  5903. -#ifdef CSDEBUG
  5904. -/* use these values for debugging bios scan */
  5905. -#define BIOS_START_SEG 0x00000
  5906. -#define BIOS_OFFSET_INC 0x0010
  5907. -#else
  5908. -#define BIOS_START_SEG 0x0c000
  5909. -#define BIOS_OFFSET_INC 0x0200
  5910. -#endif
  5911. -
  5912. -#define BIOS_LAST_OFFSET 0x0fc00
  5913. -
  5914. -/* Byte offsets into the EEPROM configuration buffer */
  5915. -#define ISA_CNF_OFFSET 0x6
  5916. -#define TX_CTL_OFFSET (ISA_CNF_OFFSET + 8) /* 8900 eeprom */
  5917. -#define AUTO_NEG_CNF_OFFSET (ISA_CNF_OFFSET + 8) /* 8920 eeprom */
  5918. -
  5919. - /* the assumption here is that the bits in the eeprom are generally */
  5920. - /* in the same position as those in the autonegctl register. */
  5921. - /* Of course the IMM bit is not in that register so it must be */
  5922. - /* masked out */
  5923. -#define EE_FORCE_FDX 0x8000
  5924. -#define EE_NLP_ENABLE 0x0200
  5925. -#define EE_AUTO_NEG_ENABLE 0x0100
  5926. -#define EE_ALLOW_FDX 0x0080
  5927. -#define EE_AUTO_NEG_CNF_MASK (EE_FORCE_FDX|EE_NLP_ENABLE|EE_AUTO_NEG_ENABLE|EE_ALLOW_FDX)
  5928. -
  5929. -#define IMM_BIT 0x0040 /* ignore missing media */
  5930. -
  5931. -#define ADAPTER_CNF_OFFSET (AUTO_NEG_CNF_OFFSET + 2)
  5932. -#define A_CNF_10B_T 0x0001
  5933. -#define A_CNF_AUI 0x0002
  5934. -#define A_CNF_10B_2 0x0004
  5935. -#define A_CNF_MEDIA_TYPE 0x0060
  5936. -#define A_CNF_MEDIA_AUTO 0x0000
  5937. -#define A_CNF_MEDIA_10B_T 0x0020
  5938. -#define A_CNF_MEDIA_AUI 0x0040
  5939. -#define A_CNF_MEDIA_10B_2 0x0060
  5940. -#define A_CNF_DC_DC_POLARITY 0x0080
  5941. -#define A_CNF_NO_AUTO_POLARITY 0x2000
  5942. -#define A_CNF_LOW_RX_SQUELCH 0x4000
  5943. -#define A_CNF_EXTND_10B_2 0x8000
  5944. -
  5945. -#define PACKET_PAGE_OFFSET 0x8
  5946. -
  5947. -/* Bit definitions for the ISA configuration word from the EEPROM */
  5948. -#define INT_NO_MASK 0x000F
  5949. -#define DMA_NO_MASK 0x0070
  5950. -#define ISA_DMA_SIZE 0x0200
  5951. -#define ISA_AUTO_RxDMA 0x0400
  5952. -#define ISA_RxDMA 0x0800
  5953. -#define DMA_BURST 0x1000
  5954. -#define STREAM_TRANSFER 0x2000
  5955. -#define ANY_ISA_DMA (ISA_AUTO_RxDMA | ISA_RxDMA)
  5956. -
  5957. -/* DMA controller registers */
  5958. -#define DMA_BASE 0x00 /* DMA controller base */
  5959. -#define DMA_BASE_2 0x0C0 /* DMA controller base */
  5960. -
  5961. -#define DMA_STAT 0x0D0 /* DMA controller status register */
  5962. -#define DMA_MASK 0x0D4 /* DMA controller mask register */
  5963. -#define DMA_MODE 0x0D6 /* DMA controller mode register */
  5964. -#define DMA_RESETFF 0x0D8 /* DMA controller first/last flip flop */
  5965. -
  5966. -/* DMA data */
  5967. -#define DMA_DISABLE 0x04 /* Disable channel n */
  5968. -#define DMA_ENABLE 0x00 /* Enable channel n */
  5969. -/* Demand transfers, incr. address, auto init, writes, ch. n */
  5970. -#define DMA_RX_MODE 0x14
  5971. -/* Demand transfers, incr. address, auto init, reads, ch. n */
  5972. -#define DMA_TX_MODE 0x18
  5973. -
  5974. -#define DMA_SIZE (16*1024) /* Size of dma buffer - 16k */
  5975. -
  5976. -#define CS8900 0x0000
  5977. -#define CS8920 0x4000
  5978. -#define CS8920M 0x6000
  5979. -#define REVISON_BITS 0x1F00
  5980. -#define EEVER_NUMBER 0x12
  5981. -#define CHKSUM_LEN 0x14
  5982. -#define CHKSUM_VAL 0x0000
  5983. -#define START_EEPROM_DATA 0x001c /* Offset into eeprom for start of data */
  5984. -#define IRQ_MAP_EEPROM_DATA 0x0046 /* Offset into eeprom for the IRQ map */
  5985. -#define IRQ_MAP_LEN 0x0004 /* No of bytes to read for the IRQ map */
  5986. -#define PNP_IRQ_FRMT 0x0022 /* PNP small item IRQ format */
  5987. -#define CS8900_IRQ_MAP 0x1c20 /* This IRQ map is fixed */
  5988. -
  5989. -#define CS8920_NO_INTS 0x0F /* Max CS8920 interrupt select # */
  5990. -
  5991. -#define PNP_ADD_PORT 0x0279
  5992. -#define PNP_WRITE_PORT 0x0A79
  5993. -
  5994. -#define GET_PNP_ISA_STRUCT 0x40
  5995. -#define PNP_ISA_STRUCT_LEN 0x06
  5996. -#define PNP_CSN_CNT_OFF 0x01
  5997. -#define PNP_RD_PORT_OFF 0x02
  5998. -#define PNP_FUNCTION_OK 0x00
  5999. -#define PNP_WAKE 0x03
  6000. -#define PNP_RSRC_DATA 0x04
  6001. -#define PNP_RSRC_READY 0x01
  6002. -#define PNP_STATUS 0x05
  6003. -#define PNP_ACTIVATE 0x30
  6004. -#define PNP_CNF_IO_H 0x60
  6005. -#define PNP_CNF_IO_L 0x61
  6006. -#define PNP_CNF_INT 0x70
  6007. -#define PNP_CNF_DMA 0x74
  6008. -#define PNP_CNF_MEM 0x48
  6009. -
  6010. -#define BIT0 1
  6011. -#define BIT15 0x8000
  6012. -
  6013. -/*
  6014. - * Local variables:
  6015. - * c-basic-offset: 8
  6016. - * End:
  6017. - */
  6018. -
  6019. diff -Naur grub-0.97.orig/netboot/cs89x0.txt grub-0.97/netboot/cs89x0.txt
  6020. --- grub-0.97.orig/netboot/cs89x0.txt 2003-07-09 11:45:37.000000000 +0000
  6021. +++ grub-0.97/netboot/cs89x0.txt 1970-01-01 00:00:00.000000000 +0000
  6022. @@ -1,26 +0,0 @@
  6023. -Permission is granted to distribute the enclosed cs89x0.[ch] driver
  6024. -only in conjunction with the Etherboot package. The code is
  6025. -ordinarily distributed under the GPL.
  6026. -
  6027. -Russ Nelson, January 2000
  6028. -
  6029. -CREDITS
  6030. -
  6031. -I want to thank
  6032. -
  6033. - Mike Cruse <mcruse@cti-ltd.com>
  6034. - for providing an evaluation NIC and for sponsoring the
  6035. - development of this driver.
  6036. -
  6037. - Randall Sears <sears@crystal.cirrus.com>
  6038. - Deva Bodas <bodas@crystal.cirrus.com>
  6039. - Andreas Kraemer <akraemer@crystal.cirrus.com>
  6040. - Wolfgang Krause <100303.2673@compuserve.com>
  6041. - for excellent technical support and for providing the required
  6042. - programming information. I appreciate Crystal Semiconductor's
  6043. - commitment towards free software.
  6044. -
  6045. - Russell Nelson <nelson@crynwr.com>
  6046. - for writing the Linux device driver for the CS89x0
  6047. - chipset. Russel's code is very well designed and simplified my
  6048. - job a lot.
  6049. diff -Naur grub-0.97.orig/netboot/davicom.c grub-0.97/netboot/davicom.c
  6050. --- grub-0.97.orig/netboot/davicom.c 2003-07-09 11:45:37.000000000 +0000
  6051. +++ grub-0.97/netboot/davicom.c 2005-08-31 19:03:35.000000000 +0000
  6052. @@ -1,12 +1,12 @@
  6053. +#ifdef ALLMULTI
  6054. +#error multicast support is not yet implemented
  6055. +#endif
  6056. /*
  6057. DAVICOM DM9009/DM9102/DM9102A Etherboot Driver V1.00
  6058. - This driver was ported from Marty Conner's Tulip Etherboot driver.
  6059. - Thanks Marty Connor (mdc@thinguin.org)
  6060. - You can get Tulip driver source file from this URL:
  6061. + This driver was ported from Marty Connor's Tulip Etherboot driver.
  6062. + Thanks Marty Connor (mdc@etherboot.org)
  6063. - "http://etherboot.sourceforge..net/#Distribution"
  6064. -
  6065. This davicom etherboot driver supports DM9009/DM9102/DM9102A/
  6066. DM9102A+DM9801/DM9102A+DM9802 NICs.
  6067. @@ -36,7 +36,6 @@
  6068. register(CR6)
  6069. */
  6070. -
  6071. /*********************************************************************/
  6072. /* Declarations */
  6073. /*********************************************************************/
  6074. @@ -44,7 +43,6 @@
  6075. #include "etherboot.h"
  6076. #include "nic.h"
  6077. #include "pci.h"
  6078. -#include "cards.h"
  6079. #undef DAVICOM_DEBUG
  6080. #undef DAVICOM_DEBUG_WHERE
  6081. @@ -99,8 +97,10 @@
  6082. #define eeprom_delay() inl(ee_addr)
  6083. /* helpful macro if on a big_endian machine for changing byte order.
  6084. - not strictly needed on Intel */
  6085. + not strictly needed on Intel
  6086. + Already defined in Etherboot includes
  6087. #define le16_to_cpu(val) (val)
  6088. +*/
  6089. /* transmit and receive descriptor format */
  6090. struct txdesc {
  6091. @@ -138,20 +138,12 @@
  6092. /* transmit descriptor and buffer */
  6093. #define NTXD 2
  6094. static struct txdesc txd[NTXD] __attribute__ ((aligned(4)));
  6095. -#ifdef USE_LOWMEM_BUFFER
  6096. -#define txb ((char *)0x10000 - BUFLEN)
  6097. -#else
  6098. static unsigned char txb[BUFLEN] __attribute__ ((aligned(4)));
  6099. -#endif
  6100. /* receive descriptor(s) and buffer(s) */
  6101. #define NRXD 4
  6102. static struct rxdesc rxd[NRXD] __attribute__ ((aligned(4)));
  6103. -#ifdef USE_LOWMEM_BUFFER
  6104. -#define rxb ((char *)0x10000 - NRXD * BUFLEN - BUFLEN)
  6105. -#else
  6106. static unsigned char rxb[NRXD * BUFLEN] __attribute__ ((aligned(4)));
  6107. -#endif
  6108. static int rxd_tail;
  6109. static int TxPtr;
  6110. @@ -161,15 +153,13 @@
  6111. /*********************************************************************/
  6112. static void whereami(const char *str);
  6113. static int read_eeprom(unsigned long ioaddr, int location, int addr_len);
  6114. -struct nic *davicom_probe(struct nic *nic, unsigned short *io_addrs,
  6115. - struct pci_device *pci);
  6116. +static int davicom_probe(struct dev *dev, struct pci_device *pci);
  6117. static void davicom_init_chain(struct nic *nic); /* Sten 10/9 */
  6118. static void davicom_reset(struct nic *nic);
  6119. static void davicom_transmit(struct nic *nic, const char *d, unsigned int t,
  6120. unsigned int s, const char *p);
  6121. -static int davicom_poll(struct nic *nic);
  6122. -static void davicom_disable(struct nic *nic);
  6123. -static void whereami (const char *str);
  6124. +static int davicom_poll(struct nic *nic, int retrieve);
  6125. +static void davicom_disable(struct dev *dev);
  6126. #ifdef DAVICOM_DEBUG
  6127. static void davicom_more(void);
  6128. #endif /* DAVICOM_DEBUG */
  6129. @@ -184,13 +174,10 @@
  6130. /*********************************************************************/
  6131. /* Utility Routines */
  6132. /*********************************************************************/
  6133. -
  6134. -static inline void whereami (const char *str)
  6135. +static inline void whereami(const char *str)
  6136. {
  6137. -#ifdef DAVICOM_DEBUG_WHERE
  6138. printf("%s\n", str);
  6139. /* sleep(2); */
  6140. -#endif
  6141. }
  6142. #ifdef DAVICOM_DEBUG
  6143. @@ -360,7 +347,7 @@
  6144. /*
  6145. Sense media mode and set CR6
  6146. */
  6147. -static void davicom_media_chk(struct nic * nic)
  6148. +static void davicom_media_chk(struct nic * nic __unused)
  6149. {
  6150. unsigned long to, csr6;
  6151. @@ -446,8 +433,8 @@
  6152. /* Sten: Set 2 TX descriptor but use one TX buffer because
  6153. it transmit a packet and wait complete every time. */
  6154. for (i=0; i<NTXD; i++) {
  6155. - txd[i].buf1addr = &txb[0]; /* Used same TX buffer */
  6156. - txd[i].buf2addr = (unsigned char *)&txd[i+1]; /* Point to Next TX desc */
  6157. + txd[i].buf1addr = (void *)virt_to_bus(&txb[0]); /* Used same TX buffer */
  6158. + txd[i].buf2addr = (void *)virt_to_bus(&txd[i+1]); /* Point to Next TX desc */
  6159. txd[i].buf1sz = 0;
  6160. txd[i].buf2sz = 0;
  6161. txd[i].control = 0x184; /* Begin/End/Chain */
  6162. @@ -466,8 +453,8 @@
  6163. /* setup receive descriptor */
  6164. for (i=0; i<NRXD; i++) {
  6165. - rxd[i].buf1addr = &rxb[i * BUFLEN];
  6166. - rxd[i].buf2addr = (unsigned char *)&rxd[i+1]; /* Point to Next RX desc */
  6167. + rxd[i].buf1addr = (void *)virt_to_bus(&rxb[i * BUFLEN]);
  6168. + rxd[i].buf2addr = (void *)virt_to_bus(&rxd[i+1]); /* Point to Next RX desc */
  6169. rxd[i].buf1sz = BUFLEN;
  6170. rxd[i].buf2sz = 0; /* not used */
  6171. rxd[i].control = 0x4; /* Chain Structure */
  6172. @@ -475,8 +462,8 @@
  6173. }
  6174. /* Chain the last descriptor to first */
  6175. - txd[NTXD - 1].buf2addr = (unsigned char *)&txd[0];
  6176. - rxd[NRXD - 1].buf2addr = (unsigned char *)&rxd[0];
  6177. + txd[NTXD - 1].buf2addr = (void *)virt_to_bus(&txd[0]);
  6178. + rxd[NRXD - 1].buf2addr = (void *)virt_to_bus(&rxd[0]);
  6179. TxPtr = 0;
  6180. rxd_tail = 0;
  6181. }
  6182. @@ -488,7 +475,6 @@
  6183. static void davicom_reset(struct nic *nic)
  6184. {
  6185. unsigned long to;
  6186. - u32 addr_low, addr_high;
  6187. whereami("davicom_reset\n");
  6188. @@ -507,8 +493,8 @@
  6189. davicom_init_chain(nic); /* Sten 10/9 */
  6190. /* Point to receive descriptor */
  6191. - outl((unsigned long)&rxd[0], ioaddr + CSR3);
  6192. - outl((unsigned long)&txd[0], ioaddr + CSR4); /* Sten 10/9 */
  6193. + outl(virt_to_bus(&rxd[0]), ioaddr + CSR3);
  6194. + outl(virt_to_bus(&txd[0]), ioaddr + CSR4); /* Sten 10/9 */
  6195. /* According phyxcer media mode to set CR6,
  6196. DM9102/A phyxcer can auto-detect media mode */
  6197. @@ -591,13 +577,15 @@
  6198. /*********************************************************************/
  6199. /* eth_poll - Wait for a frame */
  6200. /*********************************************************************/
  6201. -static int davicom_poll(struct nic *nic)
  6202. +static int davicom_poll(struct nic *nic, int retrieve)
  6203. {
  6204. whereami("davicom_poll\n");
  6205. if (rxd[rxd_tail].status & 0x80000000)
  6206. return 0;
  6207. + if ( ! retrieve ) return 1;
  6208. +
  6209. whereami("davicom_poll got one\n");
  6210. nic->packetlen = (rxd[rxd_tail].status & 0x3FFF0000) >> 16;
  6211. @@ -627,10 +615,13 @@
  6212. /*********************************************************************/
  6213. /* eth_disable - Disable the interface */
  6214. /*********************************************************************/
  6215. -static void davicom_disable(struct nic *nic)
  6216. +static void davicom_disable(struct dev *dev)
  6217. {
  6218. + struct nic *nic = (struct nic *)dev;
  6219. whereami("davicom_disable\n");
  6220. + davicom_reset(nic);
  6221. +
  6222. /* disable interrupts */
  6223. outl(0x00000000, ioaddr + CSR7);
  6224. @@ -640,24 +631,43 @@
  6225. /* Clear the missed-packet counter. */
  6226. (volatile unsigned long)inl(ioaddr + CSR8);
  6227. }
  6228. +
  6229. +
  6230. +/*********************************************************************/
  6231. +/* eth_irq - enable, disable and force interrupts */
  6232. +/*********************************************************************/
  6233. +static void davicom_irq(struct nic *nic __unused, irq_action_t action __unused)
  6234. +{
  6235. + switch ( action ) {
  6236. + case DISABLE :
  6237. + break;
  6238. + case ENABLE :
  6239. + break;
  6240. + case FORCE :
  6241. + break;
  6242. + }
  6243. +}
  6244. +
  6245. /*********************************************************************/
  6246. /* eth_probe - Look for an adapter */
  6247. /*********************************************************************/
  6248. -struct nic *davicom_probe(struct nic *nic, unsigned short *io_addrs,
  6249. - struct pci_device *pci)
  6250. +static int davicom_probe(struct dev *dev, struct pci_device *pci)
  6251. {
  6252. + struct nic *nic = (struct nic *)dev;
  6253. unsigned int i;
  6254. - u32 l1, l2;
  6255. whereami("davicom_probe\n");
  6256. - if (io_addrs == 0 || *io_addrs == 0)
  6257. + if (pci->ioaddr == 0)
  6258. return 0;
  6259. vendor = pci->vendor;
  6260. dev_id = pci->dev_id;
  6261. - ioaddr = *io_addrs;
  6262. + ioaddr = pci->ioaddr & ~3;
  6263. +
  6264. + nic->irqno = 0;
  6265. + nic->ioaddr = pci->ioaddr & ~3;
  6266. /* wakeup chip */
  6267. pcibios_write_config_dword(pci->bus, pci->devfn, 0x40, 0x00000000);
  6268. @@ -683,10 +693,26 @@
  6269. /* initialize device */
  6270. davicom_reset(nic);
  6271. - nic->reset = davicom_reset;
  6272. + dev->disable = davicom_disable;
  6273. nic->poll = davicom_poll;
  6274. nic->transmit = davicom_transmit;
  6275. - nic->disable = davicom_disable;
  6276. + nic->irq = davicom_irq;
  6277. - return nic;
  6278. + return 1;
  6279. }
  6280. +
  6281. +static struct pci_id davicom_nics[] = {
  6282. +PCI_ROM(0x1282, 0x9100, "davicom9100", "Davicom 9100"),
  6283. +PCI_ROM(0x1282, 0x9102, "davicom9102", "Davicom 9102"),
  6284. +PCI_ROM(0x1282, 0x9009, "davicom9009", "Davicom 9009"),
  6285. +PCI_ROM(0x1282, 0x9132, "davicom9132", "Davicom 9132"), /* Needs probably some fixing */
  6286. +};
  6287. +
  6288. +struct pci_driver davicom_driver = {
  6289. + .type = NIC_DRIVER,
  6290. + .name = "DAVICOM",
  6291. + .probe = davicom_probe,
  6292. + .ids = davicom_nics,
  6293. + .id_count = sizeof(davicom_nics)/sizeof(davicom_nics[0]),
  6294. + .class = 0,
  6295. +};
  6296. diff -Naur grub-0.97.orig/netboot/depca.c grub-0.97/netboot/depca.c
  6297. --- grub-0.97.orig/netboot/depca.c 2003-07-09 11:45:37.000000000 +0000
  6298. +++ grub-0.97/netboot/depca.c 1970-01-01 00:00:00.000000000 +0000
  6299. @@ -1,752 +0,0 @@
  6300. -/* Etherboot: depca.h merged, comments from Linux driver retained */
  6301. -/* depca.c: A DIGITAL DEPCA & EtherWORKS ethernet driver for linux.
  6302. -
  6303. - Written 1994, 1995 by David C. Davies.
  6304. -
  6305. -
  6306. - Copyright 1994 David C. Davies
  6307. - and
  6308. - United States Government
  6309. - (as represented by the Director, National Security Agency).
  6310. -
  6311. - Copyright 1995 Digital Equipment Corporation.
  6312. -
  6313. -
  6314. - This software may be used and distributed according to the terms of
  6315. - the GNU Public License, incorporated herein by reference.
  6316. -
  6317. - This driver is written for the Digital Equipment Corporation series
  6318. - of DEPCA and EtherWORKS ethernet cards:
  6319. -
  6320. - DEPCA (the original)
  6321. - DE100
  6322. - DE101
  6323. - DE200 Turbo
  6324. - DE201 Turbo
  6325. - DE202 Turbo (TP BNC)
  6326. - DE210
  6327. - DE422 (EISA)
  6328. -
  6329. - The driver has been tested on DE100, DE200 and DE202 cards in a
  6330. - relatively busy network. The DE422 has been tested a little.
  6331. -
  6332. - This driver will NOT work for the DE203, DE204 and DE205 series of
  6333. - cards, since they have a new custom ASIC in place of the AMD LANCE
  6334. - chip. See the 'ewrk3.c' driver in the Linux source tree for running
  6335. - those cards.
  6336. -
  6337. - I have benchmarked the driver with a DE100 at 595kB/s to (542kB/s from)
  6338. - a DECstation 5000/200.
  6339. -
  6340. - The author may be reached at davies@maniac.ultranet.com
  6341. -
  6342. - =========================================================================
  6343. -
  6344. - The driver was originally based on the 'lance.c' driver from Donald
  6345. - Becker which is included with the standard driver distribution for
  6346. - linux. V0.4 is a complete re-write with only the kernel interface
  6347. - remaining from the original code.
  6348. -
  6349. - 1) Lance.c code in /linux/drivers/net/
  6350. - 2) "Ethernet/IEEE 802.3 Family. 1992 World Network Data Book/Handbook",
  6351. - AMD, 1992 [(800) 222-9323].
  6352. - 3) "Am79C90 CMOS Local Area Network Controller for Ethernet (C-LANCE)",
  6353. - AMD, Pub. #17881, May 1993.
  6354. - 4) "Am79C960 PCnet-ISA(tm), Single-Chip Ethernet Controller for ISA",
  6355. - AMD, Pub. #16907, May 1992
  6356. - 5) "DEC EtherWORKS LC Ethernet Controller Owners Manual",
  6357. - Digital Equipment corporation, 1990, Pub. #EK-DE100-OM.003
  6358. - 6) "DEC EtherWORKS Turbo Ethernet Controller Owners Manual",
  6359. - Digital Equipment corporation, 1990, Pub. #EK-DE200-OM.003
  6360. - 7) "DEPCA Hardware Reference Manual", Pub. #EK-DEPCA-PR
  6361. - Digital Equipment Corporation, 1989
  6362. - 8) "DEC EtherWORKS Turbo_(TP BNC) Ethernet Controller Owners Manual",
  6363. - Digital Equipment corporation, 1991, Pub. #EK-DE202-OM.001
  6364. -
  6365. -
  6366. - Peter Bauer's depca.c (V0.5) was referred to when debugging V0.1 of this
  6367. - driver.
  6368. -
  6369. - The original DEPCA card requires that the ethernet ROM address counter
  6370. - be enabled to count and has an 8 bit NICSR. The ROM counter enabling is
  6371. - only done when a 0x08 is read as the first address octet (to minimise
  6372. - the chances of writing over some other hardware's I/O register). The
  6373. - NICSR accesses have been changed to byte accesses for all the cards
  6374. - supported by this driver, since there is only one useful bit in the MSB
  6375. - (remote boot timeout) and it is not used. Also, there is a maximum of
  6376. - only 48kB network RAM for this card. My thanks to Torbjorn Lindh for
  6377. - help debugging all this (and holding my feet to the fire until I got it
  6378. - right).
  6379. -
  6380. - The DE200 series boards have on-board 64kB RAM for use as a shared
  6381. - memory network buffer. Only the DE100 cards make use of a 2kB buffer
  6382. - mode which has not been implemented in this driver (only the 32kB and
  6383. - 64kB modes are supported [16kB/48kB for the original DEPCA]).
  6384. -
  6385. - At the most only 2 DEPCA cards can be supported on the ISA bus because
  6386. - there is only provision for two I/O base addresses on each card (0x300
  6387. - and 0x200). The I/O address is detected by searching for a byte sequence
  6388. - in the Ethernet station address PROM at the expected I/O address for the
  6389. - Ethernet PROM. The shared memory base address is 'autoprobed' by
  6390. - looking for the self test PROM and detecting the card name. When a
  6391. - second DEPCA is detected, information is placed in the base_addr
  6392. - variable of the next device structure (which is created if necessary),
  6393. - thus enabling ethif_probe initialization for the device. More than 2
  6394. - EISA cards can be supported, but care will be needed assigning the
  6395. - shared memory to ensure that each slot has the correct IRQ, I/O address
  6396. - and shared memory address assigned.
  6397. -
  6398. - ************************************************************************
  6399. -
  6400. - NOTE: If you are using two ISA DEPCAs, it is important that you assign
  6401. - the base memory addresses correctly. The driver autoprobes I/O 0x300
  6402. - then 0x200. The base memory address for the first device must be less
  6403. - than that of the second so that the auto probe will correctly assign the
  6404. - I/O and memory addresses on the same card. I can't think of a way to do
  6405. - this unambiguously at the moment, since there is nothing on the cards to
  6406. - tie I/O and memory information together.
  6407. -
  6408. - I am unable to test 2 cards together for now, so this code is
  6409. - unchecked. All reports, good or bad, are welcome.
  6410. -
  6411. - ************************************************************************
  6412. -
  6413. - The board IRQ setting must be at an unused IRQ which is auto-probed
  6414. - using Donald Becker's autoprobe routines. DEPCA and DE100 board IRQs are
  6415. - {2,3,4,5,7}, whereas the DE200 is at {5,9,10,11,15}. Note that IRQ2 is
  6416. - really IRQ9 in machines with 16 IRQ lines.
  6417. -
  6418. - No 16MB memory limitation should exist with this driver as DMA is not
  6419. - used and the common memory area is in low memory on the network card (my
  6420. - current system has 20MB and I've not had problems yet).
  6421. -
  6422. - The ability to load this driver as a loadable module has been added. To
  6423. - utilise this ability, you have to do <8 things:
  6424. -
  6425. - 0) have a copy of the loadable modules code installed on your system.
  6426. - 1) copy depca.c from the /linux/drivers/net directory to your favourite
  6427. - temporary directory.
  6428. - 2) if you wish, edit the source code near line 1530 to reflect the I/O
  6429. - address and IRQ you're using (see also 5).
  6430. - 3) compile depca.c, but include -DMODULE in the command line to ensure
  6431. - that the correct bits are compiled (see end of source code).
  6432. - 4) if you are wanting to add a new card, goto 5. Otherwise, recompile a
  6433. - kernel with the depca configuration turned off and reboot.
  6434. - 5) insmod depca.o [irq=7] [io=0x200] [mem=0xd0000] [adapter_name=DE100]
  6435. - [Alan Cox: Changed the code to allow command line irq/io assignments]
  6436. - [Dave Davies: Changed the code to allow command line mem/name
  6437. - assignments]
  6438. - 6) run the net startup bits for your eth?? interface manually
  6439. - (usually /etc/rc.inet[12] at boot time).
  6440. - 7) enjoy!
  6441. -
  6442. - Note that autoprobing is not allowed in loadable modules - the system is
  6443. - already up and running and you're messing with interrupts.
  6444. -
  6445. - To unload a module, turn off the associated interface
  6446. - 'ifconfig eth?? down' then 'rmmod depca'.
  6447. -
  6448. - To assign a base memory address for the shared memory when running as a
  6449. - loadable module, see 5 above. To include the adapter name (if you have
  6450. - no PROM but know the card name) also see 5 above. Note that this last
  6451. - option will not work with kernel built-in depca's.
  6452. -
  6453. - The shared memory assignment for a loadable module makes sense to avoid
  6454. - the 'memory autoprobe' picking the wrong shared memory (for the case of
  6455. - 2 depca's in a PC).
  6456. -
  6457. - ************************************************************************
  6458. - Support for MCA EtherWORKS cards added 11-3-98.
  6459. - Verified to work with up to 2 DE212 cards in a system (although not
  6460. - fully stress-tested).
  6461. -
  6462. - Currently known bugs/limitations:
  6463. -
  6464. - Note: with the MCA stuff as a module, it trusts the MCA configuration,
  6465. - not the command line for IRQ and memory address. You can
  6466. - specify them if you want, but it will throw your values out.
  6467. - You still have to pass the IO address it was configured as
  6468. - though.
  6469. -
  6470. - ************************************************************************
  6471. - TO DO:
  6472. - ------
  6473. -
  6474. -
  6475. - Revision History
  6476. - ----------------
  6477. -
  6478. - Version Date Description
  6479. -
  6480. - 0.1 25-jan-94 Initial writing.
  6481. - 0.2 27-jan-94 Added LANCE TX hardware buffer chaining.
  6482. - 0.3 1-feb-94 Added multiple DEPCA support.
  6483. - 0.31 4-feb-94 Added DE202 recognition.
  6484. - 0.32 19-feb-94 Tidy up. Improve multi-DEPCA support.
  6485. - 0.33 25-feb-94 Fix DEPCA ethernet ROM counter enable.
  6486. - Add jabber packet fix from murf@perftech.com
  6487. - and becker@super.org
  6488. - 0.34 7-mar-94 Fix DEPCA max network memory RAM & NICSR access.
  6489. - 0.35 8-mar-94 Added DE201 recognition. Tidied up.
  6490. - 0.351 30-apr-94 Added EISA support. Added DE422 recognition.
  6491. - 0.36 16-may-94 DE422 fix released.
  6492. - 0.37 22-jul-94 Added MODULE support
  6493. - 0.38 15-aug-94 Added DBR ROM switch in depca_close().
  6494. - Multi DEPCA bug fix.
  6495. - 0.38axp 15-sep-94 Special version for Alpha AXP Linux V1.0.
  6496. - 0.381 12-dec-94 Added DE101 recognition, fix multicast bug.
  6497. - 0.382 9-feb-95 Fix recognition bug reported by <bkm@star.rl.ac.uk>.
  6498. - 0.383 22-feb-95 Fix for conflict with VESA SCSI reported by
  6499. - <stromain@alf.dec.com>
  6500. - 0.384 17-mar-95 Fix a ring full bug reported by <bkm@star.rl.ac.uk>
  6501. - 0.385 3-apr-95 Fix a recognition bug reported by
  6502. - <ryan.niemi@lastfrontier.com>
  6503. - 0.386 21-apr-95 Fix the last fix...sorry, must be galloping senility
  6504. - 0.40 25-May-95 Rewrite for portability & updated.
  6505. - ALPHA support from <jestabro@amt.tay1.dec.com>
  6506. - 0.41 26-Jun-95 Added verify_area() calls in depca_ioctl() from
  6507. - suggestion by <heiko@colossus.escape.de>
  6508. - 0.42 27-Dec-95 Add 'mem' shared memory assignment for loadable
  6509. - modules.
  6510. - Add 'adapter_name' for loadable modules when no PROM.
  6511. - Both above from a suggestion by
  6512. - <pchen@woodruffs121.residence.gatech.edu>.
  6513. - Add new multicasting code.
  6514. - 0.421 22-Apr-96 Fix alloc_device() bug <jari@markkus2.fimr.fi>
  6515. - 0.422 29-Apr-96 Fix depca_hw_init() bug <jari@markkus2.fimr.fi>
  6516. - 0.423 7-Jun-96 Fix module load bug <kmg@barco.be>
  6517. - 0.43 16-Aug-96 Update alloc_device() to conform to de4x5.c
  6518. - 0.44 1-Sep-97 Fix *_probe() to test check_region() first - bug
  6519. - reported by <mmogilvi@elbert.uccs.edu>
  6520. - 0.45 3-Nov-98 Added support for MCA EtherWORKS (DE210/DE212) cards
  6521. - by <tymm@computer.org>
  6522. - 0.451 5-Nov-98 Fixed mca stuff cuz I'm a dummy. <tymm@computer.org>
  6523. - 0.5 14-Nov-98 Re-spin for 2.1.x kernels.
  6524. - 0.51 27-Jun-99 Correct received packet length for CRC from
  6525. - report by <worm@dkik.dk>
  6526. -
  6527. - =========================================================================
  6528. -*/
  6529. -
  6530. -#include "etherboot.h"
  6531. -#include "nic.h"
  6532. -#include "cards.h"
  6533. -
  6534. -/*
  6535. -** I/O addresses. Note that the 2k buffer option is not supported in
  6536. -** this driver.
  6537. -*/
  6538. -#define DEPCA_NICSR ioaddr+0x00 /* Network interface CSR */
  6539. -#define DEPCA_RBI ioaddr+0x02 /* RAM buffer index (2k buffer mode) */
  6540. -#define DEPCA_DATA ioaddr+0x04 /* LANCE registers' data port */
  6541. -#define DEPCA_ADDR ioaddr+0x06 /* LANCE registers' address port */
  6542. -#define DEPCA_HBASE ioaddr+0x08 /* EISA high memory base address reg. */
  6543. -#define DEPCA_PROM ioaddr+0x0c /* Ethernet address ROM data port */
  6544. -#define DEPCA_CNFG ioaddr+0x0c /* EISA Configuration port */
  6545. -#define DEPCA_RBSA ioaddr+0x0e /* RAM buffer starting address (2k buff.) */
  6546. -
  6547. -/*
  6548. -** These are LANCE registers addressable through DEPCA_ADDR
  6549. -*/
  6550. -#define CSR0 0
  6551. -#define CSR1 1
  6552. -#define CSR2 2
  6553. -#define CSR3 3
  6554. -
  6555. -/*
  6556. -** NETWORK INTERFACE CSR (NI_CSR) bit definitions
  6557. -*/
  6558. -
  6559. -#define TO 0x0100 /* Time Out for remote boot */
  6560. -#define SHE 0x0080 /* SHadow memory Enable */
  6561. -#define BS 0x0040 /* Bank Select */
  6562. -#define BUF 0x0020 /* BUFfer size (1->32k, 0->64k) */
  6563. -#define RBE 0x0010 /* Remote Boot Enable (1->net boot) */
  6564. -#define AAC 0x0008 /* Address ROM Address Counter (1->enable) */
  6565. -#define _128KB 0x0008 /* 128kB Network RAM (1->enable) */
  6566. -#define IM 0x0004 /* Interrupt Mask (1->mask) */
  6567. -#define IEN 0x0002 /* Interrupt tristate ENable (1->enable) */
  6568. -#define LED 0x0001 /* LED control */
  6569. -
  6570. -/*
  6571. -** Control and Status Register 0 (CSR0) bit definitions
  6572. -*/
  6573. -
  6574. -#define ERR 0x8000 /* Error summary */
  6575. -#define BABL 0x4000 /* Babble transmitter timeout error */
  6576. -#define CERR 0x2000 /* Collision Error */
  6577. -#define MISS 0x1000 /* Missed packet */
  6578. -#define MERR 0x0800 /* Memory Error */
  6579. -#define RINT 0x0400 /* Receiver Interrupt */
  6580. -#define TINT 0x0200 /* Transmit Interrupt */
  6581. -#define IDON 0x0100 /* Initialization Done */
  6582. -#define INTR 0x0080 /* Interrupt Flag */
  6583. -#define INEA 0x0040 /* Interrupt Enable */
  6584. -#define RXON 0x0020 /* Receiver on */
  6585. -#define TXON 0x0010 /* Transmitter on */
  6586. -#define TDMD 0x0008 /* Transmit Demand */
  6587. -#define STOP 0x0004 /* Stop */
  6588. -#define STRT 0x0002 /* Start */
  6589. -#define INIT 0x0001 /* Initialize */
  6590. -#define INTM 0xff00 /* Interrupt Mask */
  6591. -#define INTE 0xfff0 /* Interrupt Enable */
  6592. -
  6593. -/*
  6594. -** CONTROL AND STATUS REGISTER 3 (CSR3)
  6595. -*/
  6596. -
  6597. -#define BSWP 0x0004 /* Byte SWaP */
  6598. -#define ACON 0x0002 /* ALE control */
  6599. -#define BCON 0x0001 /* Byte CONtrol */
  6600. -
  6601. -/*
  6602. -** Initialization Block Mode Register
  6603. -*/
  6604. -
  6605. -#define PROM 0x8000 /* Promiscuous Mode */
  6606. -#define EMBA 0x0080 /* Enable Modified Back-off Algorithm */
  6607. -#define INTL 0x0040 /* Internal Loopback */
  6608. -#define DRTY 0x0020 /* Disable Retry */
  6609. -#define COLL 0x0010 /* Force Collision */
  6610. -#define DTCR 0x0008 /* Disable Transmit CRC */
  6611. -#define LOOP 0x0004 /* Loopback */
  6612. -#define DTX 0x0002 /* Disable the Transmitter */
  6613. -#define DRX 0x0001 /* Disable the Receiver */
  6614. -
  6615. -/*
  6616. -** Receive Message Descriptor 1 (RMD1) bit definitions.
  6617. -*/
  6618. -
  6619. -#define R_OWN 0x80000000 /* Owner bit 0 = host, 1 = lance */
  6620. -#define R_ERR 0x4000 /* Error Summary */
  6621. -#define R_FRAM 0x2000 /* Framing Error */
  6622. -#define R_OFLO 0x1000 /* Overflow Error */
  6623. -#define R_CRC 0x0800 /* CRC Error */
  6624. -#define R_BUFF 0x0400 /* Buffer Error */
  6625. -#define R_STP 0x0200 /* Start of Packet */
  6626. -#define R_ENP 0x0100 /* End of Packet */
  6627. -
  6628. -/*
  6629. -** Transmit Message Descriptor 1 (TMD1) bit definitions.
  6630. -*/
  6631. -
  6632. -#define T_OWN 0x80000000 /* Owner bit 0 = host, 1 = lance */
  6633. -#define T_ERR 0x4000 /* Error Summary */
  6634. -#define T_ADD_FCS 0x2000 /* More the 1 retry needed to Xmit */
  6635. -#define T_MORE 0x1000 /* >1 retry to transmit packet */
  6636. -#define T_ONE 0x0800 /* 1 try needed to transmit the packet */
  6637. -#define T_DEF 0x0400 /* Deferred */
  6638. -#define T_STP 0x02000000 /* Start of Packet */
  6639. -#define T_ENP 0x01000000 /* End of Packet */
  6640. -#define T_FLAGS 0xff000000 /* TX Flags Field */
  6641. -
  6642. -/*
  6643. -** Transmit Message Descriptor 3 (TMD3) bit definitions.
  6644. -*/
  6645. -
  6646. -#define TMD3_BUFF 0x8000 /* BUFFer error */
  6647. -#define TMD3_UFLO 0x4000 /* UnderFLOw error */
  6648. -#define TMD3_RES 0x2000 /* REServed */
  6649. -#define TMD3_LCOL 0x1000 /* Late COLlision */
  6650. -#define TMD3_LCAR 0x0800 /* Loss of CARrier */
  6651. -#define TMD3_RTRY 0x0400 /* ReTRY error */
  6652. -
  6653. -/*
  6654. -** Ethernet PROM defines
  6655. -*/
  6656. -#define PROBE_LENGTH 32
  6657. -
  6658. -/*
  6659. -** Set the number of Tx and Rx buffers. Ensure that the memory requested
  6660. -** here is <= to the amount of shared memory set up by the board switches.
  6661. -** The number of descriptors MUST BE A POWER OF 2.
  6662. -**
  6663. -** total_memory = NUM_RX_DESC*(8+RX_BUFF_SZ) + NUM_TX_DESC*(8+TX_BUFF_SZ)
  6664. -*/
  6665. -#define NUM_RX_DESC 2 /* Number of RX descriptors */
  6666. -#define NUM_TX_DESC 2 /* Number of TX descriptors */
  6667. -#define RX_BUFF_SZ 1536 /* Buffer size for each Rx buffer */
  6668. -#define TX_BUFF_SZ 1536 /* Buffer size for each Tx buffer */
  6669. -
  6670. -/*
  6671. -** ISA Bus defines
  6672. -*/
  6673. -#define DEPCA_IO_PORTS {0x300, 0x200, 0}
  6674. -
  6675. -#ifndef DEPCA_MODEL
  6676. -#define DEPCA_MODEL DEPCA
  6677. -#endif
  6678. -
  6679. -static enum {
  6680. - DEPCA, DE100, DE101, DE200, DE201, DE202, DE210, DE212, DE422, unknown
  6681. -} adapter = DEPCA_MODEL;
  6682. -
  6683. -/*
  6684. -** Name <-> Adapter mapping
  6685. -*/
  6686. -
  6687. -static char *adapter_name[] = {
  6688. - "DEPCA",
  6689. - "DE100","DE101",
  6690. - "DE200","DE201","DE202",
  6691. - "DE210","DE212",
  6692. - "DE422",
  6693. - ""
  6694. -};
  6695. -
  6696. -#ifndef DEPCA_RAM_BASE
  6697. -#define DEPCA_RAM_BASE 0xd0000
  6698. -#endif
  6699. -
  6700. -/*
  6701. -** Memory Alignment. Each descriptor is 4 longwords long. To force a
  6702. -** particular alignment on the TX descriptor, adjust DESC_SKIP_LEN and
  6703. -** DESC_ALIGN. ALIGN aligns the start address of the private memory area
  6704. -** and hence the RX descriptor ring's first entry.
  6705. -*/
  6706. -#define ALIGN4 ((u32)4 - 1) /* 1 longword align */
  6707. -#define ALIGN8 ((u32)8 - 1) /* 2 longword (quadword) align */
  6708. -#define ALIGN ALIGN8 /* Keep the LANCE happy... */
  6709. -
  6710. -typedef long s32;
  6711. -typedef unsigned long u32;
  6712. -typedef short s16;
  6713. -typedef unsigned short u16;
  6714. -typedef char s8;
  6715. -typedef unsigned char u8;
  6716. -
  6717. -/*
  6718. -** The DEPCA Rx and Tx ring descriptors.
  6719. -*/
  6720. -struct depca_rx_desc {
  6721. - volatile s32 base;
  6722. - s16 buf_length; /* This length is negative 2's complement! */
  6723. - s16 msg_length; /* This length is "normal". */
  6724. -};
  6725. -
  6726. -struct depca_tx_desc {
  6727. - volatile s32 base;
  6728. - s16 length; /* This length is negative 2's complement! */
  6729. - s16 misc; /* Errors and TDR info */
  6730. -};
  6731. -
  6732. -#define LA_MASK 0x0000ffff /* LANCE address mask for mapping network RAM
  6733. - to LANCE memory address space */
  6734. -
  6735. -/*
  6736. -** The Lance initialization block, described in databook, in common memory.
  6737. -*/
  6738. -struct depca_init {
  6739. - u16 mode; /* Mode register */
  6740. - u8 phys_addr[ETH_ALEN]; /* Physical ethernet address */
  6741. - u8 mcast_table[8]; /* Multicast Hash Table. */
  6742. - u32 rx_ring; /* Rx ring base pointer & ring length */
  6743. - u32 tx_ring; /* Tx ring base pointer & ring length */
  6744. -};
  6745. -
  6746. -struct depca_private {
  6747. - struct depca_rx_desc *rx_ring;
  6748. - struct depca_tx_desc *tx_ring;
  6749. - struct depca_init init_block; /* Shadow init block */
  6750. - char *rx_memcpy[NUM_RX_DESC];
  6751. - char *tx_memcpy[NUM_TX_DESC];
  6752. - u32 bus_offset; /* ISA bus address offset */
  6753. - u32 sh_mem; /* address of shared mem */
  6754. - u32 dma_buffs; /* Rx & Tx buffer start */
  6755. - int rx_cur, tx_cur; /* Next free ring entry */
  6756. - int txRingMask, rxRingMask;
  6757. - s32 rx_rlen, tx_rlen;
  6758. - /* log2([rt]xRingMask+1) for the descriptors */
  6759. -};
  6760. -
  6761. -static Address mem_start = DEPCA_RAM_BASE;
  6762. -static Address mem_len, offset;
  6763. -static unsigned short ioaddr = 0;
  6764. -static struct depca_private lp;
  6765. -
  6766. -/*
  6767. -** Miscellaneous defines...
  6768. -*/
  6769. -#define STOP_DEPCA \
  6770. - outw(CSR0, DEPCA_ADDR);\
  6771. - outw(STOP, DEPCA_DATA)
  6772. -
  6773. -/* Initialize the lance Rx and Tx descriptor rings. */
  6774. -static void depca_init_ring(struct nic *nic)
  6775. -{
  6776. - int i;
  6777. - u32 p;
  6778. -
  6779. - lp.rx_cur = lp.tx_cur = 0;
  6780. - /* Initialize the base addresses and length of each buffer in the ring */
  6781. - for (i = 0; i <= lp.rxRingMask; i++) {
  6782. - writel((p = lp.dma_buffs + i * RX_BUFF_SZ) | R_OWN, &lp.rx_ring[i].base);
  6783. - writew(-RX_BUFF_SZ, &lp.rx_ring[i].buf_length);
  6784. - lp.rx_memcpy[i] = (char *) (p + lp.bus_offset);
  6785. - }
  6786. - for (i = 0; i <= lp.txRingMask; i++) {
  6787. - writel((p = lp.dma_buffs + (i + lp.txRingMask + 1) * TX_BUFF_SZ) & 0x00ffffff, &lp.tx_ring[i].base);
  6788. - lp.tx_memcpy[i] = (char *) (p + lp.bus_offset);
  6789. - }
  6790. -
  6791. - /* Set up the initialization block */
  6792. - lp.init_block.rx_ring = ((u32) ((u32) lp.rx_ring) & LA_MASK) | lp.rx_rlen;
  6793. - lp.init_block.tx_ring = ((u32) ((u32) lp.tx_ring) & LA_MASK) | lp.tx_rlen;
  6794. - for (i = 0; i < ETH_ALEN; i++)
  6795. - lp.init_block.phys_addr[i] = nic->node_addr[i];
  6796. - lp.init_block.mode = 0x0000; /* Enable the Tx and Rx */
  6797. - memset(lp.init_block.mcast_table, 0, sizeof(lp.init_block.mcast_table));
  6798. -}
  6799. -
  6800. -static void LoadCSRs(void)
  6801. -{
  6802. - outw(CSR1, DEPCA_ADDR); /* initialisation block address LSW */
  6803. - outw((u16) (lp.sh_mem & LA_MASK), DEPCA_DATA);
  6804. - outw(CSR2, DEPCA_ADDR); /* initialisation block address MSW */
  6805. - outw((u16) ((lp.sh_mem & LA_MASK) >> 16), DEPCA_DATA);
  6806. - outw(CSR3, DEPCA_ADDR); /* ALE control */
  6807. - outw(ACON, DEPCA_DATA);
  6808. - outw(CSR0, DEPCA_ADDR); /* Point back to CSR0 */
  6809. -}
  6810. -
  6811. -static int InitRestartDepca(void)
  6812. -{
  6813. - int i;
  6814. -
  6815. - /* Copy the shadow init_block to shared memory */
  6816. - memcpy_toio((char *)lp.sh_mem, &lp.init_block, sizeof(struct depca_init));
  6817. - outw(CSR0, DEPCA_ADDR); /* point back to CSR0 */
  6818. - outw(INIT, DEPCA_DATA); /* initialise DEPCA */
  6819. -
  6820. - for (i = 0; i < 100 && !(inw(DEPCA_DATA) & IDON); i++)
  6821. - ;
  6822. - if (i < 100) {
  6823. - /* clear IDON by writing a 1, and start LANCE */
  6824. - outw(IDON | STRT, DEPCA_DATA);
  6825. - } else {
  6826. - printf("DEPCA not initialised\n");
  6827. - return (1);
  6828. - }
  6829. - return (0);
  6830. -}
  6831. -
  6832. -/**************************************************************************
  6833. -RESET - Reset adapter
  6834. -***************************************************************************/
  6835. -static void depca_reset(struct nic *nic)
  6836. -{
  6837. - s16 nicsr;
  6838. - int i, j;
  6839. -
  6840. - STOP_DEPCA;
  6841. - nicsr = inb(DEPCA_NICSR);
  6842. - nicsr = ((nicsr & ~SHE & ~RBE & ~IEN) | IM);
  6843. - outb(nicsr, DEPCA_NICSR);
  6844. - if (inw(DEPCA_DATA) != STOP)
  6845. - {
  6846. - printf("depca: Cannot stop NIC\n");
  6847. - return;
  6848. - }
  6849. -
  6850. - /* Initialisation block */
  6851. - lp.sh_mem = mem_start;
  6852. - mem_start += sizeof(struct depca_init);
  6853. - /* Tx & Rx descriptors (aligned to a quadword boundary) */
  6854. - mem_start = (mem_start + ALIGN) & ~ALIGN;
  6855. - lp.rx_ring = (struct depca_rx_desc *) mem_start;
  6856. - mem_start += (sizeof(struct depca_rx_desc) * NUM_RX_DESC);
  6857. - lp.tx_ring = (struct depca_tx_desc *) mem_start;
  6858. - mem_start += (sizeof(struct depca_tx_desc) * NUM_TX_DESC);
  6859. -
  6860. - lp.bus_offset = mem_start & 0x00ff0000;
  6861. - /* LANCE re-mapped start address */
  6862. - lp.dma_buffs = mem_start & LA_MASK;
  6863. -
  6864. - /* Finish initialising the ring information. */
  6865. - lp.rxRingMask = NUM_RX_DESC - 1;
  6866. - lp.txRingMask = NUM_TX_DESC - 1;
  6867. -
  6868. - /* Calculate Tx/Rx RLEN size for the descriptors. */
  6869. - for (i = 0, j = lp.rxRingMask; j > 0; i++) {
  6870. - j >>= 1;
  6871. - }
  6872. - lp.rx_rlen = (s32) (i << 29);
  6873. - for (i = 0, j = lp.txRingMask; j > 0; i++) {
  6874. - j >>= 1;
  6875. - }
  6876. - lp.tx_rlen = (s32) (i << 29);
  6877. -
  6878. - /* Load the initialisation block */
  6879. - depca_init_ring(nic);
  6880. - LoadCSRs();
  6881. - InitRestartDepca();
  6882. -}
  6883. -
  6884. -/**************************************************************************
  6885. -POLL - Wait for a frame
  6886. -***************************************************************************/
  6887. -static int depca_poll(struct nic *nic)
  6888. -{
  6889. - int entry;
  6890. - u32 status;
  6891. -
  6892. - entry = lp.rx_cur;
  6893. - if ((status = readl(&lp.rx_ring[entry].base) & R_OWN))
  6894. - return (0);
  6895. - memcpy(nic->packet, lp.rx_memcpy[entry], nic->packetlen = lp.rx_ring[entry].msg_length);
  6896. - lp.rx_ring[entry].base |= R_OWN;
  6897. - lp.rx_cur = (++lp.rx_cur) & lp.rxRingMask;
  6898. - return (1);
  6899. -}
  6900. -
  6901. -/**************************************************************************
  6902. -TRANSMIT - Transmit a frame
  6903. -***************************************************************************/
  6904. -static void depca_transmit(
  6905. - struct nic *nic,
  6906. - const char *d, /* Destination */
  6907. - unsigned int t, /* Type */
  6908. - unsigned int s, /* size */
  6909. - const char *p) /* Packet */
  6910. -{
  6911. - int entry, len;
  6912. - char *mem;
  6913. -
  6914. - /* send the packet to destination */
  6915. - /*
  6916. - ** Caution: the right order is important here... dont
  6917. - ** setup the ownership rights until all the other
  6918. - ** information is in place
  6919. - */
  6920. - mem = lp.tx_memcpy[entry = lp.tx_cur];
  6921. - memcpy_toio(mem, d, ETH_ALEN);
  6922. - memcpy_toio(mem + ETH_ALEN, nic->node_addr, ETH_ALEN);
  6923. - mem[ETH_ALEN * 2] = t >> 8;
  6924. - mem[ETH_ALEN * 2 + 1] = t;
  6925. - memcpy_toio(mem + ETH_HLEN, p, s);
  6926. - s += ETH_HLEN;
  6927. - len = (s < ETH_ZLEN ? ETH_ZLEN : s);
  6928. - /* clean out flags */
  6929. - writel(readl(&lp.tx_ring[entry].base) & ~T_FLAGS, &lp.tx_ring[entry].base);
  6930. - /* clears other error flags */
  6931. - writew(0x0000, &lp.tx_ring[entry].misc);
  6932. - /* packet length in buffer */
  6933. - writew(-len, &lp.tx_ring[entry].length);
  6934. - /* start and end of packet, ownership */
  6935. - writel(readl(&lp.tx_ring[entry].base) | (T_STP|T_ENP|T_OWN), &lp.tx_ring[entry].base);
  6936. - /* update current pointers */
  6937. - lp.tx_cur = (++lp.tx_cur) & lp.txRingMask;
  6938. -}
  6939. -
  6940. -/**************************************************************************
  6941. -DISABLE - Turn off ethernet interface
  6942. -***************************************************************************/
  6943. -static void depca_disable(struct nic *nic)
  6944. -{
  6945. - STOP_DEPCA;
  6946. -}
  6947. -
  6948. -/*
  6949. -** Look for a special sequence in the Ethernet station address PROM that
  6950. -** is common across all DEPCA products. Note that the original DEPCA needs
  6951. -** its ROM address counter to be initialized and enabled. Only enable
  6952. -** if the first address octet is a 0x08 - this minimises the chances of
  6953. -** messing around with some other hardware, but it assumes that this DEPCA
  6954. -** card initialized itself correctly.
  6955. -**
  6956. -** Search the Ethernet address ROM for the signature. Since the ROM address
  6957. -** counter can start at an arbitrary point, the search must include the entire
  6958. -** probe sequence length plus the (length_of_the_signature - 1).
  6959. -** Stop the search IMMEDIATELY after the signature is found so that the
  6960. -** PROM address counter is correctly positioned at the start of the
  6961. -** ethernet address for later read out.
  6962. -*/
  6963. -static int depca_probe1(struct nic *nic)
  6964. -{
  6965. - u8 data, nicsr;
  6966. - /* This is only correct for little endian machines, but then
  6967. - Etherboot doesn't work on anything but a PC */
  6968. - u8 sig[] = { 0xFF, 0x00, 0x55, 0xAA, 0xFF, 0x00, 0x55, 0xAA };
  6969. - int i, j;
  6970. - long sum, chksum;
  6971. -
  6972. - data = inb(DEPCA_PROM); /* clear counter on DEPCA */
  6973. - data = inb(DEPCA_PROM); /* read data */
  6974. - if (data == 0x8) {
  6975. - nicsr = inb(DEPCA_NICSR);
  6976. - nicsr |= AAC;
  6977. - outb(nicsr, DEPCA_NICSR);
  6978. - }
  6979. - for (i = 0, j = 0; j < (int)sizeof(sig) && i < PROBE_LENGTH+((int)sizeof(sig))-1; ++i) {
  6980. - data = inb(DEPCA_PROM);
  6981. - if (data == sig[j]) /* track signature */
  6982. - ++j;
  6983. - else
  6984. - j = (data == sig[0]) ? 1 : 0;
  6985. - }
  6986. - if (j != sizeof(sig))
  6987. - return (0);
  6988. - /* put the card in its initial state */
  6989. - STOP_DEPCA;
  6990. - nicsr = ((inb(DEPCA_NICSR) & ~SHE & ~RBE & ~IEN) | IM);
  6991. - outb(nicsr, DEPCA_NICSR);
  6992. - if (inw(DEPCA_DATA) != STOP)
  6993. - return (0);
  6994. - memcpy((char *)mem_start, sig, sizeof(sig));
  6995. - if (memcmp((char *)mem_start, sig, sizeof(sig)) != 0)
  6996. - return (0);
  6997. - for (i = 0, j = 0, sum = 0; j < 3; j++) {
  6998. - sum <<= 1;
  6999. - if (sum > 0xFFFF)
  7000. - sum -= 0xFFFF;
  7001. - sum += (u8)(nic->node_addr[i++] = inb(DEPCA_PROM));
  7002. - sum += (u16)((nic->node_addr[i++] = inb(DEPCA_PROM)) << 8);
  7003. - if (sum > 0xFFFF)
  7004. - sum -= 0xFFFF;
  7005. - }
  7006. - if (sum == 0xFFFF)
  7007. - sum = 0;
  7008. - chksum = (u8)inb(DEPCA_PROM);
  7009. - chksum |= (u16)(inb(DEPCA_PROM) << 8);
  7010. - mem_len = (adapter == DEPCA) ? (48 << 10) : (64 << 10);
  7011. - offset = 0;
  7012. - if (nicsr & BUF) {
  7013. - offset = 0x8000;
  7014. - nicsr &= ~BS;
  7015. - mem_len -= (32 << 10);
  7016. - }
  7017. - if (adapter != DEPCA) /* enable shadow RAM */
  7018. - outb(nicsr |= SHE, DEPCA_NICSR);
  7019. - printf("%s base %#hX, memory [%#hX-%#hX], addr %!",
  7020. - adapter_name[adapter], ioaddr, mem_start, mem_start + mem_len,
  7021. - nic->node_addr);
  7022. - if (sum != chksum)
  7023. - printf(" (bad checksum)");
  7024. - putchar('\n');
  7025. - return (1);
  7026. -}
  7027. -
  7028. -/**************************************************************************
  7029. -PROBE - Look for an adapter, this routine's visible to the outside
  7030. -***************************************************************************/
  7031. -struct nic *depca_probe(struct nic *nic, unsigned short *probe_addrs)
  7032. -{
  7033. - static unsigned short base[] = DEPCA_IO_PORTS;
  7034. - int i;
  7035. -
  7036. - if (probe_addrs == 0 || probe_addrs[0] == 0)
  7037. - probe_addrs = base; /* Use defaults */
  7038. - for (i = 0; (ioaddr = base[i]) != 0; ++i) {
  7039. - if (depca_probe1(nic))
  7040. - break;
  7041. - }
  7042. - if (ioaddr == 0)
  7043. - return (0);
  7044. - depca_reset(nic);
  7045. - /* point to NIC specific routines */
  7046. - nic->reset = depca_reset;
  7047. - nic->poll = depca_poll;
  7048. - nic->transmit = depca_transmit;
  7049. - nic->disable = depca_disable;
  7050. - return (nic);
  7051. -}
  7052. diff -Naur grub-0.97.orig/netboot/dev.h grub-0.97/netboot/dev.h
  7053. --- grub-0.97.orig/netboot/dev.h 1970-01-01 00:00:00.000000000 +0000
  7054. +++ grub-0.97/netboot/dev.h 2005-08-31 19:03:35.000000000 +0000
  7055. @@ -0,0 +1,83 @@
  7056. +#ifndef _DEV_H
  7057. +#define _DEV_H
  7058. +
  7059. +#include "isa.h"
  7060. +#include "pci.h"
  7061. +
  7062. +/* Need to check the packing of this struct if Etherboot is ported */
  7063. +struct dev_id
  7064. +{
  7065. + unsigned short vendor_id;
  7066. + unsigned short device_id;
  7067. + unsigned char bus_type;
  7068. +#define PCI_BUS_TYPE 1
  7069. +#define ISA_BUS_TYPE 2
  7070. +};
  7071. +
  7072. +/* Dont use sizeof, that will include the padding */
  7073. +#define DEV_ID_SIZE 8
  7074. +
  7075. +
  7076. +struct pci_probe_state
  7077. +{
  7078. +#ifdef CONFIG_PCI
  7079. + struct pci_device dev;
  7080. + int advance;
  7081. +#else
  7082. + int dummy;
  7083. +#endif
  7084. +};
  7085. +struct isa_probe_state
  7086. +{
  7087. +#ifdef CONFIG_ISA
  7088. + const struct isa_driver *driver;
  7089. + int advance;
  7090. +#else
  7091. + int dummy;
  7092. +#endif
  7093. +};
  7094. +
  7095. +union probe_state
  7096. +{
  7097. + struct pci_probe_state pci;
  7098. + struct isa_probe_state isa;
  7099. +};
  7100. +
  7101. +struct dev
  7102. +{
  7103. + void (*disable)P((struct dev *));
  7104. + struct dev_id devid; /* device ID string (sent to DHCP server) */
  7105. + int index; /* Index of next device on this controller to probe */
  7106. + int type; /* Type of device I am probing for */
  7107. + int how_probe; /* First, next or awake */
  7108. + int to_probe; /* Flavor of device I am probing */
  7109. + int failsafe; /* Failsafe probe requested */
  7110. + int type_index; /* Index of this device (within type) */
  7111. +#define PROBE_NONE 0
  7112. +#define PROBE_PCI 1
  7113. +#define PROBE_ISA 2
  7114. + union probe_state state;
  7115. +};
  7116. +
  7117. +
  7118. +#define NIC_DRIVER 0
  7119. +#define DISK_DRIVER 1
  7120. +#define FLOPPY_DRIVER 2
  7121. +
  7122. +#define BRIDGE_DRIVER 1000
  7123. +
  7124. +#define PROBE_FIRST (-1)
  7125. +#define PROBE_NEXT 0
  7126. +#define PROBE_AWAKE 1 /* After calling disable bring up the same device */
  7127. +
  7128. +/* The probe result codes are selected
  7129. + * to allow them to be fed back into the probe
  7130. + * routine and get a successful probe.
  7131. + */
  7132. +#define PROBE_FAILED PROBE_FIRST
  7133. +#define PROBE_WORKED PROBE_NEXT
  7134. +
  7135. +extern int probe(struct dev *dev);
  7136. +extern void disable(struct dev *dev);
  7137. +
  7138. +#endif /* _DEV_H */
  7139. diff -Naur grub-0.97.orig/netboot/e1000.c grub-0.97/netboot/e1000.c
  7140. --- grub-0.97.orig/netboot/e1000.c 1970-01-01 00:00:00.000000000 +0000
  7141. +++ grub-0.97/netboot/e1000.c 2005-08-31 19:03:35.000000000 +0000
  7142. @@ -0,0 +1,3682 @@
  7143. +/**************************************************************************
  7144. +Etherboot - BOOTP/TFTP Bootstrap Program
  7145. +Inter Pro 1000 for Etherboot
  7146. +Drivers are port from Intel's Linux driver e1000-4.3.15
  7147. +
  7148. +***************************************************************************/
  7149. +/*******************************************************************************
  7150. +
  7151. +
  7152. + Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved.
  7153. +
  7154. + This program is free software; you can redistribute it and/or modify it
  7155. + under the terms of the GNU General Public License as published by the Free
  7156. + Software Foundation; either version 2 of the License, or (at your option)
  7157. + any later version.
  7158. +
  7159. + This program is distributed in the hope that it will be useful, but WITHOUT
  7160. + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  7161. + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  7162. + more details.
  7163. +
  7164. + You should have received a copy of the GNU General Public License along with
  7165. + this program; if not, write to the Free Software Foundation, Inc., 59
  7166. + Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  7167. +
  7168. + The full GNU General Public License is included in this distribution in the
  7169. + file called LICENSE.
  7170. +
  7171. + Contact Information:
  7172. + Linux NICS <linux.nics@intel.com>
  7173. + Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  7174. +
  7175. +*******************************************************************************/
  7176. +/*
  7177. + * Copyright (C) Archway Digital Solutions.
  7178. + *
  7179. + * written by Chrsitopher Li <cli at arcyway dot com> or <chrisl at gnuchina dot org>
  7180. + * 2/9/2002
  7181. + *
  7182. + * Copyright (C) Linux Networx.
  7183. + * Massive upgrade to work with the new intel gigabit NICs.
  7184. + * <ebiederman at lnxi dot com>
  7185. + *
  7186. + * Support for 82541ei & 82547ei chips from Intel's Linux driver 5.1.13 added by
  7187. + * Georg Baum <gbaum@users.sf.net>, sponsored by PetaMem GmbH and linkLINE Communications, Inc.
  7188. + *
  7189. + * 01/2004: Updated to Linux driver 5.2.22 by Georg Baum <gbaum@users.sf.net>
  7190. + */
  7191. +
  7192. +/* to get some global routines like printf */
  7193. +#include "etherboot.h"
  7194. +/* to get the interface to the body of the program */
  7195. +#include "nic.h"
  7196. +/* to get the PCI support functions, if this is a PCI NIC */
  7197. +#include "pci.h"
  7198. +#include "timer.h"
  7199. +
  7200. +typedef unsigned char *dma_addr_t;
  7201. +
  7202. +typedef enum {
  7203. + FALSE = 0,
  7204. + TRUE = 1
  7205. +} boolean_t;
  7206. +
  7207. +#define DEBUG 0
  7208. +
  7209. +
  7210. +/* Some pieces of code are disabled with #if 0 ... #endif.
  7211. + * They are not deleted to show where the etherboot driver differs
  7212. + * from the linux driver below the function level.
  7213. + * Some member variables of the hw struct have been eliminated
  7214. + * and the corresponding inplace checks inserted instead.
  7215. + * Pieces such as LED handling that we definitely don't need are deleted.
  7216. + *
  7217. + * The following defines should not be needed normally,
  7218. + * but may be helpful for debugging purposes. */
  7219. +
  7220. +/* Define this if you want to program the transmission control register
  7221. + * the way the Linux driver does it. */
  7222. +#undef LINUX_DRIVER_TCTL
  7223. +
  7224. +/* Define this to behave more like the Linux driver. */
  7225. +#undef LINUX_DRIVER
  7226. +
  7227. +#include "e1000_hw.h"
  7228. +
  7229. +/* NIC specific static variables go here */
  7230. +static struct e1000_hw hw;
  7231. +static char tx_pool[128 + 16];
  7232. +static char rx_pool[128 + 16];
  7233. +static char packet[2096];
  7234. +
  7235. +static struct e1000_tx_desc *tx_base;
  7236. +static struct e1000_rx_desc *rx_base;
  7237. +
  7238. +static int tx_tail;
  7239. +static int rx_tail, rx_last;
  7240. +
  7241. +/* Function forward declarations */
  7242. +static int e1000_setup_link(struct e1000_hw *hw);
  7243. +static int e1000_setup_fiber_serdes_link(struct e1000_hw *hw);
  7244. +static int e1000_setup_copper_link(struct e1000_hw *hw);
  7245. +static int e1000_phy_setup_autoneg(struct e1000_hw *hw);
  7246. +static void e1000_config_collision_dist(struct e1000_hw *hw);
  7247. +static int e1000_config_mac_to_phy(struct e1000_hw *hw);
  7248. +static int e1000_config_fc_after_link_up(struct e1000_hw *hw);
  7249. +static int e1000_check_for_link(struct e1000_hw *hw);
  7250. +static int e1000_wait_autoneg(struct e1000_hw *hw);
  7251. +static void e1000_get_speed_and_duplex(struct e1000_hw *hw, uint16_t *speed, uint16_t *duplex);
  7252. +static int e1000_read_phy_reg(struct e1000_hw *hw, uint32_t reg_addr, uint16_t *phy_data);
  7253. +static int e1000_read_phy_reg_ex(struct e1000_hw *hw, uint32_t reg_addr, uint16_t *phy_data);
  7254. +static int e1000_write_phy_reg(struct e1000_hw *hw, uint32_t reg_addr, uint16_t phy_data);
  7255. +static int e1000_write_phy_reg_ex(struct e1000_hw *hw, uint32_t reg_addr, uint16_t phy_data);
  7256. +static void e1000_phy_hw_reset(struct e1000_hw *hw);
  7257. +static int e1000_phy_reset(struct e1000_hw *hw);
  7258. +static int e1000_detect_gig_phy(struct e1000_hw *hw);
  7259. +
  7260. +/* Printing macros... */
  7261. +
  7262. +#define E1000_ERR(args...) printf("e1000: " args)
  7263. +
  7264. +#if DEBUG >= 3
  7265. +#define E1000_DBG(args...) printf("e1000: " args)
  7266. +#else
  7267. +#define E1000_DBG(args...)
  7268. +#endif
  7269. +
  7270. +#define MSGOUT(S, A, B) printk(S "\n", A, B)
  7271. +#if DEBUG >= 2
  7272. +#define DEBUGFUNC(F) DEBUGOUT(F "\n");
  7273. +#else
  7274. +#define DEBUGFUNC(F)
  7275. +#endif
  7276. +#if DEBUG >= 1
  7277. +#define DEBUGOUT(S) printf(S)
  7278. +#define DEBUGOUT1(S,A) printf(S,A)
  7279. +#define DEBUGOUT2(S,A,B) printf(S,A,B)
  7280. +#define DEBUGOUT3(S,A,B,C) printf(S,A,B,C)
  7281. +#define DEBUGOUT7(S,A,B,C,D,E,F,G) printf(S,A,B,C,D,E,F,G)
  7282. +#else
  7283. +#define DEBUGOUT(S)
  7284. +#define DEBUGOUT1(S,A)
  7285. +#define DEBUGOUT2(S,A,B)
  7286. +#define DEBUGOUT3(S,A,B,C)
  7287. +#define DEBUGOUT7(S,A,B,C,D,E,F,G)
  7288. +#endif
  7289. +
  7290. +#define E1000_WRITE_REG(a, reg, value) ( \
  7291. + ((a)->mac_type >= e1000_82543) ? \
  7292. + (writel((value), ((a)->hw_addr + E1000_##reg))) : \
  7293. + (writel((value), ((a)->hw_addr + E1000_82542_##reg))))
  7294. +
  7295. +#define E1000_READ_REG(a, reg) ( \
  7296. + ((a)->mac_type >= e1000_82543) ? \
  7297. + readl((a)->hw_addr + E1000_##reg) : \
  7298. + readl((a)->hw_addr + E1000_82542_##reg))
  7299. +
  7300. +#define E1000_WRITE_REG_ARRAY(a, reg, offset, value) ( \
  7301. + ((a)->mac_type >= e1000_82543) ? \
  7302. + writel((value), ((a)->hw_addr + E1000_##reg + ((offset) << 2))) : \
  7303. + writel((value), ((a)->hw_addr + E1000_82542_##reg + ((offset) << 2))))
  7304. +
  7305. +#define E1000_READ_REG_ARRAY(a, reg, offset) ( \
  7306. + ((a)->mac_type >= e1000_82543) ? \
  7307. + readl((a)->hw_addr + E1000_##reg + ((offset) << 2)) : \
  7308. + readl((a)->hw_addr + E1000_82542_##reg + ((offset) << 2)))
  7309. +
  7310. +#define E1000_WRITE_FLUSH(a) {uint32_t x; x = E1000_READ_REG(a, STATUS);}
  7311. +
  7312. +uint32_t
  7313. +e1000_io_read(struct e1000_hw *hw __unused, uint32_t port)
  7314. +{
  7315. + return inl(port);
  7316. +}
  7317. +
  7318. +void
  7319. +e1000_io_write(struct e1000_hw *hw __unused, uint32_t port, uint32_t value)
  7320. +{
  7321. + outl(value, port);
  7322. +}
  7323. +
  7324. +static inline void e1000_pci_set_mwi(struct e1000_hw *hw)
  7325. +{
  7326. + pci_write_config_word(hw->pdev, PCI_COMMAND, hw->pci_cmd_word);
  7327. +}
  7328. +
  7329. +static inline void e1000_pci_clear_mwi(struct e1000_hw *hw)
  7330. +{
  7331. + pci_write_config_word(hw->pdev, PCI_COMMAND,
  7332. + hw->pci_cmd_word & ~PCI_COMMAND_INVALIDATE);
  7333. +}
  7334. +
  7335. +/******************************************************************************
  7336. + * Raises the EEPROM's clock input.
  7337. + *
  7338. + * hw - Struct containing variables accessed by shared code
  7339. + * eecd - EECD's current value
  7340. + *****************************************************************************/
  7341. +static void
  7342. +e1000_raise_ee_clk(struct e1000_hw *hw,
  7343. + uint32_t *eecd)
  7344. +{
  7345. + /* Raise the clock input to the EEPROM (by setting the SK bit), and then
  7346. + * wait <delay> microseconds.
  7347. + */
  7348. + *eecd = *eecd | E1000_EECD_SK;
  7349. + E1000_WRITE_REG(hw, EECD, *eecd);
  7350. + E1000_WRITE_FLUSH(hw);
  7351. + udelay(hw->eeprom.delay_usec);
  7352. +}
  7353. +
  7354. +/******************************************************************************
  7355. + * Lowers the EEPROM's clock input.
  7356. + *
  7357. + * hw - Struct containing variables accessed by shared code
  7358. + * eecd - EECD's current value
  7359. + *****************************************************************************/
  7360. +static void
  7361. +e1000_lower_ee_clk(struct e1000_hw *hw,
  7362. + uint32_t *eecd)
  7363. +{
  7364. + /* Lower the clock input to the EEPROM (by clearing the SK bit), and then
  7365. + * wait 50 microseconds.
  7366. + */
  7367. + *eecd = *eecd & ~E1000_EECD_SK;
  7368. + E1000_WRITE_REG(hw, EECD, *eecd);
  7369. + E1000_WRITE_FLUSH(hw);
  7370. + udelay(hw->eeprom.delay_usec);
  7371. +}
  7372. +
  7373. +/******************************************************************************
  7374. + * Shift data bits out to the EEPROM.
  7375. + *
  7376. + * hw - Struct containing variables accessed by shared code
  7377. + * data - data to send to the EEPROM
  7378. + * count - number of bits to shift out
  7379. + *****************************************************************************/
  7380. +static void
  7381. +e1000_shift_out_ee_bits(struct e1000_hw *hw,
  7382. + uint16_t data,
  7383. + uint16_t count)
  7384. +{
  7385. + struct e1000_eeprom_info *eeprom = &hw->eeprom;
  7386. + uint32_t eecd;
  7387. + uint32_t mask;
  7388. +
  7389. + /* We need to shift "count" bits out to the EEPROM. So, value in the
  7390. + * "data" parameter will be shifted out to the EEPROM one bit at a time.
  7391. + * In order to do this, "data" must be broken down into bits.
  7392. + */
  7393. + mask = 0x01 << (count - 1);
  7394. + eecd = E1000_READ_REG(hw, EECD);
  7395. + if (eeprom->type == e1000_eeprom_microwire) {
  7396. + eecd &= ~E1000_EECD_DO;
  7397. + } else if (eeprom->type == e1000_eeprom_spi) {
  7398. + eecd |= E1000_EECD_DO;
  7399. + }
  7400. + do {
  7401. + /* A "1" is shifted out to the EEPROM by setting bit "DI" to a "1",
  7402. + * and then raising and then lowering the clock (the SK bit controls
  7403. + * the clock input to the EEPROM). A "0" is shifted out to the EEPROM
  7404. + * by setting "DI" to "0" and then raising and then lowering the clock.
  7405. + */
  7406. + eecd &= ~E1000_EECD_DI;
  7407. +
  7408. + if(data & mask)
  7409. + eecd |= E1000_EECD_DI;
  7410. +
  7411. + E1000_WRITE_REG(hw, EECD, eecd);
  7412. + E1000_WRITE_FLUSH(hw);
  7413. +
  7414. + udelay(eeprom->delay_usec);
  7415. +
  7416. + e1000_raise_ee_clk(hw, &eecd);
  7417. + e1000_lower_ee_clk(hw, &eecd);
  7418. +
  7419. + mask = mask >> 1;
  7420. +
  7421. + } while(mask);
  7422. +
  7423. + /* We leave the "DI" bit set to "0" when we leave this routine. */
  7424. + eecd &= ~E1000_EECD_DI;
  7425. + E1000_WRITE_REG(hw, EECD, eecd);
  7426. +}
  7427. +
  7428. +/******************************************************************************
  7429. + * Shift data bits in from the EEPROM
  7430. + *
  7431. + * hw - Struct containing variables accessed by shared code
  7432. + *****************************************************************************/
  7433. +static uint16_t
  7434. +e1000_shift_in_ee_bits(struct e1000_hw *hw,
  7435. + uint16_t count)
  7436. +{
  7437. + uint32_t eecd;
  7438. + uint32_t i;
  7439. + uint16_t data;
  7440. +
  7441. + /* In order to read a register from the EEPROM, we need to shift 'count'
  7442. + * bits in from the EEPROM. Bits are "shifted in" by raising the clock
  7443. + * input to the EEPROM (setting the SK bit), and then reading the value of
  7444. + * the "DO" bit. During this "shifting in" process the "DI" bit should
  7445. + * always be clear.
  7446. + */
  7447. +
  7448. + eecd = E1000_READ_REG(hw, EECD);
  7449. +
  7450. + eecd &= ~(E1000_EECD_DO | E1000_EECD_DI);
  7451. + data = 0;
  7452. +
  7453. + for(i = 0; i < count; i++) {
  7454. + data = data << 1;
  7455. + e1000_raise_ee_clk(hw, &eecd);
  7456. +
  7457. + eecd = E1000_READ_REG(hw, EECD);
  7458. +
  7459. + eecd &= ~(E1000_EECD_DI);
  7460. + if(eecd & E1000_EECD_DO)
  7461. + data |= 1;
  7462. +
  7463. + e1000_lower_ee_clk(hw, &eecd);
  7464. + }
  7465. +
  7466. + return data;
  7467. +}
  7468. +
  7469. +/******************************************************************************
  7470. + * Prepares EEPROM for access
  7471. + *
  7472. + * hw - Struct containing variables accessed by shared code
  7473. + *
  7474. + * Lowers EEPROM clock. Clears input pin. Sets the chip select pin. This
  7475. + * function should be called before issuing a command to the EEPROM.
  7476. + *****************************************************************************/
  7477. +static int32_t
  7478. +e1000_acquire_eeprom(struct e1000_hw *hw)
  7479. +{
  7480. + struct e1000_eeprom_info *eeprom = &hw->eeprom;
  7481. + uint32_t eecd, i=0;
  7482. +
  7483. + eecd = E1000_READ_REG(hw, EECD);
  7484. +
  7485. + /* Request EEPROM Access */
  7486. + if(hw->mac_type > e1000_82544) {
  7487. + eecd |= E1000_EECD_REQ;
  7488. + E1000_WRITE_REG(hw, EECD, eecd);
  7489. + eecd = E1000_READ_REG(hw, EECD);
  7490. + while((!(eecd & E1000_EECD_GNT)) &&
  7491. + (i < E1000_EEPROM_GRANT_ATTEMPTS)) {
  7492. + i++;
  7493. + udelay(5);
  7494. + eecd = E1000_READ_REG(hw, EECD);
  7495. + }
  7496. + if(!(eecd & E1000_EECD_GNT)) {
  7497. + eecd &= ~E1000_EECD_REQ;
  7498. + E1000_WRITE_REG(hw, EECD, eecd);
  7499. + DEBUGOUT("Could not acquire EEPROM grant\n");
  7500. + return -E1000_ERR_EEPROM;
  7501. + }
  7502. + }
  7503. +
  7504. + /* Setup EEPROM for Read/Write */
  7505. +
  7506. + if (eeprom->type == e1000_eeprom_microwire) {
  7507. + /* Clear SK and DI */
  7508. + eecd &= ~(E1000_EECD_DI | E1000_EECD_SK);
  7509. + E1000_WRITE_REG(hw, EECD, eecd);
  7510. +
  7511. + /* Set CS */
  7512. + eecd |= E1000_EECD_CS;
  7513. + E1000_WRITE_REG(hw, EECD, eecd);
  7514. + } else if (eeprom->type == e1000_eeprom_spi) {
  7515. + /* Clear SK and CS */
  7516. + eecd &= ~(E1000_EECD_CS | E1000_EECD_SK);
  7517. + E1000_WRITE_REG(hw, EECD, eecd);
  7518. + udelay(1);
  7519. + }
  7520. +
  7521. + return E1000_SUCCESS;
  7522. +}
  7523. +
  7524. +/******************************************************************************
  7525. + * Returns EEPROM to a "standby" state
  7526. + *
  7527. + * hw - Struct containing variables accessed by shared code
  7528. + *****************************************************************************/
  7529. +static void
  7530. +e1000_standby_eeprom(struct e1000_hw *hw)
  7531. +{
  7532. + struct e1000_eeprom_info *eeprom = &hw->eeprom;
  7533. + uint32_t eecd;
  7534. +
  7535. + eecd = E1000_READ_REG(hw, EECD);
  7536. +
  7537. + if(eeprom->type == e1000_eeprom_microwire) {
  7538. +
  7539. + /* Deselect EEPROM */
  7540. + eecd &= ~(E1000_EECD_CS | E1000_EECD_SK);
  7541. + E1000_WRITE_REG(hw, EECD, eecd);
  7542. + E1000_WRITE_FLUSH(hw);
  7543. + udelay(eeprom->delay_usec);
  7544. +
  7545. + /* Clock high */
  7546. + eecd |= E1000_EECD_SK;
  7547. + E1000_WRITE_REG(hw, EECD, eecd);
  7548. + E1000_WRITE_FLUSH(hw);
  7549. + udelay(eeprom->delay_usec);
  7550. +
  7551. + /* Select EEPROM */
  7552. + eecd |= E1000_EECD_CS;
  7553. + E1000_WRITE_REG(hw, EECD, eecd);
  7554. + E1000_WRITE_FLUSH(hw);
  7555. + udelay(eeprom->delay_usec);
  7556. +
  7557. + /* Clock low */
  7558. + eecd &= ~E1000_EECD_SK;
  7559. + E1000_WRITE_REG(hw, EECD, eecd);
  7560. + E1000_WRITE_FLUSH(hw);
  7561. + udelay(eeprom->delay_usec);
  7562. + } else if(eeprom->type == e1000_eeprom_spi) {
  7563. + /* Toggle CS to flush commands */
  7564. + eecd |= E1000_EECD_CS;
  7565. + E1000_WRITE_REG(hw, EECD, eecd);
  7566. + E1000_WRITE_FLUSH(hw);
  7567. + udelay(eeprom->delay_usec);
  7568. + eecd &= ~E1000_EECD_CS;
  7569. + E1000_WRITE_REG(hw, EECD, eecd);
  7570. + E1000_WRITE_FLUSH(hw);
  7571. + udelay(eeprom->delay_usec);
  7572. + }
  7573. +}
  7574. +
  7575. +/******************************************************************************
  7576. + * Terminates a command by inverting the EEPROM's chip select pin
  7577. + *
  7578. + * hw - Struct containing variables accessed by shared code
  7579. + *****************************************************************************/
  7580. +static void
  7581. +e1000_release_eeprom(struct e1000_hw *hw)
  7582. +{
  7583. + uint32_t eecd;
  7584. +
  7585. + eecd = E1000_READ_REG(hw, EECD);
  7586. +
  7587. + if (hw->eeprom.type == e1000_eeprom_spi) {
  7588. + eecd |= E1000_EECD_CS; /* Pull CS high */
  7589. + eecd &= ~E1000_EECD_SK; /* Lower SCK */
  7590. +
  7591. + E1000_WRITE_REG(hw, EECD, eecd);
  7592. +
  7593. + udelay(hw->eeprom.delay_usec);
  7594. + } else if(hw->eeprom.type == e1000_eeprom_microwire) {
  7595. + /* cleanup eeprom */
  7596. +
  7597. + /* CS on Microwire is active-high */
  7598. + eecd &= ~(E1000_EECD_CS | E1000_EECD_DI);
  7599. +
  7600. + E1000_WRITE_REG(hw, EECD, eecd);
  7601. +
  7602. + /* Rising edge of clock */
  7603. + eecd |= E1000_EECD_SK;
  7604. + E1000_WRITE_REG(hw, EECD, eecd);
  7605. + E1000_WRITE_FLUSH(hw);
  7606. + udelay(hw->eeprom.delay_usec);
  7607. +
  7608. + /* Falling edge of clock */
  7609. + eecd &= ~E1000_EECD_SK;
  7610. + E1000_WRITE_REG(hw, EECD, eecd);
  7611. + E1000_WRITE_FLUSH(hw);
  7612. + udelay(hw->eeprom.delay_usec);
  7613. + }
  7614. +
  7615. + /* Stop requesting EEPROM access */
  7616. + if(hw->mac_type > e1000_82544) {
  7617. + eecd &= ~E1000_EECD_REQ;
  7618. + E1000_WRITE_REG(hw, EECD, eecd);
  7619. + }
  7620. +}
  7621. +
  7622. +/******************************************************************************
  7623. + * Reads a 16 bit word from the EEPROM.
  7624. + *
  7625. + * hw - Struct containing variables accessed by shared code
  7626. + *****************************************************************************/
  7627. +static int32_t
  7628. +e1000_spi_eeprom_ready(struct e1000_hw *hw)
  7629. +{
  7630. + uint16_t retry_count = 0;
  7631. + uint8_t spi_stat_reg;
  7632. +
  7633. + /* Read "Status Register" repeatedly until the LSB is cleared. The
  7634. + * EEPROM will signal that the command has been completed by clearing
  7635. + * bit 0 of the internal status register. If it's not cleared within
  7636. + * 5 milliseconds, then error out.
  7637. + */
  7638. + retry_count = 0;
  7639. + do {
  7640. + e1000_shift_out_ee_bits(hw, EEPROM_RDSR_OPCODE_SPI,
  7641. + hw->eeprom.opcode_bits);
  7642. + spi_stat_reg = (uint8_t)e1000_shift_in_ee_bits(hw, 8);
  7643. + if (!(spi_stat_reg & EEPROM_STATUS_RDY_SPI))
  7644. + break;
  7645. +
  7646. + udelay(5);
  7647. + retry_count += 5;
  7648. +
  7649. + } while(retry_count < EEPROM_MAX_RETRY_SPI);
  7650. +
  7651. + /* ATMEL SPI write time could vary from 0-20mSec on 3.3V devices (and
  7652. + * only 0-5mSec on 5V devices)
  7653. + */
  7654. + if(retry_count >= EEPROM_MAX_RETRY_SPI) {
  7655. + DEBUGOUT("SPI EEPROM Status error\n");
  7656. + return -E1000_ERR_EEPROM;
  7657. + }
  7658. +
  7659. + return E1000_SUCCESS;
  7660. +}
  7661. +
  7662. +/******************************************************************************
  7663. + * Reads a 16 bit word from the EEPROM.
  7664. + *
  7665. + * hw - Struct containing variables accessed by shared code
  7666. + * offset - offset of word in the EEPROM to read
  7667. + * data - word read from the EEPROM
  7668. + * words - number of words to read
  7669. + *****************************************************************************/
  7670. +static int
  7671. +e1000_read_eeprom(struct e1000_hw *hw,
  7672. + uint16_t offset,
  7673. + uint16_t words,
  7674. + uint16_t *data)
  7675. +{
  7676. + struct e1000_eeprom_info *eeprom = &hw->eeprom;
  7677. + uint32_t i = 0;
  7678. +
  7679. + DEBUGFUNC("e1000_read_eeprom");
  7680. +
  7681. + /* A check for invalid values: offset too large, too many words, and not
  7682. + * enough words.
  7683. + */
  7684. + if((offset > eeprom->word_size) || (words > eeprom->word_size - offset) ||
  7685. + (words == 0)) {
  7686. + DEBUGOUT("\"words\" parameter out of bounds\n");
  7687. + return -E1000_ERR_EEPROM;
  7688. + }
  7689. +
  7690. + /* Prepare the EEPROM for reading */
  7691. + if(e1000_acquire_eeprom(hw) != E1000_SUCCESS)
  7692. + return -E1000_ERR_EEPROM;
  7693. +
  7694. + if(eeprom->type == e1000_eeprom_spi) {
  7695. + uint16_t word_in;
  7696. + uint8_t read_opcode = EEPROM_READ_OPCODE_SPI;
  7697. +
  7698. + if(e1000_spi_eeprom_ready(hw)) {
  7699. + e1000_release_eeprom(hw);
  7700. + return -E1000_ERR_EEPROM;
  7701. + }
  7702. +
  7703. + e1000_standby_eeprom(hw);
  7704. +
  7705. + /* Some SPI eeproms use the 8th address bit embedded in the opcode */
  7706. + if((eeprom->address_bits == 8) && (offset >= 128))
  7707. + read_opcode |= EEPROM_A8_OPCODE_SPI;
  7708. +
  7709. + /* Send the READ command (opcode + addr) */
  7710. + e1000_shift_out_ee_bits(hw, read_opcode, eeprom->opcode_bits);
  7711. + e1000_shift_out_ee_bits(hw, (uint16_t)(offset*2), eeprom->address_bits);
  7712. +
  7713. + /* Read the data. The address of the eeprom internally increments with
  7714. + * each byte (spi) being read, saving on the overhead of eeprom setup
  7715. + * and tear-down. The address counter will roll over if reading beyond
  7716. + * the size of the eeprom, thus allowing the entire memory to be read
  7717. + * starting from any offset. */
  7718. + for (i = 0; i < words; i++) {
  7719. + word_in = e1000_shift_in_ee_bits(hw, 16);
  7720. + data[i] = (word_in >> 8) | (word_in << 8);
  7721. + }
  7722. + } else if(eeprom->type == e1000_eeprom_microwire) {
  7723. + for (i = 0; i < words; i++) {
  7724. + /* Send the READ command (opcode + addr) */
  7725. + e1000_shift_out_ee_bits(hw, EEPROM_READ_OPCODE_MICROWIRE,
  7726. + eeprom->opcode_bits);
  7727. + e1000_shift_out_ee_bits(hw, (uint16_t)(offset + i),
  7728. + eeprom->address_bits);
  7729. +
  7730. + /* Read the data. For microwire, each word requires the overhead
  7731. + * of eeprom setup and tear-down. */
  7732. + data[i] = e1000_shift_in_ee_bits(hw, 16);
  7733. + e1000_standby_eeprom(hw);
  7734. + }
  7735. + }
  7736. +
  7737. + /* End this read operation */
  7738. + e1000_release_eeprom(hw);
  7739. +
  7740. + return E1000_SUCCESS;
  7741. +}
  7742. +
  7743. +/******************************************************************************
  7744. + * Verifies that the EEPROM has a valid checksum
  7745. + *
  7746. + * hw - Struct containing variables accessed by shared code
  7747. + *
  7748. + * Reads the first 64 16 bit words of the EEPROM and sums the values read.
  7749. + * If the the sum of the 64 16 bit words is 0xBABA, the EEPROM's checksum is
  7750. + * valid.
  7751. + *****************************************************************************/
  7752. +static int
  7753. +e1000_validate_eeprom_checksum(struct e1000_hw *hw)
  7754. +{
  7755. + uint16_t checksum = 0;
  7756. + uint16_t i, eeprom_data;
  7757. +
  7758. + DEBUGFUNC("e1000_validate_eeprom_checksum");
  7759. +
  7760. + for(i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) {
  7761. + if(e1000_read_eeprom(hw, i, 1, &eeprom_data) < 0) {
  7762. + DEBUGOUT("EEPROM Read Error\n");
  7763. + return -E1000_ERR_EEPROM;
  7764. + }
  7765. + checksum += eeprom_data;
  7766. + }
  7767. +
  7768. + if(checksum == (uint16_t) EEPROM_SUM)
  7769. + return E1000_SUCCESS;
  7770. + else {
  7771. + DEBUGOUT("EEPROM Checksum Invalid\n");
  7772. + return -E1000_ERR_EEPROM;
  7773. + }
  7774. +}
  7775. +
  7776. +/******************************************************************************
  7777. + * Reads the adapter's MAC address from the EEPROM and inverts the LSB for the
  7778. + * second function of dual function devices
  7779. + *
  7780. + * hw - Struct containing variables accessed by shared code
  7781. + *****************************************************************************/
  7782. +static int
  7783. +e1000_read_mac_addr(struct e1000_hw *hw)
  7784. +{
  7785. + uint16_t offset;
  7786. + uint16_t eeprom_data;
  7787. + int i;
  7788. +
  7789. + DEBUGFUNC("e1000_read_mac_addr");
  7790. +
  7791. + for(i = 0; i < NODE_ADDRESS_SIZE; i += 2) {
  7792. + offset = i >> 1;
  7793. + if(e1000_read_eeprom(hw, offset, 1, &eeprom_data) < 0) {
  7794. + DEBUGOUT("EEPROM Read Error\n");
  7795. + return -E1000_ERR_EEPROM;
  7796. + }
  7797. + hw->mac_addr[i] = eeprom_data & 0xff;
  7798. + hw->mac_addr[i+1] = (eeprom_data >> 8) & 0xff;
  7799. + }
  7800. + if(((hw->mac_type == e1000_82546) || (hw->mac_type == e1000_82546_rev_3)) &&
  7801. + (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1))
  7802. + /* Invert the last bit if this is the second device */
  7803. + hw->mac_addr[5] ^= 1;
  7804. + return E1000_SUCCESS;
  7805. +}
  7806. +
  7807. +/******************************************************************************
  7808. + * Initializes receive address filters.
  7809. + *
  7810. + * hw - Struct containing variables accessed by shared code
  7811. + *
  7812. + * Places the MAC address in receive address register 0 and clears the rest
  7813. + * of the receive addresss registers. Clears the multicast table. Assumes
  7814. + * the receiver is in reset when the routine is called.
  7815. + *****************************************************************************/
  7816. +static void
  7817. +e1000_init_rx_addrs(struct e1000_hw *hw)
  7818. +{
  7819. + uint32_t i;
  7820. + uint32_t addr_low;
  7821. + uint32_t addr_high;
  7822. +
  7823. + DEBUGFUNC("e1000_init_rx_addrs");
  7824. +
  7825. + /* Setup the receive address. */
  7826. + DEBUGOUT("Programming MAC Address into RAR[0]\n");
  7827. + addr_low = (hw->mac_addr[0] |
  7828. + (hw->mac_addr[1] << 8) |
  7829. + (hw->mac_addr[2] << 16) | (hw->mac_addr[3] << 24));
  7830. +
  7831. + addr_high = (hw->mac_addr[4] |
  7832. + (hw->mac_addr[5] << 8) | E1000_RAH_AV);
  7833. +
  7834. + E1000_WRITE_REG_ARRAY(hw, RA, 0, addr_low);
  7835. + E1000_WRITE_REG_ARRAY(hw, RA, 1, addr_high);
  7836. +
  7837. + /* Zero out the other 15 receive addresses. */
  7838. + DEBUGOUT("Clearing RAR[1-15]\n");
  7839. + for(i = 1; i < E1000_RAR_ENTRIES; i++) {
  7840. + E1000_WRITE_REG_ARRAY(hw, RA, (i << 1), 0);
  7841. + E1000_WRITE_REG_ARRAY(hw, RA, ((i << 1) + 1), 0);
  7842. + }
  7843. +}
  7844. +
  7845. +/******************************************************************************
  7846. + * Clears the VLAN filer table
  7847. + *
  7848. + * hw - Struct containing variables accessed by shared code
  7849. + *****************************************************************************/
  7850. +static void
  7851. +e1000_clear_vfta(struct e1000_hw *hw)
  7852. +{
  7853. + uint32_t offset;
  7854. +
  7855. + for(offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++)
  7856. + E1000_WRITE_REG_ARRAY(hw, VFTA, offset, 0);
  7857. +}
  7858. +
  7859. +/******************************************************************************
  7860. +* Writes a value to one of the devices registers using port I/O (as opposed to
  7861. +* memory mapped I/O). Only 82544 and newer devices support port I/O. *
  7862. +* hw - Struct containing variables accessed by shared code
  7863. +* offset - offset to write to * value - value to write
  7864. +*****************************************************************************/
  7865. +void e1000_write_reg_io(struct e1000_hw *hw, uint32_t offset, uint32_t value){
  7866. + uint32_t io_addr = hw->io_base;
  7867. + uint32_t io_data = hw->io_base + 4;
  7868. + e1000_io_write(hw, io_addr, offset);
  7869. + e1000_io_write(hw, io_data, value);
  7870. +}
  7871. +
  7872. +/******************************************************************************
  7873. + * Set the phy type member in the hw struct.
  7874. + *
  7875. + * hw - Struct containing variables accessed by shared code
  7876. + *****************************************************************************/
  7877. +static int32_t
  7878. +e1000_set_phy_type(struct e1000_hw *hw)
  7879. +{
  7880. + DEBUGFUNC("e1000_set_phy_type");
  7881. +
  7882. + switch(hw->phy_id) {
  7883. + case M88E1000_E_PHY_ID:
  7884. + case M88E1000_I_PHY_ID:
  7885. + case M88E1011_I_PHY_ID:
  7886. + hw->phy_type = e1000_phy_m88;
  7887. + break;
  7888. + case IGP01E1000_I_PHY_ID:
  7889. + hw->phy_type = e1000_phy_igp;
  7890. + break;
  7891. + default:
  7892. + /* Should never have loaded on this device */
  7893. + hw->phy_type = e1000_phy_undefined;
  7894. + return -E1000_ERR_PHY_TYPE;
  7895. + }
  7896. +
  7897. + return E1000_SUCCESS;
  7898. +}
  7899. +
  7900. +/******************************************************************************
  7901. + * IGP phy init script - initializes the GbE PHY
  7902. + *
  7903. + * hw - Struct containing variables accessed by shared code
  7904. + *****************************************************************************/
  7905. +static void
  7906. +e1000_phy_init_script(struct e1000_hw *hw)
  7907. +{
  7908. + DEBUGFUNC("e1000_phy_init_script");
  7909. +
  7910. +#if 0
  7911. + /* See e1000_sw_init() of the Linux driver */
  7912. + if(hw->phy_init_script) {
  7913. +#else
  7914. + if((hw->mac_type == e1000_82541) ||
  7915. + (hw->mac_type == e1000_82547) ||
  7916. + (hw->mac_type == e1000_82541_rev_2) ||
  7917. + (hw->mac_type == e1000_82547_rev_2)) {
  7918. +#endif
  7919. + mdelay(20);
  7920. +
  7921. + e1000_write_phy_reg(hw,0x0000,0x0140);
  7922. +
  7923. + mdelay(5);
  7924. +
  7925. + if(hw->mac_type == e1000_82541 || hw->mac_type == e1000_82547) {
  7926. + e1000_write_phy_reg(hw, 0x1F95, 0x0001);
  7927. +
  7928. + e1000_write_phy_reg(hw, 0x1F71, 0xBD21);
  7929. +
  7930. + e1000_write_phy_reg(hw, 0x1F79, 0x0018);
  7931. +
  7932. + e1000_write_phy_reg(hw, 0x1F30, 0x1600);
  7933. +
  7934. + e1000_write_phy_reg(hw, 0x1F31, 0x0014);
  7935. +
  7936. + e1000_write_phy_reg(hw, 0x1F32, 0x161C);
  7937. +
  7938. + e1000_write_phy_reg(hw, 0x1F94, 0x0003);
  7939. +
  7940. + e1000_write_phy_reg(hw, 0x1F96, 0x003F);
  7941. +
  7942. + e1000_write_phy_reg(hw, 0x2010, 0x0008);
  7943. + } else {
  7944. + e1000_write_phy_reg(hw, 0x1F73, 0x0099);
  7945. + }
  7946. +
  7947. + e1000_write_phy_reg(hw, 0x0000, 0x3300);
  7948. +
  7949. +
  7950. + if(hw->mac_type == e1000_82547) {
  7951. + uint16_t fused, fine, coarse;
  7952. +
  7953. + /* Move to analog registers page */
  7954. + e1000_read_phy_reg(hw, IGP01E1000_ANALOG_SPARE_FUSE_STATUS, &fused);
  7955. +
  7956. + if(!(fused & IGP01E1000_ANALOG_SPARE_FUSE_ENABLED)) {
  7957. + e1000_read_phy_reg(hw, IGP01E1000_ANALOG_FUSE_STATUS, &fused);
  7958. +
  7959. + fine = fused & IGP01E1000_ANALOG_FUSE_FINE_MASK;
  7960. + coarse = fused & IGP01E1000_ANALOG_FUSE_COARSE_MASK;
  7961. +
  7962. + if(coarse > IGP01E1000_ANALOG_FUSE_COARSE_THRESH) {
  7963. + coarse -= IGP01E1000_ANALOG_FUSE_COARSE_10;
  7964. + fine -= IGP01E1000_ANALOG_FUSE_FINE_1;
  7965. + } else if(coarse == IGP01E1000_ANALOG_FUSE_COARSE_THRESH)
  7966. + fine -= IGP01E1000_ANALOG_FUSE_FINE_10;
  7967. +
  7968. + fused = (fused & IGP01E1000_ANALOG_FUSE_POLY_MASK) |
  7969. + (fine & IGP01E1000_ANALOG_FUSE_FINE_MASK) |
  7970. + (coarse & IGP01E1000_ANALOG_FUSE_COARSE_MASK);
  7971. +
  7972. + e1000_write_phy_reg(hw, IGP01E1000_ANALOG_FUSE_CONTROL, fused);
  7973. + e1000_write_phy_reg(hw, IGP01E1000_ANALOG_FUSE_BYPASS,
  7974. + IGP01E1000_ANALOG_FUSE_ENABLE_SW_CONTROL);
  7975. + }
  7976. + }
  7977. + }
  7978. +}
  7979. +
  7980. +/******************************************************************************
  7981. + * Set the mac type member in the hw struct.
  7982. + *
  7983. + * hw - Struct containing variables accessed by shared code
  7984. + *****************************************************************************/
  7985. +static int
  7986. +e1000_set_mac_type(struct e1000_hw *hw)
  7987. +{
  7988. + DEBUGFUNC("e1000_set_mac_type");
  7989. +
  7990. + switch (hw->device_id) {
  7991. + case E1000_DEV_ID_82542:
  7992. + switch (hw->revision_id) {
  7993. + case E1000_82542_2_0_REV_ID:
  7994. + hw->mac_type = e1000_82542_rev2_0;
  7995. + break;
  7996. + case E1000_82542_2_1_REV_ID:
  7997. + hw->mac_type = e1000_82542_rev2_1;
  7998. + break;
  7999. + default:
  8000. + /* Invalid 82542 revision ID */
  8001. + return -E1000_ERR_MAC_TYPE;
  8002. + }
  8003. + break;
  8004. + case E1000_DEV_ID_82543GC_FIBER:
  8005. + case E1000_DEV_ID_82543GC_COPPER:
  8006. + hw->mac_type = e1000_82543;
  8007. + break;
  8008. + case E1000_DEV_ID_82544EI_COPPER:
  8009. + case E1000_DEV_ID_82544EI_FIBER:
  8010. + case E1000_DEV_ID_82544GC_COPPER:
  8011. + case E1000_DEV_ID_82544GC_LOM:
  8012. + hw->mac_type = e1000_82544;
  8013. + break;
  8014. + case E1000_DEV_ID_82540EM:
  8015. + case E1000_DEV_ID_82540EM_LOM:
  8016. + case E1000_DEV_ID_82540EP:
  8017. + case E1000_DEV_ID_82540EP_LOM:
  8018. + case E1000_DEV_ID_82540EP_LP:
  8019. + hw->mac_type = e1000_82540;
  8020. + break;
  8021. + case E1000_DEV_ID_82545EM_COPPER:
  8022. + case E1000_DEV_ID_82545EM_FIBER:
  8023. + hw->mac_type = e1000_82545;
  8024. + break;
  8025. + case E1000_DEV_ID_82545GM_COPPER:
  8026. + case E1000_DEV_ID_82545GM_FIBER:
  8027. + case E1000_DEV_ID_82545GM_SERDES:
  8028. + hw->mac_type = e1000_82545_rev_3;
  8029. + break;
  8030. + case E1000_DEV_ID_82546EB_COPPER:
  8031. + case E1000_DEV_ID_82546EB_FIBER:
  8032. + case E1000_DEV_ID_82546EB_QUAD_COPPER:
  8033. + hw->mac_type = e1000_82546;
  8034. + break;
  8035. + case E1000_DEV_ID_82546GB_COPPER:
  8036. + case E1000_DEV_ID_82546GB_FIBER:
  8037. + case E1000_DEV_ID_82546GB_SERDES:
  8038. + hw->mac_type = e1000_82546_rev_3;
  8039. + break;
  8040. + case E1000_DEV_ID_82541EI:
  8041. + case E1000_DEV_ID_82541EI_MOBILE:
  8042. + hw->mac_type = e1000_82541;
  8043. + break;
  8044. + case E1000_DEV_ID_82541ER:
  8045. + case E1000_DEV_ID_82541GI:
  8046. + case E1000_DEV_ID_82541GI_MOBILE:
  8047. + hw->mac_type = e1000_82541_rev_2;
  8048. + break;
  8049. + case E1000_DEV_ID_82547EI:
  8050. + hw->mac_type = e1000_82547;
  8051. + break;
  8052. + case E1000_DEV_ID_82547GI:
  8053. + hw->mac_type = e1000_82547_rev_2;
  8054. + break;
  8055. + default:
  8056. + /* Should never have loaded on this device */
  8057. + return -E1000_ERR_MAC_TYPE;
  8058. + }
  8059. +
  8060. + return E1000_SUCCESS;
  8061. +}
  8062. +
  8063. +/*****************************************************************************
  8064. + * Set media type and TBI compatibility.
  8065. + *
  8066. + * hw - Struct containing variables accessed by shared code
  8067. + * **************************************************************************/
  8068. +static void
  8069. +e1000_set_media_type(struct e1000_hw *hw)
  8070. +{
  8071. + uint32_t status;
  8072. +
  8073. + DEBUGFUNC("e1000_set_media_type");
  8074. +
  8075. + if(hw->mac_type != e1000_82543) {
  8076. + /* tbi_compatibility is only valid on 82543 */
  8077. + hw->tbi_compatibility_en = FALSE;
  8078. + }
  8079. +
  8080. + switch (hw->device_id) {
  8081. + case E1000_DEV_ID_82545GM_SERDES:
  8082. + case E1000_DEV_ID_82546GB_SERDES:
  8083. + hw->media_type = e1000_media_type_internal_serdes;
  8084. + break;
  8085. + default:
  8086. + if(hw->mac_type >= e1000_82543) {
  8087. + status = E1000_READ_REG(hw, STATUS);
  8088. + if(status & E1000_STATUS_TBIMODE) {
  8089. + hw->media_type = e1000_media_type_fiber;
  8090. + /* tbi_compatibility not valid on fiber */
  8091. + hw->tbi_compatibility_en = FALSE;
  8092. + } else {
  8093. + hw->media_type = e1000_media_type_copper;
  8094. + }
  8095. + } else {
  8096. + /* This is an 82542 (fiber only) */
  8097. + hw->media_type = e1000_media_type_fiber;
  8098. + }
  8099. + }
  8100. +}
  8101. +
  8102. +/******************************************************************************
  8103. + * Reset the transmit and receive units; mask and clear all interrupts.
  8104. + *
  8105. + * hw - Struct containing variables accessed by shared code
  8106. + *****************************************************************************/
  8107. +static void
  8108. +e1000_reset_hw(struct e1000_hw *hw)
  8109. +{
  8110. + uint32_t ctrl;
  8111. + uint32_t ctrl_ext;
  8112. + uint32_t icr;
  8113. + uint32_t manc;
  8114. +
  8115. + DEBUGFUNC("e1000_reset_hw");
  8116. +
  8117. + /* For 82542 (rev 2.0), disable MWI before issuing a device reset */
  8118. + if(hw->mac_type == e1000_82542_rev2_0) {
  8119. + DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");
  8120. + e1000_pci_clear_mwi(hw);
  8121. + }
  8122. +
  8123. + /* Clear interrupt mask to stop board from generating interrupts */
  8124. + DEBUGOUT("Masking off all interrupts\n");
  8125. + E1000_WRITE_REG(hw, IMC, 0xffffffff);
  8126. +
  8127. + /* Disable the Transmit and Receive units. Then delay to allow
  8128. + * any pending transactions to complete before we hit the MAC with
  8129. + * the global reset.
  8130. + */
  8131. + E1000_WRITE_REG(hw, RCTL, 0);
  8132. + E1000_WRITE_REG(hw, TCTL, E1000_TCTL_PSP);
  8133. + E1000_WRITE_FLUSH(hw);
  8134. +
  8135. + /* The tbi_compatibility_on Flag must be cleared when Rctl is cleared. */
  8136. + hw->tbi_compatibility_on = FALSE;
  8137. +
  8138. + /* Delay to allow any outstanding PCI transactions to complete before
  8139. + * resetting the device
  8140. + */
  8141. + mdelay(10);
  8142. +
  8143. + ctrl = E1000_READ_REG(hw, CTRL);
  8144. +
  8145. + /* Must reset the PHY before resetting the MAC */
  8146. + if((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
  8147. + E1000_WRITE_REG_IO(hw, CTRL, (ctrl | E1000_CTRL_PHY_RST));
  8148. + mdelay(5);
  8149. + }
  8150. +
  8151. + /* Issue a global reset to the MAC. This will reset the chip's
  8152. + * transmit, receive, DMA, and link units. It will not effect
  8153. + * the current PCI configuration. The global reset bit is self-
  8154. + * clearing, and should clear within a microsecond.
  8155. + */
  8156. + DEBUGOUT("Issuing a global reset to MAC\n");
  8157. +
  8158. + switch(hw->mac_type) {
  8159. + case e1000_82544:
  8160. + case e1000_82540:
  8161. + case e1000_82545:
  8162. + case e1000_82546:
  8163. + case e1000_82541:
  8164. + case e1000_82541_rev_2:
  8165. + /* These controllers can't ack the 64-bit write when issuing the
  8166. + * reset, so use IO-mapping as a workaround to issue the reset */
  8167. + E1000_WRITE_REG_IO(hw, CTRL, (ctrl | E1000_CTRL_RST));
  8168. + break;
  8169. + case e1000_82545_rev_3:
  8170. + case e1000_82546_rev_3:
  8171. + /* Reset is performed on a shadow of the control register */
  8172. + E1000_WRITE_REG(hw, CTRL_DUP, (ctrl | E1000_CTRL_RST));
  8173. + break;
  8174. + default:
  8175. + E1000_WRITE_REG(hw, CTRL, (ctrl | E1000_CTRL_RST));
  8176. + break;
  8177. + }
  8178. +
  8179. + /* After MAC reset, force reload of EEPROM to restore power-on settings to
  8180. + * device. Later controllers reload the EEPROM automatically, so just wait
  8181. + * for reload to complete.
  8182. + */
  8183. + switch(hw->mac_type) {
  8184. + case e1000_82542_rev2_0:
  8185. + case e1000_82542_rev2_1:
  8186. + case e1000_82543:
  8187. + case e1000_82544:
  8188. + /* Wait for reset to complete */
  8189. + udelay(10);
  8190. + ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
  8191. + ctrl_ext |= E1000_CTRL_EXT_EE_RST;
  8192. + E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
  8193. + E1000_WRITE_FLUSH(hw);
  8194. + /* Wait for EEPROM reload */
  8195. + mdelay(2);
  8196. + break;
  8197. + case e1000_82541:
  8198. + case e1000_82541_rev_2:
  8199. + case e1000_82547:
  8200. + case e1000_82547_rev_2:
  8201. + /* Wait for EEPROM reload */
  8202. + mdelay(20);
  8203. + break;
  8204. + default:
  8205. + /* Wait for EEPROM reload (it happens automatically) */
  8206. + mdelay(5);
  8207. + break;
  8208. + }
  8209. +
  8210. + /* Disable HW ARPs on ASF enabled adapters */
  8211. + if(hw->mac_type >= e1000_82540) {
  8212. + manc = E1000_READ_REG(hw, MANC);
  8213. + manc &= ~(E1000_MANC_ARP_EN);
  8214. + E1000_WRITE_REG(hw, MANC, manc);
  8215. + }
  8216. +
  8217. + if((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
  8218. + e1000_phy_init_script(hw);
  8219. + }
  8220. +
  8221. + /* Clear interrupt mask to stop board from generating interrupts */
  8222. + DEBUGOUT("Masking off all interrupts\n");
  8223. + E1000_WRITE_REG(hw, IMC, 0xffffffff);
  8224. +
  8225. + /* Clear any pending interrupt events. */
  8226. + icr = E1000_READ_REG(hw, ICR);
  8227. +
  8228. + /* If MWI was previously enabled, reenable it. */
  8229. + if(hw->mac_type == e1000_82542_rev2_0) {
  8230. +#ifdef LINUX_DRIVER
  8231. + if(hw->pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
  8232. +#endif
  8233. + e1000_pci_set_mwi(hw);
  8234. + }
  8235. +}
  8236. +
  8237. +/******************************************************************************
  8238. + * Performs basic configuration of the adapter.
  8239. + *
  8240. + * hw - Struct containing variables accessed by shared code
  8241. + *
  8242. + * Assumes that the controller has previously been reset and is in a
  8243. + * post-reset uninitialized state. Initializes the receive address registers,
  8244. + * multicast table, and VLAN filter table. Calls routines to setup link
  8245. + * configuration and flow control settings. Clears all on-chip counters. Leaves
  8246. + * the transmit and receive units disabled and uninitialized.
  8247. + *****************************************************************************/
  8248. +static int
  8249. +e1000_init_hw(struct e1000_hw *hw)
  8250. +{
  8251. + uint32_t ctrl, status;
  8252. + uint32_t i;
  8253. + int32_t ret_val;
  8254. + uint16_t pcix_cmd_word;
  8255. + uint16_t pcix_stat_hi_word;
  8256. + uint16_t cmd_mmrbc;
  8257. + uint16_t stat_mmrbc;
  8258. + e1000_bus_type bus_type = e1000_bus_type_unknown;
  8259. +
  8260. + DEBUGFUNC("e1000_init_hw");
  8261. +
  8262. + /* Set the media type and TBI compatibility */
  8263. + e1000_set_media_type(hw);
  8264. +
  8265. + /* Disabling VLAN filtering. */
  8266. + DEBUGOUT("Initializing the IEEE VLAN\n");
  8267. + E1000_WRITE_REG(hw, VET, 0);
  8268. +
  8269. + e1000_clear_vfta(hw);
  8270. +
  8271. + /* For 82542 (rev 2.0), disable MWI and put the receiver into reset */
  8272. + if(hw->mac_type == e1000_82542_rev2_0) {
  8273. + DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");
  8274. + e1000_pci_clear_mwi(hw);
  8275. + E1000_WRITE_REG(hw, RCTL, E1000_RCTL_RST);
  8276. + E1000_WRITE_FLUSH(hw);
  8277. + mdelay(5);
  8278. + }
  8279. +
  8280. + /* Setup the receive address. This involves initializing all of the Receive
  8281. + * Address Registers (RARs 0 - 15).
  8282. + */
  8283. + e1000_init_rx_addrs(hw);
  8284. +
  8285. + /* For 82542 (rev 2.0), take the receiver out of reset and enable MWI */
  8286. + if(hw->mac_type == e1000_82542_rev2_0) {
  8287. + E1000_WRITE_REG(hw, RCTL, 0);
  8288. + E1000_WRITE_FLUSH(hw);
  8289. + mdelay(1);
  8290. +#ifdef LINUX_DRIVER
  8291. + if(hw->pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
  8292. +#endif
  8293. + e1000_pci_set_mwi(hw);
  8294. + }
  8295. +
  8296. + /* Zero out the Multicast HASH table */
  8297. + DEBUGOUT("Zeroing the MTA\n");
  8298. + for(i = 0; i < E1000_MC_TBL_SIZE; i++)
  8299. + E1000_WRITE_REG_ARRAY(hw, MTA, i, 0);
  8300. +
  8301. +#if 0
  8302. + /* Set the PCI priority bit correctly in the CTRL register. This
  8303. + * determines if the adapter gives priority to receives, or if it
  8304. + * gives equal priority to transmits and receives.
  8305. + */
  8306. + if(hw->dma_fairness) {
  8307. + ctrl = E1000_READ_REG(hw, CTRL);
  8308. + E1000_WRITE_REG(hw, CTRL, ctrl | E1000_CTRL_PRIOR);
  8309. + }
  8310. +#endif
  8311. +
  8312. + switch(hw->mac_type) {
  8313. + case e1000_82545_rev_3:
  8314. + case e1000_82546_rev_3:
  8315. + break;
  8316. + default:
  8317. + if (hw->mac_type >= e1000_82543) {
  8318. + /* See e1000_get_bus_info() of the Linux driver */
  8319. + status = E1000_READ_REG(hw, STATUS);
  8320. + bus_type = (status & E1000_STATUS_PCIX_MODE) ?
  8321. + e1000_bus_type_pcix : e1000_bus_type_pci;
  8322. + }
  8323. +
  8324. + /* Workaround for PCI-X problem when BIOS sets MMRBC incorrectly. */
  8325. + if(bus_type == e1000_bus_type_pcix) {
  8326. + pci_read_config_word(hw->pdev, PCIX_COMMAND_REGISTER, &pcix_cmd_word);
  8327. + pci_read_config_word(hw->pdev, PCIX_STATUS_REGISTER_HI, &pcix_stat_hi_word);
  8328. + cmd_mmrbc = (pcix_cmd_word & PCIX_COMMAND_MMRBC_MASK) >>
  8329. + PCIX_COMMAND_MMRBC_SHIFT;
  8330. + stat_mmrbc = (pcix_stat_hi_word & PCIX_STATUS_HI_MMRBC_MASK) >>
  8331. + PCIX_STATUS_HI_MMRBC_SHIFT;
  8332. + if(stat_mmrbc == PCIX_STATUS_HI_MMRBC_4K)
  8333. + stat_mmrbc = PCIX_STATUS_HI_MMRBC_2K;
  8334. + if(cmd_mmrbc > stat_mmrbc) {
  8335. + pcix_cmd_word &= ~PCIX_COMMAND_MMRBC_MASK;
  8336. + pcix_cmd_word |= stat_mmrbc << PCIX_COMMAND_MMRBC_SHIFT;
  8337. + pci_write_config_word(hw->pdev, PCIX_COMMAND_REGISTER, pcix_cmd_word);
  8338. + }
  8339. + }
  8340. + break;
  8341. + }
  8342. +
  8343. + /* Call a subroutine to configure the link and setup flow control. */
  8344. + ret_val = e1000_setup_link(hw);
  8345. +
  8346. + /* Set the transmit descriptor write-back policy */
  8347. + if(hw->mac_type > e1000_82544) {
  8348. + ctrl = E1000_READ_REG(hw, TXDCTL);
  8349. + ctrl = (ctrl & ~E1000_TXDCTL_WTHRESH) | E1000_TXDCTL_FULL_TX_DESC_WB;
  8350. + E1000_WRITE_REG(hw, TXDCTL, ctrl);
  8351. + }
  8352. +
  8353. +#if 0
  8354. + /* Clear all of the statistics registers (clear on read). It is
  8355. + * important that we do this after we have tried to establish link
  8356. + * because the symbol error count will increment wildly if there
  8357. + * is no link.
  8358. + */
  8359. + e1000_clear_hw_cntrs(hw);
  8360. +#endif
  8361. +
  8362. + return ret_val;
  8363. +}
  8364. +
  8365. +/******************************************************************************
  8366. + * Adjust SERDES output amplitude based on EEPROM setting.
  8367. + *
  8368. + * hw - Struct containing variables accessed by shared code.
  8369. + *****************************************************************************/
  8370. +static int32_t
  8371. +e1000_adjust_serdes_amplitude(struct e1000_hw *hw)
  8372. +{
  8373. + uint16_t eeprom_data;
  8374. + int32_t ret_val;
  8375. +
  8376. + DEBUGFUNC("e1000_adjust_serdes_amplitude");
  8377. +
  8378. + if(hw->media_type != e1000_media_type_internal_serdes)
  8379. + return E1000_SUCCESS;
  8380. +
  8381. + switch(hw->mac_type) {
  8382. + case e1000_82545_rev_3:
  8383. + case e1000_82546_rev_3:
  8384. + break;
  8385. + default:
  8386. + return E1000_SUCCESS;
  8387. + }
  8388. +
  8389. + if ((ret_val = e1000_read_eeprom(hw, EEPROM_SERDES_AMPLITUDE, 1,
  8390. + &eeprom_data))) {
  8391. + return ret_val;
  8392. + }
  8393. +
  8394. + if(eeprom_data != EEPROM_RESERVED_WORD) {
  8395. + /* Adjust SERDES output amplitude only. */
  8396. + eeprom_data &= EEPROM_SERDES_AMPLITUDE_MASK;
  8397. + if((ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_EXT_CTRL,
  8398. + eeprom_data)))
  8399. + return ret_val;
  8400. + }
  8401. +
  8402. + return E1000_SUCCESS;
  8403. +}
  8404. +
  8405. +/******************************************************************************
  8406. + * Configures flow control and link settings.
  8407. + *
  8408. + * hw - Struct containing variables accessed by shared code
  8409. + *
  8410. + * Determines which flow control settings to use. Calls the apropriate media-
  8411. + * specific link configuration function. Configures the flow control settings.
  8412. + * Assuming the adapter has a valid link partner, a valid link should be
  8413. + * established. Assumes the hardware has previously been reset and the
  8414. + * transmitter and receiver are not enabled.
  8415. + *****************************************************************************/
  8416. +static int
  8417. +e1000_setup_link(struct e1000_hw *hw)
  8418. +{
  8419. + uint32_t ctrl_ext;
  8420. + int32_t ret_val;
  8421. + uint16_t eeprom_data;
  8422. +
  8423. + DEBUGFUNC("e1000_setup_link");
  8424. +
  8425. + /* Read and store word 0x0F of the EEPROM. This word contains bits
  8426. + * that determine the hardware's default PAUSE (flow control) mode,
  8427. + * a bit that determines whether the HW defaults to enabling or
  8428. + * disabling auto-negotiation, and the direction of the
  8429. + * SW defined pins. If there is no SW over-ride of the flow
  8430. + * control setting, then the variable hw->fc will
  8431. + * be initialized based on a value in the EEPROM.
  8432. + */
  8433. + if(e1000_read_eeprom(hw, EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data) < 0) {
  8434. + DEBUGOUT("EEPROM Read Error\n");
  8435. + return -E1000_ERR_EEPROM;
  8436. + }
  8437. +
  8438. + if(hw->fc == e1000_fc_default) {
  8439. + if((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) == 0)
  8440. + hw->fc = e1000_fc_none;
  8441. + else if((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) ==
  8442. + EEPROM_WORD0F_ASM_DIR)
  8443. + hw->fc = e1000_fc_tx_pause;
  8444. + else
  8445. + hw->fc = e1000_fc_full;
  8446. + }
  8447. +
  8448. + /* We want to save off the original Flow Control configuration just
  8449. + * in case we get disconnected and then reconnected into a different
  8450. + * hub or switch with different Flow Control capabilities.
  8451. + */
  8452. + if(hw->mac_type == e1000_82542_rev2_0)
  8453. + hw->fc &= (~e1000_fc_tx_pause);
  8454. +
  8455. +#if 0
  8456. + /* See e1000_sw_init() of the Linux driver */
  8457. + if((hw->mac_type < e1000_82543) && (hw->report_tx_early == 1))
  8458. +#else
  8459. + if((hw->mac_type < e1000_82543) && (hw->mac_type >= e1000_82543))
  8460. +#endif
  8461. + hw->fc &= (~e1000_fc_rx_pause);
  8462. +
  8463. +#if 0
  8464. + hw->original_fc = hw->fc;
  8465. +#endif
  8466. +
  8467. + DEBUGOUT1("After fix-ups FlowControl is now = %x\n", hw->fc);
  8468. +
  8469. + /* Take the 4 bits from EEPROM word 0x0F that determine the initial
  8470. + * polarity value for the SW controlled pins, and setup the
  8471. + * Extended Device Control reg with that info.
  8472. + * This is needed because one of the SW controlled pins is used for
  8473. + * signal detection. So this should be done before e1000_setup_pcs_link()
  8474. + * or e1000_phy_setup() is called.
  8475. + */
  8476. + if(hw->mac_type == e1000_82543) {
  8477. + ctrl_ext = ((eeprom_data & EEPROM_WORD0F_SWPDIO_EXT) <<
  8478. + SWDPIO__EXT_SHIFT);
  8479. + E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
  8480. + }
  8481. +
  8482. + /* Call the necessary subroutine to configure the link. */
  8483. + ret_val = (hw->media_type == e1000_media_type_copper) ?
  8484. + e1000_setup_copper_link(hw) :
  8485. + e1000_setup_fiber_serdes_link(hw);
  8486. + if (ret_val < 0) {
  8487. + return ret_val;
  8488. + }
  8489. +
  8490. + /* Initialize the flow control address, type, and PAUSE timer
  8491. + * registers to their default values. This is done even if flow
  8492. + * control is disabled, because it does not hurt anything to
  8493. + * initialize these registers.
  8494. + */
  8495. + DEBUGOUT("Initializing the Flow Control address, type and timer regs\n");
  8496. +
  8497. + E1000_WRITE_REG(hw, FCAL, FLOW_CONTROL_ADDRESS_LOW);
  8498. + E1000_WRITE_REG(hw, FCAH, FLOW_CONTROL_ADDRESS_HIGH);
  8499. + E1000_WRITE_REG(hw, FCT, FLOW_CONTROL_TYPE);
  8500. +#if 0
  8501. + E1000_WRITE_REG(hw, FCTTV, hw->fc_pause_time);
  8502. +#else
  8503. + E1000_WRITE_REG(hw, FCTTV, FC_DEFAULT_TX_TIMER);
  8504. +#endif
  8505. +
  8506. + /* Set the flow control receive threshold registers. Normally,
  8507. + * these registers will be set to a default threshold that may be
  8508. + * adjusted later by the driver's runtime code. However, if the
  8509. + * ability to transmit pause frames in not enabled, then these
  8510. + * registers will be set to 0.
  8511. + */
  8512. + if(!(hw->fc & e1000_fc_tx_pause)) {
  8513. + E1000_WRITE_REG(hw, FCRTL, 0);
  8514. + E1000_WRITE_REG(hw, FCRTH, 0);
  8515. + } else {
  8516. + /* We need to set up the Receive Threshold high and low water marks
  8517. + * as well as (optionally) enabling the transmission of XON frames.
  8518. + */
  8519. +#if 0
  8520. + if(hw->fc_send_xon) {
  8521. + E1000_WRITE_REG(hw, FCRTL, (hw->fc_low_water | E1000_FCRTL_XONE));
  8522. + E1000_WRITE_REG(hw, FCRTH, hw->fc_high_water);
  8523. + } else {
  8524. + E1000_WRITE_REG(hw, FCRTL, hw->fc_low_water);
  8525. + E1000_WRITE_REG(hw, FCRTH, hw->fc_high_water);
  8526. + }
  8527. +#else
  8528. + E1000_WRITE_REG(hw, FCRTL, (FC_DEFAULT_LO_THRESH | E1000_FCRTL_XONE));
  8529. + E1000_WRITE_REG(hw, FCRTH, FC_DEFAULT_HI_THRESH);
  8530. +#endif
  8531. + }
  8532. + return ret_val;
  8533. +}
  8534. +
  8535. +/******************************************************************************
  8536. + * Sets up link for a fiber based or serdes based adapter
  8537. + *
  8538. + * hw - Struct containing variables accessed by shared code
  8539. + *
  8540. + * Manipulates Physical Coding Sublayer functions in order to configure
  8541. + * link. Assumes the hardware has been previously reset and the transmitter
  8542. + * and receiver are not enabled.
  8543. + *****************************************************************************/
  8544. +static int
  8545. +e1000_setup_fiber_serdes_link(struct e1000_hw *hw)
  8546. +{
  8547. + uint32_t ctrl;
  8548. + uint32_t status;
  8549. + uint32_t txcw = 0;
  8550. + uint32_t i;
  8551. + uint32_t signal = 0;
  8552. + int32_t ret_val;
  8553. +
  8554. + DEBUGFUNC("e1000_setup_fiber_serdes_link");
  8555. +
  8556. + /* On adapters with a MAC newer than 82544, SW Defineable pin 1 will be
  8557. + * set when the optics detect a signal. On older adapters, it will be
  8558. + * cleared when there is a signal. This applies to fiber media only.
  8559. + * If we're on serdes media, adjust the output amplitude to value set in
  8560. + * the EEPROM.
  8561. + */
  8562. + ctrl = E1000_READ_REG(hw, CTRL);
  8563. + if(hw->media_type == e1000_media_type_fiber)
  8564. + signal = (hw->mac_type > e1000_82544) ? E1000_CTRL_SWDPIN1 : 0;
  8565. +
  8566. + if((ret_val = e1000_adjust_serdes_amplitude(hw)))
  8567. + return ret_val;
  8568. +
  8569. + /* Take the link out of reset */
  8570. + ctrl &= ~(E1000_CTRL_LRST);
  8571. +
  8572. +#if 0
  8573. + /* Adjust VCO speed to improve BER performance */
  8574. + if((ret_val = e1000_set_vco_speed(hw)))
  8575. + return ret_val;
  8576. +#endif
  8577. +
  8578. + e1000_config_collision_dist(hw);
  8579. +
  8580. + /* Check for a software override of the flow control settings, and setup
  8581. + * the device accordingly. If auto-negotiation is enabled, then software
  8582. + * will have to set the "PAUSE" bits to the correct value in the Tranmsit
  8583. + * Config Word Register (TXCW) and re-start auto-negotiation. However, if
  8584. + * auto-negotiation is disabled, then software will have to manually
  8585. + * configure the two flow control enable bits in the CTRL register.
  8586. + *
  8587. + * The possible values of the "fc" parameter are:
  8588. + * 0: Flow control is completely disabled
  8589. + * 1: Rx flow control is enabled (we can receive pause frames, but
  8590. + * not send pause frames).
  8591. + * 2: Tx flow control is enabled (we can send pause frames but we do
  8592. + * not support receiving pause frames).
  8593. + * 3: Both Rx and TX flow control (symmetric) are enabled.
  8594. + */
  8595. + switch (hw->fc) {
  8596. + case e1000_fc_none:
  8597. + /* Flow control is completely disabled by a software over-ride. */
  8598. + txcw = (E1000_TXCW_ANE | E1000_TXCW_FD);
  8599. + break;
  8600. + case e1000_fc_rx_pause:
  8601. + /* RX Flow control is enabled and TX Flow control is disabled by a
  8602. + * software over-ride. Since there really isn't a way to advertise
  8603. + * that we are capable of RX Pause ONLY, we will advertise that we
  8604. + * support both symmetric and asymmetric RX PAUSE. Later, we will
  8605. + * disable the adapter's ability to send PAUSE frames.
  8606. + */
  8607. + txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);
  8608. + break;
  8609. + case e1000_fc_tx_pause:
  8610. + /* TX Flow control is enabled, and RX Flow control is disabled, by a
  8611. + * software over-ride.
  8612. + */
  8613. + txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_ASM_DIR);
  8614. + break;
  8615. + case e1000_fc_full:
  8616. + /* Flow control (both RX and TX) is enabled by a software over-ride. */
  8617. + txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);
  8618. + break;
  8619. + default:
  8620. + DEBUGOUT("Flow control param set incorrectly\n");
  8621. + return -E1000_ERR_CONFIG;
  8622. + break;
  8623. + }
  8624. +
  8625. + /* Since auto-negotiation is enabled, take the link out of reset (the link
  8626. + * will be in reset, because we previously reset the chip). This will
  8627. + * restart auto-negotiation. If auto-neogtiation is successful then the
  8628. + * link-up status bit will be set and the flow control enable bits (RFCE
  8629. + * and TFCE) will be set according to their negotiated value.
  8630. + */
  8631. + DEBUGOUT("Auto-negotiation enabled\n");
  8632. +
  8633. + E1000_WRITE_REG(hw, TXCW, txcw);
  8634. + E1000_WRITE_REG(hw, CTRL, ctrl);
  8635. + E1000_WRITE_FLUSH(hw);
  8636. +
  8637. + hw->txcw = txcw;
  8638. + mdelay(1);
  8639. +
  8640. + /* If we have a signal (the cable is plugged in) then poll for a "Link-Up"
  8641. + * indication in the Device Status Register. Time-out if a link isn't
  8642. + * seen in 500 milliseconds seconds (Auto-negotiation should complete in
  8643. + * less than 500 milliseconds even if the other end is doing it in SW).
  8644. + * For internal serdes, we just assume a signal is present, then poll.
  8645. + */
  8646. + if(hw->media_type == e1000_media_type_internal_serdes ||
  8647. + (E1000_READ_REG(hw, CTRL) & E1000_CTRL_SWDPIN1) == signal) {
  8648. + DEBUGOUT("Looking for Link\n");
  8649. + for(i = 0; i < (LINK_UP_TIMEOUT / 10); i++) {
  8650. + mdelay(10);
  8651. + status = E1000_READ_REG(hw, STATUS);
  8652. + if(status & E1000_STATUS_LU) break;
  8653. + }
  8654. + if(i == (LINK_UP_TIMEOUT / 10)) {
  8655. + DEBUGOUT("Never got a valid link from auto-neg!!!\n");
  8656. + hw->autoneg_failed = 1;
  8657. + /* AutoNeg failed to achieve a link, so we'll call
  8658. + * e1000_check_for_link. This routine will force the link up if
  8659. + * we detect a signal. This will allow us to communicate with
  8660. + * non-autonegotiating link partners.
  8661. + */
  8662. + if((ret_val = e1000_check_for_link(hw))) {
  8663. + DEBUGOUT("Error while checking for link\n");
  8664. + return ret_val;
  8665. + }
  8666. + hw->autoneg_failed = 0;
  8667. + } else {
  8668. + hw->autoneg_failed = 0;
  8669. + DEBUGOUT("Valid Link Found\n");
  8670. + }
  8671. + } else {
  8672. + DEBUGOUT("No Signal Detected\n");
  8673. + }
  8674. + return E1000_SUCCESS;
  8675. +}
  8676. +
  8677. +/******************************************************************************
  8678. +* Detects which PHY is present and the speed and duplex
  8679. +*
  8680. +* hw - Struct containing variables accessed by shared code
  8681. +******************************************************************************/
  8682. +static int
  8683. +e1000_setup_copper_link(struct e1000_hw *hw)
  8684. +{
  8685. + uint32_t ctrl;
  8686. + int32_t ret_val;
  8687. + uint16_t i;
  8688. + uint16_t phy_data;
  8689. +
  8690. + DEBUGFUNC("e1000_setup_copper_link");
  8691. +
  8692. + ctrl = E1000_READ_REG(hw, CTRL);
  8693. + /* With 82543, we need to force speed and duplex on the MAC equal to what
  8694. + * the PHY speed and duplex configuration is. In addition, we need to
  8695. + * perform a hardware reset on the PHY to take it out of reset.
  8696. + */
  8697. + if(hw->mac_type > e1000_82543) {
  8698. + ctrl |= E1000_CTRL_SLU;
  8699. + ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
  8700. + E1000_WRITE_REG(hw, CTRL, ctrl);
  8701. + } else {
  8702. + ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX | E1000_CTRL_SLU);
  8703. + E1000_WRITE_REG(hw, CTRL, ctrl);
  8704. + e1000_phy_hw_reset(hw);
  8705. + }
  8706. +
  8707. + /* Make sure we have a valid PHY */
  8708. + if((ret_val = e1000_detect_gig_phy(hw))) {
  8709. + DEBUGOUT("Error, did not detect valid phy.\n");
  8710. + return ret_val;
  8711. + }
  8712. + DEBUGOUT1("Phy ID = %x \n", hw->phy_id);
  8713. +
  8714. + if(hw->mac_type <= e1000_82543 ||
  8715. + hw->mac_type == e1000_82541 || hw->mac_type == e1000_82547 ||
  8716. +#if 0
  8717. + hw->mac_type == e1000_82541_rev_2 || hw->mac_type == e1000_82547_rev_2)
  8718. + hw->phy_reset_disable = FALSE;
  8719. +
  8720. + if(!hw->phy_reset_disable) {
  8721. +#else
  8722. + hw->mac_type == e1000_82541_rev_2 || hw->mac_type == e1000_82547_rev_2) {
  8723. +#endif
  8724. + if (hw->phy_type == e1000_phy_igp) {
  8725. +
  8726. + if((ret_val = e1000_phy_reset(hw))) {
  8727. + DEBUGOUT("Error Resetting the PHY\n");
  8728. + return ret_val;
  8729. + }
  8730. +
  8731. + /* Wait 10ms for MAC to configure PHY from eeprom settings */
  8732. + mdelay(15);
  8733. +
  8734. +#if 0
  8735. + /* disable lplu d3 during driver init */
  8736. + if((ret_val = e1000_set_d3_lplu_state(hw, FALSE))) {
  8737. + DEBUGOUT("Error Disabling LPLU D3\n");
  8738. + return ret_val;
  8739. + }
  8740. +
  8741. + /* Configure mdi-mdix settings */
  8742. + if((ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL,
  8743. + &phy_data)))
  8744. + return ret_val;
  8745. +
  8746. + if((hw->mac_type == e1000_82541) || (hw->mac_type == e1000_82547)) {
  8747. + hw->dsp_config_state = e1000_dsp_config_disabled;
  8748. + /* Force MDI for IGP B-0 PHY */
  8749. + phy_data &= ~(IGP01E1000_PSCR_AUTO_MDIX |
  8750. + IGP01E1000_PSCR_FORCE_MDI_MDIX);
  8751. + hw->mdix = 1;
  8752. +
  8753. + } else {
  8754. + hw->dsp_config_state = e1000_dsp_config_enabled;
  8755. + phy_data &= ~IGP01E1000_PSCR_AUTO_MDIX;
  8756. +
  8757. + switch (hw->mdix) {
  8758. + case 1:
  8759. + phy_data &= ~IGP01E1000_PSCR_FORCE_MDI_MDIX;
  8760. + break;
  8761. + case 2:
  8762. + phy_data |= IGP01E1000_PSCR_FORCE_MDI_MDIX;
  8763. + break;
  8764. + case 0:
  8765. + default:
  8766. + phy_data |= IGP01E1000_PSCR_AUTO_MDIX;
  8767. + break;
  8768. + }
  8769. + }
  8770. + if((ret_val = e1000_write_phy_reg(hw, IGP01E1000_PHY_PORT_CTRL,
  8771. + phy_data)))
  8772. + return ret_val;
  8773. +
  8774. + /* set auto-master slave resolution settings */
  8775. + e1000_ms_type phy_ms_setting = hw->master_slave;
  8776. +
  8777. + if(hw->ffe_config_state == e1000_ffe_config_active)
  8778. + hw->ffe_config_state = e1000_ffe_config_enabled;
  8779. +
  8780. + if(hw->dsp_config_state == e1000_dsp_config_activated)
  8781. + hw->dsp_config_state = e1000_dsp_config_enabled;
  8782. +#endif
  8783. +
  8784. + /* when autonegotiation advertisment is only 1000Mbps then we
  8785. + * should disable SmartSpeed and enable Auto MasterSlave
  8786. + * resolution as hardware default. */
  8787. + if(hw->autoneg_advertised == ADVERTISE_1000_FULL) {
  8788. + /* Disable SmartSpeed */
  8789. + if((ret_val = e1000_read_phy_reg(hw,
  8790. + IGP01E1000_PHY_PORT_CONFIG,
  8791. + &phy_data)))
  8792. + return ret_val;
  8793. + phy_data &= ~IGP01E1000_PSCFR_SMART_SPEED;
  8794. + if((ret_val = e1000_write_phy_reg(hw,
  8795. + IGP01E1000_PHY_PORT_CONFIG,
  8796. + phy_data)))
  8797. + return ret_val;
  8798. + /* Set auto Master/Slave resolution process */
  8799. + if((ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL,
  8800. + &phy_data)))
  8801. + return ret_val;
  8802. + phy_data &= ~CR_1000T_MS_ENABLE;
  8803. + if((ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL,
  8804. + phy_data)))
  8805. + return ret_val;
  8806. + }
  8807. +
  8808. + if((ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL,
  8809. + &phy_data)))
  8810. + return ret_val;
  8811. +
  8812. +#if 0
  8813. + /* load defaults for future use */
  8814. + hw->original_master_slave = (phy_data & CR_1000T_MS_ENABLE) ?
  8815. + ((phy_data & CR_1000T_MS_VALUE) ?
  8816. + e1000_ms_force_master :
  8817. + e1000_ms_force_slave) :
  8818. + e1000_ms_auto;
  8819. +
  8820. + switch (phy_ms_setting) {
  8821. + case e1000_ms_force_master:
  8822. + phy_data |= (CR_1000T_MS_ENABLE | CR_1000T_MS_VALUE);
  8823. + break;
  8824. + case e1000_ms_force_slave:
  8825. + phy_data |= CR_1000T_MS_ENABLE;
  8826. + phy_data &= ~(CR_1000T_MS_VALUE);
  8827. + break;
  8828. + case e1000_ms_auto:
  8829. + phy_data &= ~CR_1000T_MS_ENABLE;
  8830. + default:
  8831. + break;
  8832. + }
  8833. +#endif
  8834. +
  8835. + if((ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL,
  8836. + phy_data)))
  8837. + return ret_val;
  8838. + } else {
  8839. + /* Enable CRS on TX. This must be set for half-duplex operation. */
  8840. + if((ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL,
  8841. + &phy_data)))
  8842. + return ret_val;
  8843. +
  8844. + phy_data |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
  8845. +
  8846. + /* Options:
  8847. + * MDI/MDI-X = 0 (default)
  8848. + * 0 - Auto for all speeds
  8849. + * 1 - MDI mode
  8850. + * 2 - MDI-X mode
  8851. + * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes)
  8852. + */
  8853. +#if 0
  8854. + phy_data &= ~M88E1000_PSCR_AUTO_X_MODE;
  8855. +
  8856. + switch (hw->mdix) {
  8857. + case 1:
  8858. + phy_data |= M88E1000_PSCR_MDI_MANUAL_MODE;
  8859. + break;
  8860. + case 2:
  8861. + phy_data |= M88E1000_PSCR_MDIX_MANUAL_MODE;
  8862. + break;
  8863. + case 3:
  8864. + phy_data |= M88E1000_PSCR_AUTO_X_1000T;
  8865. + break;
  8866. + case 0:
  8867. + default:
  8868. +#endif
  8869. + phy_data |= M88E1000_PSCR_AUTO_X_MODE;
  8870. +#if 0
  8871. + break;
  8872. + }
  8873. +#endif
  8874. +
  8875. + /* Options:
  8876. + * disable_polarity_correction = 0 (default)
  8877. + * Automatic Correction for Reversed Cable Polarity
  8878. + * 0 - Disabled
  8879. + * 1 - Enabled
  8880. + */
  8881. + phy_data &= ~M88E1000_PSCR_POLARITY_REVERSAL;
  8882. + if((ret_val = e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL,
  8883. + phy_data)))
  8884. + return ret_val;
  8885. +
  8886. + /* Force TX_CLK in the Extended PHY Specific Control Register
  8887. + * to 25MHz clock.
  8888. + */
  8889. + if((ret_val = e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL,
  8890. + &phy_data)))
  8891. + return ret_val;
  8892. +
  8893. + phy_data |= M88E1000_EPSCR_TX_CLK_25;
  8894. +
  8895. +#ifdef LINUX_DRIVER
  8896. + if (hw->phy_revision < M88E1011_I_REV_4) {
  8897. +#endif
  8898. + /* Configure Master and Slave downshift values */
  8899. + phy_data &= ~(M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK |
  8900. + M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK);
  8901. + phy_data |= (M88E1000_EPSCR_MASTER_DOWNSHIFT_1X |
  8902. + M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X);
  8903. + if((ret_val = e1000_write_phy_reg(hw,
  8904. + M88E1000_EXT_PHY_SPEC_CTRL,
  8905. + phy_data)))
  8906. + return ret_val;
  8907. + }
  8908. +
  8909. + /* SW Reset the PHY so all changes take effect */
  8910. + if((ret_val = e1000_phy_reset(hw))) {
  8911. + DEBUGOUT("Error Resetting the PHY\n");
  8912. + return ret_val;
  8913. +#ifdef LINUX_DRIVER
  8914. + }
  8915. +#endif
  8916. + }
  8917. +
  8918. + /* Options:
  8919. + * autoneg = 1 (default)
  8920. + * PHY will advertise value(s) parsed from
  8921. + * autoneg_advertised and fc
  8922. + * autoneg = 0
  8923. + * PHY will be set to 10H, 10F, 100H, or 100F
  8924. + * depending on value parsed from forced_speed_duplex.
  8925. + */
  8926. +
  8927. + /* Is autoneg enabled? This is enabled by default or by software
  8928. + * override. If so, call e1000_phy_setup_autoneg routine to parse the
  8929. + * autoneg_advertised and fc options. If autoneg is NOT enabled, then
  8930. + * the user should have provided a speed/duplex override. If so, then
  8931. + * call e1000_phy_force_speed_duplex to parse and set this up.
  8932. + */
  8933. + /* Perform some bounds checking on the hw->autoneg_advertised
  8934. + * parameter. If this variable is zero, then set it to the default.
  8935. + */
  8936. + hw->autoneg_advertised &= AUTONEG_ADVERTISE_SPEED_DEFAULT;
  8937. +
  8938. + /* If autoneg_advertised is zero, we assume it was not defaulted
  8939. + * by the calling code so we set to advertise full capability.
  8940. + */
  8941. + if(hw->autoneg_advertised == 0)
  8942. + hw->autoneg_advertised = AUTONEG_ADVERTISE_SPEED_DEFAULT;
  8943. +
  8944. + DEBUGOUT("Reconfiguring auto-neg advertisement params\n");
  8945. + if((ret_val = e1000_phy_setup_autoneg(hw))) {
  8946. + DEBUGOUT("Error Setting up Auto-Negotiation\n");
  8947. + return ret_val;
  8948. + }
  8949. + DEBUGOUT("Restarting Auto-Neg\n");
  8950. +
  8951. + /* Restart auto-negotiation by setting the Auto Neg Enable bit and
  8952. + * the Auto Neg Restart bit in the PHY control register.
  8953. + */
  8954. + if((ret_val = e1000_read_phy_reg(hw, PHY_CTRL, &phy_data)))
  8955. + return ret_val;
  8956. +
  8957. + phy_data |= (MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG);
  8958. + if((ret_val = e1000_write_phy_reg(hw, PHY_CTRL, phy_data)))
  8959. + return ret_val;
  8960. +
  8961. +#if 0
  8962. + /* Does the user want to wait for Auto-Neg to complete here, or
  8963. + * check at a later time (for example, callback routine).
  8964. + */
  8965. + if(hw->wait_autoneg_complete) {
  8966. + if((ret_val = e1000_wait_autoneg(hw))) {
  8967. + DEBUGOUT("Error while waiting for autoneg to complete\n");
  8968. + return ret_val;
  8969. + }
  8970. + }
  8971. +#else
  8972. + /* If we do not wait for autonegotiation to complete I
  8973. + * do not see a valid link status.
  8974. + */
  8975. + if((ret_val = e1000_wait_autoneg(hw))) {
  8976. + DEBUGOUT("Error while waiting for autoneg to complete\n");
  8977. + return ret_val;
  8978. + }
  8979. +#endif
  8980. + } /* !hw->phy_reset_disable */
  8981. +
  8982. + /* Check link status. Wait up to 100 microseconds for link to become
  8983. + * valid.
  8984. + */
  8985. + for(i = 0; i < 10; i++) {
  8986. + if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data)))
  8987. + return ret_val;
  8988. + if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data)))
  8989. + return ret_val;
  8990. +
  8991. + if(phy_data & MII_SR_LINK_STATUS) {
  8992. + /* We have link, so we need to finish the config process:
  8993. + * 1) Set up the MAC to the current PHY speed/duplex
  8994. + * if we are on 82543. If we
  8995. + * are on newer silicon, we only need to configure
  8996. + * collision distance in the Transmit Control Register.
  8997. + * 2) Set up flow control on the MAC to that established with
  8998. + * the link partner.
  8999. + */
  9000. + if(hw->mac_type >= e1000_82544) {
  9001. + e1000_config_collision_dist(hw);
  9002. + } else {
  9003. + if((ret_val = e1000_config_mac_to_phy(hw))) {
  9004. + DEBUGOUT("Error configuring MAC to PHY settings\n");
  9005. + return ret_val;
  9006. + }
  9007. + }
  9008. + if((ret_val = e1000_config_fc_after_link_up(hw))) {
  9009. + DEBUGOUT("Error Configuring Flow Control\n");
  9010. + return ret_val;
  9011. + }
  9012. +#if 0
  9013. + if(hw->phy_type == e1000_phy_igp) {
  9014. + if((ret_val = e1000_config_dsp_after_link_change(hw, TRUE))) {
  9015. + DEBUGOUT("Error Configuring DSP after link up\n");
  9016. + return ret_val;
  9017. + }
  9018. + }
  9019. +#endif
  9020. + DEBUGOUT("Valid link established!!!\n");
  9021. + return E1000_SUCCESS;
  9022. + }
  9023. + udelay(10);
  9024. + }
  9025. +
  9026. + DEBUGOUT("Unable to establish link!!!\n");
  9027. + return -E1000_ERR_NOLINK;
  9028. +}
  9029. +
  9030. +/******************************************************************************
  9031. +* Configures PHY autoneg and flow control advertisement settings
  9032. +*
  9033. +* hw - Struct containing variables accessed by shared code
  9034. +******************************************************************************/
  9035. +static int
  9036. +e1000_phy_setup_autoneg(struct e1000_hw *hw)
  9037. +{
  9038. + int32_t ret_val;
  9039. + uint16_t mii_autoneg_adv_reg;
  9040. + uint16_t mii_1000t_ctrl_reg;
  9041. +
  9042. + DEBUGFUNC("e1000_phy_setup_autoneg");
  9043. +
  9044. + /* Read the MII Auto-Neg Advertisement Register (Address 4). */
  9045. + if((ret_val = e1000_read_phy_reg(hw, PHY_AUTONEG_ADV,
  9046. + &mii_autoneg_adv_reg)))
  9047. + return ret_val;
  9048. +
  9049. + /* Read the MII 1000Base-T Control Register (Address 9). */
  9050. + if((ret_val = e1000_read_phy_reg(hw, PHY_1000T_CTRL, &mii_1000t_ctrl_reg)))
  9051. + return ret_val;
  9052. +
  9053. + /* Need to parse both autoneg_advertised and fc and set up
  9054. + * the appropriate PHY registers. First we will parse for
  9055. + * autoneg_advertised software override. Since we can advertise
  9056. + * a plethora of combinations, we need to check each bit
  9057. + * individually.
  9058. + */
  9059. +
  9060. + /* First we clear all the 10/100 mb speed bits in the Auto-Neg
  9061. + * Advertisement Register (Address 4) and the 1000 mb speed bits in
  9062. + * the 1000Base-T Control Register (Address 9).
  9063. + */
  9064. + mii_autoneg_adv_reg &= ~REG4_SPEED_MASK;
  9065. + mii_1000t_ctrl_reg &= ~REG9_SPEED_MASK;
  9066. +
  9067. + DEBUGOUT1("autoneg_advertised %x\n", hw->autoneg_advertised);
  9068. +
  9069. + /* Do we want to advertise 10 Mb Half Duplex? */
  9070. + if(hw->autoneg_advertised & ADVERTISE_10_HALF) {
  9071. + DEBUGOUT("Advertise 10mb Half duplex\n");
  9072. + mii_autoneg_adv_reg |= NWAY_AR_10T_HD_CAPS;
  9073. + }
  9074. +
  9075. + /* Do we want to advertise 10 Mb Full Duplex? */
  9076. + if(hw->autoneg_advertised & ADVERTISE_10_FULL) {
  9077. + DEBUGOUT("Advertise 10mb Full duplex\n");
  9078. + mii_autoneg_adv_reg |= NWAY_AR_10T_FD_CAPS;
  9079. + }
  9080. +
  9081. + /* Do we want to advertise 100 Mb Half Duplex? */
  9082. + if(hw->autoneg_advertised & ADVERTISE_100_HALF) {
  9083. + DEBUGOUT("Advertise 100mb Half duplex\n");
  9084. + mii_autoneg_adv_reg |= NWAY_AR_100TX_HD_CAPS;
  9085. + }
  9086. +
  9087. + /* Do we want to advertise 100 Mb Full Duplex? */
  9088. + if(hw->autoneg_advertised & ADVERTISE_100_FULL) {
  9089. + DEBUGOUT("Advertise 100mb Full duplex\n");
  9090. + mii_autoneg_adv_reg |= NWAY_AR_100TX_FD_CAPS;
  9091. + }
  9092. +
  9093. + /* We do not allow the Phy to advertise 1000 Mb Half Duplex */
  9094. + if(hw->autoneg_advertised & ADVERTISE_1000_HALF) {
  9095. + DEBUGOUT("Advertise 1000mb Half duplex requested, request denied!\n");
  9096. + }
  9097. +
  9098. + /* Do we want to advertise 1000 Mb Full Duplex? */
  9099. + if(hw->autoneg_advertised & ADVERTISE_1000_FULL) {
  9100. + DEBUGOUT("Advertise 1000mb Full duplex\n");
  9101. + mii_1000t_ctrl_reg |= CR_1000T_FD_CAPS;
  9102. + }
  9103. +
  9104. + /* Check for a software override of the flow control settings, and
  9105. + * setup the PHY advertisement registers accordingly. If
  9106. + * auto-negotiation is enabled, then software will have to set the
  9107. + * "PAUSE" bits to the correct value in the Auto-Negotiation
  9108. + * Advertisement Register (PHY_AUTONEG_ADV) and re-start auto-negotiation.
  9109. + *
  9110. + * The possible values of the "fc" parameter are:
  9111. + * 0: Flow control is completely disabled
  9112. + * 1: Rx flow control is enabled (we can receive pause frames
  9113. + * but not send pause frames).
  9114. + * 2: Tx flow control is enabled (we can send pause frames
  9115. + * but we do not support receiving pause frames).
  9116. + * 3: Both Rx and TX flow control (symmetric) are enabled.
  9117. + * other: No software override. The flow control configuration
  9118. + * in the EEPROM is used.
  9119. + */
  9120. + switch (hw->fc) {
  9121. + case e1000_fc_none: /* 0 */
  9122. + /* Flow control (RX & TX) is completely disabled by a
  9123. + * software over-ride.
  9124. + */
  9125. + mii_autoneg_adv_reg &= ~(NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
  9126. + break;
  9127. + case e1000_fc_rx_pause: /* 1 */
  9128. + /* RX Flow control is enabled, and TX Flow control is
  9129. + * disabled, by a software over-ride.
  9130. + */
  9131. + /* Since there really isn't a way to advertise that we are
  9132. + * capable of RX Pause ONLY, we will advertise that we
  9133. + * support both symmetric and asymmetric RX PAUSE. Later
  9134. + * (in e1000_config_fc_after_link_up) we will disable the
  9135. + *hw's ability to send PAUSE frames.
  9136. + */
  9137. + mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
  9138. + break;
  9139. + case e1000_fc_tx_pause: /* 2 */
  9140. + /* TX Flow control is enabled, and RX Flow control is
  9141. + * disabled, by a software over-ride.
  9142. + */
  9143. + mii_autoneg_adv_reg |= NWAY_AR_ASM_DIR;
  9144. + mii_autoneg_adv_reg &= ~NWAY_AR_PAUSE;
  9145. + break;
  9146. + case e1000_fc_full: /* 3 */
  9147. + /* Flow control (both RX and TX) is enabled by a software
  9148. + * over-ride.
  9149. + */
  9150. + mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);
  9151. + break;
  9152. + default:
  9153. + DEBUGOUT("Flow control param set incorrectly\n");
  9154. + return -E1000_ERR_CONFIG;
  9155. + }
  9156. +
  9157. + if((ret_val = e1000_write_phy_reg(hw, PHY_AUTONEG_ADV,
  9158. + mii_autoneg_adv_reg)))
  9159. + return ret_val;
  9160. +
  9161. + DEBUGOUT1("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg);
  9162. +
  9163. + if((ret_val = e1000_write_phy_reg(hw, PHY_1000T_CTRL, mii_1000t_ctrl_reg)))
  9164. + return ret_val;
  9165. +
  9166. + return E1000_SUCCESS;
  9167. +}
  9168. +
  9169. +/******************************************************************************
  9170. +* Sets the collision distance in the Transmit Control register
  9171. +*
  9172. +* hw - Struct containing variables accessed by shared code
  9173. +*
  9174. +* Link should have been established previously. Reads the speed and duplex
  9175. +* information from the Device Status register.
  9176. +******************************************************************************/
  9177. +static void
  9178. +e1000_config_collision_dist(struct e1000_hw *hw)
  9179. +{
  9180. + uint32_t tctl;
  9181. +
  9182. + tctl = E1000_READ_REG(hw, TCTL);
  9183. +
  9184. + tctl &= ~E1000_TCTL_COLD;
  9185. + tctl |= E1000_COLLISION_DISTANCE << E1000_COLD_SHIFT;
  9186. +
  9187. + E1000_WRITE_REG(hw, TCTL, tctl);
  9188. + E1000_WRITE_FLUSH(hw);
  9189. +}
  9190. +
  9191. +/******************************************************************************
  9192. +* Sets MAC speed and duplex settings to reflect the those in the PHY
  9193. +*
  9194. +* hw - Struct containing variables accessed by shared code
  9195. +* mii_reg - data to write to the MII control register
  9196. +*
  9197. +* The contents of the PHY register containing the needed information need to
  9198. +* be passed in.
  9199. +******************************************************************************/
  9200. +static int
  9201. +e1000_config_mac_to_phy(struct e1000_hw *hw)
  9202. +{
  9203. + uint32_t ctrl;
  9204. + int32_t ret_val;
  9205. + uint16_t phy_data;
  9206. +
  9207. + DEBUGFUNC("e1000_config_mac_to_phy");
  9208. +
  9209. + /* Read the Device Control Register and set the bits to Force Speed
  9210. + * and Duplex.
  9211. + */
  9212. + ctrl = E1000_READ_REG(hw, CTRL);
  9213. + ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
  9214. + ctrl &= ~(E1000_CTRL_SPD_SEL | E1000_CTRL_ILOS);
  9215. +
  9216. + /* Set up duplex in the Device Control and Transmit Control
  9217. + * registers depending on negotiated values.
  9218. + */
  9219. + if (hw->phy_type == e1000_phy_igp) {
  9220. + if((ret_val = e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_STATUS,
  9221. + &phy_data)))
  9222. + return ret_val;
  9223. +
  9224. + if(phy_data & IGP01E1000_PSSR_FULL_DUPLEX) ctrl |= E1000_CTRL_FD;
  9225. + else ctrl &= ~E1000_CTRL_FD;
  9226. +
  9227. + e1000_config_collision_dist(hw);
  9228. +
  9229. + /* Set up speed in the Device Control register depending on
  9230. + * negotiated values.
  9231. + */
  9232. + if((phy_data & IGP01E1000_PSSR_SPEED_MASK) ==
  9233. + IGP01E1000_PSSR_SPEED_1000MBPS)
  9234. + ctrl |= E1000_CTRL_SPD_1000;
  9235. + else if((phy_data & IGP01E1000_PSSR_SPEED_MASK) ==
  9236. + IGP01E1000_PSSR_SPEED_100MBPS)
  9237. + ctrl |= E1000_CTRL_SPD_100;
  9238. + } else {
  9239. + if((ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS,
  9240. + &phy_data)))
  9241. + return ret_val;
  9242. +
  9243. + if(phy_data & M88E1000_PSSR_DPLX) ctrl |= E1000_CTRL_FD;
  9244. + else ctrl &= ~E1000_CTRL_FD;
  9245. +
  9246. + e1000_config_collision_dist(hw);
  9247. +
  9248. + /* Set up speed in the Device Control register depending on
  9249. + * negotiated values.
  9250. + */
  9251. + if((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS)
  9252. + ctrl |= E1000_CTRL_SPD_1000;
  9253. + else if((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_100MBS)
  9254. + ctrl |= E1000_CTRL_SPD_100;
  9255. + }
  9256. + /* Write the configured values back to the Device Control Reg. */
  9257. + E1000_WRITE_REG(hw, CTRL, ctrl);
  9258. + return E1000_SUCCESS;
  9259. +}
  9260. +
  9261. +/******************************************************************************
  9262. + * Forces the MAC's flow control settings.
  9263. + *
  9264. + * hw - Struct containing variables accessed by shared code
  9265. + *
  9266. + * Sets the TFCE and RFCE bits in the device control register to reflect
  9267. + * the adapter settings. TFCE and RFCE need to be explicitly set by
  9268. + * software when a Copper PHY is used because autonegotiation is managed
  9269. + * by the PHY rather than the MAC. Software must also configure these
  9270. + * bits when link is forced on a fiber connection.
  9271. + *****************************************************************************/
  9272. +static int
  9273. +e1000_force_mac_fc(struct e1000_hw *hw)
  9274. +{
  9275. + uint32_t ctrl;
  9276. +
  9277. + DEBUGFUNC("e1000_force_mac_fc");
  9278. +
  9279. + /* Get the current configuration of the Device Control Register */
  9280. + ctrl = E1000_READ_REG(hw, CTRL);
  9281. +
  9282. + /* Because we didn't get link via the internal auto-negotiation
  9283. + * mechanism (we either forced link or we got link via PHY
  9284. + * auto-neg), we have to manually enable/disable transmit an
  9285. + * receive flow control.
  9286. + *
  9287. + * The "Case" statement below enables/disable flow control
  9288. + * according to the "hw->fc" parameter.
  9289. + *
  9290. + * The possible values of the "fc" parameter are:
  9291. + * 0: Flow control is completely disabled
  9292. + * 1: Rx flow control is enabled (we can receive pause
  9293. + * frames but not send pause frames).
  9294. + * 2: Tx flow control is enabled (we can send pause frames
  9295. + * frames but we do not receive pause frames).
  9296. + * 3: Both Rx and TX flow control (symmetric) is enabled.
  9297. + * other: No other values should be possible at this point.
  9298. + */
  9299. +
  9300. + switch (hw->fc) {
  9301. + case e1000_fc_none:
  9302. + ctrl &= (~(E1000_CTRL_TFCE | E1000_CTRL_RFCE));
  9303. + break;
  9304. + case e1000_fc_rx_pause:
  9305. + ctrl &= (~E1000_CTRL_TFCE);
  9306. + ctrl |= E1000_CTRL_RFCE;
  9307. + break;
  9308. + case e1000_fc_tx_pause:
  9309. + ctrl &= (~E1000_CTRL_RFCE);
  9310. + ctrl |= E1000_CTRL_TFCE;
  9311. + break;
  9312. + case e1000_fc_full:
  9313. + ctrl |= (E1000_CTRL_TFCE | E1000_CTRL_RFCE);
  9314. + break;
  9315. + default:
  9316. + DEBUGOUT("Flow control param set incorrectly\n");
  9317. + return -E1000_ERR_CONFIG;
  9318. + }
  9319. +
  9320. + /* Disable TX Flow Control for 82542 (rev 2.0) */
  9321. + if(hw->mac_type == e1000_82542_rev2_0)
  9322. + ctrl &= (~E1000_CTRL_TFCE);
  9323. +
  9324. + E1000_WRITE_REG(hw, CTRL, ctrl);
  9325. + return E1000_SUCCESS;
  9326. +}
  9327. +
  9328. +/******************************************************************************
  9329. + * Configures flow control settings after link is established
  9330. + *
  9331. + * hw - Struct containing variables accessed by shared code
  9332. + *
  9333. + * Should be called immediately after a valid link has been established.
  9334. + * Forces MAC flow control settings if link was forced. When in MII/GMII mode
  9335. + * and autonegotiation is enabled, the MAC flow control settings will be set
  9336. + * based on the flow control negotiated by the PHY. In TBI mode, the TFCE
  9337. + * and RFCE bits will be automaticaly set to the negotiated flow control mode.
  9338. + *****************************************************************************/
  9339. +static int
  9340. +e1000_config_fc_after_link_up(struct e1000_hw *hw)
  9341. +{
  9342. + int32_t ret_val;
  9343. + uint16_t mii_status_reg;
  9344. + uint16_t mii_nway_adv_reg;
  9345. + uint16_t mii_nway_lp_ability_reg;
  9346. + uint16_t speed;
  9347. + uint16_t duplex;
  9348. +
  9349. + DEBUGFUNC("e1000_config_fc_after_link_up");
  9350. +
  9351. + /* Check for the case where we have fiber media and auto-neg failed
  9352. + * so we had to force link. In this case, we need to force the
  9353. + * configuration of the MAC to match the "fc" parameter.
  9354. + */
  9355. + if(((hw->media_type == e1000_media_type_fiber) && (hw->autoneg_failed)) ||
  9356. + ((hw->media_type == e1000_media_type_internal_serdes) && (hw->autoneg_failed))) {
  9357. + if((ret_val = e1000_force_mac_fc(hw))) {
  9358. + DEBUGOUT("Error forcing flow control settings\n");
  9359. + return ret_val;
  9360. + }
  9361. + }
  9362. +
  9363. + /* Check for the case where we have copper media and auto-neg is
  9364. + * enabled. In this case, we need to check and see if Auto-Neg
  9365. + * has completed, and if so, how the PHY and link partner has
  9366. + * flow control configured.
  9367. + */
  9368. + if(hw->media_type == e1000_media_type_copper) {
  9369. + /* Read the MII Status Register and check to see if AutoNeg
  9370. + * has completed. We read this twice because this reg has
  9371. + * some "sticky" (latched) bits.
  9372. + */
  9373. + if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg)))
  9374. + return ret_val;
  9375. + if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg)))
  9376. + return ret_val;
  9377. +
  9378. + if(mii_status_reg & MII_SR_AUTONEG_COMPLETE) {
  9379. + /* The AutoNeg process has completed, so we now need to
  9380. + * read both the Auto Negotiation Advertisement Register
  9381. + * (Address 4) and the Auto_Negotiation Base Page Ability
  9382. + * Register (Address 5) to determine how flow control was
  9383. + * negotiated.
  9384. + */
  9385. + if((ret_val = e1000_read_phy_reg(hw, PHY_AUTONEG_ADV,
  9386. + &mii_nway_adv_reg)))
  9387. + return ret_val;
  9388. + if((ret_val = e1000_read_phy_reg(hw, PHY_LP_ABILITY,
  9389. + &mii_nway_lp_ability_reg)))
  9390. + return ret_val;
  9391. +
  9392. + /* Two bits in the Auto Negotiation Advertisement Register
  9393. + * (Address 4) and two bits in the Auto Negotiation Base
  9394. + * Page Ability Register (Address 5) determine flow control
  9395. + * for both the PHY and the link partner. The following
  9396. + * table, taken out of the IEEE 802.3ab/D6.0 dated March 25,
  9397. + * 1999, describes these PAUSE resolution bits and how flow
  9398. + * control is determined based upon these settings.
  9399. + * NOTE: DC = Don't Care
  9400. + *
  9401. + * LOCAL DEVICE | LINK PARTNER
  9402. + * PAUSE | ASM_DIR | PAUSE | ASM_DIR | NIC Resolution
  9403. + *-------|---------|-------|---------|--------------------
  9404. + * 0 | 0 | DC | DC | e1000_fc_none
  9405. + * 0 | 1 | 0 | DC | e1000_fc_none
  9406. + * 0 | 1 | 1 | 0 | e1000_fc_none
  9407. + * 0 | 1 | 1 | 1 | e1000_fc_tx_pause
  9408. + * 1 | 0 | 0 | DC | e1000_fc_none
  9409. + * 1 | DC | 1 | DC | e1000_fc_full
  9410. + * 1 | 1 | 0 | 0 | e1000_fc_none
  9411. + * 1 | 1 | 0 | 1 | e1000_fc_rx_pause
  9412. + *
  9413. + */
  9414. + /* Are both PAUSE bits set to 1? If so, this implies
  9415. + * Symmetric Flow Control is enabled at both ends. The
  9416. + * ASM_DIR bits are irrelevant per the spec.
  9417. + *
  9418. + * For Symmetric Flow Control:
  9419. + *
  9420. + * LOCAL DEVICE | LINK PARTNER
  9421. + * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
  9422. + *-------|---------|-------|---------|--------------------
  9423. + * 1 | DC | 1 | DC | e1000_fc_full
  9424. + *
  9425. + */
  9426. + if((mii_nway_adv_reg & NWAY_AR_PAUSE) &&
  9427. + (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE)) {
  9428. + /* Now we need to check if the user selected RX ONLY
  9429. + * of pause frames. In this case, we had to advertise
  9430. + * FULL flow control because we could not advertise RX
  9431. + * ONLY. Hence, we must now check to see if we need to
  9432. + * turn OFF the TRANSMISSION of PAUSE frames.
  9433. + */
  9434. +#if 0
  9435. + if(hw->original_fc == e1000_fc_full) {
  9436. + hw->fc = e1000_fc_full;
  9437. +#else
  9438. + if(hw->fc == e1000_fc_full) {
  9439. +#endif
  9440. + DEBUGOUT("Flow Control = FULL.\r\n");
  9441. + } else {
  9442. + hw->fc = e1000_fc_rx_pause;
  9443. + DEBUGOUT("Flow Control = RX PAUSE frames only.\r\n");
  9444. + }
  9445. + }
  9446. + /* For receiving PAUSE frames ONLY.
  9447. + *
  9448. + * LOCAL DEVICE | LINK PARTNER
  9449. + * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
  9450. + *-------|---------|-------|---------|--------------------
  9451. + * 0 | 1 | 1 | 1 | e1000_fc_tx_pause
  9452. + *
  9453. + */
  9454. + else if(!(mii_nway_adv_reg & NWAY_AR_PAUSE) &&
  9455. + (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
  9456. + (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
  9457. + (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
  9458. + hw->fc = e1000_fc_tx_pause;
  9459. + DEBUGOUT("Flow Control = TX PAUSE frames only.\r\n");
  9460. + }
  9461. + /* For transmitting PAUSE frames ONLY.
  9462. + *
  9463. + * LOCAL DEVICE | LINK PARTNER
  9464. + * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result
  9465. + *-------|---------|-------|---------|--------------------
  9466. + * 1 | 1 | 0 | 1 | e1000_fc_rx_pause
  9467. + *
  9468. + */
  9469. + else if((mii_nway_adv_reg & NWAY_AR_PAUSE) &&
  9470. + (mii_nway_adv_reg & NWAY_AR_ASM_DIR) &&
  9471. + !(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) &&
  9472. + (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) {
  9473. + hw->fc = e1000_fc_rx_pause;
  9474. + DEBUGOUT("Flow Control = RX PAUSE frames only.\r\n");
  9475. + }
  9476. + /* Per the IEEE spec, at this point flow control should be
  9477. + * disabled. However, we want to consider that we could
  9478. + * be connected to a legacy switch that doesn't advertise
  9479. + * desired flow control, but can be forced on the link
  9480. + * partner. So if we advertised no flow control, that is
  9481. + * what we will resolve to. If we advertised some kind of
  9482. + * receive capability (Rx Pause Only or Full Flow Control)
  9483. + * and the link partner advertised none, we will configure
  9484. + * ourselves to enable Rx Flow Control only. We can do
  9485. + * this safely for two reasons: If the link partner really
  9486. + * didn't want flow control enabled, and we enable Rx, no
  9487. + * harm done since we won't be receiving any PAUSE frames
  9488. + * anyway. If the intent on the link partner was to have
  9489. + * flow control enabled, then by us enabling RX only, we
  9490. + * can at least receive pause frames and process them.
  9491. + * This is a good idea because in most cases, since we are
  9492. + * predominantly a server NIC, more times than not we will
  9493. + * be asked to delay transmission of packets than asking
  9494. + * our link partner to pause transmission of frames.
  9495. + */
  9496. +#if 0
  9497. + else if(hw->original_fc == e1000_fc_none ||
  9498. + hw->original_fc == e1000_fc_tx_pause) {
  9499. +#else
  9500. + else if(hw->fc == e1000_fc_none)
  9501. + DEBUGOUT("Flow Control = NONE.\r\n");
  9502. + else if(hw->fc == e1000_fc_tx_pause) {
  9503. +#endif
  9504. + hw->fc = e1000_fc_none;
  9505. + DEBUGOUT("Flow Control = NONE.\r\n");
  9506. + } else {
  9507. + hw->fc = e1000_fc_rx_pause;
  9508. + DEBUGOUT("Flow Control = RX PAUSE frames only.\r\n");
  9509. + }
  9510. +
  9511. + /* Now we need to do one last check... If we auto-
  9512. + * negotiated to HALF DUPLEX, flow control should not be
  9513. + * enabled per IEEE 802.3 spec.
  9514. + */
  9515. + e1000_get_speed_and_duplex(hw, &speed, &duplex);
  9516. +
  9517. + if(duplex == HALF_DUPLEX)
  9518. + hw->fc = e1000_fc_none;
  9519. +
  9520. + /* Now we call a subroutine to actually force the MAC
  9521. + * controller to use the correct flow control settings.
  9522. + */
  9523. + if((ret_val = e1000_force_mac_fc(hw))) {
  9524. + DEBUGOUT("Error forcing flow control settings\n");
  9525. + return ret_val;
  9526. + }
  9527. + } else {
  9528. + DEBUGOUT("Copper PHY and Auto Neg has not completed.\r\n");
  9529. + }
  9530. + }
  9531. + return E1000_SUCCESS;
  9532. +}
  9533. +
  9534. +/******************************************************************************
  9535. + * Checks to see if the link status of the hardware has changed.
  9536. + *
  9537. + * hw - Struct containing variables accessed by shared code
  9538. + *
  9539. + * Called by any function that needs to check the link status of the adapter.
  9540. + *****************************************************************************/
  9541. +static int
  9542. +e1000_check_for_link(struct e1000_hw *hw)
  9543. +{
  9544. + uint32_t rxcw;
  9545. + uint32_t ctrl;
  9546. + uint32_t status;
  9547. + uint32_t rctl;
  9548. + uint32_t signal = 0;
  9549. + int32_t ret_val;
  9550. + uint16_t phy_data;
  9551. + uint16_t lp_capability;
  9552. +
  9553. + DEBUGFUNC("e1000_check_for_link");
  9554. +
  9555. + /* On adapters with a MAC newer than 82544, SW Defineable pin 1 will be
  9556. + * set when the optics detect a signal. On older adapters, it will be
  9557. + * cleared when there is a signal. This applies to fiber media only.
  9558. + */
  9559. + if(hw->media_type == e1000_media_type_fiber)
  9560. + signal = (hw->mac_type > e1000_82544) ? E1000_CTRL_SWDPIN1 : 0;
  9561. +
  9562. + ctrl = E1000_READ_REG(hw, CTRL);
  9563. + status = E1000_READ_REG(hw, STATUS);
  9564. + rxcw = E1000_READ_REG(hw, RXCW);
  9565. +
  9566. + /* If we have a copper PHY then we only want to go out to the PHY
  9567. + * registers to see if Auto-Neg has completed and/or if our link
  9568. + * status has changed. The get_link_status flag will be set if we
  9569. + * receive a Link Status Change interrupt or we have Rx Sequence
  9570. + * Errors.
  9571. + */
  9572. +#if 0
  9573. + if((hw->media_type == e1000_media_type_copper) && hw->get_link_status) {
  9574. +#else
  9575. + if(hw->media_type == e1000_media_type_copper) {
  9576. +#endif
  9577. + /* First we want to see if the MII Status Register reports
  9578. + * link. If so, then we want to get the current speed/duplex
  9579. + * of the PHY.
  9580. + * Read the register twice since the link bit is sticky.
  9581. + */
  9582. + if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data)))
  9583. + return ret_val;
  9584. + if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data)))
  9585. + return ret_val;
  9586. +
  9587. + if(phy_data & MII_SR_LINK_STATUS) {
  9588. +#if 0
  9589. + hw->get_link_status = FALSE;
  9590. +#endif
  9591. + } else {
  9592. + /* No link detected */
  9593. + return -E1000_ERR_NOLINK;
  9594. + }
  9595. +
  9596. + /* We have a M88E1000 PHY and Auto-Neg is enabled. If we
  9597. + * have Si on board that is 82544 or newer, Auto
  9598. + * Speed Detection takes care of MAC speed/duplex
  9599. + * configuration. So we only need to configure Collision
  9600. + * Distance in the MAC. Otherwise, we need to force
  9601. + * speed/duplex on the MAC to the current PHY speed/duplex
  9602. + * settings.
  9603. + */
  9604. + if(hw->mac_type >= e1000_82544)
  9605. + e1000_config_collision_dist(hw);
  9606. + else {
  9607. + if((ret_val = e1000_config_mac_to_phy(hw))) {
  9608. + DEBUGOUT("Error configuring MAC to PHY settings\n");
  9609. + return ret_val;
  9610. + }
  9611. + }
  9612. +
  9613. + /* Configure Flow Control now that Auto-Neg has completed. First, we
  9614. + * need to restore the desired flow control settings because we may
  9615. + * have had to re-autoneg with a different link partner.
  9616. + */
  9617. + if((ret_val = e1000_config_fc_after_link_up(hw))) {
  9618. + DEBUGOUT("Error configuring flow control\n");
  9619. + return ret_val;
  9620. + }
  9621. +
  9622. + /* At this point we know that we are on copper and we have
  9623. + * auto-negotiated link. These are conditions for checking the link
  9624. + * parter capability register. We use the link partner capability to
  9625. + * determine if TBI Compatibility needs to be turned on or off. If
  9626. + * the link partner advertises any speed in addition to Gigabit, then
  9627. + * we assume that they are GMII-based, and TBI compatibility is not
  9628. + * needed. If no other speeds are advertised, we assume the link
  9629. + * partner is TBI-based, and we turn on TBI Compatibility.
  9630. + */
  9631. + if(hw->tbi_compatibility_en) {
  9632. + if((ret_val = e1000_read_phy_reg(hw, PHY_LP_ABILITY,
  9633. + &lp_capability)))
  9634. + return ret_val;
  9635. + if(lp_capability & (NWAY_LPAR_10T_HD_CAPS |
  9636. + NWAY_LPAR_10T_FD_CAPS |
  9637. + NWAY_LPAR_100TX_HD_CAPS |
  9638. + NWAY_LPAR_100TX_FD_CAPS |
  9639. + NWAY_LPAR_100T4_CAPS)) {
  9640. + /* If our link partner advertises anything in addition to
  9641. + * gigabit, we do not need to enable TBI compatibility.
  9642. + */
  9643. + if(hw->tbi_compatibility_on) {
  9644. + /* If we previously were in the mode, turn it off. */
  9645. + rctl = E1000_READ_REG(hw, RCTL);
  9646. + rctl &= ~E1000_RCTL_SBP;
  9647. + E1000_WRITE_REG(hw, RCTL, rctl);
  9648. + hw->tbi_compatibility_on = FALSE;
  9649. + }
  9650. + } else {
  9651. + /* If TBI compatibility is was previously off, turn it on. For
  9652. + * compatibility with a TBI link partner, we will store bad
  9653. + * packets. Some frames have an additional byte on the end and
  9654. + * will look like CRC errors to to the hardware.
  9655. + */
  9656. + if(!hw->tbi_compatibility_on) {
  9657. + hw->tbi_compatibility_on = TRUE;
  9658. + rctl = E1000_READ_REG(hw, RCTL);
  9659. + rctl |= E1000_RCTL_SBP;
  9660. + E1000_WRITE_REG(hw, RCTL, rctl);
  9661. + }
  9662. + }
  9663. + }
  9664. + }
  9665. + /* If we don't have link (auto-negotiation failed or link partner cannot
  9666. + * auto-negotiate), the cable is plugged in (we have signal), and our
  9667. + * link partner is not trying to auto-negotiate with us (we are receiving
  9668. + * idles or data), we need to force link up. We also need to give
  9669. + * auto-negotiation time to complete, in case the cable was just plugged
  9670. + * in. The autoneg_failed flag does this.
  9671. + */
  9672. + else if((((hw->media_type == e1000_media_type_fiber) &&
  9673. + ((ctrl & E1000_CTRL_SWDPIN1) == signal)) ||
  9674. + (hw->media_type == e1000_media_type_internal_serdes)) &&
  9675. + (!(status & E1000_STATUS_LU)) &&
  9676. + (!(rxcw & E1000_RXCW_C))) {
  9677. + if(hw->autoneg_failed == 0) {
  9678. + hw->autoneg_failed = 1;
  9679. + return 0;
  9680. + }
  9681. + DEBUGOUT("NOT RXing /C/, disable AutoNeg and force link.\r\n");
  9682. +
  9683. + /* Disable auto-negotiation in the TXCW register */
  9684. + E1000_WRITE_REG(hw, TXCW, (hw->txcw & ~E1000_TXCW_ANE));
  9685. +
  9686. + /* Force link-up and also force full-duplex. */
  9687. + ctrl = E1000_READ_REG(hw, CTRL);
  9688. + ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD);
  9689. + E1000_WRITE_REG(hw, CTRL, ctrl);
  9690. +
  9691. + /* Configure Flow Control after forcing link up. */
  9692. + if((ret_val = e1000_config_fc_after_link_up(hw))) {
  9693. + DEBUGOUT("Error configuring flow control\n");
  9694. + return ret_val;
  9695. + }
  9696. + }
  9697. + /* If we are forcing link and we are receiving /C/ ordered sets, re-enable
  9698. + * auto-negotiation in the TXCW register and disable forced link in the
  9699. + * Device Control register in an attempt to auto-negotiate with our link
  9700. + * partner.
  9701. + */
  9702. + else if(((hw->media_type == e1000_media_type_fiber) ||
  9703. + (hw->media_type == e1000_media_type_internal_serdes)) &&
  9704. + (ctrl & E1000_CTRL_SLU) &&
  9705. + (rxcw & E1000_RXCW_C)) {
  9706. + DEBUGOUT("RXing /C/, enable AutoNeg and stop forcing link.\r\n");
  9707. + E1000_WRITE_REG(hw, TXCW, hw->txcw);
  9708. + E1000_WRITE_REG(hw, CTRL, (ctrl & ~E1000_CTRL_SLU));
  9709. + }
  9710. +#if 0
  9711. + /* If we force link for non-auto-negotiation switch, check link status
  9712. + * based on MAC synchronization for internal serdes media type.
  9713. + */
  9714. + else if((hw->media_type == e1000_media_type_internal_serdes) &&
  9715. + !(E1000_TXCW_ANE & E1000_READ_REG(hw, TXCW))) {
  9716. + /* SYNCH bit and IV bit are sticky. */
  9717. + udelay(10);
  9718. + if(E1000_RXCW_SYNCH & E1000_READ_REG(hw, RXCW)) {
  9719. + if(!(rxcw & E1000_RXCW_IV)) {
  9720. + hw->serdes_link_down = FALSE;
  9721. + DEBUGOUT("SERDES: Link is up.\n");
  9722. + }
  9723. + } else {
  9724. + hw->serdes_link_down = TRUE;
  9725. + DEBUGOUT("SERDES: Link is down.\n");
  9726. + }
  9727. + }
  9728. +#endif
  9729. + return E1000_SUCCESS;
  9730. +}
  9731. +
  9732. +/******************************************************************************
  9733. + * Detects the current speed and duplex settings of the hardware.
  9734. + *
  9735. + * hw - Struct containing variables accessed by shared code
  9736. + * speed - Speed of the connection
  9737. + * duplex - Duplex setting of the connection
  9738. + *****************************************************************************/
  9739. +static void
  9740. +e1000_get_speed_and_duplex(struct e1000_hw *hw,
  9741. + uint16_t *speed,
  9742. + uint16_t *duplex)
  9743. +{
  9744. + uint32_t status;
  9745. +
  9746. + DEBUGFUNC("e1000_get_speed_and_duplex");
  9747. +
  9748. + if(hw->mac_type >= e1000_82543) {
  9749. + status = E1000_READ_REG(hw, STATUS);
  9750. + if(status & E1000_STATUS_SPEED_1000) {
  9751. + *speed = SPEED_1000;
  9752. + DEBUGOUT("1000 Mbs, ");
  9753. + } else if(status & E1000_STATUS_SPEED_100) {
  9754. + *speed = SPEED_100;
  9755. + DEBUGOUT("100 Mbs, ");
  9756. + } else {
  9757. + *speed = SPEED_10;
  9758. + DEBUGOUT("10 Mbs, ");
  9759. + }
  9760. +
  9761. + if(status & E1000_STATUS_FD) {
  9762. + *duplex = FULL_DUPLEX;
  9763. + DEBUGOUT("Full Duplex\r\n");
  9764. + } else {
  9765. + *duplex = HALF_DUPLEX;
  9766. + DEBUGOUT(" Half Duplex\r\n");
  9767. + }
  9768. + } else {
  9769. + DEBUGOUT("1000 Mbs, Full Duplex\r\n");
  9770. + *speed = SPEED_1000;
  9771. + *duplex = FULL_DUPLEX;
  9772. + }
  9773. +}
  9774. +
  9775. +/******************************************************************************
  9776. +* Blocks until autoneg completes or times out (~4.5 seconds)
  9777. +*
  9778. +* hw - Struct containing variables accessed by shared code
  9779. +******************************************************************************/
  9780. +static int
  9781. +e1000_wait_autoneg(struct e1000_hw *hw)
  9782. +{
  9783. + int32_t ret_val;
  9784. + uint16_t i;
  9785. + uint16_t phy_data;
  9786. +
  9787. + DEBUGFUNC("e1000_wait_autoneg");
  9788. + DEBUGOUT("Waiting for Auto-Neg to complete.\n");
  9789. +
  9790. + /* We will wait for autoneg to complete or 4.5 seconds to expire. */
  9791. + for(i = PHY_AUTO_NEG_TIME; i > 0; i--) {
  9792. + /* Read the MII Status Register and wait for Auto-Neg
  9793. + * Complete bit to be set.
  9794. + */
  9795. + if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data)))
  9796. + return ret_val;
  9797. + if((ret_val = e1000_read_phy_reg(hw, PHY_STATUS, &phy_data)))
  9798. + return ret_val;
  9799. + if(phy_data & MII_SR_AUTONEG_COMPLETE) {
  9800. + DEBUGOUT("Auto-Neg complete.\n");
  9801. + return E1000_SUCCESS;
  9802. + }
  9803. + mdelay(100);
  9804. + }
  9805. + DEBUGOUT("Auto-Neg timedout.\n");
  9806. + return -E1000_ERR_TIMEOUT;
  9807. +}
  9808. +
  9809. +/******************************************************************************
  9810. +* Raises the Management Data Clock
  9811. +*
  9812. +* hw - Struct containing variables accessed by shared code
  9813. +* ctrl - Device control register's current value
  9814. +******************************************************************************/
  9815. +static void
  9816. +e1000_raise_mdi_clk(struct e1000_hw *hw,
  9817. + uint32_t *ctrl)
  9818. +{
  9819. + /* Raise the clock input to the Management Data Clock (by setting the MDC
  9820. + * bit), and then delay 10 microseconds.
  9821. + */
  9822. + E1000_WRITE_REG(hw, CTRL, (*ctrl | E1000_CTRL_MDC));
  9823. + E1000_WRITE_FLUSH(hw);
  9824. + udelay(10);
  9825. +}
  9826. +
  9827. +/******************************************************************************
  9828. +* Lowers the Management Data Clock
  9829. +*
  9830. +* hw - Struct containing variables accessed by shared code
  9831. +* ctrl - Device control register's current value
  9832. +******************************************************************************/
  9833. +static void
  9834. +e1000_lower_mdi_clk(struct e1000_hw *hw,
  9835. + uint32_t *ctrl)
  9836. +{
  9837. + /* Lower the clock input to the Management Data Clock (by clearing the MDC
  9838. + * bit), and then delay 10 microseconds.
  9839. + */
  9840. + E1000_WRITE_REG(hw, CTRL, (*ctrl & ~E1000_CTRL_MDC));
  9841. + E1000_WRITE_FLUSH(hw);
  9842. + udelay(10);
  9843. +}
  9844. +
  9845. +/******************************************************************************
  9846. +* Shifts data bits out to the PHY
  9847. +*
  9848. +* hw - Struct containing variables accessed by shared code
  9849. +* data - Data to send out to the PHY
  9850. +* count - Number of bits to shift out
  9851. +*
  9852. +* Bits are shifted out in MSB to LSB order.
  9853. +******************************************************************************/
  9854. +static void
  9855. +e1000_shift_out_mdi_bits(struct e1000_hw *hw,
  9856. + uint32_t data,
  9857. + uint16_t count)
  9858. +{
  9859. + uint32_t ctrl;
  9860. + uint32_t mask;
  9861. +
  9862. + /* We need to shift "count" number of bits out to the PHY. So, the value
  9863. + * in the "data" parameter will be shifted out to the PHY one bit at a
  9864. + * time. In order to do this, "data" must be broken down into bits.
  9865. + */
  9866. + mask = 0x01;
  9867. + mask <<= (count - 1);
  9868. +
  9869. + ctrl = E1000_READ_REG(hw, CTRL);
  9870. +
  9871. + /* Set MDIO_DIR and MDC_DIR direction bits to be used as output pins. */
  9872. + ctrl |= (E1000_CTRL_MDIO_DIR | E1000_CTRL_MDC_DIR);
  9873. +
  9874. + while(mask) {
  9875. + /* A "1" is shifted out to the PHY by setting the MDIO bit to "1" and
  9876. + * then raising and lowering the Management Data Clock. A "0" is
  9877. + * shifted out to the PHY by setting the MDIO bit to "0" and then
  9878. + * raising and lowering the clock.
  9879. + */
  9880. + if(data & mask) ctrl |= E1000_CTRL_MDIO;
  9881. + else ctrl &= ~E1000_CTRL_MDIO;
  9882. +
  9883. + E1000_WRITE_REG(hw, CTRL, ctrl);
  9884. + E1000_WRITE_FLUSH(hw);
  9885. +
  9886. + udelay(10);
  9887. +
  9888. + e1000_raise_mdi_clk(hw, &ctrl);
  9889. + e1000_lower_mdi_clk(hw, &ctrl);
  9890. +
  9891. + mask = mask >> 1;
  9892. + }
  9893. +}
  9894. +
  9895. +/******************************************************************************
  9896. +* Shifts data bits in from the PHY
  9897. +*
  9898. +* hw - Struct containing variables accessed by shared code
  9899. +*
  9900. +* Bits are shifted in in MSB to LSB order.
  9901. +******************************************************************************/
  9902. +static uint16_t
  9903. +e1000_shift_in_mdi_bits(struct e1000_hw *hw)
  9904. +{
  9905. + uint32_t ctrl;
  9906. + uint16_t data = 0;
  9907. + uint8_t i;
  9908. +
  9909. + /* In order to read a register from the PHY, we need to shift in a total
  9910. + * of 18 bits from the PHY. The first two bit (turnaround) times are used
  9911. + * to avoid contention on the MDIO pin when a read operation is performed.
  9912. + * These two bits are ignored by us and thrown away. Bits are "shifted in"
  9913. + * by raising the input to the Management Data Clock (setting the MDC bit),
  9914. + * and then reading the value of the MDIO bit.
  9915. + */
  9916. + ctrl = E1000_READ_REG(hw, CTRL);
  9917. +
  9918. + /* Clear MDIO_DIR (SWDPIO1) to indicate this bit is to be used as input. */
  9919. + ctrl &= ~E1000_CTRL_MDIO_DIR;
  9920. + ctrl &= ~E1000_CTRL_MDIO;
  9921. +
  9922. + E1000_WRITE_REG(hw, CTRL, ctrl);
  9923. + E1000_WRITE_FLUSH(hw);
  9924. +
  9925. + /* Raise and Lower the clock before reading in the data. This accounts for
  9926. + * the turnaround bits. The first clock occurred when we clocked out the
  9927. + * last bit of the Register Address.
  9928. + */
  9929. + e1000_raise_mdi_clk(hw, &ctrl);
  9930. + e1000_lower_mdi_clk(hw, &ctrl);
  9931. +
  9932. + for(data = 0, i = 0; i < 16; i++) {
  9933. + data = data << 1;
  9934. + e1000_raise_mdi_clk(hw, &ctrl);
  9935. + ctrl = E1000_READ_REG(hw, CTRL);
  9936. + /* Check to see if we shifted in a "1". */
  9937. + if(ctrl & E1000_CTRL_MDIO) data |= 1;
  9938. + e1000_lower_mdi_clk(hw, &ctrl);
  9939. + }
  9940. +
  9941. + e1000_raise_mdi_clk(hw, &ctrl);
  9942. + e1000_lower_mdi_clk(hw, &ctrl);
  9943. +
  9944. + return data;
  9945. +}
  9946. +
  9947. +/*****************************************************************************
  9948. +* Reads the value from a PHY register, if the value is on a specific non zero
  9949. +* page, sets the page first.
  9950. +*
  9951. +* hw - Struct containing variables accessed by shared code
  9952. +* reg_addr - address of the PHY register to read
  9953. +******************************************************************************/
  9954. +static int
  9955. +e1000_read_phy_reg(struct e1000_hw *hw,
  9956. + uint32_t reg_addr,
  9957. + uint16_t *phy_data)
  9958. +{
  9959. + uint32_t ret_val;
  9960. +
  9961. + DEBUGFUNC("e1000_read_phy_reg");
  9962. +
  9963. + if(hw->phy_type == e1000_phy_igp &&
  9964. + (reg_addr > MAX_PHY_MULTI_PAGE_REG)) {
  9965. + if((ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT,
  9966. + (uint16_t)reg_addr)))
  9967. + return ret_val;
  9968. + }
  9969. +
  9970. + ret_val = e1000_read_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT & reg_addr,
  9971. + phy_data);
  9972. +
  9973. + return ret_val;
  9974. +}
  9975. +
  9976. +static int
  9977. +e1000_read_phy_reg_ex(struct e1000_hw *hw,
  9978. + uint32_t reg_addr,
  9979. + uint16_t *phy_data)
  9980. +{
  9981. + uint32_t i;
  9982. + uint32_t mdic = 0;
  9983. + const uint32_t phy_addr = 1;
  9984. +
  9985. + DEBUGFUNC("e1000_read_phy_reg_ex");
  9986. +
  9987. + if(reg_addr > MAX_PHY_REG_ADDRESS) {
  9988. + DEBUGOUT1("PHY Address %d is out of range\n", reg_addr);
  9989. + return -E1000_ERR_PARAM;
  9990. + }
  9991. +
  9992. + if(hw->mac_type > e1000_82543) {
  9993. + /* Set up Op-code, Phy Address, and register address in the MDI
  9994. + * Control register. The MAC will take care of interfacing with the
  9995. + * PHY to retrieve the desired data.
  9996. + */
  9997. + mdic = ((reg_addr << E1000_MDIC_REG_SHIFT) |
  9998. + (phy_addr << E1000_MDIC_PHY_SHIFT) |
  9999. + (E1000_MDIC_OP_READ));
  10000. +
  10001. + E1000_WRITE_REG(hw, MDIC, mdic);
  10002. +
  10003. + /* Poll the ready bit to see if the MDI read completed */
  10004. + for(i = 0; i < 64; i++) {
  10005. + udelay(50);
  10006. + mdic = E1000_READ_REG(hw, MDIC);
  10007. + if(mdic & E1000_MDIC_READY) break;
  10008. + }
  10009. + if(!(mdic & E1000_MDIC_READY)) {
  10010. + DEBUGOUT("MDI Read did not complete\n");
  10011. + return -E1000_ERR_PHY;
  10012. + }
  10013. + if(mdic & E1000_MDIC_ERROR) {
  10014. + DEBUGOUT("MDI Error\n");
  10015. + return -E1000_ERR_PHY;
  10016. + }
  10017. + *phy_data = (uint16_t) mdic;
  10018. + } else {
  10019. + /* We must first send a preamble through the MDIO pin to signal the
  10020. + * beginning of an MII instruction. This is done by sending 32
  10021. + * consecutive "1" bits.
  10022. + */
  10023. + e1000_shift_out_mdi_bits(hw, PHY_PREAMBLE, PHY_PREAMBLE_SIZE);
  10024. +
  10025. + /* Now combine the next few fields that are required for a read
  10026. + * operation. We use this method instead of calling the
  10027. + * e1000_shift_out_mdi_bits routine five different times. The format of
  10028. + * a MII read instruction consists of a shift out of 14 bits and is
  10029. + * defined as follows:
  10030. + * <Preamble><SOF><Op Code><Phy Addr><Reg Addr>
  10031. + * followed by a shift in of 18 bits. This first two bits shifted in
  10032. + * are TurnAround bits used to avoid contention on the MDIO pin when a
  10033. + * READ operation is performed. These two bits are thrown away
  10034. + * followed by a shift in of 16 bits which contains the desired data.
  10035. + */
  10036. + mdic = ((reg_addr) | (phy_addr << 5) |
  10037. + (PHY_OP_READ << 10) | (PHY_SOF << 12));
  10038. +
  10039. + e1000_shift_out_mdi_bits(hw, mdic, 14);
  10040. +
  10041. + /* Now that we've shifted out the read command to the MII, we need to
  10042. + * "shift in" the 16-bit value (18 total bits) of the requested PHY
  10043. + * register address.
  10044. + */
  10045. + *phy_data = e1000_shift_in_mdi_bits(hw);
  10046. + }
  10047. + return E1000_SUCCESS;
  10048. +}
  10049. +
  10050. +/******************************************************************************
  10051. +* Writes a value to a PHY register
  10052. +*
  10053. +* hw - Struct containing variables accessed by shared code
  10054. +* reg_addr - address of the PHY register to write
  10055. +* data - data to write to the PHY
  10056. +******************************************************************************/
  10057. +static int
  10058. +e1000_write_phy_reg(struct e1000_hw *hw,
  10059. + uint32_t reg_addr,
  10060. + uint16_t phy_data)
  10061. +{
  10062. + uint32_t ret_val;
  10063. +
  10064. + DEBUGFUNC("e1000_write_phy_reg");
  10065. +
  10066. + if(hw->phy_type == e1000_phy_igp &&
  10067. + (reg_addr > MAX_PHY_MULTI_PAGE_REG)) {
  10068. + if((ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT,
  10069. + (uint16_t)reg_addr)))
  10070. + return ret_val;
  10071. + }
  10072. +
  10073. + ret_val = e1000_write_phy_reg_ex(hw, IGP01E1000_PHY_PAGE_SELECT & reg_addr,
  10074. + phy_data);
  10075. +
  10076. + return ret_val;
  10077. +}
  10078. +
  10079. +static int
  10080. +e1000_write_phy_reg_ex(struct e1000_hw *hw,
  10081. + uint32_t reg_addr,
  10082. + uint16_t phy_data)
  10083. +{
  10084. + uint32_t i;
  10085. + uint32_t mdic = 0;
  10086. + const uint32_t phy_addr = 1;
  10087. +
  10088. + DEBUGFUNC("e1000_write_phy_reg_ex");
  10089. +
  10090. + if(reg_addr > MAX_PHY_REG_ADDRESS) {
  10091. + DEBUGOUT1("PHY Address %d is out of range\n", reg_addr);
  10092. + return -E1000_ERR_PARAM;
  10093. + }
  10094. +
  10095. + if(hw->mac_type > e1000_82543) {
  10096. + /* Set up Op-code, Phy Address, register address, and data intended
  10097. + * for the PHY register in the MDI Control register. The MAC will take
  10098. + * care of interfacing with the PHY to send the desired data.
  10099. + */
  10100. + mdic = (((uint32_t) phy_data) |
  10101. + (reg_addr << E1000_MDIC_REG_SHIFT) |
  10102. + (phy_addr << E1000_MDIC_PHY_SHIFT) |
  10103. + (E1000_MDIC_OP_WRITE));
  10104. +
  10105. + E1000_WRITE_REG(hw, MDIC, mdic);
  10106. +
  10107. + /* Poll the ready bit to see if the MDI read completed */
  10108. + for(i = 0; i < 640; i++) {
  10109. + udelay(5);
  10110. + mdic = E1000_READ_REG(hw, MDIC);
  10111. + if(mdic & E1000_MDIC_READY) break;
  10112. + }
  10113. + if(!(mdic & E1000_MDIC_READY)) {
  10114. + DEBUGOUT("MDI Write did not complete\n");
  10115. + return -E1000_ERR_PHY;
  10116. + }
  10117. + } else {
  10118. + /* We'll need to use the SW defined pins to shift the write command
  10119. + * out to the PHY. We first send a preamble to the PHY to signal the
  10120. + * beginning of the MII instruction. This is done by sending 32
  10121. + * consecutive "1" bits.
  10122. + */
  10123. + e1000_shift_out_mdi_bits(hw, PHY_PREAMBLE, PHY_PREAMBLE_SIZE);
  10124. +
  10125. + /* Now combine the remaining required fields that will indicate a
  10126. + * write operation. We use this method instead of calling the
  10127. + * e1000_shift_out_mdi_bits routine for each field in the command. The
  10128. + * format of a MII write instruction is as follows:
  10129. + * <Preamble><SOF><Op Code><Phy Addr><Reg Addr><Turnaround><Data>.
  10130. + */
  10131. + mdic = ((PHY_TURNAROUND) | (reg_addr << 2) | (phy_addr << 7) |
  10132. + (PHY_OP_WRITE << 12) | (PHY_SOF << 14));
  10133. + mdic <<= 16;
  10134. + mdic |= (uint32_t) phy_data;
  10135. +
  10136. + e1000_shift_out_mdi_bits(hw, mdic, 32);
  10137. + }
  10138. +
  10139. + return E1000_SUCCESS;
  10140. +}
  10141. +
  10142. +/******************************************************************************
  10143. +* Returns the PHY to the power-on reset state
  10144. +*
  10145. +* hw - Struct containing variables accessed by shared code
  10146. +******************************************************************************/
  10147. +static void
  10148. +e1000_phy_hw_reset(struct e1000_hw *hw)
  10149. +{
  10150. + uint32_t ctrl, ctrl_ext;
  10151. +
  10152. + DEBUGFUNC("e1000_phy_hw_reset");
  10153. +
  10154. + DEBUGOUT("Resetting Phy...\n");
  10155. +
  10156. + if(hw->mac_type > e1000_82543) {
  10157. + /* Read the device control register and assert the E1000_CTRL_PHY_RST
  10158. + * bit. Then, take it out of reset.
  10159. + */
  10160. + ctrl = E1000_READ_REG(hw, CTRL);
  10161. + E1000_WRITE_REG(hw, CTRL, ctrl | E1000_CTRL_PHY_RST);
  10162. + E1000_WRITE_FLUSH(hw);
  10163. + mdelay(10);
  10164. + E1000_WRITE_REG(hw, CTRL, ctrl);
  10165. + E1000_WRITE_FLUSH(hw);
  10166. + } else {
  10167. + /* Read the Extended Device Control Register, assert the PHY_RESET_DIR
  10168. + * bit to put the PHY into reset. Then, take it out of reset.
  10169. + */
  10170. + ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
  10171. + ctrl_ext |= E1000_CTRL_EXT_SDP4_DIR;
  10172. + ctrl_ext &= ~E1000_CTRL_EXT_SDP4_DATA;
  10173. + E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
  10174. + E1000_WRITE_FLUSH(hw);
  10175. + mdelay(10);
  10176. + ctrl_ext |= E1000_CTRL_EXT_SDP4_DATA;
  10177. + E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
  10178. + E1000_WRITE_FLUSH(hw);
  10179. + }
  10180. + udelay(150);
  10181. +}
  10182. +
  10183. +/******************************************************************************
  10184. +* Resets the PHY
  10185. +*
  10186. +* hw - Struct containing variables accessed by shared code
  10187. +*
  10188. +* Sets bit 15 of the MII Control regiser
  10189. +******************************************************************************/
  10190. +static int
  10191. +e1000_phy_reset(struct e1000_hw *hw)
  10192. +{
  10193. + int32_t ret_val;
  10194. + uint16_t phy_data;
  10195. +
  10196. + DEBUGFUNC("e1000_phy_reset");
  10197. +
  10198. + if(hw->mac_type != e1000_82541_rev_2) {
  10199. + if((ret_val = e1000_read_phy_reg(hw, PHY_CTRL, &phy_data)))
  10200. + return ret_val;
  10201. +
  10202. + phy_data |= MII_CR_RESET;
  10203. + if((ret_val = e1000_write_phy_reg(hw, PHY_CTRL, phy_data)))
  10204. + return ret_val;
  10205. +
  10206. + udelay(1);
  10207. + } else e1000_phy_hw_reset(hw);
  10208. +
  10209. + if(hw->phy_type == e1000_phy_igp)
  10210. + e1000_phy_init_script(hw);
  10211. +
  10212. + return E1000_SUCCESS;
  10213. +}
  10214. +
  10215. +/******************************************************************************
  10216. +* Probes the expected PHY address for known PHY IDs
  10217. +*
  10218. +* hw - Struct containing variables accessed by shared code
  10219. +******************************************************************************/
  10220. +static int
  10221. +e1000_detect_gig_phy(struct e1000_hw *hw)
  10222. +{
  10223. + int32_t phy_init_status, ret_val;
  10224. + uint16_t phy_id_high, phy_id_low;
  10225. + boolean_t match = FALSE;
  10226. +
  10227. + DEBUGFUNC("e1000_detect_gig_phy");
  10228. +
  10229. + /* Read the PHY ID Registers to identify which PHY is onboard. */
  10230. + if((ret_val = e1000_read_phy_reg(hw, PHY_ID1, &phy_id_high)))
  10231. + return ret_val;
  10232. +
  10233. + hw->phy_id = (uint32_t) (phy_id_high << 16);
  10234. + udelay(20);
  10235. + if((ret_val = e1000_read_phy_reg(hw, PHY_ID2, &phy_id_low)))
  10236. + return ret_val;
  10237. +
  10238. + hw->phy_id |= (uint32_t) (phy_id_low & PHY_REVISION_MASK);
  10239. +#ifdef LINUX_DRIVER
  10240. + hw->phy_revision = (uint32_t) phy_id_low & ~PHY_REVISION_MASK;
  10241. +#endif
  10242. +
  10243. + switch(hw->mac_type) {
  10244. + case e1000_82543:
  10245. + if(hw->phy_id == M88E1000_E_PHY_ID) match = TRUE;
  10246. + break;
  10247. + case e1000_82544:
  10248. + if(hw->phy_id == M88E1000_I_PHY_ID) match = TRUE;
  10249. + break;
  10250. + case e1000_82540:
  10251. + case e1000_82545:
  10252. + case e1000_82545_rev_3:
  10253. + case e1000_82546:
  10254. + case e1000_82546_rev_3:
  10255. + if(hw->phy_id == M88E1011_I_PHY_ID) match = TRUE;
  10256. + break;
  10257. + case e1000_82541:
  10258. + case e1000_82541_rev_2:
  10259. + case e1000_82547:
  10260. + case e1000_82547_rev_2:
  10261. + if(hw->phy_id == IGP01E1000_I_PHY_ID) match = TRUE;
  10262. + break;
  10263. + default:
  10264. + DEBUGOUT1("Invalid MAC type %d\n", hw->mac_type);
  10265. + return -E1000_ERR_CONFIG;
  10266. + }
  10267. + phy_init_status = e1000_set_phy_type(hw);
  10268. +
  10269. + if ((match) && (phy_init_status == E1000_SUCCESS)) {
  10270. + DEBUGOUT1("PHY ID 0x%X detected\n", hw->phy_id);
  10271. + return E1000_SUCCESS;
  10272. + }
  10273. + DEBUGOUT1("Invalid PHY ID 0x%X\n", hw->phy_id);
  10274. + return -E1000_ERR_PHY;
  10275. +}
  10276. +
  10277. +/******************************************************************************
  10278. + * Sets up eeprom variables in the hw struct. Must be called after mac_type
  10279. + * is configured.
  10280. + *
  10281. + * hw - Struct containing variables accessed by shared code
  10282. + *****************************************************************************/
  10283. +static void
  10284. +e1000_init_eeprom_params(struct e1000_hw *hw)
  10285. +{
  10286. + struct e1000_eeprom_info *eeprom = &hw->eeprom;
  10287. + uint32_t eecd = E1000_READ_REG(hw, EECD);
  10288. + uint16_t eeprom_size;
  10289. +
  10290. + DEBUGFUNC("e1000_init_eeprom_params");
  10291. +
  10292. + switch (hw->mac_type) {
  10293. + case e1000_82542_rev2_0:
  10294. + case e1000_82542_rev2_1:
  10295. + case e1000_82543:
  10296. + case e1000_82544:
  10297. + eeprom->type = e1000_eeprom_microwire;
  10298. + eeprom->word_size = 64;
  10299. + eeprom->opcode_bits = 3;
  10300. + eeprom->address_bits = 6;
  10301. + eeprom->delay_usec = 50;
  10302. + break;
  10303. + case e1000_82540:
  10304. + case e1000_82545:
  10305. + case e1000_82545_rev_3:
  10306. + case e1000_82546:
  10307. + case e1000_82546_rev_3:
  10308. + eeprom->type = e1000_eeprom_microwire;
  10309. + eeprom->opcode_bits = 3;
  10310. + eeprom->delay_usec = 50;
  10311. + if(eecd & E1000_EECD_SIZE) {
  10312. + eeprom->word_size = 256;
  10313. + eeprom->address_bits = 8;
  10314. + } else {
  10315. + eeprom->word_size = 64;
  10316. + eeprom->address_bits = 6;
  10317. + }
  10318. + break;
  10319. + case e1000_82541:
  10320. + case e1000_82541_rev_2:
  10321. + case e1000_82547:
  10322. + case e1000_82547_rev_2:
  10323. + if (eecd & E1000_EECD_TYPE) {
  10324. + eeprom->type = e1000_eeprom_spi;
  10325. + if (eecd & E1000_EECD_ADDR_BITS) {
  10326. + eeprom->page_size = 32;
  10327. + eeprom->address_bits = 16;
  10328. + } else {
  10329. + eeprom->page_size = 8;
  10330. + eeprom->address_bits = 8;
  10331. + }
  10332. + } else {
  10333. + eeprom->type = e1000_eeprom_microwire;
  10334. + eeprom->opcode_bits = 3;
  10335. + eeprom->delay_usec = 50;
  10336. + if (eecd & E1000_EECD_ADDR_BITS) {
  10337. + eeprom->word_size = 256;
  10338. + eeprom->address_bits = 8;
  10339. + } else {
  10340. + eeprom->word_size = 64;
  10341. + eeprom->address_bits = 6;
  10342. + }
  10343. + }
  10344. + break;
  10345. + default:
  10346. + eeprom->type = e1000_eeprom_spi;
  10347. + if (eecd & E1000_EECD_ADDR_BITS) {
  10348. + eeprom->page_size = 32;
  10349. + eeprom->address_bits = 16;
  10350. + } else {
  10351. + eeprom->page_size = 8;
  10352. + eeprom->address_bits = 8;
  10353. + }
  10354. + break;
  10355. + }
  10356. +
  10357. + if (eeprom->type == e1000_eeprom_spi) {
  10358. + eeprom->opcode_bits = 8;
  10359. + eeprom->delay_usec = 1;
  10360. + eeprom->word_size = 64;
  10361. + if (e1000_read_eeprom(hw, EEPROM_CFG, 1, &eeprom_size) == 0) {
  10362. + eeprom_size &= EEPROM_SIZE_MASK;
  10363. +
  10364. + switch (eeprom_size) {
  10365. + case EEPROM_SIZE_16KB:
  10366. + eeprom->word_size = 8192;
  10367. + break;
  10368. + case EEPROM_SIZE_8KB:
  10369. + eeprom->word_size = 4096;
  10370. + break;
  10371. + case EEPROM_SIZE_4KB:
  10372. + eeprom->word_size = 2048;
  10373. + break;
  10374. + case EEPROM_SIZE_2KB:
  10375. + eeprom->word_size = 1024;
  10376. + break;
  10377. + case EEPROM_SIZE_1KB:
  10378. + eeprom->word_size = 512;
  10379. + break;
  10380. + case EEPROM_SIZE_512B:
  10381. + eeprom->word_size = 256;
  10382. + break;
  10383. + case EEPROM_SIZE_128B:
  10384. + default:
  10385. + break;
  10386. + }
  10387. + }
  10388. + }
  10389. +}
  10390. +
  10391. +/**
  10392. + * e1000_reset - Reset the adapter
  10393. + */
  10394. +
  10395. +static int
  10396. +e1000_reset(struct e1000_hw *hw)
  10397. +{
  10398. + uint32_t pba;
  10399. + /* Repartition Pba for greater than 9k mtu
  10400. + * To take effect CTRL.RST is required.
  10401. + */
  10402. +
  10403. + if(hw->mac_type < e1000_82547) {
  10404. + pba = E1000_PBA_48K;
  10405. + } else {
  10406. + pba = E1000_PBA_30K;
  10407. + }
  10408. + E1000_WRITE_REG(hw, PBA, pba);
  10409. +
  10410. + /* flow control settings */
  10411. +#if 0
  10412. + hw->fc_high_water = FC_DEFAULT_HI_THRESH;
  10413. + hw->fc_low_water = FC_DEFAULT_LO_THRESH;
  10414. + hw->fc_pause_time = FC_DEFAULT_TX_TIMER;
  10415. + hw->fc_send_xon = 1;
  10416. + hw->fc = hw->original_fc;
  10417. +#endif
  10418. +
  10419. + e1000_reset_hw(hw);
  10420. + if(hw->mac_type >= e1000_82544)
  10421. + E1000_WRITE_REG(hw, WUC, 0);
  10422. + return e1000_init_hw(hw);
  10423. +}
  10424. +
  10425. +/**
  10426. + * e1000_sw_init - Initialize general software structures (struct e1000_adapter)
  10427. + * @adapter: board private structure to initialize
  10428. + *
  10429. + * e1000_sw_init initializes the Adapter private data structure.
  10430. + * Fields are initialized based on PCI device information and
  10431. + * OS network device settings (MTU size).
  10432. + **/
  10433. +
  10434. +static int
  10435. +e1000_sw_init(struct pci_device *pdev, struct e1000_hw *hw)
  10436. +{
  10437. + int result;
  10438. +
  10439. + /* PCI config space info */
  10440. + pci_read_config_word(pdev, PCI_VENDOR_ID, &hw->vendor_id);
  10441. + pci_read_config_word(pdev, PCI_DEVICE_ID, &hw->device_id);
  10442. + pci_read_config_byte(pdev, PCI_REVISION, &hw->revision_id);
  10443. +#if 0
  10444. + pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID,
  10445. + &hw->subsystem_vendor_id);
  10446. + pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &hw->subsystem_id);
  10447. +#endif
  10448. +
  10449. + pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
  10450. +
  10451. + /* identify the MAC */
  10452. +
  10453. + result = e1000_set_mac_type(hw);
  10454. + if (result) {
  10455. + E1000_ERR("Unknown MAC Type\n");
  10456. + return result;
  10457. + }
  10458. +
  10459. + /* initialize eeprom parameters */
  10460. +
  10461. + e1000_init_eeprom_params(hw);
  10462. +
  10463. +#if 0
  10464. + if((hw->mac_type == e1000_82541) ||
  10465. + (hw->mac_type == e1000_82547) ||
  10466. + (hw->mac_type == e1000_82541_rev_2) ||
  10467. + (hw->mac_type == e1000_82547_rev_2))
  10468. + hw->phy_init_script = 1;
  10469. +#endif
  10470. +
  10471. + e1000_set_media_type(hw);
  10472. +
  10473. +#if 0
  10474. + if(hw->mac_type < e1000_82543)
  10475. + hw->report_tx_early = 0;
  10476. + else
  10477. + hw->report_tx_early = 1;
  10478. +
  10479. + hw->wait_autoneg_complete = FALSE;
  10480. +#endif
  10481. + hw->tbi_compatibility_en = TRUE;
  10482. +#if 0
  10483. + hw->adaptive_ifs = TRUE;
  10484. +
  10485. + /* Copper options */
  10486. +
  10487. + if(hw->media_type == e1000_media_type_copper) {
  10488. + hw->mdix = AUTO_ALL_MODES;
  10489. + hw->disable_polarity_correction = FALSE;
  10490. + hw->master_slave = E1000_MASTER_SLAVE;
  10491. + }
  10492. +#endif
  10493. + return E1000_SUCCESS;
  10494. +}
  10495. +
  10496. +static void fill_rx (void)
  10497. +{
  10498. + struct e1000_rx_desc *rd;
  10499. + rx_last = rx_tail;
  10500. + rd = rx_base + rx_tail;
  10501. + rx_tail = (rx_tail + 1) % 8;
  10502. + memset (rd, 0, 16);
  10503. + rd->buffer_addr = virt_to_bus(&packet);
  10504. + E1000_WRITE_REG (&hw, RDT, rx_tail);
  10505. +}
  10506. +
  10507. +static void init_descriptor (void)
  10508. +{
  10509. + unsigned long ptr;
  10510. + unsigned long tctl;
  10511. +
  10512. + ptr = virt_to_phys(tx_pool);
  10513. + if (ptr & 0xf)
  10514. + ptr = (ptr + 0x10) & (~0xf);
  10515. +
  10516. + tx_base = phys_to_virt(ptr);
  10517. +
  10518. + E1000_WRITE_REG (&hw, TDBAL, virt_to_bus(tx_base));
  10519. + E1000_WRITE_REG (&hw, TDBAH, 0);
  10520. + E1000_WRITE_REG (&hw, TDLEN, 128);
  10521. +
  10522. + /* Setup the HW Tx Head and Tail descriptor pointers */
  10523. +
  10524. + E1000_WRITE_REG (&hw, TDH, 0);
  10525. + E1000_WRITE_REG (&hw, TDT, 0);
  10526. + tx_tail = 0;
  10527. +
  10528. + /* Program the Transmit Control Register */
  10529. +
  10530. +#ifdef LINUX_DRIVER_TCTL
  10531. + tctl = E1000_READ_REG(&hw, TCTL);
  10532. +
  10533. + tctl &= ~E1000_TCTL_CT;
  10534. + tctl |= E1000_TCTL_EN | E1000_TCTL_PSP |
  10535. + (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
  10536. +#else
  10537. + tctl = E1000_TCTL_PSP | E1000_TCTL_EN |
  10538. + (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT) |
  10539. + (E1000_HDX_COLLISION_DISTANCE << E1000_COLD_SHIFT);
  10540. +#endif
  10541. +
  10542. + E1000_WRITE_REG (&hw, TCTL, tctl);
  10543. +
  10544. + e1000_config_collision_dist(&hw);
  10545. +
  10546. +
  10547. + rx_tail = 0;
  10548. + /* disable receive */
  10549. + E1000_WRITE_REG (&hw, RCTL, 0);
  10550. + ptr = virt_to_phys(rx_pool);
  10551. + if (ptr & 0xf)
  10552. + ptr = (ptr + 0x10) & (~0xf);
  10553. + rx_base = phys_to_virt(ptr);
  10554. +
  10555. + /* Setup the Base and Length of the Rx Descriptor Ring */
  10556. +
  10557. + E1000_WRITE_REG (&hw, RDBAL, virt_to_bus(rx_base));
  10558. + E1000_WRITE_REG (&hw, RDBAH, 0);
  10559. +
  10560. + E1000_WRITE_REG (&hw, RDLEN, 128);
  10561. +
  10562. + /* Setup the HW Rx Head and Tail Descriptor Pointers */
  10563. + E1000_WRITE_REG (&hw, RDH, 0);
  10564. + E1000_WRITE_REG (&hw, RDT, 0);
  10565. +
  10566. + E1000_WRITE_REG (&hw, RCTL,
  10567. + E1000_RCTL_EN |
  10568. + E1000_RCTL_BAM |
  10569. + E1000_RCTL_SZ_2048 |
  10570. + E1000_RCTL_MPE);
  10571. + fill_rx();
  10572. +}
  10573. +
  10574. +
  10575. +
  10576. +/**************************************************************************
  10577. +POLL - Wait for a frame
  10578. +***************************************************************************/
  10579. +static int
  10580. +e1000_poll (struct nic *nic, int retrieve)
  10581. +{
  10582. + /* return true if there's an ethernet packet ready to read */
  10583. + /* nic->packet should contain data on return */
  10584. + /* nic->packetlen should contain length of data */
  10585. + struct e1000_rx_desc *rd;
  10586. +
  10587. + rd = rx_base + rx_last;
  10588. + if (!rd->status & E1000_RXD_STAT_DD)
  10589. + return 0;
  10590. +
  10591. + if ( ! retrieve ) return 1;
  10592. +
  10593. + // printf("recv: packet %! -> %! len=%d \n", packet+6, packet,rd->Length);
  10594. + memcpy (nic->packet, packet, rd->length);
  10595. + nic->packetlen = rd->length;
  10596. + fill_rx ();
  10597. + return 1;
  10598. +}
  10599. +
  10600. +/**************************************************************************
  10601. +TRANSMIT - Transmit a frame
  10602. +***************************************************************************/
  10603. +static void
  10604. +e1000_transmit (struct nic *nic, const char *d, /* Destination */
  10605. + unsigned int type, /* Type */
  10606. + unsigned int size, /* size */
  10607. + const char *p) /* Packet */
  10608. +{
  10609. + /* send the packet to destination */
  10610. + struct eth_hdr {
  10611. + unsigned char dst_addr[ETH_ALEN];
  10612. + unsigned char src_addr[ETH_ALEN];
  10613. + unsigned short type;
  10614. + } hdr;
  10615. + struct e1000_tx_desc *txhd; /* header */
  10616. + struct e1000_tx_desc *txp; /* payload */
  10617. + DEBUGFUNC("send");
  10618. +
  10619. + memcpy (&hdr.dst_addr, d, ETH_ALEN);
  10620. + memcpy (&hdr.src_addr, nic->node_addr, ETH_ALEN);
  10621. +
  10622. + hdr.type = htons (type);
  10623. + txhd = tx_base + tx_tail;
  10624. + tx_tail = (tx_tail + 1) % 8;
  10625. + txp = tx_base + tx_tail;
  10626. + tx_tail = (tx_tail + 1) % 8;
  10627. +
  10628. + txhd->buffer_addr = virt_to_bus (&hdr);
  10629. + txhd->lower.data = sizeof (hdr);
  10630. + txhd->upper.data = 0;
  10631. +
  10632. + txp->buffer_addr = virt_to_bus(p);
  10633. + txp->lower.data = E1000_TXD_CMD_RPS | E1000_TXD_CMD_EOP | E1000_TXD_CMD_IFCS | size;
  10634. + txp->upper.data = 0;
  10635. +
  10636. + E1000_WRITE_REG (&hw, TDT, tx_tail);
  10637. + while (!(txp->upper.data & E1000_TXD_STAT_DD)) {
  10638. + udelay(10); /* give the nic a chance to write to the register */
  10639. + poll_interruptions();
  10640. + }
  10641. + DEBUGFUNC("send end");
  10642. +}
  10643. +
  10644. +
  10645. +/**************************************************************************
  10646. +DISABLE - Turn off ethernet interface
  10647. +***************************************************************************/
  10648. +static void e1000_disable (struct dev *dev __unused)
  10649. +{
  10650. + /* Clear the transmit ring */
  10651. + E1000_WRITE_REG (&hw, TDH, 0);
  10652. + E1000_WRITE_REG (&hw, TDT, 0);
  10653. +
  10654. + /* Clear the receive ring */
  10655. + E1000_WRITE_REG (&hw, RDH, 0);
  10656. + E1000_WRITE_REG (&hw, RDT, 0);
  10657. +
  10658. + /* put the card in its initial state */
  10659. + E1000_WRITE_REG (&hw, CTRL, E1000_CTRL_RST);
  10660. +
  10661. + /* Turn off the ethernet interface */
  10662. + E1000_WRITE_REG (&hw, RCTL, 0);
  10663. + E1000_WRITE_REG (&hw, TCTL, 0);
  10664. + mdelay (10);
  10665. +
  10666. + /* Unmap my window to the device */
  10667. + iounmap(hw.hw_addr);
  10668. +}
  10669. +
  10670. +/**************************************************************************
  10671. +IRQ - Enable, Disable, or Force interrupts
  10672. +***************************************************************************/
  10673. +static void e1000_irq(struct nic *nic __unused, irq_action_t action __unused)
  10674. +{
  10675. + switch ( action ) {
  10676. + case DISABLE :
  10677. + break;
  10678. + case ENABLE :
  10679. + break;
  10680. + case FORCE :
  10681. + break;
  10682. + }
  10683. +}
  10684. +
  10685. +#define IORESOURCE_IO 0x00000100 /* Resource type */
  10686. +#define BAR_0 0
  10687. +#define BAR_1 1
  10688. +#define BAR_5 5
  10689. +
  10690. +/**************************************************************************
  10691. +PROBE - Look for an adapter, this routine's visible to the outside
  10692. +You should omit the last argument struct pci_device * for a non-PCI NIC
  10693. +***************************************************************************/
  10694. +static int e1000_probe(struct dev *dev, struct pci_device *p)
  10695. +{
  10696. + struct nic *nic = (struct nic *)dev;
  10697. + unsigned long mmio_start, mmio_len;
  10698. + int ret_val, i;
  10699. +
  10700. + if (p == 0)
  10701. + return 0;
  10702. + /* Initialize hw with default values */
  10703. + memset(&hw, 0, sizeof(hw));
  10704. + hw.pdev = p;
  10705. +
  10706. +#if 1
  10707. + /* Are these variables needed? */
  10708. + hw.fc = e1000_fc_none;
  10709. +#if 0
  10710. + hw.original_fc = e1000_fc_none;
  10711. +#endif
  10712. + hw.autoneg_failed = 0;
  10713. +#if 0
  10714. + hw.get_link_status = TRUE;
  10715. +#endif
  10716. +#endif
  10717. +
  10718. + mmio_start = pci_bar_start(p, PCI_BASE_ADDRESS_0);
  10719. + mmio_len = pci_bar_size(p, PCI_BASE_ADDRESS_0);
  10720. + hw.hw_addr = ioremap(mmio_start, mmio_len);
  10721. +
  10722. + for(i = BAR_1; i <= BAR_5; i++) {
  10723. + if(pci_bar_size(p, i) == 0)
  10724. + continue;
  10725. + if(pci_find_capability(p, i) & IORESOURCE_IO) {
  10726. + hw.io_base = pci_bar_start(p, i);
  10727. + break;
  10728. + }
  10729. + }
  10730. +
  10731. + adjust_pci_device(p);
  10732. +
  10733. + nic->ioaddr = p->ioaddr & ~3;
  10734. + nic->irqno = 0;
  10735. +
  10736. + /* From Matt Hortman <mbhortman@acpthinclient.com> */
  10737. + /* MAC and Phy settings */
  10738. +
  10739. + /* setup the private structure */
  10740. + if (e1000_sw_init(p, &hw) < 0) {
  10741. + iounmap(hw.hw_addr);
  10742. + return 0;
  10743. + }
  10744. +
  10745. + /* make sure the EEPROM is good */
  10746. +
  10747. + if (e1000_validate_eeprom_checksum(&hw) < 0) {
  10748. + printf ("The EEPROM Checksum Is Not Valid\n");
  10749. + iounmap(hw.hw_addr);
  10750. + return 0;
  10751. + }
  10752. +
  10753. + /* copy the MAC address out of the EEPROM */
  10754. +
  10755. + e1000_read_mac_addr(&hw);
  10756. + memcpy (nic->node_addr, hw.mac_addr, ETH_ALEN);
  10757. +
  10758. + printf("Ethernet addr: %!\n", nic->node_addr);
  10759. +
  10760. + /* reset the hardware with the new settings */
  10761. +
  10762. + ret_val = e1000_reset(&hw);
  10763. + if (ret_val < 0) {
  10764. + if ((ret_val == -E1000_ERR_NOLINK) ||
  10765. + (ret_val == -E1000_ERR_TIMEOUT)) {
  10766. + E1000_ERR("Valid Link not detected\n");
  10767. + } else {
  10768. + E1000_ERR("Hardware Initialization Failed\n");
  10769. + }
  10770. + iounmap(hw.hw_addr);
  10771. + return 0;
  10772. + }
  10773. + init_descriptor();
  10774. +
  10775. + /* point to NIC specific routines */
  10776. + dev->disable = e1000_disable;
  10777. + nic->poll = e1000_poll;
  10778. + nic->transmit = e1000_transmit;
  10779. + nic->irq = e1000_irq;
  10780. +
  10781. + return 1;
  10782. +}
  10783. +
  10784. +static struct pci_id e1000_nics[] = {
  10785. +PCI_ROM(0x8086, 0x1000, "e1000-82542", "Intel EtherExpressPro1000"),
  10786. +PCI_ROM(0x8086, 0x1001, "e1000-82543gc-fiber", "Intel EtherExpressPro1000 82543GC Fiber"),
  10787. +PCI_ROM(0x8086, 0x1004, "e1000-82543gc-copper", "Intel EtherExpressPro1000 82543GC Copper"),
  10788. +PCI_ROM(0x8086, 0x1008, "e1000-82544ei-copper", "Intel EtherExpressPro1000 82544EI Copper"),
  10789. +PCI_ROM(0x8086, 0x1009, "e1000-82544ei-fiber", "Intel EtherExpressPro1000 82544EI Fiber"),
  10790. +PCI_ROM(0x8086, 0x100C, "e1000-82544gc-copper", "Intel EtherExpressPro1000 82544GC Copper"),
  10791. +PCI_ROM(0x8086, 0x100D, "e1000-82544gc-lom", "Intel EtherExpressPro1000 82544GC LOM"),
  10792. +PCI_ROM(0x8086, 0x100E, "e1000-82540em", "Intel EtherExpressPro1000 82540EM"),
  10793. +PCI_ROM(0x8086, 0x100F, "e1000-82545em-copper", "Intel EtherExpressPro1000 82545EM Copper"),
  10794. +PCI_ROM(0x8086, 0x1010, "e1000-82546eb-copper", "Intel EtherExpressPro1000 82546EB Copper"),
  10795. +PCI_ROM(0x8086, 0x1011, "e1000-82545em-fiber", "Intel EtherExpressPro1000 82545EM Fiber"),
  10796. +PCI_ROM(0x8086, 0x1012, "e1000-82546eb-fiber", "Intel EtherExpressPro1000 82546EB Copper"),
  10797. +PCI_ROM(0x8086, 0x1013, "e1000-82541ei", "Intel EtherExpressPro1000 82541EI"),
  10798. +PCI_ROM(0x8086, 0x1015, "e1000-82540em-lom", "Intel EtherExpressPro1000 82540EM LOM"),
  10799. +PCI_ROM(0x8086, 0x1016, "e1000-82540ep-lom", "Intel EtherExpressPro1000 82540EP LOM"),
  10800. +PCI_ROM(0x8086, 0x1017, "e1000-82540ep", "Intel EtherExpressPro1000 82540EP"),
  10801. +PCI_ROM(0x8086, 0x1018, "e1000-82541ep", "Intel EtherExpressPro1000 82541EP"),
  10802. +PCI_ROM(0x8086, 0x1019, "e1000-82547ei", "Intel EtherExpressPro1000 82547EI"),
  10803. +PCI_ROM(0x8086, 0x101d, "e1000-82546eb-quad-copper", "Intel EtherExpressPro1000 82546EB Quad Copper"),
  10804. +PCI_ROM(0x8086, 0x101e, "e1000-82540ep-lp", "Intel EtherExpressPro1000 82540EP LP"),
  10805. +PCI_ROM(0x8086, 0x1026, "e1000-82545gm-copper", "Intel EtherExpressPro1000 82545GM Copper"),
  10806. +PCI_ROM(0x8086, 0x1027, "e1000-82545gm-fiber", "Intel EtherExpressPro1000 82545GM Fiber"),
  10807. +PCI_ROM(0x8086, 0x1028, "e1000-82545gm-serdes", "Intel EtherExpressPro1000 82545GM SERDES"),
  10808. +PCI_ROM(0x8086, 0x1075, "e1000-82547gi", "Intel EtherExpressPro1000 82547GI"),
  10809. +PCI_ROM(0x8086, 0x1076, "e1000-82541gi", "Intel EtherExpressPro1000 82541GI"),
  10810. +PCI_ROM(0x8086, 0x1077, "e1000-82541gi-mobile", "Intel EtherExpressPro1000 82541GI Mobile"),
  10811. +PCI_ROM(0x8086, 0x1078, "e1000-82541er", "Intel EtherExpressPro1000 82541ER"),
  10812. +PCI_ROM(0x8086, 0x1079, "e1000-82546gb-copper", "Intel EtherExpressPro1000 82546GB Copper"),
  10813. +PCI_ROM(0x8086, 0x107a, "e1000-82546gb-fiber", "Intel EtherExpressPro1000 82546GB Fiber"),
  10814. +PCI_ROM(0x8086, 0x107b, "e1000-82546gb-serdes", "Intel EtherExpressPro1000 82546GB SERDES"),
  10815. +};
  10816. +
  10817. +struct pci_driver e1000_driver = {
  10818. + .type = NIC_DRIVER,
  10819. + .name = "E1000",
  10820. + .probe = e1000_probe,
  10821. + .ids = e1000_nics,
  10822. + .id_count = sizeof(e1000_nics)/sizeof(e1000_nics[0]),
  10823. + .class = 0,
  10824. +};
  10825. diff -Naur grub-0.97.orig/netboot/e1000_hw.h grub-0.97/netboot/e1000_hw.h
  10826. --- grub-0.97.orig/netboot/e1000_hw.h 1970-01-01 00:00:00.000000000 +0000
  10827. +++ grub-0.97/netboot/e1000_hw.h 2005-08-31 19:03:35.000000000 +0000
  10828. @@ -0,0 +1,2058 @@
  10829. +/*******************************************************************************
  10830. +
  10831. +
  10832. + Copyright(c) 1999 - 2003 Intel Corporation. All rights reserved.
  10833. +
  10834. + This program is free software; you can redistribute it and/or modify it
  10835. + under the terms of the GNU General Public License as published by the Free
  10836. + Software Foundation; either version 2 of the License, or (at your option)
  10837. + any later version.
  10838. +
  10839. + This program is distributed in the hope that it will be useful, but WITHOUT
  10840. + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10841. + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  10842. + more details.
  10843. +
  10844. + You should have received a copy of the GNU General Public License along with
  10845. + this program; if not, write to the Free Software Foundation, Inc., 59
  10846. + Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  10847. +
  10848. + The full GNU General Public License is included in this distribution in the
  10849. + file called LICENSE.
  10850. +
  10851. + Contact Information:
  10852. + Linux NICS <linux.nics@intel.com>
  10853. + Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  10854. +
  10855. +*******************************************************************************/
  10856. +
  10857. +/* e1000_hw.h
  10858. + * Structures, enums, and macros for the MAC
  10859. + */
  10860. +
  10861. +#ifndef _E1000_HW_H_
  10862. +#define _E1000_HW_H_
  10863. +
  10864. +/* Forward declarations of structures used by the shared code */
  10865. +struct e1000_hw;
  10866. +struct e1000_hw_stats;
  10867. +
  10868. +/* Enumerated types specific to the e1000 hardware */
  10869. +/* Media Access Controlers */
  10870. +typedef enum {
  10871. + e1000_undefined = 0,
  10872. + e1000_82542_rev2_0,
  10873. + e1000_82542_rev2_1,
  10874. + e1000_82543,
  10875. + e1000_82544,
  10876. + e1000_82540,
  10877. + e1000_82545,
  10878. + e1000_82545_rev_3,
  10879. + e1000_82546,
  10880. + e1000_82546_rev_3,
  10881. + e1000_82541,
  10882. + e1000_82541_rev_2,
  10883. + e1000_82547,
  10884. + e1000_82547_rev_2,
  10885. + e1000_num_macs
  10886. +} e1000_mac_type;
  10887. +
  10888. +typedef enum {
  10889. + e1000_eeprom_uninitialized = 0,
  10890. + e1000_eeprom_spi,
  10891. + e1000_eeprom_microwire,
  10892. + e1000_num_eeprom_types
  10893. +} e1000_eeprom_type;
  10894. +
  10895. +/* Media Types */
  10896. +typedef enum {
  10897. + e1000_media_type_copper = 0,
  10898. + e1000_media_type_fiber = 1,
  10899. + e1000_media_type_internal_serdes = 2,
  10900. + e1000_num_media_types
  10901. +} e1000_media_type;
  10902. +
  10903. +typedef enum {
  10904. + e1000_10_half = 0,
  10905. + e1000_10_full = 1,
  10906. + e1000_100_half = 2,
  10907. + e1000_100_full = 3
  10908. +} e1000_speed_duplex_type;
  10909. +
  10910. +/* Flow Control Settings */
  10911. +typedef enum {
  10912. + e1000_fc_none = 0,
  10913. + e1000_fc_rx_pause = 1,
  10914. + e1000_fc_tx_pause = 2,
  10915. + e1000_fc_full = 3,
  10916. + e1000_fc_default = 0xFF
  10917. +} e1000_fc_type;
  10918. +
  10919. +/* PCI bus types */
  10920. +typedef enum {
  10921. + e1000_bus_type_unknown = 0,
  10922. + e1000_bus_type_pci,
  10923. + e1000_bus_type_pcix,
  10924. + e1000_bus_type_reserved
  10925. +} e1000_bus_type;
  10926. +
  10927. +/* PCI bus speeds */
  10928. +typedef enum {
  10929. + e1000_bus_speed_unknown = 0,
  10930. + e1000_bus_speed_33,
  10931. + e1000_bus_speed_66,
  10932. + e1000_bus_speed_100,
  10933. + e1000_bus_speed_120,
  10934. + e1000_bus_speed_133,
  10935. + e1000_bus_speed_reserved
  10936. +} e1000_bus_speed;
  10937. +
  10938. +/* PCI bus widths */
  10939. +typedef enum {
  10940. + e1000_bus_width_unknown = 0,
  10941. + e1000_bus_width_32,
  10942. + e1000_bus_width_64,
  10943. + e1000_bus_width_reserved
  10944. +} e1000_bus_width;
  10945. +
  10946. +/* PHY status info structure and supporting enums */
  10947. +typedef enum {
  10948. + e1000_cable_length_50 = 0,
  10949. + e1000_cable_length_50_80,
  10950. + e1000_cable_length_80_110,
  10951. + e1000_cable_length_110_140,
  10952. + e1000_cable_length_140,
  10953. + e1000_cable_length_undefined = 0xFF
  10954. +} e1000_cable_length;
  10955. +
  10956. +typedef enum {
  10957. + e1000_igp_cable_length_10 = 10,
  10958. + e1000_igp_cable_length_20 = 20,
  10959. + e1000_igp_cable_length_30 = 30,
  10960. + e1000_igp_cable_length_40 = 40,
  10961. + e1000_igp_cable_length_50 = 50,
  10962. + e1000_igp_cable_length_60 = 60,
  10963. + e1000_igp_cable_length_70 = 70,
  10964. + e1000_igp_cable_length_80 = 80,
  10965. + e1000_igp_cable_length_90 = 90,
  10966. + e1000_igp_cable_length_100 = 100,
  10967. + e1000_igp_cable_length_110 = 110,
  10968. + e1000_igp_cable_length_120 = 120,
  10969. + e1000_igp_cable_length_130 = 130,
  10970. + e1000_igp_cable_length_140 = 140,
  10971. + e1000_igp_cable_length_150 = 150,
  10972. + e1000_igp_cable_length_160 = 160,
  10973. + e1000_igp_cable_length_170 = 170,
  10974. + e1000_igp_cable_length_180 = 180
  10975. +} e1000_igp_cable_length;
  10976. +
  10977. +typedef enum {
  10978. + e1000_10bt_ext_dist_enable_normal = 0,
  10979. + e1000_10bt_ext_dist_enable_lower,
  10980. + e1000_10bt_ext_dist_enable_undefined = 0xFF
  10981. +} e1000_10bt_ext_dist_enable;
  10982. +
  10983. +typedef enum {
  10984. + e1000_rev_polarity_normal = 0,
  10985. + e1000_rev_polarity_reversed,
  10986. + e1000_rev_polarity_undefined = 0xFF
  10987. +} e1000_rev_polarity;
  10988. +
  10989. +typedef enum {
  10990. + e1000_downshift_normal = 0,
  10991. + e1000_downshift_activated,
  10992. + e1000_downshift_undefined = 0xFF
  10993. +} e1000_downshift;
  10994. +
  10995. +typedef enum {
  10996. + e1000_polarity_reversal_enabled = 0,
  10997. + e1000_polarity_reversal_disabled,
  10998. + e1000_polarity_reversal_undefined = 0xFF
  10999. +} e1000_polarity_reversal;
  11000. +
  11001. +typedef enum {
  11002. + e1000_auto_x_mode_manual_mdi = 0,
  11003. + e1000_auto_x_mode_manual_mdix,
  11004. + e1000_auto_x_mode_auto1,
  11005. + e1000_auto_x_mode_auto2,
  11006. + e1000_auto_x_mode_undefined = 0xFF
  11007. +} e1000_auto_x_mode;
  11008. +
  11009. +typedef enum {
  11010. + e1000_1000t_rx_status_not_ok = 0,
  11011. + e1000_1000t_rx_status_ok,
  11012. + e1000_1000t_rx_status_undefined = 0xFF
  11013. +} e1000_1000t_rx_status;
  11014. +
  11015. +typedef enum {
  11016. + e1000_phy_m88 = 0,
  11017. + e1000_phy_igp,
  11018. + e1000_phy_undefined = 0xFF
  11019. +} e1000_phy_type;
  11020. +
  11021. +typedef enum {
  11022. + e1000_ms_hw_default = 0,
  11023. + e1000_ms_force_master,
  11024. + e1000_ms_force_slave,
  11025. + e1000_ms_auto
  11026. +} e1000_ms_type;
  11027. +
  11028. +typedef enum {
  11029. + e1000_ffe_config_enabled = 0,
  11030. + e1000_ffe_config_active,
  11031. + e1000_ffe_config_blocked
  11032. +} e1000_ffe_config;
  11033. +
  11034. +typedef enum {
  11035. + e1000_dsp_config_disabled = 0,
  11036. + e1000_dsp_config_enabled,
  11037. + e1000_dsp_config_activated,
  11038. + e1000_dsp_config_undefined = 0xFF
  11039. +} e1000_dsp_config;
  11040. +
  11041. +struct e1000_phy_info {
  11042. + e1000_cable_length cable_length;
  11043. + e1000_10bt_ext_dist_enable extended_10bt_distance;
  11044. + e1000_rev_polarity cable_polarity;
  11045. + e1000_downshift downshift;
  11046. + e1000_polarity_reversal polarity_correction;
  11047. + e1000_auto_x_mode mdix_mode;
  11048. + e1000_1000t_rx_status local_rx;
  11049. + e1000_1000t_rx_status remote_rx;
  11050. +};
  11051. +
  11052. +struct e1000_phy_stats {
  11053. + uint32_t idle_errors;
  11054. + uint32_t receive_errors;
  11055. +};
  11056. +
  11057. +struct e1000_eeprom_info {
  11058. + e1000_eeprom_type type;
  11059. + uint16_t word_size;
  11060. + uint16_t opcode_bits;
  11061. + uint16_t address_bits;
  11062. + uint16_t delay_usec;
  11063. + uint16_t page_size;
  11064. +};
  11065. +
  11066. +
  11067. +
  11068. +/* Error Codes */
  11069. +#define E1000_SUCCESS 0
  11070. +#define E1000_ERR_EEPROM 1
  11071. +#define E1000_ERR_PHY 2
  11072. +#define E1000_ERR_CONFIG 3
  11073. +#define E1000_ERR_PARAM 4
  11074. +#define E1000_ERR_MAC_TYPE 5
  11075. +#define E1000_ERR_PHY_TYPE 6
  11076. +#define E1000_ERR_NOLINK 7
  11077. +#define E1000_ERR_TIMEOUT 8
  11078. +
  11079. +#define E1000_READ_REG_IO(a, reg) \
  11080. + e1000_read_reg_io((a), E1000_##reg)
  11081. +#define E1000_WRITE_REG_IO(a, reg, val) \
  11082. + e1000_write_reg_io((a), E1000_##reg, val)
  11083. +
  11084. +/* PCI Device IDs */
  11085. +#define E1000_DEV_ID_82542 0x1000
  11086. +#define E1000_DEV_ID_82543GC_FIBER 0x1001
  11087. +#define E1000_DEV_ID_82543GC_COPPER 0x1004
  11088. +#define E1000_DEV_ID_82544EI_COPPER 0x1008
  11089. +#define E1000_DEV_ID_82544EI_FIBER 0x1009
  11090. +#define E1000_DEV_ID_82544GC_COPPER 0x100C
  11091. +#define E1000_DEV_ID_82544GC_LOM 0x100D
  11092. +#define E1000_DEV_ID_82540EM 0x100E
  11093. +#define E1000_DEV_ID_82540EM_LOM 0x1015
  11094. +#define E1000_DEV_ID_82540EP_LOM 0x1016
  11095. +#define E1000_DEV_ID_82540EP 0x1017
  11096. +#define E1000_DEV_ID_82540EP_LP 0x101E
  11097. +#define E1000_DEV_ID_82545EM_COPPER 0x100F
  11098. +#define E1000_DEV_ID_82545EM_FIBER 0x1011
  11099. +#define E1000_DEV_ID_82545GM_COPPER 0x1026
  11100. +#define E1000_DEV_ID_82545GM_FIBER 0x1027
  11101. +#define E1000_DEV_ID_82545GM_SERDES 0x1028
  11102. +#define E1000_DEV_ID_82546EB_COPPER 0x1010
  11103. +#define E1000_DEV_ID_82546EB_FIBER 0x1012
  11104. +#define E1000_DEV_ID_82546EB_QUAD_COPPER 0x101D
  11105. +#define E1000_DEV_ID_82541EI 0x1013
  11106. +#define E1000_DEV_ID_82541EI_MOBILE 0x1018
  11107. +#define E1000_DEV_ID_82541ER 0x1078
  11108. +#define E1000_DEV_ID_82547GI 0x1075
  11109. +#define E1000_DEV_ID_82541GI 0x1076
  11110. +#define E1000_DEV_ID_82541GI_MOBILE 0x1077
  11111. +#define E1000_DEV_ID_82546GB_COPPER 0x1079
  11112. +#define E1000_DEV_ID_82546GB_FIBER 0x107A
  11113. +#define E1000_DEV_ID_82546GB_SERDES 0x107B
  11114. +#define E1000_DEV_ID_82547EI 0x1019
  11115. +
  11116. +#define NODE_ADDRESS_SIZE 6
  11117. +#define ETH_LENGTH_OF_ADDRESS 6
  11118. +
  11119. +/* MAC decode size is 128K - This is the size of BAR0 */
  11120. +#define MAC_DECODE_SIZE (128 * 1024)
  11121. +
  11122. +#define E1000_82542_2_0_REV_ID 2
  11123. +#define E1000_82542_2_1_REV_ID 3
  11124. +
  11125. +#define SPEED_10 10
  11126. +#define SPEED_100 100
  11127. +#define SPEED_1000 1000
  11128. +#define HALF_DUPLEX 1
  11129. +#define FULL_DUPLEX 2
  11130. +
  11131. +/* The sizes (in bytes) of a ethernet packet */
  11132. +#define ENET_HEADER_SIZE 14
  11133. +#define MAXIMUM_ETHERNET_FRAME_SIZE 1518 /* With FCS */
  11134. +#define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */
  11135. +#define ETHERNET_FCS_SIZE 4
  11136. +#define MAXIMUM_ETHERNET_PACKET_SIZE \
  11137. + (MAXIMUM_ETHERNET_FRAME_SIZE - ETHERNET_FCS_SIZE)
  11138. +#define MINIMUM_ETHERNET_PACKET_SIZE \
  11139. + (MINIMUM_ETHERNET_FRAME_SIZE - ETHERNET_FCS_SIZE)
  11140. +#define CRC_LENGTH ETHERNET_FCS_SIZE
  11141. +#define MAX_JUMBO_FRAME_SIZE 0x3F00
  11142. +
  11143. +
  11144. +/* 802.1q VLAN Packet Sizes */
  11145. +#define VLAN_TAG_SIZE 4 /* 802.3ac tag (not DMAed) */
  11146. +
  11147. +/* Ethertype field values */
  11148. +#define ETHERNET_IEEE_VLAN_TYPE 0x8100 /* 802.3ac packet */
  11149. +#define ETHERNET_IP_TYPE 0x0800 /* IP packets */
  11150. +#define ETHERNET_ARP_TYPE 0x0806 /* Address Resolution Protocol (ARP) */
  11151. +
  11152. +/* Packet Header defines */
  11153. +#define IP_PROTOCOL_TCP 6
  11154. +#define IP_PROTOCOL_UDP 0x11
  11155. +
  11156. +/* This defines the bits that are set in the Interrupt Mask
  11157. + * Set/Read Register. Each bit is documented below:
  11158. + * o RXDMT0 = Receive Descriptor Minimum Threshold hit (ring 0)
  11159. + * o RXSEQ = Receive Sequence Error
  11160. + */
  11161. +#define POLL_IMS_ENABLE_MASK ( \
  11162. + E1000_IMS_RXDMT0 | \
  11163. + E1000_IMS_RXSEQ)
  11164. +
  11165. +/* This defines the bits that are set in the Interrupt Mask
  11166. + * Set/Read Register. Each bit is documented below:
  11167. + * o RXT0 = Receiver Timer Interrupt (ring 0)
  11168. + * o TXDW = Transmit Descriptor Written Back
  11169. + * o RXDMT0 = Receive Descriptor Minimum Threshold hit (ring 0)
  11170. + * o RXSEQ = Receive Sequence Error
  11171. + * o LSC = Link Status Change
  11172. + */
  11173. +#define IMS_ENABLE_MASK ( \
  11174. + E1000_IMS_RXT0 | \
  11175. + E1000_IMS_TXDW | \
  11176. + E1000_IMS_RXDMT0 | \
  11177. + E1000_IMS_RXSEQ | \
  11178. + E1000_IMS_LSC)
  11179. +
  11180. +/* Number of high/low register pairs in the RAR. The RAR (Receive Address
  11181. + * Registers) holds the directed and multicast addresses that we monitor. We
  11182. + * reserve one of these spots for our directed address, allowing us room for
  11183. + * E1000_RAR_ENTRIES - 1 multicast addresses.
  11184. + */
  11185. +#define E1000_RAR_ENTRIES 15
  11186. +
  11187. +#define MIN_NUMBER_OF_DESCRIPTORS 8
  11188. +#define MAX_NUMBER_OF_DESCRIPTORS 0xFFF8
  11189. +
  11190. +/* Receive Descriptor */
  11191. +struct e1000_rx_desc {
  11192. + uint64_t buffer_addr; /* Address of the descriptor's data buffer */
  11193. + uint16_t length; /* Length of data DMAed into data buffer */
  11194. + uint16_t csum; /* Packet checksum */
  11195. + uint8_t status; /* Descriptor status */
  11196. + uint8_t errors; /* Descriptor Errors */
  11197. + uint16_t special;
  11198. +};
  11199. +
  11200. +/* Receive Decriptor bit definitions */
  11201. +#define E1000_RXD_STAT_DD 0x01 /* Descriptor Done */
  11202. +#define E1000_RXD_STAT_EOP 0x02 /* End of Packet */
  11203. +#define E1000_RXD_STAT_IXSM 0x04 /* Ignore checksum */
  11204. +#define E1000_RXD_STAT_VP 0x08 /* IEEE VLAN Packet */
  11205. +#define E1000_RXD_STAT_TCPCS 0x20 /* TCP xsum calculated */
  11206. +#define E1000_RXD_STAT_IPCS 0x40 /* IP xsum calculated */
  11207. +#define E1000_RXD_STAT_PIF 0x80 /* passed in-exact filter */
  11208. +#define E1000_RXD_ERR_CE 0x01 /* CRC Error */
  11209. +#define E1000_RXD_ERR_SE 0x02 /* Symbol Error */
  11210. +#define E1000_RXD_ERR_SEQ 0x04 /* Sequence Error */
  11211. +#define E1000_RXD_ERR_CXE 0x10 /* Carrier Extension Error */
  11212. +#define E1000_RXD_ERR_TCPE 0x20 /* TCP/UDP Checksum Error */
  11213. +#define E1000_RXD_ERR_IPE 0x40 /* IP Checksum Error */
  11214. +#define E1000_RXD_ERR_RXE 0x80 /* Rx Data Error */
  11215. +#define E1000_RXD_SPC_VLAN_MASK 0x0FFF /* VLAN ID is in lower 12 bits */
  11216. +#define E1000_RXD_SPC_PRI_MASK 0xE000 /* Priority is in upper 3 bits */
  11217. +#define E1000_RXD_SPC_PRI_SHIFT 0x000D /* Priority is in upper 3 of 16 */
  11218. +#define E1000_RXD_SPC_CFI_MASK 0x1000 /* CFI is bit 12 */
  11219. +#define E1000_RXD_SPC_CFI_SHIFT 0x000C /* CFI is bit 12 */
  11220. +
  11221. +/* mask to determine if packets should be dropped due to frame errors */
  11222. +#define E1000_RXD_ERR_FRAME_ERR_MASK ( \
  11223. + E1000_RXD_ERR_CE | \
  11224. + E1000_RXD_ERR_SE | \
  11225. + E1000_RXD_ERR_SEQ | \
  11226. + E1000_RXD_ERR_CXE | \
  11227. + E1000_RXD_ERR_RXE)
  11228. +
  11229. +/* Transmit Descriptor */
  11230. +struct e1000_tx_desc {
  11231. + uint64_t buffer_addr; /* Address of the descriptor's data buffer */
  11232. + union {
  11233. + uint32_t data;
  11234. + struct {
  11235. + uint16_t length; /* Data buffer length */
  11236. + uint8_t cso; /* Checksum offset */
  11237. + uint8_t cmd; /* Descriptor control */
  11238. + } flags;
  11239. + } lower;
  11240. + union {
  11241. + uint32_t data;
  11242. + struct {
  11243. + uint8_t status; /* Descriptor status */
  11244. + uint8_t css; /* Checksum start */
  11245. + uint16_t special;
  11246. + } fields;
  11247. + } upper;
  11248. +};
  11249. +
  11250. +/* Transmit Descriptor bit definitions */
  11251. +#define E1000_TXD_DTYP_D 0x00100000 /* Data Descriptor */
  11252. +#define E1000_TXD_DTYP_C 0x00000000 /* Context Descriptor */
  11253. +#define E1000_TXD_POPTS_IXSM 0x01 /* Insert IP checksum */
  11254. +#define E1000_TXD_POPTS_TXSM 0x02 /* Insert TCP/UDP checksum */
  11255. +#define E1000_TXD_CMD_EOP 0x01000000 /* End of Packet */
  11256. +#define E1000_TXD_CMD_IFCS 0x02000000 /* Insert FCS (Ethernet CRC) */
  11257. +#define E1000_TXD_CMD_IC 0x04000000 /* Insert Checksum */
  11258. +#define E1000_TXD_CMD_RS 0x08000000 /* Report Status */
  11259. +#define E1000_TXD_CMD_RPS 0x10000000 /* Report Packet Sent */
  11260. +#define E1000_TXD_CMD_DEXT 0x20000000 /* Descriptor extension (0 = legacy) */
  11261. +#define E1000_TXD_CMD_VLE 0x40000000 /* Add VLAN tag */
  11262. +#define E1000_TXD_CMD_IDE 0x80000000 /* Enable Tidv register */
  11263. +#define E1000_TXD_STAT_DD 0x00000001 /* Descriptor Done */
  11264. +#define E1000_TXD_STAT_EC 0x00000002 /* Excess Collisions */
  11265. +#define E1000_TXD_STAT_LC 0x00000004 /* Late Collisions */
  11266. +#define E1000_TXD_STAT_TU 0x00000008 /* Transmit underrun */
  11267. +#define E1000_TXD_CMD_TCP 0x01000000 /* TCP packet */
  11268. +#define E1000_TXD_CMD_IP 0x02000000 /* IP packet */
  11269. +#define E1000_TXD_CMD_TSE 0x04000000 /* TCP Seg enable */
  11270. +#define E1000_TXD_STAT_TC 0x00000004 /* Tx Underrun */
  11271. +
  11272. +/* Offload Context Descriptor */
  11273. +struct e1000_context_desc {
  11274. + union {
  11275. + uint32_t ip_config;
  11276. + struct {
  11277. + uint8_t ipcss; /* IP checksum start */
  11278. + uint8_t ipcso; /* IP checksum offset */
  11279. + uint16_t ipcse; /* IP checksum end */
  11280. + } ip_fields;
  11281. + } lower_setup;
  11282. + union {
  11283. + uint32_t tcp_config;
  11284. + struct {
  11285. + uint8_t tucss; /* TCP checksum start */
  11286. + uint8_t tucso; /* TCP checksum offset */
  11287. + uint16_t tucse; /* TCP checksum end */
  11288. + } tcp_fields;
  11289. + } upper_setup;
  11290. + uint32_t cmd_and_length; /* */
  11291. + union {
  11292. + uint32_t data;
  11293. + struct {
  11294. + uint8_t status; /* Descriptor status */
  11295. + uint8_t hdr_len; /* Header length */
  11296. + uint16_t mss; /* Maximum segment size */
  11297. + } fields;
  11298. + } tcp_seg_setup;
  11299. +};
  11300. +
  11301. +/* Offload data descriptor */
  11302. +struct e1000_data_desc {
  11303. + uint64_t buffer_addr; /* Address of the descriptor's buffer address */
  11304. + union {
  11305. + uint32_t data;
  11306. + struct {
  11307. + uint16_t length; /* Data buffer length */
  11308. + uint8_t typ_len_ext; /* */
  11309. + uint8_t cmd; /* */
  11310. + } flags;
  11311. + } lower;
  11312. + union {
  11313. + uint32_t data;
  11314. + struct {
  11315. + uint8_t status; /* Descriptor status */
  11316. + uint8_t popts; /* Packet Options */
  11317. + uint16_t special; /* */
  11318. + } fields;
  11319. + } upper;
  11320. +};
  11321. +
  11322. +/* Filters */
  11323. +#define E1000_NUM_UNICAST 16 /* Unicast filter entries */
  11324. +#define E1000_MC_TBL_SIZE 128 /* Multicast Filter Table (4096 bits) */
  11325. +#define E1000_VLAN_FILTER_TBL_SIZE 128 /* VLAN Filter Table (4096 bits) */
  11326. +
  11327. +
  11328. +/* Receive Address Register */
  11329. +struct e1000_rar {
  11330. + volatile uint32_t low; /* receive address low */
  11331. + volatile uint32_t high; /* receive address high */
  11332. +};
  11333. +
  11334. +/* Number of entries in the Multicast Table Array (MTA). */
  11335. +#define E1000_NUM_MTA_REGISTERS 128
  11336. +
  11337. +/* IPv4 Address Table Entry */
  11338. +struct e1000_ipv4_at_entry {
  11339. + volatile uint32_t ipv4_addr; /* IP Address (RW) */
  11340. + volatile uint32_t reserved;
  11341. +};
  11342. +
  11343. +/* Four wakeup IP addresses are supported */
  11344. +#define E1000_WAKEUP_IP_ADDRESS_COUNT_MAX 4
  11345. +#define E1000_IP4AT_SIZE E1000_WAKEUP_IP_ADDRESS_COUNT_MAX
  11346. +#define E1000_IP6AT_SIZE 1
  11347. +
  11348. +/* IPv6 Address Table Entry */
  11349. +struct e1000_ipv6_at_entry {
  11350. + volatile uint8_t ipv6_addr[16];
  11351. +};
  11352. +
  11353. +/* Flexible Filter Length Table Entry */
  11354. +struct e1000_fflt_entry {
  11355. + volatile uint32_t length; /* Flexible Filter Length (RW) */
  11356. + volatile uint32_t reserved;
  11357. +};
  11358. +
  11359. +/* Flexible Filter Mask Table Entry */
  11360. +struct e1000_ffmt_entry {
  11361. + volatile uint32_t mask; /* Flexible Filter Mask (RW) */
  11362. + volatile uint32_t reserved;
  11363. +};
  11364. +
  11365. +/* Flexible Filter Value Table Entry */
  11366. +struct e1000_ffvt_entry {
  11367. + volatile uint32_t value; /* Flexible Filter Value (RW) */
  11368. + volatile uint32_t reserved;
  11369. +};
  11370. +
  11371. +/* Four Flexible Filters are supported */
  11372. +#define E1000_FLEXIBLE_FILTER_COUNT_MAX 4
  11373. +
  11374. +/* Each Flexible Filter is at most 128 (0x80) bytes in length */
  11375. +#define E1000_FLEXIBLE_FILTER_SIZE_MAX 128
  11376. +
  11377. +#define E1000_FFLT_SIZE E1000_FLEXIBLE_FILTER_COUNT_MAX
  11378. +#define E1000_FFMT_SIZE E1000_FLEXIBLE_FILTER_SIZE_MAX
  11379. +#define E1000_FFVT_SIZE E1000_FLEXIBLE_FILTER_SIZE_MAX
  11380. +
  11381. +/* Register Set. (82543, 82544)
  11382. + *
  11383. + * Registers are defined to be 32 bits and should be accessed as 32 bit values.
  11384. + * These registers are physically located on the NIC, but are mapped into the
  11385. + * host memory address space.
  11386. + *
  11387. + * RW - register is both readable and writable
  11388. + * RO - register is read only
  11389. + * WO - register is write only
  11390. + * R/clr - register is read only and is cleared when read
  11391. + * A - register array
  11392. + */
  11393. +#define E1000_CTRL 0x00000 /* Device Control - RW */
  11394. +#define E1000_CTRL_DUP 0x00004 /* Device Control Duplicate (Shadow) - RW */
  11395. +#define E1000_STATUS 0x00008 /* Device Status - RO */
  11396. +#define E1000_EECD 0x00010 /* EEPROM/Flash Control - RW */
  11397. +#define E1000_EERD 0x00014 /* EEPROM Read - RW */
  11398. +#define E1000_CTRL_EXT 0x00018 /* Extended Device Control - RW */
  11399. +#define E1000_FLA 0x0001C /* Flash Access - RW */
  11400. +#define E1000_MDIC 0x00020 /* MDI Control - RW */
  11401. +#define E1000_FCAL 0x00028 /* Flow Control Address Low - RW */
  11402. +#define E1000_FCAH 0x0002C /* Flow Control Address High -RW */
  11403. +#define E1000_FCT 0x00030 /* Flow Control Type - RW */
  11404. +#define E1000_VET 0x00038 /* VLAN Ether Type - RW */
  11405. +#define E1000_ICR 0x000C0 /* Interrupt Cause Read - R/clr */
  11406. +#define E1000_ITR 0x000C4 /* Interrupt Throttling Rate - RW */
  11407. +#define E1000_ICS 0x000C8 /* Interrupt Cause Set - WO */
  11408. +#define E1000_IMS 0x000D0 /* Interrupt Mask Set - RW */
  11409. +#define E1000_IMC 0x000D8 /* Interrupt Mask Clear - WO */
  11410. +#define E1000_RCTL 0x00100 /* RX Control - RW */
  11411. +#define E1000_FCTTV 0x00170 /* Flow Control Transmit Timer Value - RW */
  11412. +#define E1000_TXCW 0x00178 /* TX Configuration Word - RW */
  11413. +#define E1000_RXCW 0x00180 /* RX Configuration Word - RO */
  11414. +#define E1000_TCTL 0x00400 /* TX Control - RW */
  11415. +#define E1000_TIPG 0x00410 /* TX Inter-packet gap -RW */
  11416. +#define E1000_TBT 0x00448 /* TX Burst Timer - RW */
  11417. +#define E1000_AIT 0x00458 /* Adaptive Interframe Spacing Throttle - RW */
  11418. +#define E1000_LEDCTL 0x00E00 /* LED Control - RW */
  11419. +#define E1000_PBA 0x01000 /* Packet Buffer Allocation - RW */
  11420. +#define E1000_FCRTL 0x02160 /* Flow Control Receive Threshold Low - RW */
  11421. +#define E1000_FCRTH 0x02168 /* Flow Control Receive Threshold High - RW */
  11422. +#define E1000_RDBAL 0x02800 /* RX Descriptor Base Address Low - RW */
  11423. +#define E1000_RDBAH 0x02804 /* RX Descriptor Base Address High - RW */
  11424. +#define E1000_RDLEN 0x02808 /* RX Descriptor Length - RW */
  11425. +#define E1000_RDH 0x02810 /* RX Descriptor Head - RW */
  11426. +#define E1000_RDT 0x02818 /* RX Descriptor Tail - RW */
  11427. +#define E1000_RDTR 0x02820 /* RX Delay Timer - RW */
  11428. +#define E1000_RXDCTL 0x02828 /* RX Descriptor Control - RW */
  11429. +#define E1000_RADV 0x0282C /* RX Interrupt Absolute Delay Timer - RW */
  11430. +#define E1000_RSRPD 0x02C00 /* RX Small Packet Detect - RW */
  11431. +#define E1000_TXDMAC 0x03000 /* TX DMA Control - RW */
  11432. +#define E1000_TDFH 0x03410 /* TX Data FIFO Head - RW */
  11433. +#define E1000_TDFT 0x03418 /* TX Data FIFO Tail - RW */
  11434. +#define E1000_TDFHS 0x03420 /* TX Data FIFO Head Saved - RW */
  11435. +#define E1000_TDFTS 0x03428 /* TX Data FIFO Tail Saved - RW */
  11436. +#define E1000_TDFPC 0x03430 /* TX Data FIFO Packet Count - RW */
  11437. +#define E1000_TDBAL 0x03800 /* TX Descriptor Base Address Low - RW */
  11438. +#define E1000_TDBAH 0x03804 /* TX Descriptor Base Address High - RW */
  11439. +#define E1000_TDLEN 0x03808 /* TX Descriptor Length - RW */
  11440. +#define E1000_TDH 0x03810 /* TX Descriptor Head - RW */
  11441. +#define E1000_TDT 0x03818 /* TX Descripotr Tail - RW */
  11442. +#define E1000_TIDV 0x03820 /* TX Interrupt Delay Value - RW */
  11443. +#define E1000_TXDCTL 0x03828 /* TX Descriptor Control - RW */
  11444. +#define E1000_TADV 0x0382C /* TX Interrupt Absolute Delay Val - RW */
  11445. +#define E1000_TSPMT 0x03830 /* TCP Segmentation PAD & Min Threshold - RW */
  11446. +#define E1000_CRCERRS 0x04000 /* CRC Error Count - R/clr */
  11447. +#define E1000_ALGNERRC 0x04004 /* Alignment Error Count - R/clr */
  11448. +#define E1000_SYMERRS 0x04008 /* Symbol Error Count - R/clr */
  11449. +#define E1000_RXERRC 0x0400C /* Receive Error Count - R/clr */
  11450. +#define E1000_MPC 0x04010 /* Missed Packet Count - R/clr */
  11451. +#define E1000_SCC 0x04014 /* Single Collision Count - R/clr */
  11452. +#define E1000_ECOL 0x04018 /* Excessive Collision Count - R/clr */
  11453. +#define E1000_MCC 0x0401C /* Multiple Collision Count - R/clr */
  11454. +#define E1000_LATECOL 0x04020 /* Late Collision Count - R/clr */
  11455. +#define E1000_COLC 0x04028 /* Collision Count - R/clr */
  11456. +#define E1000_DC 0x04030 /* Defer Count - R/clr */
  11457. +#define E1000_TNCRS 0x04034 /* TX-No CRS - R/clr */
  11458. +#define E1000_SEC 0x04038 /* Sequence Error Count - R/clr */
  11459. +#define E1000_CEXTERR 0x0403C /* Carrier Extension Error Count - R/clr */
  11460. +#define E1000_RLEC 0x04040 /* Receive Length Error Count - R/clr */
  11461. +#define E1000_XONRXC 0x04048 /* XON RX Count - R/clr */
  11462. +#define E1000_XONTXC 0x0404C /* XON TX Count - R/clr */
  11463. +#define E1000_XOFFRXC 0x04050 /* XOFF RX Count - R/clr */
  11464. +#define E1000_XOFFTXC 0x04054 /* XOFF TX Count - R/clr */
  11465. +#define E1000_FCRUC 0x04058 /* Flow Control RX Unsupported Count- R/clr */
  11466. +#define E1000_PRC64 0x0405C /* Packets RX (64 bytes) - R/clr */
  11467. +#define E1000_PRC127 0x04060 /* Packets RX (65-127 bytes) - R/clr */
  11468. +#define E1000_PRC255 0x04064 /* Packets RX (128-255 bytes) - R/clr */
  11469. +#define E1000_PRC511 0x04068 /* Packets RX (255-511 bytes) - R/clr */
  11470. +#define E1000_PRC1023 0x0406C /* Packets RX (512-1023 bytes) - R/clr */
  11471. +#define E1000_PRC1522 0x04070 /* Packets RX (1024-1522 bytes) - R/clr */
  11472. +#define E1000_GPRC 0x04074 /* Good Packets RX Count - R/clr */
  11473. +#define E1000_BPRC 0x04078 /* Broadcast Packets RX Count - R/clr */
  11474. +#define E1000_MPRC 0x0407C /* Multicast Packets RX Count - R/clr */
  11475. +#define E1000_GPTC 0x04080 /* Good Packets TX Count - R/clr */
  11476. +#define E1000_GORCL 0x04088 /* Good Octets RX Count Low - R/clr */
  11477. +#define E1000_GORCH 0x0408C /* Good Octets RX Count High - R/clr */
  11478. +#define E1000_GOTCL 0x04090 /* Good Octets TX Count Low - R/clr */
  11479. +#define E1000_GOTCH 0x04094 /* Good Octets TX Count High - R/clr */
  11480. +#define E1000_RNBC 0x040A0 /* RX No Buffers Count - R/clr */
  11481. +#define E1000_RUC 0x040A4 /* RX Undersize Count - R/clr */
  11482. +#define E1000_RFC 0x040A8 /* RX Fragment Count - R/clr */
  11483. +#define E1000_ROC 0x040AC /* RX Oversize Count - R/clr */
  11484. +#define E1000_RJC 0x040B0 /* RX Jabber Count - R/clr */
  11485. +#define E1000_MGTPRC 0x040B4 /* Management Packets RX Count - R/clr */
  11486. +#define E1000_MGTPDC 0x040B8 /* Management Packets Dropped Count - R/clr */
  11487. +#define E1000_MGTPTC 0x040BC /* Management Packets TX Count - R/clr */
  11488. +#define E1000_TORL 0x040C0 /* Total Octets RX Low - R/clr */
  11489. +#define E1000_TORH 0x040C4 /* Total Octets RX High - R/clr */
  11490. +#define E1000_TOTL 0x040C8 /* Total Octets TX Low - R/clr */
  11491. +#define E1000_TOTH 0x040CC /* Total Octets TX High - R/clr */
  11492. +#define E1000_TPR 0x040D0 /* Total Packets RX - R/clr */
  11493. +#define E1000_TPT 0x040D4 /* Total Packets TX - R/clr */
  11494. +#define E1000_PTC64 0x040D8 /* Packets TX (64 bytes) - R/clr */
  11495. +#define E1000_PTC127 0x040DC /* Packets TX (65-127 bytes) - R/clr */
  11496. +#define E1000_PTC255 0x040E0 /* Packets TX (128-255 bytes) - R/clr */
  11497. +#define E1000_PTC511 0x040E4 /* Packets TX (256-511 bytes) - R/clr */
  11498. +#define E1000_PTC1023 0x040E8 /* Packets TX (512-1023 bytes) - R/clr */
  11499. +#define E1000_PTC1522 0x040EC /* Packets TX (1024-1522 Bytes) - R/clr */
  11500. +#define E1000_MPTC 0x040F0 /* Multicast Packets TX Count - R/clr */
  11501. +#define E1000_BPTC 0x040F4 /* Broadcast Packets TX Count - R/clr */
  11502. +#define E1000_TSCTC 0x040F8 /* TCP Segmentation Context TX - R/clr */
  11503. +#define E1000_TSCTFC 0x040FC /* TCP Segmentation Context TX Fail - R/clr */
  11504. +#define E1000_RXCSUM 0x05000 /* RX Checksum Control - RW */
  11505. +#define E1000_MTA 0x05200 /* Multicast Table Array - RW Array */
  11506. +#define E1000_RA 0x05400 /* Receive Address - RW Array */
  11507. +#define E1000_VFTA 0x05600 /* VLAN Filter Table Array - RW Array */
  11508. +#define E1000_WUC 0x05800 /* Wakeup Control - RW */
  11509. +#define E1000_WUFC 0x05808 /* Wakeup Filter Control - RW */
  11510. +#define E1000_WUS 0x05810 /* Wakeup Status - RO */
  11511. +#define E1000_MANC 0x05820 /* Management Control - RW */
  11512. +#define E1000_IPAV 0x05838 /* IP Address Valid - RW */
  11513. +#define E1000_IP4AT 0x05840 /* IPv4 Address Table - RW Array */
  11514. +#define E1000_IP6AT 0x05880 /* IPv6 Address Table - RW Array */
  11515. +#define E1000_WUPL 0x05900 /* Wakeup Packet Length - RW */
  11516. +#define E1000_WUPM 0x05A00 /* Wakeup Packet Memory - RO A */
  11517. +#define E1000_FFLT 0x05F00 /* Flexible Filter Length Table - RW Array */
  11518. +#define E1000_FFMT 0x09000 /* Flexible Filter Mask Table - RW Array */
  11519. +#define E1000_FFVT 0x09800 /* Flexible Filter Value Table - RW Array */
  11520. +
  11521. +/* Register Set (82542)
  11522. + *
  11523. + * Some of the 82542 registers are located at different offsets than they are
  11524. + * in more current versions of the 8254x. Despite the difference in location,
  11525. + * the registers function in the same manner.
  11526. + */
  11527. +#define E1000_82542_CTRL E1000_CTRL
  11528. +#define E1000_82542_CTRL_DUP E1000_CTRL_DUP
  11529. +#define E1000_82542_STATUS E1000_STATUS
  11530. +#define E1000_82542_EECD E1000_EECD
  11531. +#define E1000_82542_EERD E1000_EERD
  11532. +#define E1000_82542_CTRL_EXT E1000_CTRL_EXT
  11533. +#define E1000_82542_FLA E1000_FLA
  11534. +#define E1000_82542_MDIC E1000_MDIC
  11535. +#define E1000_82542_FCAL E1000_FCAL
  11536. +#define E1000_82542_FCAH E1000_FCAH
  11537. +#define E1000_82542_FCT E1000_FCT
  11538. +#define E1000_82542_VET E1000_VET
  11539. +#define E1000_82542_RA 0x00040
  11540. +#define E1000_82542_ICR E1000_ICR
  11541. +#define E1000_82542_ITR E1000_ITR
  11542. +#define E1000_82542_ICS E1000_ICS
  11543. +#define E1000_82542_IMS E1000_IMS
  11544. +#define E1000_82542_IMC E1000_IMC
  11545. +#define E1000_82542_RCTL E1000_RCTL
  11546. +#define E1000_82542_RDTR 0x00108
  11547. +#define E1000_82542_RDBAL 0x00110
  11548. +#define E1000_82542_RDBAH 0x00114
  11549. +#define E1000_82542_RDLEN 0x00118
  11550. +#define E1000_82542_RDH 0x00120
  11551. +#define E1000_82542_RDT 0x00128
  11552. +#define E1000_82542_FCRTH 0x00160
  11553. +#define E1000_82542_FCRTL 0x00168
  11554. +#define E1000_82542_FCTTV E1000_FCTTV
  11555. +#define E1000_82542_TXCW E1000_TXCW
  11556. +#define E1000_82542_RXCW E1000_RXCW
  11557. +#define E1000_82542_MTA 0x00200
  11558. +#define E1000_82542_TCTL E1000_TCTL
  11559. +#define E1000_82542_TIPG E1000_TIPG
  11560. +#define E1000_82542_TDBAL 0x00420
  11561. +#define E1000_82542_TDBAH 0x00424
  11562. +#define E1000_82542_TDLEN 0x00428
  11563. +#define E1000_82542_TDH 0x00430
  11564. +#define E1000_82542_TDT 0x00438
  11565. +#define E1000_82542_TIDV 0x00440
  11566. +#define E1000_82542_TBT E1000_TBT
  11567. +#define E1000_82542_AIT E1000_AIT
  11568. +#define E1000_82542_VFTA 0x00600
  11569. +#define E1000_82542_LEDCTL E1000_LEDCTL
  11570. +#define E1000_82542_PBA E1000_PBA
  11571. +#define E1000_82542_RXDCTL E1000_RXDCTL
  11572. +#define E1000_82542_RADV E1000_RADV
  11573. +#define E1000_82542_RSRPD E1000_RSRPD
  11574. +#define E1000_82542_TXDMAC E1000_TXDMAC
  11575. +#define E1000_82542_TDFHS E1000_TDFHS
  11576. +#define E1000_82542_TDFTS E1000_TDFTS
  11577. +#define E1000_82542_TDFPC E1000_TDFPC
  11578. +#define E1000_82542_TXDCTL E1000_TXDCTL
  11579. +#define E1000_82542_TADV E1000_TADV
  11580. +#define E1000_82542_TSPMT E1000_TSPMT
  11581. +#define E1000_82542_CRCERRS E1000_CRCERRS
  11582. +#define E1000_82542_ALGNERRC E1000_ALGNERRC
  11583. +#define E1000_82542_SYMERRS E1000_SYMERRS
  11584. +#define E1000_82542_RXERRC E1000_RXERRC
  11585. +#define E1000_82542_MPC E1000_MPC
  11586. +#define E1000_82542_SCC E1000_SCC
  11587. +#define E1000_82542_ECOL E1000_ECOL
  11588. +#define E1000_82542_MCC E1000_MCC
  11589. +#define E1000_82542_LATECOL E1000_LATECOL
  11590. +#define E1000_82542_COLC E1000_COLC
  11591. +#define E1000_82542_DC E1000_DC
  11592. +#define E1000_82542_TNCRS E1000_TNCRS
  11593. +#define E1000_82542_SEC E1000_SEC
  11594. +#define E1000_82542_CEXTERR E1000_CEXTERR
  11595. +#define E1000_82542_RLEC E1000_RLEC
  11596. +#define E1000_82542_XONRXC E1000_XONRXC
  11597. +#define E1000_82542_XONTXC E1000_XONTXC
  11598. +#define E1000_82542_XOFFRXC E1000_XOFFRXC
  11599. +#define E1000_82542_XOFFTXC E1000_XOFFTXC
  11600. +#define E1000_82542_FCRUC E1000_FCRUC
  11601. +#define E1000_82542_PRC64 E1000_PRC64
  11602. +#define E1000_82542_PRC127 E1000_PRC127
  11603. +#define E1000_82542_PRC255 E1000_PRC255
  11604. +#define E1000_82542_PRC511 E1000_PRC511
  11605. +#define E1000_82542_PRC1023 E1000_PRC1023
  11606. +#define E1000_82542_PRC1522 E1000_PRC1522
  11607. +#define E1000_82542_GPRC E1000_GPRC
  11608. +#define E1000_82542_BPRC E1000_BPRC
  11609. +#define E1000_82542_MPRC E1000_MPRC
  11610. +#define E1000_82542_GPTC E1000_GPTC
  11611. +#define E1000_82542_GORCL E1000_GORCL
  11612. +#define E1000_82542_GORCH E1000_GORCH
  11613. +#define E1000_82542_GOTCL E1000_GOTCL
  11614. +#define E1000_82542_GOTCH E1000_GOTCH
  11615. +#define E1000_82542_RNBC E1000_RNBC
  11616. +#define E1000_82542_RUC E1000_RUC
  11617. +#define E1000_82542_RFC E1000_RFC
  11618. +#define E1000_82542_ROC E1000_ROC
  11619. +#define E1000_82542_RJC E1000_RJC
  11620. +#define E1000_82542_MGTPRC E1000_MGTPRC
  11621. +#define E1000_82542_MGTPDC E1000_MGTPDC
  11622. +#define E1000_82542_MGTPTC E1000_MGTPTC
  11623. +#define E1000_82542_TORL E1000_TORL
  11624. +#define E1000_82542_TORH E1000_TORH
  11625. +#define E1000_82542_TOTL E1000_TOTL
  11626. +#define E1000_82542_TOTH E1000_TOTH
  11627. +#define E1000_82542_TPR E1000_TPR
  11628. +#define E1000_82542_TPT E1000_TPT
  11629. +#define E1000_82542_PTC64 E1000_PTC64
  11630. +#define E1000_82542_PTC127 E1000_PTC127
  11631. +#define E1000_82542_PTC255 E1000_PTC255
  11632. +#define E1000_82542_PTC511 E1000_PTC511
  11633. +#define E1000_82542_PTC1023 E1000_PTC1023
  11634. +#define E1000_82542_PTC1522 E1000_PTC1522
  11635. +#define E1000_82542_MPTC E1000_MPTC
  11636. +#define E1000_82542_BPTC E1000_BPTC
  11637. +#define E1000_82542_TSCTC E1000_TSCTC
  11638. +#define E1000_82542_TSCTFC E1000_TSCTFC
  11639. +#define E1000_82542_RXCSUM E1000_RXCSUM
  11640. +#define E1000_82542_WUC E1000_WUC
  11641. +#define E1000_82542_WUFC E1000_WUFC
  11642. +#define E1000_82542_WUS E1000_WUS
  11643. +#define E1000_82542_MANC E1000_MANC
  11644. +#define E1000_82542_IPAV E1000_IPAV
  11645. +#define E1000_82542_IP4AT E1000_IP4AT
  11646. +#define E1000_82542_IP6AT E1000_IP6AT
  11647. +#define E1000_82542_WUPL E1000_WUPL
  11648. +#define E1000_82542_WUPM E1000_WUPM
  11649. +#define E1000_82542_FFLT E1000_FFLT
  11650. +#define E1000_82542_TDFH 0x08010
  11651. +#define E1000_82542_TDFT 0x08018
  11652. +#define E1000_82542_FFMT E1000_FFMT
  11653. +#define E1000_82542_FFVT E1000_FFVT
  11654. +
  11655. +/* Statistics counters collected by the MAC */
  11656. +struct e1000_hw_stats {
  11657. + uint64_t crcerrs;
  11658. + uint64_t algnerrc;
  11659. + uint64_t symerrs;
  11660. + uint64_t rxerrc;
  11661. + uint64_t mpc;
  11662. + uint64_t scc;
  11663. + uint64_t ecol;
  11664. + uint64_t mcc;
  11665. + uint64_t latecol;
  11666. + uint64_t colc;
  11667. + uint64_t dc;
  11668. + uint64_t tncrs;
  11669. + uint64_t sec;
  11670. + uint64_t cexterr;
  11671. + uint64_t rlec;
  11672. + uint64_t xonrxc;
  11673. + uint64_t xontxc;
  11674. + uint64_t xoffrxc;
  11675. + uint64_t xofftxc;
  11676. + uint64_t fcruc;
  11677. + uint64_t prc64;
  11678. + uint64_t prc127;
  11679. + uint64_t prc255;
  11680. + uint64_t prc511;
  11681. + uint64_t prc1023;
  11682. + uint64_t prc1522;
  11683. + uint64_t gprc;
  11684. + uint64_t bprc;
  11685. + uint64_t mprc;
  11686. + uint64_t gptc;
  11687. + uint64_t gorcl;
  11688. + uint64_t gorch;
  11689. + uint64_t gotcl;
  11690. + uint64_t gotch;
  11691. + uint64_t rnbc;
  11692. + uint64_t ruc;
  11693. + uint64_t rfc;
  11694. + uint64_t roc;
  11695. + uint64_t rjc;
  11696. + uint64_t mgprc;
  11697. + uint64_t mgpdc;
  11698. + uint64_t mgptc;
  11699. + uint64_t torl;
  11700. + uint64_t torh;
  11701. + uint64_t totl;
  11702. + uint64_t toth;
  11703. + uint64_t tpr;
  11704. + uint64_t tpt;
  11705. + uint64_t ptc64;
  11706. + uint64_t ptc127;
  11707. + uint64_t ptc255;
  11708. + uint64_t ptc511;
  11709. + uint64_t ptc1023;
  11710. + uint64_t ptc1522;
  11711. + uint64_t mptc;
  11712. + uint64_t bptc;
  11713. + uint64_t tsctc;
  11714. + uint64_t tsctfc;
  11715. +};
  11716. +
  11717. +/* Structure containing variables used by the shared code (e1000_hw.c) */
  11718. +struct e1000_hw {
  11719. + struct pci_device *pdev;
  11720. + uint8_t *hw_addr;
  11721. + e1000_mac_type mac_type;
  11722. + e1000_phy_type phy_type;
  11723. +#if 0
  11724. + uint32_t phy_init_script;
  11725. +#endif
  11726. + e1000_media_type media_type;
  11727. + e1000_fc_type fc;
  11728. +#if 0
  11729. + e1000_bus_speed bus_speed;
  11730. + e1000_bus_width bus_width;
  11731. + e1000_bus_type bus_type;
  11732. +#endif
  11733. + struct e1000_eeprom_info eeprom;
  11734. +#if 0
  11735. + e1000_ms_type master_slave;
  11736. + e1000_ms_type original_master_slave;
  11737. + e1000_ffe_config ffe_config_state;
  11738. +#endif
  11739. + uint32_t io_base;
  11740. + uint32_t phy_id;
  11741. +#ifdef LINUX_DRIVER
  11742. + uint32_t phy_revision;
  11743. +#endif
  11744. + uint32_t phy_addr;
  11745. +#if 0
  11746. + uint32_t original_fc;
  11747. +#endif
  11748. + uint32_t txcw;
  11749. + uint32_t autoneg_failed;
  11750. +#if 0
  11751. + uint32_t max_frame_size;
  11752. + uint32_t min_frame_size;
  11753. + uint32_t mc_filter_type;
  11754. + uint32_t num_mc_addrs;
  11755. + uint32_t collision_delta;
  11756. + uint32_t tx_packet_delta;
  11757. + uint32_t ledctl_default;
  11758. + uint32_t ledctl_mode1;
  11759. + uint32_t ledctl_mode2;
  11760. + uint16_t phy_spd_default;
  11761. +#endif
  11762. + uint16_t autoneg_advertised;
  11763. + uint16_t pci_cmd_word;
  11764. +#if 0
  11765. + uint16_t fc_high_water;
  11766. + uint16_t fc_low_water;
  11767. + uint16_t fc_pause_time;
  11768. + uint16_t current_ifs_val;
  11769. + uint16_t ifs_min_val;
  11770. + uint16_t ifs_max_val;
  11771. + uint16_t ifs_step_size;
  11772. + uint16_t ifs_ratio;
  11773. +#endif
  11774. + uint16_t device_id;
  11775. + uint16_t vendor_id;
  11776. +#if 0
  11777. + uint16_t subsystem_id;
  11778. + uint16_t subsystem_vendor_id;
  11779. +#endif
  11780. + uint8_t revision_id;
  11781. +#if 0
  11782. + uint8_t autoneg;
  11783. + uint8_t mdix;
  11784. + uint8_t forced_speed_duplex;
  11785. + uint8_t wait_autoneg_complete;
  11786. + uint8_t dma_fairness;
  11787. +#endif
  11788. + uint8_t mac_addr[NODE_ADDRESS_SIZE];
  11789. +#if 0
  11790. + uint8_t perm_mac_addr[NODE_ADDRESS_SIZE];
  11791. + boolean_t disable_polarity_correction;
  11792. + boolean_t speed_downgraded;
  11793. + e1000_dsp_config dsp_config_state;
  11794. + boolean_t get_link_status;
  11795. + boolean_t serdes_link_down;
  11796. +#endif
  11797. + boolean_t tbi_compatibility_en;
  11798. + boolean_t tbi_compatibility_on;
  11799. +#if 0
  11800. + boolean_t phy_reset_disable;
  11801. + boolean_t fc_send_xon;
  11802. + boolean_t fc_strict_ieee;
  11803. + boolean_t report_tx_early;
  11804. + boolean_t adaptive_ifs;
  11805. + boolean_t ifs_params_forced;
  11806. + boolean_t in_ifs_mode;
  11807. +#endif
  11808. +};
  11809. +
  11810. +
  11811. +#define E1000_EEPROM_SWDPIN0 0x0001 /* SWDPIN 0 EEPROM Value */
  11812. +#define E1000_EEPROM_LED_LOGIC 0x0020 /* Led Logic Word */
  11813. +
  11814. +/* Register Bit Masks */
  11815. +/* Device Control */
  11816. +#define E1000_CTRL_FD 0x00000001 /* Full duplex.0=half; 1=full */
  11817. +#define E1000_CTRL_BEM 0x00000002 /* Endian Mode.0=little,1=big */
  11818. +#define E1000_CTRL_PRIOR 0x00000004 /* Priority on PCI. 0=rx,1=fair */
  11819. +#define E1000_CTRL_LRST 0x00000008 /* Link reset. 0=normal,1=reset */
  11820. +#define E1000_CTRL_TME 0x00000010 /* Test mode. 0=normal,1=test */
  11821. +#define E1000_CTRL_SLE 0x00000020 /* Serial Link on 0=dis,1=en */
  11822. +#define E1000_CTRL_ASDE 0x00000020 /* Auto-speed detect enable */
  11823. +#define E1000_CTRL_SLU 0x00000040 /* Set link up (Force Link) */
  11824. +#define E1000_CTRL_ILOS 0x00000080 /* Invert Loss-Of Signal */
  11825. +#define E1000_CTRL_SPD_SEL 0x00000300 /* Speed Select Mask */
  11826. +#define E1000_CTRL_SPD_10 0x00000000 /* Force 10Mb */
  11827. +#define E1000_CTRL_SPD_100 0x00000100 /* Force 100Mb */
  11828. +#define E1000_CTRL_SPD_1000 0x00000200 /* Force 1Gb */
  11829. +#define E1000_CTRL_BEM32 0x00000400 /* Big Endian 32 mode */
  11830. +#define E1000_CTRL_FRCSPD 0x00000800 /* Force Speed */
  11831. +#define E1000_CTRL_FRCDPX 0x00001000 /* Force Duplex */
  11832. +#define E1000_CTRL_SWDPIN0 0x00040000 /* SWDPIN 0 value */
  11833. +#define E1000_CTRL_SWDPIN1 0x00080000 /* SWDPIN 1 value */
  11834. +#define E1000_CTRL_SWDPIN2 0x00100000 /* SWDPIN 2 value */
  11835. +#define E1000_CTRL_SWDPIN3 0x00200000 /* SWDPIN 3 value */
  11836. +#define E1000_CTRL_SWDPIO0 0x00400000 /* SWDPIN 0 Input or output */
  11837. +#define E1000_CTRL_SWDPIO1 0x00800000 /* SWDPIN 1 input or output */
  11838. +#define E1000_CTRL_SWDPIO2 0x01000000 /* SWDPIN 2 input or output */
  11839. +#define E1000_CTRL_SWDPIO3 0x02000000 /* SWDPIN 3 input or output */
  11840. +#define E1000_CTRL_RST 0x04000000 /* Global reset */
  11841. +#define E1000_CTRL_RFCE 0x08000000 /* Receive Flow Control enable */
  11842. +#define E1000_CTRL_TFCE 0x10000000 /* Transmit flow control enable */
  11843. +#define E1000_CTRL_RTE 0x20000000 /* Routing tag enable */
  11844. +#define E1000_CTRL_VME 0x40000000 /* IEEE VLAN mode enable */
  11845. +#define E1000_CTRL_PHY_RST 0x80000000 /* PHY Reset */
  11846. +
  11847. +/* Device Status */
  11848. +#define E1000_STATUS_FD 0x00000001 /* Full duplex.0=half,1=full */
  11849. +#define E1000_STATUS_LU 0x00000002 /* Link up.0=no,1=link */
  11850. +#define E1000_STATUS_FUNC_MASK 0x0000000C /* PCI Function Mask */
  11851. +#define E1000_STATUS_FUNC_0 0x00000000 /* Function 0 */
  11852. +#define E1000_STATUS_FUNC_1 0x00000004 /* Function 1 */
  11853. +#define E1000_STATUS_TXOFF 0x00000010 /* transmission paused */
  11854. +#define E1000_STATUS_TBIMODE 0x00000020 /* TBI mode */
  11855. +#define E1000_STATUS_SPEED_MASK 0x000000C0
  11856. +#define E1000_STATUS_SPEED_10 0x00000000 /* Speed 10Mb/s */
  11857. +#define E1000_STATUS_SPEED_100 0x00000040 /* Speed 100Mb/s */
  11858. +#define E1000_STATUS_SPEED_1000 0x00000080 /* Speed 1000Mb/s */
  11859. +#define E1000_STATUS_ASDV 0x00000300 /* Auto speed detect value */
  11860. +#define E1000_STATUS_MTXCKOK 0x00000400 /* MTX clock running OK */
  11861. +#define E1000_STATUS_PCI66 0x00000800 /* In 66Mhz slot */
  11862. +#define E1000_STATUS_BUS64 0x00001000 /* In 64 bit slot */
  11863. +#define E1000_STATUS_PCIX_MODE 0x00002000 /* PCI-X mode */
  11864. +#define E1000_STATUS_PCIX_SPEED 0x0000C000 /* PCI-X bus speed */
  11865. +
  11866. +/* Constants used to intrepret the masked PCI-X bus speed. */
  11867. +#define E1000_STATUS_PCIX_SPEED_66 0x00000000 /* PCI-X bus speed 50-66 MHz */
  11868. +#define E1000_STATUS_PCIX_SPEED_100 0x00004000 /* PCI-X bus speed 66-100 MHz */
  11869. +#define E1000_STATUS_PCIX_SPEED_133 0x00008000 /* PCI-X bus speed 100-133 MHz */
  11870. +
  11871. +/* EEPROM/Flash Control */
  11872. +#define E1000_EECD_SK 0x00000001 /* EEPROM Clock */
  11873. +#define E1000_EECD_CS 0x00000002 /* EEPROM Chip Select */
  11874. +#define E1000_EECD_DI 0x00000004 /* EEPROM Data In */
  11875. +#define E1000_EECD_DO 0x00000008 /* EEPROM Data Out */
  11876. +#define E1000_EECD_FWE_MASK 0x00000030
  11877. +#define E1000_EECD_FWE_DIS 0x00000010 /* Disable FLASH writes */
  11878. +#define E1000_EECD_FWE_EN 0x00000020 /* Enable FLASH writes */
  11879. +#define E1000_EECD_FWE_SHIFT 4
  11880. +#define E1000_EECD_REQ 0x00000040 /* EEPROM Access Request */
  11881. +#define E1000_EECD_GNT 0x00000080 /* EEPROM Access Grant */
  11882. +#define E1000_EECD_PRES 0x00000100 /* EEPROM Present */
  11883. +#define E1000_EECD_SIZE 0x00000200 /* EEPROM Size (0=64 word 1=256 word) */
  11884. +#define E1000_EECD_ADDR_BITS 0x00000400 /* EEPROM Addressing bits based on type
  11885. + * (0-small, 1-large) */
  11886. +#define E1000_EECD_TYPE 0x00002000 /* EEPROM Type (1-SPI, 0-Microwire) */
  11887. +#ifndef E1000_EEPROM_GRANT_ATTEMPTS
  11888. +#define E1000_EEPROM_GRANT_ATTEMPTS 1000 /* EEPROM # attempts to gain grant */
  11889. +#endif
  11890. +
  11891. +/* EEPROM Read */
  11892. +#define E1000_EERD_START 0x00000001 /* Start Read */
  11893. +#define E1000_EERD_DONE 0x00000010 /* Read Done */
  11894. +#define E1000_EERD_ADDR_SHIFT 8
  11895. +#define E1000_EERD_ADDR_MASK 0x0000FF00 /* Read Address */
  11896. +#define E1000_EERD_DATA_SHIFT 16
  11897. +#define E1000_EERD_DATA_MASK 0xFFFF0000 /* Read Data */
  11898. +
  11899. +/* SPI EEPROM Status Register */
  11900. +#define EEPROM_STATUS_RDY_SPI 0x01
  11901. +#define EEPROM_STATUS_WEN_SPI 0x02
  11902. +#define EEPROM_STATUS_BP0_SPI 0x04
  11903. +#define EEPROM_STATUS_BP1_SPI 0x08
  11904. +#define EEPROM_STATUS_WPEN_SPI 0x80
  11905. +
  11906. +/* Extended Device Control */
  11907. +#define E1000_CTRL_EXT_GPI0_EN 0x00000001 /* Maps SDP4 to GPI0 */
  11908. +#define E1000_CTRL_EXT_GPI1_EN 0x00000002 /* Maps SDP5 to GPI1 */
  11909. +#define E1000_CTRL_EXT_PHYINT_EN E1000_CTRL_EXT_GPI1_EN
  11910. +#define E1000_CTRL_EXT_GPI2_EN 0x00000004 /* Maps SDP6 to GPI2 */
  11911. +#define E1000_CTRL_EXT_GPI3_EN 0x00000008 /* Maps SDP7 to GPI3 */
  11912. +#define E1000_CTRL_EXT_SDP4_DATA 0x00000010 /* Value of SW Defineable Pin 4 */
  11913. +#define E1000_CTRL_EXT_SDP5_DATA 0x00000020 /* Value of SW Defineable Pin 5 */
  11914. +#define E1000_CTRL_EXT_PHY_INT E1000_CTRL_EXT_SDP5_DATA
  11915. +#define E1000_CTRL_EXT_SDP6_DATA 0x00000040 /* Value of SW Defineable Pin 6 */
  11916. +#define E1000_CTRL_EXT_SDP7_DATA 0x00000080 /* Value of SW Defineable Pin 7 */
  11917. +#define E1000_CTRL_EXT_SDP4_DIR 0x00000100 /* Direction of SDP4 0=in 1=out */
  11918. +#define E1000_CTRL_EXT_SDP5_DIR 0x00000200 /* Direction of SDP5 0=in 1=out */
  11919. +#define E1000_CTRL_EXT_SDP6_DIR 0x00000400 /* Direction of SDP6 0=in 1=out */
  11920. +#define E1000_CTRL_EXT_SDP7_DIR 0x00000800 /* Direction of SDP7 0=in 1=out */
  11921. +#define E1000_CTRL_EXT_ASDCHK 0x00001000 /* Initiate an ASD sequence */
  11922. +#define E1000_CTRL_EXT_EE_RST 0x00002000 /* Reinitialize from EEPROM */
  11923. +#define E1000_CTRL_EXT_IPS 0x00004000 /* Invert Power State */
  11924. +#define E1000_CTRL_EXT_SPD_BYPS 0x00008000 /* Speed Select Bypass */
  11925. +#define E1000_CTRL_EXT_LINK_MODE_MASK 0x00C00000
  11926. +#define E1000_CTRL_EXT_LINK_MODE_GMII 0x00000000
  11927. +#define E1000_CTRL_EXT_LINK_MODE_TBI 0x00C00000
  11928. +#define E1000_CTRL_EXT_WR_WMARK_MASK 0x03000000
  11929. +#define E1000_CTRL_EXT_WR_WMARK_256 0x00000000
  11930. +#define E1000_CTRL_EXT_WR_WMARK_320 0x01000000
  11931. +#define E1000_CTRL_EXT_WR_WMARK_384 0x02000000
  11932. +#define E1000_CTRL_EXT_WR_WMARK_448 0x03000000
  11933. +
  11934. +/* MDI Control */
  11935. +#define E1000_MDIC_DATA_MASK 0x0000FFFF
  11936. +#define E1000_MDIC_REG_MASK 0x001F0000
  11937. +#define E1000_MDIC_REG_SHIFT 16
  11938. +#define E1000_MDIC_PHY_MASK 0x03E00000
  11939. +#define E1000_MDIC_PHY_SHIFT 21
  11940. +#define E1000_MDIC_OP_WRITE 0x04000000
  11941. +#define E1000_MDIC_OP_READ 0x08000000
  11942. +#define E1000_MDIC_READY 0x10000000
  11943. +#define E1000_MDIC_INT_EN 0x20000000
  11944. +#define E1000_MDIC_ERROR 0x40000000
  11945. +
  11946. +/* LED Control */
  11947. +#define E1000_LEDCTL_LED0_MODE_MASK 0x0000000F
  11948. +#define E1000_LEDCTL_LED0_MODE_SHIFT 0
  11949. +#define E1000_LEDCTL_LED0_IVRT 0x00000040
  11950. +#define E1000_LEDCTL_LED0_BLINK 0x00000080
  11951. +#define E1000_LEDCTL_LED1_MODE_MASK 0x00000F00
  11952. +#define E1000_LEDCTL_LED1_MODE_SHIFT 8
  11953. +#define E1000_LEDCTL_LED1_IVRT 0x00004000
  11954. +#define E1000_LEDCTL_LED1_BLINK 0x00008000
  11955. +#define E1000_LEDCTL_LED2_MODE_MASK 0x000F0000
  11956. +#define E1000_LEDCTL_LED2_MODE_SHIFT 16
  11957. +#define E1000_LEDCTL_LED2_IVRT 0x00400000
  11958. +#define E1000_LEDCTL_LED2_BLINK 0x00800000
  11959. +#define E1000_LEDCTL_LED3_MODE_MASK 0x0F000000
  11960. +#define E1000_LEDCTL_LED3_MODE_SHIFT 24
  11961. +#define E1000_LEDCTL_LED3_IVRT 0x40000000
  11962. +#define E1000_LEDCTL_LED3_BLINK 0x80000000
  11963. +
  11964. +#define E1000_LEDCTL_MODE_LINK_10_1000 0x0
  11965. +#define E1000_LEDCTL_MODE_LINK_100_1000 0x1
  11966. +#define E1000_LEDCTL_MODE_LINK_UP 0x2
  11967. +#define E1000_LEDCTL_MODE_ACTIVITY 0x3
  11968. +#define E1000_LEDCTL_MODE_LINK_ACTIVITY 0x4
  11969. +#define E1000_LEDCTL_MODE_LINK_10 0x5
  11970. +#define E1000_LEDCTL_MODE_LINK_100 0x6
  11971. +#define E1000_LEDCTL_MODE_LINK_1000 0x7
  11972. +#define E1000_LEDCTL_MODE_PCIX_MODE 0x8
  11973. +#define E1000_LEDCTL_MODE_FULL_DUPLEX 0x9
  11974. +#define E1000_LEDCTL_MODE_COLLISION 0xA
  11975. +#define E1000_LEDCTL_MODE_BUS_SPEED 0xB
  11976. +#define E1000_LEDCTL_MODE_BUS_SIZE 0xC
  11977. +#define E1000_LEDCTL_MODE_PAUSED 0xD
  11978. +#define E1000_LEDCTL_MODE_LED_ON 0xE
  11979. +#define E1000_LEDCTL_MODE_LED_OFF 0xF
  11980. +
  11981. +/* Receive Address */
  11982. +#define E1000_RAH_AV 0x80000000 /* Receive descriptor valid */
  11983. +
  11984. +/* Interrupt Cause Read */
  11985. +#define E1000_ICR_TXDW 0x00000001 /* Transmit desc written back */
  11986. +#define E1000_ICR_TXQE 0x00000002 /* Transmit Queue empty */
  11987. +#define E1000_ICR_LSC 0x00000004 /* Link Status Change */
  11988. +#define E1000_ICR_RXSEQ 0x00000008 /* rx sequence error */
  11989. +#define E1000_ICR_RXDMT0 0x00000010 /* rx desc min. threshold (0) */
  11990. +#define E1000_ICR_RXO 0x00000040 /* rx overrun */
  11991. +#define E1000_ICR_RXT0 0x00000080 /* rx timer intr (ring 0) */
  11992. +#define E1000_ICR_MDAC 0x00000200 /* MDIO access complete */
  11993. +#define E1000_ICR_RXCFG 0x00000400 /* RX /c/ ordered set */
  11994. +#define E1000_ICR_GPI_EN0 0x00000800 /* GP Int 0 */
  11995. +#define E1000_ICR_GPI_EN1 0x00001000 /* GP Int 1 */
  11996. +#define E1000_ICR_GPI_EN2 0x00002000 /* GP Int 2 */
  11997. +#define E1000_ICR_GPI_EN3 0x00004000 /* GP Int 3 */
  11998. +#define E1000_ICR_TXD_LOW 0x00008000
  11999. +#define E1000_ICR_SRPD 0x00010000
  12000. +
  12001. +/* Interrupt Cause Set */
  12002. +#define E1000_ICS_TXDW E1000_ICR_TXDW /* Transmit desc written back */
  12003. +#define E1000_ICS_TXQE E1000_ICR_TXQE /* Transmit Queue empty */
  12004. +#define E1000_ICS_LSC E1000_ICR_LSC /* Link Status Change */
  12005. +#define E1000_ICS_RXSEQ E1000_ICR_RXSEQ /* rx sequence error */
  12006. +#define E1000_ICS_RXDMT0 E1000_ICR_RXDMT0 /* rx desc min. threshold */
  12007. +#define E1000_ICS_RXO E1000_ICR_RXO /* rx overrun */
  12008. +#define E1000_ICS_RXT0 E1000_ICR_RXT0 /* rx timer intr */
  12009. +#define E1000_ICS_MDAC E1000_ICR_MDAC /* MDIO access complete */
  12010. +#define E1000_ICS_RXCFG E1000_ICR_RXCFG /* RX /c/ ordered set */
  12011. +#define E1000_ICS_GPI_EN0 E1000_ICR_GPI_EN0 /* GP Int 0 */
  12012. +#define E1000_ICS_GPI_EN1 E1000_ICR_GPI_EN1 /* GP Int 1 */
  12013. +#define E1000_ICS_GPI_EN2 E1000_ICR_GPI_EN2 /* GP Int 2 */
  12014. +#define E1000_ICS_GPI_EN3 E1000_ICR_GPI_EN3 /* GP Int 3 */
  12015. +#define E1000_ICS_TXD_LOW E1000_ICR_TXD_LOW
  12016. +#define E1000_ICS_SRPD E1000_ICR_SRPD
  12017. +
  12018. +/* Interrupt Mask Set */
  12019. +#define E1000_IMS_TXDW E1000_ICR_TXDW /* Transmit desc written back */
  12020. +#define E1000_IMS_TXQE E1000_ICR_TXQE /* Transmit Queue empty */
  12021. +#define E1000_IMS_LSC E1000_ICR_LSC /* Link Status Change */
  12022. +#define E1000_IMS_RXSEQ E1000_ICR_RXSEQ /* rx sequence error */
  12023. +#define E1000_IMS_RXDMT0 E1000_ICR_RXDMT0 /* rx desc min. threshold */
  12024. +#define E1000_IMS_RXO E1000_ICR_RXO /* rx overrun */
  12025. +#define E1000_IMS_RXT0 E1000_ICR_RXT0 /* rx timer intr */
  12026. +#define E1000_IMS_MDAC E1000_ICR_MDAC /* MDIO access complete */
  12027. +#define E1000_IMS_RXCFG E1000_ICR_RXCFG /* RX /c/ ordered set */
  12028. +#define E1000_IMS_GPI_EN0 E1000_ICR_GPI_EN0 /* GP Int 0 */
  12029. +#define E1000_IMS_GPI_EN1 E1000_ICR_GPI_EN1 /* GP Int 1 */
  12030. +#define E1000_IMS_GPI_EN2 E1000_ICR_GPI_EN2 /* GP Int 2 */
  12031. +#define E1000_IMS_GPI_EN3 E1000_ICR_GPI_EN3 /* GP Int 3 */
  12032. +#define E1000_IMS_TXD_LOW E1000_ICR_TXD_LOW
  12033. +#define E1000_IMS_SRPD E1000_ICR_SRPD
  12034. +
  12035. +/* Interrupt Mask Clear */
  12036. +#define E1000_IMC_TXDW E1000_ICR_TXDW /* Transmit desc written back */
  12037. +#define E1000_IMC_TXQE E1000_ICR_TXQE /* Transmit Queue empty */
  12038. +#define E1000_IMC_LSC E1000_ICR_LSC /* Link Status Change */
  12039. +#define E1000_IMC_RXSEQ E1000_ICR_RXSEQ /* rx sequence error */
  12040. +#define E1000_IMC_RXDMT0 E1000_ICR_RXDMT0 /* rx desc min. threshold */
  12041. +#define E1000_IMC_RXO E1000_ICR_RXO /* rx overrun */
  12042. +#define E1000_IMC_RXT0 E1000_ICR_RXT0 /* rx timer intr */
  12043. +#define E1000_IMC_MDAC E1000_ICR_MDAC /* MDIO access complete */
  12044. +#define E1000_IMC_RXCFG E1000_ICR_RXCFG /* RX /c/ ordered set */
  12045. +#define E1000_IMC_GPI_EN0 E1000_ICR_GPI_EN0 /* GP Int 0 */
  12046. +#define E1000_IMC_GPI_EN1 E1000_ICR_GPI_EN1 /* GP Int 1 */
  12047. +#define E1000_IMC_GPI_EN2 E1000_ICR_GPI_EN2 /* GP Int 2 */
  12048. +#define E1000_IMC_GPI_EN3 E1000_ICR_GPI_EN3 /* GP Int 3 */
  12049. +#define E1000_IMC_TXD_LOW E1000_ICR_TXD_LOW
  12050. +#define E1000_IMC_SRPD E1000_ICR_SRPD
  12051. +
  12052. +/* Receive Control */
  12053. +#define E1000_RCTL_RST 0x00000001 /* Software reset */
  12054. +#define E1000_RCTL_EN 0x00000002 /* enable */
  12055. +#define E1000_RCTL_SBP 0x00000004 /* store bad packet */
  12056. +#define E1000_RCTL_UPE 0x00000008 /* unicast promiscuous enable */
  12057. +#define E1000_RCTL_MPE 0x00000010 /* multicast promiscuous enab */
  12058. +#define E1000_RCTL_LPE 0x00000020 /* long packet enable */
  12059. +#define E1000_RCTL_LBM_NO 0x00000000 /* no loopback mode */
  12060. +#define E1000_RCTL_LBM_MAC 0x00000040 /* MAC loopback mode */
  12061. +#define E1000_RCTL_LBM_SLP 0x00000080 /* serial link loopback mode */
  12062. +#define E1000_RCTL_LBM_TCVR 0x000000C0 /* tcvr loopback mode */
  12063. +#define E1000_RCTL_RDMTS_HALF 0x00000000 /* rx desc min threshold size */
  12064. +#define E1000_RCTL_RDMTS_QUAT 0x00000100 /* rx desc min threshold size */
  12065. +#define E1000_RCTL_RDMTS_EIGTH 0x00000200 /* rx desc min threshold size */
  12066. +#define E1000_RCTL_MO_SHIFT 12 /* multicast offset shift */
  12067. +#define E1000_RCTL_MO_0 0x00000000 /* multicast offset 11:0 */
  12068. +#define E1000_RCTL_MO_1 0x00001000 /* multicast offset 12:1 */
  12069. +#define E1000_RCTL_MO_2 0x00002000 /* multicast offset 13:2 */
  12070. +#define E1000_RCTL_MO_3 0x00003000 /* multicast offset 15:4 */
  12071. +#define E1000_RCTL_MDR 0x00004000 /* multicast desc ring 0 */
  12072. +#define E1000_RCTL_BAM 0x00008000 /* broadcast enable */
  12073. +/* these buffer sizes are valid if E1000_RCTL_BSEX is 0 */
  12074. +#define E1000_RCTL_SZ_2048 0x00000000 /* rx buffer size 2048 */
  12075. +#define E1000_RCTL_SZ_1024 0x00010000 /* rx buffer size 1024 */
  12076. +#define E1000_RCTL_SZ_512 0x00020000 /* rx buffer size 512 */
  12077. +#define E1000_RCTL_SZ_256 0x00030000 /* rx buffer size 256 */
  12078. +/* these buffer sizes are valid if E1000_RCTL_BSEX is 1 */
  12079. +#define E1000_RCTL_SZ_16384 0x00010000 /* rx buffer size 16384 */
  12080. +#define E1000_RCTL_SZ_8192 0x00020000 /* rx buffer size 8192 */
  12081. +#define E1000_RCTL_SZ_4096 0x00030000 /* rx buffer size 4096 */
  12082. +#define E1000_RCTL_VFE 0x00040000 /* vlan filter enable */
  12083. +#define E1000_RCTL_CFIEN 0x00080000 /* canonical form enable */
  12084. +#define E1000_RCTL_CFI 0x00100000 /* canonical form indicator */
  12085. +#define E1000_RCTL_DPF 0x00400000 /* discard pause frames */
  12086. +#define E1000_RCTL_PMCF 0x00800000 /* pass MAC control frames */
  12087. +#define E1000_RCTL_BSEX 0x02000000 /* Buffer size extension */
  12088. +
  12089. +/* Receive Descriptor */
  12090. +#define E1000_RDT_DELAY 0x0000ffff /* Delay timer (1=1024us) */
  12091. +#define E1000_RDT_FPDB 0x80000000 /* Flush descriptor block */
  12092. +#define E1000_RDLEN_LEN 0x0007ff80 /* descriptor length */
  12093. +#define E1000_RDH_RDH 0x0000ffff /* receive descriptor head */
  12094. +#define E1000_RDT_RDT 0x0000ffff /* receive descriptor tail */
  12095. +
  12096. +/* Flow Control */
  12097. +#define E1000_FCRTH_RTH 0x0000FFF8 /* Mask Bits[15:3] for RTH */
  12098. +#define E1000_FCRTH_XFCE 0x80000000 /* External Flow Control Enable */
  12099. +#define E1000_FCRTL_RTL 0x0000FFF8 /* Mask Bits[15:3] for RTL */
  12100. +#define E1000_FCRTL_XONE 0x80000000 /* Enable XON frame transmission */
  12101. +
  12102. +/* Receive Descriptor Control */
  12103. +#define E1000_RXDCTL_PTHRESH 0x0000003F /* RXDCTL Prefetch Threshold */
  12104. +#define E1000_RXDCTL_HTHRESH 0x00003F00 /* RXDCTL Host Threshold */
  12105. +#define E1000_RXDCTL_WTHRESH 0x003F0000 /* RXDCTL Writeback Threshold */
  12106. +#define E1000_RXDCTL_GRAN 0x01000000 /* RXDCTL Granularity */
  12107. +
  12108. +/* Transmit Descriptor Control */
  12109. +#define E1000_TXDCTL_PTHRESH 0x000000FF /* TXDCTL Prefetch Threshold */
  12110. +#define E1000_TXDCTL_HTHRESH 0x0000FF00 /* TXDCTL Host Threshold */
  12111. +#define E1000_TXDCTL_WTHRESH 0x00FF0000 /* TXDCTL Writeback Threshold */
  12112. +#define E1000_TXDCTL_GRAN 0x01000000 /* TXDCTL Granularity */
  12113. +#define E1000_TXDCTL_LWTHRESH 0xFE000000 /* TXDCTL Low Threshold */
  12114. +#define E1000_TXDCTL_FULL_TX_DESC_WB 0x01010000 /* GRAN=1, WTHRESH=1 */
  12115. +
  12116. +/* Transmit Configuration Word */
  12117. +#define E1000_TXCW_FD 0x00000020 /* TXCW full duplex */
  12118. +#define E1000_TXCW_HD 0x00000040 /* TXCW half duplex */
  12119. +#define E1000_TXCW_PAUSE 0x00000080 /* TXCW sym pause request */
  12120. +#define E1000_TXCW_ASM_DIR 0x00000100 /* TXCW astm pause direction */
  12121. +#define E1000_TXCW_PAUSE_MASK 0x00000180 /* TXCW pause request mask */
  12122. +#define E1000_TXCW_RF 0x00003000 /* TXCW remote fault */
  12123. +#define E1000_TXCW_NP 0x00008000 /* TXCW next page */
  12124. +#define E1000_TXCW_CW 0x0000ffff /* TxConfigWord mask */
  12125. +#define E1000_TXCW_TXC 0x40000000 /* Transmit Config control */
  12126. +#define E1000_TXCW_ANE 0x80000000 /* Auto-neg enable */
  12127. +
  12128. +/* Receive Configuration Word */
  12129. +#define E1000_RXCW_CW 0x0000ffff /* RxConfigWord mask */
  12130. +#define E1000_RXCW_NC 0x04000000 /* Receive config no carrier */
  12131. +#define E1000_RXCW_IV 0x08000000 /* Receive config invalid */
  12132. +#define E1000_RXCW_CC 0x10000000 /* Receive config change */
  12133. +#define E1000_RXCW_C 0x20000000 /* Receive config */
  12134. +#define E1000_RXCW_SYNCH 0x40000000 /* Receive config synch */
  12135. +#define E1000_RXCW_ANC 0x80000000 /* Auto-neg complete */
  12136. +
  12137. +/* Transmit Control */
  12138. +#define E1000_TCTL_RST 0x00000001 /* software reset */
  12139. +#define E1000_TCTL_EN 0x00000002 /* enable tx */
  12140. +#define E1000_TCTL_BCE 0x00000004 /* busy check enable */
  12141. +#define E1000_TCTL_PSP 0x00000008 /* pad short packets */
  12142. +#define E1000_TCTL_CT 0x00000ff0 /* collision threshold */
  12143. +#define E1000_TCTL_COLD 0x003ff000 /* collision distance */
  12144. +#define E1000_TCTL_SWXOFF 0x00400000 /* SW Xoff transmission */
  12145. +#define E1000_TCTL_PBE 0x00800000 /* Packet Burst Enable */
  12146. +#define E1000_TCTL_RTLC 0x01000000 /* Re-transmit on late collision */
  12147. +#define E1000_TCTL_NRTU 0x02000000 /* No Re-transmit on underrun */
  12148. +
  12149. +/* Receive Checksum Control */
  12150. +#define E1000_RXCSUM_PCSS_MASK 0x000000FF /* Packet Checksum Start */
  12151. +#define E1000_RXCSUM_IPOFL 0x00000100 /* IPv4 checksum offload */
  12152. +#define E1000_RXCSUM_TUOFL 0x00000200 /* TCP / UDP checksum offload */
  12153. +#define E1000_RXCSUM_IPV6OFL 0x00000400 /* IPv6 checksum offload */
  12154. +
  12155. +/* Definitions for power management and wakeup registers */
  12156. +/* Wake Up Control */
  12157. +#define E1000_WUC_APME 0x00000001 /* APM Enable */
  12158. +#define E1000_WUC_PME_EN 0x00000002 /* PME Enable */
  12159. +#define E1000_WUC_PME_STATUS 0x00000004 /* PME Status */
  12160. +#define E1000_WUC_APMPME 0x00000008 /* Assert PME on APM Wakeup */
  12161. +#define E1000_WUC_SPM 0x80000000 /* Enable SPM */
  12162. +
  12163. +/* Wake Up Filter Control */
  12164. +#define E1000_WUFC_LNKC 0x00000001 /* Link Status Change Wakeup Enable */
  12165. +#define E1000_WUFC_MAG 0x00000002 /* Magic Packet Wakeup Enable */
  12166. +#define E1000_WUFC_EX 0x00000004 /* Directed Exact Wakeup Enable */
  12167. +#define E1000_WUFC_MC 0x00000008 /* Directed Multicast Wakeup Enable */
  12168. +#define E1000_WUFC_BC 0x00000010 /* Broadcast Wakeup Enable */
  12169. +#define E1000_WUFC_ARP 0x00000020 /* ARP Request Packet Wakeup Enable */
  12170. +#define E1000_WUFC_IPV4 0x00000040 /* Directed IPv4 Packet Wakeup Enable */
  12171. +#define E1000_WUFC_IPV6 0x00000080 /* Directed IPv6 Packet Wakeup Enable */
  12172. +#define E1000_WUFC_FLX0 0x00010000 /* Flexible Filter 0 Enable */
  12173. +#define E1000_WUFC_FLX1 0x00020000 /* Flexible Filter 1 Enable */
  12174. +#define E1000_WUFC_FLX2 0x00040000 /* Flexible Filter 2 Enable */
  12175. +#define E1000_WUFC_FLX3 0x00080000 /* Flexible Filter 3 Enable */
  12176. +#define E1000_WUFC_ALL_FILTERS 0x000F00FF /* Mask for all wakeup filters */
  12177. +#define E1000_WUFC_FLX_OFFSET 16 /* Offset to the Flexible Filters bits */
  12178. +#define E1000_WUFC_FLX_FILTERS 0x000F0000 /* Mask for the 4 flexible filters */
  12179. +
  12180. +/* Wake Up Status */
  12181. +#define E1000_WUS_LNKC 0x00000001 /* Link Status Changed */
  12182. +#define E1000_WUS_MAG 0x00000002 /* Magic Packet Received */
  12183. +#define E1000_WUS_EX 0x00000004 /* Directed Exact Received */
  12184. +#define E1000_WUS_MC 0x00000008 /* Directed Multicast Received */
  12185. +#define E1000_WUS_BC 0x00000010 /* Broadcast Received */
  12186. +#define E1000_WUS_ARP 0x00000020 /* ARP Request Packet Received */
  12187. +#define E1000_WUS_IPV4 0x00000040 /* Directed IPv4 Packet Wakeup Received */
  12188. +#define E1000_WUS_IPV6 0x00000080 /* Directed IPv6 Packet Wakeup Received */
  12189. +#define E1000_WUS_FLX0 0x00010000 /* Flexible Filter 0 Match */
  12190. +#define E1000_WUS_FLX1 0x00020000 /* Flexible Filter 1 Match */
  12191. +#define E1000_WUS_FLX2 0x00040000 /* Flexible Filter 2 Match */
  12192. +#define E1000_WUS_FLX3 0x00080000 /* Flexible Filter 3 Match */
  12193. +#define E1000_WUS_FLX_FILTERS 0x000F0000 /* Mask for the 4 flexible filters */
  12194. +
  12195. +/* Management Control */
  12196. +#define E1000_MANC_SMBUS_EN 0x00000001 /* SMBus Enabled - RO */
  12197. +#define E1000_MANC_ASF_EN 0x00000002 /* ASF Enabled - RO */
  12198. +#define E1000_MANC_R_ON_FORCE 0x00000004 /* Reset on Force TCO - RO */
  12199. +#define E1000_MANC_RMCP_EN 0x00000100 /* Enable RCMP 026Fh Filtering */
  12200. +#define E1000_MANC_0298_EN 0x00000200 /* Enable RCMP 0298h Filtering */
  12201. +#define E1000_MANC_IPV4_EN 0x00000400 /* Enable IPv4 */
  12202. +#define E1000_MANC_IPV6_EN 0x00000800 /* Enable IPv6 */
  12203. +#define E1000_MANC_SNAP_EN 0x00001000 /* Accept LLC/SNAP */
  12204. +#define E1000_MANC_ARP_EN 0x00002000 /* Enable ARP Request Filtering */
  12205. +#define E1000_MANC_NEIGHBOR_EN 0x00004000 /* Enable Neighbor Discovery
  12206. + * Filtering */
  12207. +#define E1000_MANC_TCO_RESET 0x00010000 /* TCO Reset Occurred */
  12208. +#define E1000_MANC_RCV_TCO_EN 0x00020000 /* Receive TCO Packets Enabled */
  12209. +#define E1000_MANC_REPORT_STATUS 0x00040000 /* Status Reporting Enabled */
  12210. +#define E1000_MANC_SMB_REQ 0x01000000 /* SMBus Request */
  12211. +#define E1000_MANC_SMB_GNT 0x02000000 /* SMBus Grant */
  12212. +#define E1000_MANC_SMB_CLK_IN 0x04000000 /* SMBus Clock In */
  12213. +#define E1000_MANC_SMB_DATA_IN 0x08000000 /* SMBus Data In */
  12214. +#define E1000_MANC_SMB_DATA_OUT 0x10000000 /* SMBus Data Out */
  12215. +#define E1000_MANC_SMB_CLK_OUT 0x20000000 /* SMBus Clock Out */
  12216. +
  12217. +#define E1000_MANC_SMB_DATA_OUT_SHIFT 28 /* SMBus Data Out Shift */
  12218. +#define E1000_MANC_SMB_CLK_OUT_SHIFT 29 /* SMBus Clock Out Shift */
  12219. +
  12220. +/* Wake Up Packet Length */
  12221. +#define E1000_WUPL_LENGTH_MASK 0x0FFF /* Only the lower 12 bits are valid */
  12222. +
  12223. +#define E1000_MDALIGN 4096
  12224. +
  12225. +/* EEPROM Commands - Microwire */
  12226. +#define EEPROM_READ_OPCODE_MICROWIRE 0x6 /* EEPROM read opcode */
  12227. +#define EEPROM_WRITE_OPCODE_MICROWIRE 0x5 /* EEPROM write opcode */
  12228. +#define EEPROM_ERASE_OPCODE_MICROWIRE 0x7 /* EEPROM erase opcode */
  12229. +#define EEPROM_EWEN_OPCODE_MICROWIRE 0x13 /* EEPROM erase/write enable */
  12230. +#define EEPROM_EWDS_OPCODE_MICROWIRE 0x10 /* EEPROM erast/write disable */
  12231. +
  12232. +/* EEPROM Commands - SPI */
  12233. +#define EEPROM_MAX_RETRY_SPI 5000 /* Max wait of 5ms, for RDY signal */
  12234. +#define EEPROM_READ_OPCODE_SPI 0x3 /* EEPROM read opcode */
  12235. +#define EEPROM_WRITE_OPCODE_SPI 0x2 /* EEPROM write opcode */
  12236. +#define EEPROM_A8_OPCODE_SPI 0x8 /* opcode bit-3 = address bit-8 */
  12237. +#define EEPROM_WREN_OPCODE_SPI 0x6 /* EEPROM set Write Enable latch */
  12238. +#define EEPROM_WRDI_OPCODE_SPI 0x4 /* EEPROM reset Write Enable latch */
  12239. +#define EEPROM_RDSR_OPCODE_SPI 0x5 /* EEPROM read Status register */
  12240. +#define EEPROM_WRSR_OPCODE_SPI 0x1 /* EEPROM write Status register */
  12241. +
  12242. +/* EEPROM Size definitions */
  12243. +#define EEPROM_SIZE_16KB 0x1800
  12244. +#define EEPROM_SIZE_8KB 0x1400
  12245. +#define EEPROM_SIZE_4KB 0x1000
  12246. +#define EEPROM_SIZE_2KB 0x0C00
  12247. +#define EEPROM_SIZE_1KB 0x0800
  12248. +#define EEPROM_SIZE_512B 0x0400
  12249. +#define EEPROM_SIZE_128B 0x0000
  12250. +#define EEPROM_SIZE_MASK 0x1C00
  12251. +
  12252. +/* EEPROM Word Offsets */
  12253. +#define EEPROM_COMPAT 0x0003
  12254. +#define EEPROM_ID_LED_SETTINGS 0x0004
  12255. +#define EEPROM_SERDES_AMPLITUDE 0x0006 /* For SERDES output amplitude adjustment. */
  12256. +#define EEPROM_INIT_CONTROL1_REG 0x000A
  12257. +#define EEPROM_INIT_CONTROL2_REG 0x000F
  12258. +#define EEPROM_INIT_CONTROL3_PORT_B 0x0014
  12259. +#define EEPROM_INIT_CONTROL3_PORT_A 0x0024
  12260. +#define EEPROM_CFG 0x0012
  12261. +#define EEPROM_FLASH_VERSION 0x0032
  12262. +#define EEPROM_CHECKSUM_REG 0x003F
  12263. +
  12264. +/* Word definitions for ID LED Settings */
  12265. +#define ID_LED_RESERVED_0000 0x0000
  12266. +#define ID_LED_RESERVED_FFFF 0xFFFF
  12267. +#define ID_LED_DEFAULT ((ID_LED_OFF1_ON2 << 12) | \
  12268. + (ID_LED_OFF1_OFF2 << 8) | \
  12269. + (ID_LED_DEF1_DEF2 << 4) | \
  12270. + (ID_LED_DEF1_DEF2))
  12271. +#define ID_LED_DEF1_DEF2 0x1
  12272. +#define ID_LED_DEF1_ON2 0x2
  12273. +#define ID_LED_DEF1_OFF2 0x3
  12274. +#define ID_LED_ON1_DEF2 0x4
  12275. +#define ID_LED_ON1_ON2 0x5
  12276. +#define ID_LED_ON1_OFF2 0x6
  12277. +#define ID_LED_OFF1_DEF2 0x7
  12278. +#define ID_LED_OFF1_ON2 0x8
  12279. +#define ID_LED_OFF1_OFF2 0x9
  12280. +
  12281. +#define IGP_ACTIVITY_LED_MASK 0xFFFFF0FF
  12282. +#define IGP_ACTIVITY_LED_ENABLE 0x0300
  12283. +#define IGP_LED3_MODE 0x07000000
  12284. +
  12285. +
  12286. +/* Mask bits for SERDES amplitude adjustment in Word 6 of the EEPROM */
  12287. +#define EEPROM_SERDES_AMPLITUDE_MASK 0x000F
  12288. +
  12289. +/* Mask bits for fields in Word 0x0a of the EEPROM */
  12290. +#define EEPROM_WORD0A_ILOS 0x0010
  12291. +#define EEPROM_WORD0A_SWDPIO 0x01E0
  12292. +#define EEPROM_WORD0A_LRST 0x0200
  12293. +#define EEPROM_WORD0A_FD 0x0400
  12294. +#define EEPROM_WORD0A_66MHZ 0x0800
  12295. +
  12296. +/* Mask bits for fields in Word 0x0f of the EEPROM */
  12297. +#define EEPROM_WORD0F_PAUSE_MASK 0x3000
  12298. +#define EEPROM_WORD0F_PAUSE 0x1000
  12299. +#define EEPROM_WORD0F_ASM_DIR 0x2000
  12300. +#define EEPROM_WORD0F_ANE 0x0800
  12301. +#define EEPROM_WORD0F_SWPDIO_EXT 0x00F0
  12302. +
  12303. +/* For checksumming, the sum of all words in the EEPROM should equal 0xBABA. */
  12304. +#define EEPROM_SUM 0xBABA
  12305. +
  12306. +/* EEPROM Map defines (WORD OFFSETS)*/
  12307. +#define EEPROM_NODE_ADDRESS_BYTE_0 0
  12308. +#define EEPROM_PBA_BYTE_1 8
  12309. +
  12310. +#define EEPROM_RESERVED_WORD 0xFFFF
  12311. +
  12312. +/* EEPROM Map Sizes (Byte Counts) */
  12313. +#define PBA_SIZE 4
  12314. +
  12315. +/* Collision related configuration parameters */
  12316. +#define E1000_COLLISION_THRESHOLD 16
  12317. +#define E1000_CT_SHIFT 4
  12318. +#define E1000_COLLISION_DISTANCE 64
  12319. +#define E1000_FDX_COLLISION_DISTANCE E1000_COLLISION_DISTANCE
  12320. +#define E1000_HDX_COLLISION_DISTANCE E1000_COLLISION_DISTANCE
  12321. +#define E1000_COLD_SHIFT 12
  12322. +
  12323. +/* Number of Transmit and Receive Descriptors must be a multiple of 8 */
  12324. +#define REQ_TX_DESCRIPTOR_MULTIPLE 8
  12325. +#define REQ_RX_DESCRIPTOR_MULTIPLE 8
  12326. +
  12327. +/* Default values for the transmit IPG register */
  12328. +#define DEFAULT_82542_TIPG_IPGT 10
  12329. +#define DEFAULT_82543_TIPG_IPGT_FIBER 9
  12330. +#define DEFAULT_82543_TIPG_IPGT_COPPER 8
  12331. +
  12332. +#define E1000_TIPG_IPGT_MASK 0x000003FF
  12333. +#define E1000_TIPG_IPGR1_MASK 0x000FFC00
  12334. +#define E1000_TIPG_IPGR2_MASK 0x3FF00000
  12335. +
  12336. +#define DEFAULT_82542_TIPG_IPGR1 2
  12337. +#define DEFAULT_82543_TIPG_IPGR1 8
  12338. +#define E1000_TIPG_IPGR1_SHIFT 10
  12339. +
  12340. +#define DEFAULT_82542_TIPG_IPGR2 10
  12341. +#define DEFAULT_82543_TIPG_IPGR2 6
  12342. +#define E1000_TIPG_IPGR2_SHIFT 20
  12343. +
  12344. +#define E1000_TXDMAC_DPP 0x00000001
  12345. +
  12346. +/* Adaptive IFS defines */
  12347. +#define TX_THRESHOLD_START 8
  12348. +#define TX_THRESHOLD_INCREMENT 10
  12349. +#define TX_THRESHOLD_DECREMENT 1
  12350. +#define TX_THRESHOLD_STOP 190
  12351. +#define TX_THRESHOLD_DISABLE 0
  12352. +#define TX_THRESHOLD_TIMER_MS 10000
  12353. +#define MIN_NUM_XMITS 1000
  12354. +#define IFS_MAX 80
  12355. +#define IFS_STEP 10
  12356. +#define IFS_MIN 40
  12357. +#define IFS_RATIO 4
  12358. +
  12359. +/* PBA constants */
  12360. +#define E1000_PBA_16K 0x0010 /* 16KB, default TX allocation */
  12361. +#define E1000_PBA_22K 0x0016
  12362. +#define E1000_PBA_24K 0x0018
  12363. +#define E1000_PBA_30K 0x001E
  12364. +#define E1000_PBA_40K 0x0028
  12365. +#define E1000_PBA_48K 0x0030 /* 48KB, default RX allocation */
  12366. +
  12367. +/* Flow Control Constants */
  12368. +#define FLOW_CONTROL_ADDRESS_LOW 0x00C28001
  12369. +#define FLOW_CONTROL_ADDRESS_HIGH 0x00000100
  12370. +#define FLOW_CONTROL_TYPE 0x8808
  12371. +
  12372. +/* The historical defaults for the flow control values are given below. */
  12373. +#define FC_DEFAULT_HI_THRESH (0x8000) /* 32KB */
  12374. +#define FC_DEFAULT_LO_THRESH (0x4000) /* 16KB */
  12375. +#define FC_DEFAULT_TX_TIMER (0x100) /* ~130 us */
  12376. +
  12377. +/* PCIX Config space */
  12378. +#define PCIX_COMMAND_REGISTER 0xE6
  12379. +#define PCIX_STATUS_REGISTER_LO 0xE8
  12380. +#define PCIX_STATUS_REGISTER_HI 0xEA
  12381. +
  12382. +#define PCIX_COMMAND_MMRBC_MASK 0x000C
  12383. +#define PCIX_COMMAND_MMRBC_SHIFT 0x2
  12384. +#define PCIX_STATUS_HI_MMRBC_MASK 0x0060
  12385. +#define PCIX_STATUS_HI_MMRBC_SHIFT 0x5
  12386. +#define PCIX_STATUS_HI_MMRBC_4K 0x3
  12387. +#define PCIX_STATUS_HI_MMRBC_2K 0x2
  12388. +
  12389. +
  12390. +/* Number of bits required to shift right the "pause" bits from the
  12391. + * EEPROM (bits 13:12) to the "pause" (bits 8:7) field in the TXCW register.
  12392. + */
  12393. +#define PAUSE_SHIFT 5
  12394. +
  12395. +/* Number of bits required to shift left the "SWDPIO" bits from the
  12396. + * EEPROM (bits 8:5) to the "SWDPIO" (bits 25:22) field in the CTRL register.
  12397. + */
  12398. +#define SWDPIO_SHIFT 17
  12399. +
  12400. +/* Number of bits required to shift left the "SWDPIO_EXT" bits from the
  12401. + * EEPROM word F (bits 7:4) to the bits 11:8 of The Extended CTRL register.
  12402. + */
  12403. +#define SWDPIO__EXT_SHIFT 4
  12404. +
  12405. +/* Number of bits required to shift left the "ILOS" bit from the EEPROM
  12406. + * (bit 4) to the "ILOS" (bit 7) field in the CTRL register.
  12407. + */
  12408. +#define ILOS_SHIFT 3
  12409. +
  12410. +
  12411. +#define RECEIVE_BUFFER_ALIGN_SIZE (256)
  12412. +
  12413. +/* Number of milliseconds we wait for auto-negotiation to complete */
  12414. +#define LINK_UP_TIMEOUT 500
  12415. +
  12416. +#define E1000_TX_BUFFER_SIZE ((uint32_t)1514)
  12417. +
  12418. +/* The carrier extension symbol, as received by the NIC. */
  12419. +#define CARRIER_EXTENSION 0x0F
  12420. +
  12421. +/* TBI_ACCEPT macro definition:
  12422. + *
  12423. + * This macro requires:
  12424. + * adapter = a pointer to struct e1000_hw
  12425. + * status = the 8 bit status field of the RX descriptor with EOP set
  12426. + * error = the 8 bit error field of the RX descriptor with EOP set
  12427. + * length = the sum of all the length fields of the RX descriptors that
  12428. + * make up the current frame
  12429. + * last_byte = the last byte of the frame DMAed by the hardware
  12430. + * max_frame_length = the maximum frame length we want to accept.
  12431. + * min_frame_length = the minimum frame length we want to accept.
  12432. + *
  12433. + * This macro is a conditional that should be used in the interrupt
  12434. + * handler's Rx processing routine when RxErrors have been detected.
  12435. + *
  12436. + * Typical use:
  12437. + * ...
  12438. + * if (TBI_ACCEPT) {
  12439. + * accept_frame = TRUE;
  12440. + * e1000_tbi_adjust_stats(adapter, MacAddress);
  12441. + * frame_length--;
  12442. + * } else {
  12443. + * accept_frame = FALSE;
  12444. + * }
  12445. + * ...
  12446. + */
  12447. +
  12448. +#define TBI_ACCEPT(adapter, status, errors, length, last_byte) \
  12449. + ((adapter)->tbi_compatibility_on && \
  12450. + (((errors) & E1000_RXD_ERR_FRAME_ERR_MASK) == E1000_RXD_ERR_CE) && \
  12451. + ((last_byte) == CARRIER_EXTENSION) && \
  12452. + (((status) & E1000_RXD_STAT_VP) ? \
  12453. + (((length) > ((adapter)->min_frame_size - VLAN_TAG_SIZE)) && \
  12454. + ((length) <= ((adapter)->max_frame_size + 1))) : \
  12455. + (((length) > (adapter)->min_frame_size) && \
  12456. + ((length) <= ((adapter)->max_frame_size + VLAN_TAG_SIZE + 1)))))
  12457. +
  12458. +
  12459. +/* Structures, enums, and macros for the PHY */
  12460. +
  12461. +/* Bit definitions for the Management Data IO (MDIO) and Management Data
  12462. + * Clock (MDC) pins in the Device Control Register.
  12463. + */
  12464. +#define E1000_CTRL_PHY_RESET_DIR E1000_CTRL_SWDPIO0
  12465. +#define E1000_CTRL_PHY_RESET E1000_CTRL_SWDPIN0
  12466. +#define E1000_CTRL_MDIO_DIR E1000_CTRL_SWDPIO2
  12467. +#define E1000_CTRL_MDIO E1000_CTRL_SWDPIN2
  12468. +#define E1000_CTRL_MDC_DIR E1000_CTRL_SWDPIO3
  12469. +#define E1000_CTRL_MDC E1000_CTRL_SWDPIN3
  12470. +#define E1000_CTRL_PHY_RESET_DIR4 E1000_CTRL_EXT_SDP4_DIR
  12471. +#define E1000_CTRL_PHY_RESET4 E1000_CTRL_EXT_SDP4_DATA
  12472. +
  12473. +/* PHY 1000 MII Register/Bit Definitions */
  12474. +/* PHY Registers defined by IEEE */
  12475. +#define PHY_CTRL 0x00 /* Control Register */
  12476. +#define PHY_STATUS 0x01 /* Status Regiser */
  12477. +#define PHY_ID1 0x02 /* Phy Id Reg (word 1) */
  12478. +#define PHY_ID2 0x03 /* Phy Id Reg (word 2) */
  12479. +#define PHY_AUTONEG_ADV 0x04 /* Autoneg Advertisement */
  12480. +#define PHY_LP_ABILITY 0x05 /* Link Partner Ability (Base Page) */
  12481. +#define PHY_AUTONEG_EXP 0x06 /* Autoneg Expansion Reg */
  12482. +#define PHY_NEXT_PAGE_TX 0x07 /* Next Page TX */
  12483. +#define PHY_LP_NEXT_PAGE 0x08 /* Link Partner Next Page */
  12484. +#define PHY_1000T_CTRL 0x09 /* 1000Base-T Control Reg */
  12485. +#define PHY_1000T_STATUS 0x0A /* 1000Base-T Status Reg */
  12486. +#define PHY_EXT_STATUS 0x0F /* Extended Status Reg */
  12487. +
  12488. +/* M88E1000 Specific Registers */
  12489. +#define M88E1000_PHY_SPEC_CTRL 0x10 /* PHY Specific Control Register */
  12490. +#define M88E1000_PHY_SPEC_STATUS 0x11 /* PHY Specific Status Register */
  12491. +#define M88E1000_INT_ENABLE 0x12 /* Interrupt Enable Register */
  12492. +#define M88E1000_INT_STATUS 0x13 /* Interrupt Status Register */
  12493. +#define M88E1000_EXT_PHY_SPEC_CTRL 0x14 /* Extended PHY Specific Control */
  12494. +#define M88E1000_RX_ERR_CNTR 0x15 /* Receive Error Counter */
  12495. +
  12496. +#define M88E1000_PHY_EXT_CTRL 0x1A /* PHY extend control register */
  12497. +#define M88E1000_PHY_PAGE_SELECT 0x1D /* Reg 29 for page number setting */
  12498. +#define M88E1000_PHY_GEN_CONTROL 0x1E /* Its meaning depends on reg 29 */
  12499. +#define M88E1000_PHY_VCO_REG_BIT8 0x100 /* Bits 8 & 11 are adjusted for */
  12500. +#define M88E1000_PHY_VCO_REG_BIT11 0x800 /* improved BER performance */
  12501. +
  12502. +#define IGP01E1000_IEEE_REGS_PAGE 0x0000
  12503. +#define IGP01E1000_IEEE_RESTART_AUTONEG 0x3300
  12504. +#define IGP01E1000_IEEE_FORCE_GIGA 0x0140
  12505. +
  12506. +/* IGP01E1000 Specific Registers */
  12507. +#define IGP01E1000_PHY_PORT_CONFIG 0x10 /* PHY Specific Port Config Register */
  12508. +#define IGP01E1000_PHY_PORT_STATUS 0x11 /* PHY Specific Status Register */
  12509. +#define IGP01E1000_PHY_PORT_CTRL 0x12 /* PHY Specific Control Register */
  12510. +#define IGP01E1000_PHY_LINK_HEALTH 0x13 /* PHY Link Health Register */
  12511. +#define IGP01E1000_GMII_FIFO 0x14 /* GMII FIFO Register */
  12512. +#define IGP01E1000_PHY_CHANNEL_QUALITY 0x15 /* PHY Channel Quality Register */
  12513. +#define IGP01E1000_PHY_PAGE_SELECT 0x1F /* PHY Page Select Core Register */
  12514. +
  12515. +/* IGP01E1000 AGC Registers - stores the cable length values*/
  12516. +#define IGP01E1000_PHY_AGC_A 0x1172
  12517. +#define IGP01E1000_PHY_AGC_B 0x1272
  12518. +#define IGP01E1000_PHY_AGC_C 0x1472
  12519. +#define IGP01E1000_PHY_AGC_D 0x1872
  12520. +
  12521. +/* IGP01E1000 DSP Reset Register */
  12522. +#define IGP01E1000_PHY_DSP_RESET 0x1F33
  12523. +#define IGP01E1000_PHY_DSP_SET 0x1F71
  12524. +#define IGP01E1000_PHY_DSP_FFE 0x1F35
  12525. +
  12526. +#define IGP01E1000_PHY_CHANNEL_NUM 4
  12527. +#define IGP01E1000_PHY_AGC_PARAM_A 0x1171
  12528. +#define IGP01E1000_PHY_AGC_PARAM_B 0x1271
  12529. +#define IGP01E1000_PHY_AGC_PARAM_C 0x1471
  12530. +#define IGP01E1000_PHY_AGC_PARAM_D 0x1871
  12531. +
  12532. +#define IGP01E1000_PHY_EDAC_MU_INDEX 0xC000
  12533. +#define IGP01E1000_PHY_EDAC_SIGN_EXT_9_BITS 0x8000
  12534. +
  12535. +#define IGP01E1000_PHY_ANALOG_TX_STATE 0x2890
  12536. +#define IGP01E1000_PHY_ANALOG_CLASS_A 0x2000
  12537. +#define IGP01E1000_PHY_FORCE_ANALOG_ENABLE 0x0004
  12538. +#define IGP01E1000_PHY_DSP_FFE_CM_CP 0x0069
  12539. +
  12540. +#define IGP01E1000_PHY_DSP_FFE_DEFAULT 0x002A
  12541. +/* IGP01E1000 PCS Initialization register - stores the polarity status when
  12542. + * speed = 1000 Mbps. */
  12543. +#define IGP01E1000_PHY_PCS_INIT_REG 0x00B4
  12544. +#define IGP01E1000_PHY_PCS_CTRL_REG 0x00B5
  12545. +
  12546. +#define IGP01E1000_ANALOG_REGS_PAGE 0x20C0
  12547. +
  12548. +#define MAX_PHY_REG_ADDRESS 0x1F /* 5 bit address bus (0-0x1F) */
  12549. +#define MAX_PHY_MULTI_PAGE_REG 0xF /*Registers that are equal on all pages*/
  12550. +/* PHY Control Register */
  12551. +#define MII_CR_SPEED_SELECT_MSB 0x0040 /* bits 6,13: 10=1000, 01=100, 00=10 */
  12552. +#define MII_CR_COLL_TEST_ENABLE 0x0080 /* Collision test enable */
  12553. +#define MII_CR_FULL_DUPLEX 0x0100 /* FDX =1, half duplex =0 */
  12554. +#define MII_CR_RESTART_AUTO_NEG 0x0200 /* Restart auto negotiation */
  12555. +#define MII_CR_ISOLATE 0x0400 /* Isolate PHY from MII */
  12556. +#define MII_CR_POWER_DOWN 0x0800 /* Power down */
  12557. +#define MII_CR_AUTO_NEG_EN 0x1000 /* Auto Neg Enable */
  12558. +#define MII_CR_SPEED_SELECT_LSB 0x2000 /* bits 6,13: 10=1000, 01=100, 00=10 */
  12559. +#define MII_CR_LOOPBACK 0x4000 /* 0 = normal, 1 = loopback */
  12560. +#define MII_CR_RESET 0x8000 /* 0 = normal, 1 = PHY reset */
  12561. +
  12562. +/* PHY Status Register */
  12563. +#define MII_SR_EXTENDED_CAPS 0x0001 /* Extended register capabilities */
  12564. +#define MII_SR_JABBER_DETECT 0x0002 /* Jabber Detected */
  12565. +#define MII_SR_LINK_STATUS 0x0004 /* Link Status 1 = link */
  12566. +#define MII_SR_AUTONEG_CAPS 0x0008 /* Auto Neg Capable */
  12567. +#define MII_SR_REMOTE_FAULT 0x0010 /* Remote Fault Detect */
  12568. +#define MII_SR_AUTONEG_COMPLETE 0x0020 /* Auto Neg Complete */
  12569. +#define MII_SR_PREAMBLE_SUPPRESS 0x0040 /* Preamble may be suppressed */
  12570. +#define MII_SR_EXTENDED_STATUS 0x0100 /* Ext. status info in Reg 0x0F */
  12571. +#define MII_SR_100T2_HD_CAPS 0x0200 /* 100T2 Half Duplex Capable */
  12572. +#define MII_SR_100T2_FD_CAPS 0x0400 /* 100T2 Full Duplex Capable */
  12573. +#define MII_SR_10T_HD_CAPS 0x0800 /* 10T Half Duplex Capable */
  12574. +#define MII_SR_10T_FD_CAPS 0x1000 /* 10T Full Duplex Capable */
  12575. +#define MII_SR_100X_HD_CAPS 0x2000 /* 100X Half Duplex Capable */
  12576. +#define MII_SR_100X_FD_CAPS 0x4000 /* 100X Full Duplex Capable */
  12577. +#define MII_SR_100T4_CAPS 0x8000 /* 100T4 Capable */
  12578. +
  12579. +/* Autoneg Advertisement Register */
  12580. +#define NWAY_AR_SELECTOR_FIELD 0x0001 /* indicates IEEE 802.3 CSMA/CD */
  12581. +#define NWAY_AR_10T_HD_CAPS 0x0020 /* 10T Half Duplex Capable */
  12582. +#define NWAY_AR_10T_FD_CAPS 0x0040 /* 10T Full Duplex Capable */
  12583. +#define NWAY_AR_100TX_HD_CAPS 0x0080 /* 100TX Half Duplex Capable */
  12584. +#define NWAY_AR_100TX_FD_CAPS 0x0100 /* 100TX Full Duplex Capable */
  12585. +#define NWAY_AR_100T4_CAPS 0x0200 /* 100T4 Capable */
  12586. +#define NWAY_AR_PAUSE 0x0400 /* Pause operation desired */
  12587. +#define NWAY_AR_ASM_DIR 0x0800 /* Asymmetric Pause Direction bit */
  12588. +#define NWAY_AR_REMOTE_FAULT 0x2000 /* Remote Fault detected */
  12589. +#define NWAY_AR_NEXT_PAGE 0x8000 /* Next Page ability supported */
  12590. +
  12591. +/* Link Partner Ability Register (Base Page) */
  12592. +#define NWAY_LPAR_SELECTOR_FIELD 0x0000 /* LP protocol selector field */
  12593. +#define NWAY_LPAR_10T_HD_CAPS 0x0020 /* LP is 10T Half Duplex Capable */
  12594. +#define NWAY_LPAR_10T_FD_CAPS 0x0040 /* LP is 10T Full Duplex Capable */
  12595. +#define NWAY_LPAR_100TX_HD_CAPS 0x0080 /* LP is 100TX Half Duplex Capable */
  12596. +#define NWAY_LPAR_100TX_FD_CAPS 0x0100 /* LP is 100TX Full Duplex Capable */
  12597. +#define NWAY_LPAR_100T4_CAPS 0x0200 /* LP is 100T4 Capable */
  12598. +#define NWAY_LPAR_PAUSE 0x0400 /* LP Pause operation desired */
  12599. +#define NWAY_LPAR_ASM_DIR 0x0800 /* LP Asymmetric Pause Direction bit */
  12600. +#define NWAY_LPAR_REMOTE_FAULT 0x2000 /* LP has detected Remote Fault */
  12601. +#define NWAY_LPAR_ACKNOWLEDGE 0x4000 /* LP has rx'd link code word */
  12602. +#define NWAY_LPAR_NEXT_PAGE 0x8000 /* Next Page ability supported */
  12603. +
  12604. +/* Autoneg Expansion Register */
  12605. +#define NWAY_ER_LP_NWAY_CAPS 0x0001 /* LP has Auto Neg Capability */
  12606. +#define NWAY_ER_PAGE_RXD 0x0002 /* LP is 10T Half Duplex Capable */
  12607. +#define NWAY_ER_NEXT_PAGE_CAPS 0x0004 /* LP is 10T Full Duplex Capable */
  12608. +#define NWAY_ER_LP_NEXT_PAGE_CAPS 0x0008 /* LP is 100TX Half Duplex Capable */
  12609. +#define NWAY_ER_PAR_DETECT_FAULT 0x0010 /* LP is 100TX Full Duplex Capable */
  12610. +
  12611. +/* Next Page TX Register */
  12612. +#define NPTX_MSG_CODE_FIELD 0x0001 /* NP msg code or unformatted data */
  12613. +#define NPTX_TOGGLE 0x0800 /* Toggles between exchanges
  12614. + * of different NP
  12615. + */
  12616. +#define NPTX_ACKNOWLDGE2 0x1000 /* 1 = will comply with msg
  12617. + * 0 = cannot comply with msg
  12618. + */
  12619. +#define NPTX_MSG_PAGE 0x2000 /* formatted(1)/unformatted(0) pg */
  12620. +#define NPTX_NEXT_PAGE 0x8000 /* 1 = addition NP will follow
  12621. + * 0 = sending last NP
  12622. + */
  12623. +
  12624. +/* Link Partner Next Page Register */
  12625. +#define LP_RNPR_MSG_CODE_FIELD 0x0001 /* NP msg code or unformatted data */
  12626. +#define LP_RNPR_TOGGLE 0x0800 /* Toggles between exchanges
  12627. + * of different NP
  12628. + */
  12629. +#define LP_RNPR_ACKNOWLDGE2 0x1000 /* 1 = will comply with msg
  12630. + * 0 = cannot comply with msg
  12631. + */
  12632. +#define LP_RNPR_MSG_PAGE 0x2000 /* formatted(1)/unformatted(0) pg */
  12633. +#define LP_RNPR_ACKNOWLDGE 0x4000 /* 1 = ACK / 0 = NO ACK */
  12634. +#define LP_RNPR_NEXT_PAGE 0x8000 /* 1 = addition NP will follow
  12635. + * 0 = sending last NP
  12636. + */
  12637. +
  12638. +/* 1000BASE-T Control Register */
  12639. +#define CR_1000T_ASYM_PAUSE 0x0080 /* Advertise asymmetric pause bit */
  12640. +#define CR_1000T_HD_CAPS 0x0100 /* Advertise 1000T HD capability */
  12641. +#define CR_1000T_FD_CAPS 0x0200 /* Advertise 1000T FD capability */
  12642. +#define CR_1000T_REPEATER_DTE 0x0400 /* 1=Repeater/switch device port */
  12643. + /* 0=DTE device */
  12644. +#define CR_1000T_MS_VALUE 0x0800 /* 1=Configure PHY as Master */
  12645. + /* 0=Configure PHY as Slave */
  12646. +#define CR_1000T_MS_ENABLE 0x1000 /* 1=Master/Slave manual config value */
  12647. + /* 0=Automatic Master/Slave config */
  12648. +#define CR_1000T_TEST_MODE_NORMAL 0x0000 /* Normal Operation */
  12649. +#define CR_1000T_TEST_MODE_1 0x2000 /* Transmit Waveform test */
  12650. +#define CR_1000T_TEST_MODE_2 0x4000 /* Master Transmit Jitter test */
  12651. +#define CR_1000T_TEST_MODE_3 0x6000 /* Slave Transmit Jitter test */
  12652. +#define CR_1000T_TEST_MODE_4 0x8000 /* Transmitter Distortion test */
  12653. +
  12654. +/* 1000BASE-T Status Register */
  12655. +#define SR_1000T_IDLE_ERROR_CNT 0x00FF /* Num idle errors since last read */
  12656. +#define SR_1000T_ASYM_PAUSE_DIR 0x0100 /* LP asymmetric pause direction bit */
  12657. +#define SR_1000T_LP_HD_CAPS 0x0400 /* LP is 1000T HD capable */
  12658. +#define SR_1000T_LP_FD_CAPS 0x0800 /* LP is 1000T FD capable */
  12659. +#define SR_1000T_REMOTE_RX_STATUS 0x1000 /* Remote receiver OK */
  12660. +#define SR_1000T_LOCAL_RX_STATUS 0x2000 /* Local receiver OK */
  12661. +#define SR_1000T_MS_CONFIG_RES 0x4000 /* 1=Local TX is Master, 0=Slave */
  12662. +#define SR_1000T_MS_CONFIG_FAULT 0x8000 /* Master/Slave config fault */
  12663. +#define SR_1000T_REMOTE_RX_STATUS_SHIFT 12
  12664. +#define SR_1000T_LOCAL_RX_STATUS_SHIFT 13
  12665. +#define SR_1000T_PHY_EXCESSIVE_IDLE_ERR_COUNT 5
  12666. +#define FFE_IDLE_ERR_COUNT_TIMEOUT_20 20
  12667. +#define FFE_IDLE_ERR_COUNT_TIMEOUT_100 100
  12668. +
  12669. +/* Extended Status Register */
  12670. +#define IEEE_ESR_1000T_HD_CAPS 0x1000 /* 1000T HD capable */
  12671. +#define IEEE_ESR_1000T_FD_CAPS 0x2000 /* 1000T FD capable */
  12672. +#define IEEE_ESR_1000X_HD_CAPS 0x4000 /* 1000X HD capable */
  12673. +#define IEEE_ESR_1000X_FD_CAPS 0x8000 /* 1000X FD capable */
  12674. +
  12675. +#define PHY_TX_POLARITY_MASK 0x0100 /* register 10h bit 8 (polarity bit) */
  12676. +#define PHY_TX_NORMAL_POLARITY 0 /* register 10h bit 8 (normal polarity) */
  12677. +
  12678. +#define AUTO_POLARITY_DISABLE 0x0010 /* register 11h bit 4 */
  12679. + /* (0=enable, 1=disable) */
  12680. +
  12681. +/* M88E1000 PHY Specific Control Register */
  12682. +#define M88E1000_PSCR_JABBER_DISABLE 0x0001 /* 1=Jabber Function disabled */
  12683. +#define M88E1000_PSCR_POLARITY_REVERSAL 0x0002 /* 1=Polarity Reversal enabled */
  12684. +#define M88E1000_PSCR_SQE_TEST 0x0004 /* 1=SQE Test enabled */
  12685. +#define M88E1000_PSCR_CLK125_DISABLE 0x0010 /* 1=CLK125 low,
  12686. + * 0=CLK125 toggling
  12687. + */
  12688. +#define M88E1000_PSCR_MDI_MANUAL_MODE 0x0000 /* MDI Crossover Mode bits 6:5 */
  12689. + /* Manual MDI configuration */
  12690. +#define M88E1000_PSCR_MDIX_MANUAL_MODE 0x0020 /* Manual MDIX configuration */
  12691. +#define M88E1000_PSCR_AUTO_X_1000T 0x0040 /* 1000BASE-T: Auto crossover,
  12692. + * 100BASE-TX/10BASE-T:
  12693. + * MDI Mode
  12694. + */
  12695. +#define M88E1000_PSCR_AUTO_X_MODE 0x0060 /* Auto crossover enabled
  12696. + * all speeds.
  12697. + */
  12698. +#define M88E1000_PSCR_10BT_EXT_DIST_ENABLE 0x0080
  12699. + /* 1=Enable Extended 10BASE-T distance
  12700. + * (Lower 10BASE-T RX Threshold)
  12701. + * 0=Normal 10BASE-T RX Threshold */
  12702. +#define M88E1000_PSCR_MII_5BIT_ENABLE 0x0100
  12703. + /* 1=5-Bit interface in 100BASE-TX
  12704. + * 0=MII interface in 100BASE-TX */
  12705. +#define M88E1000_PSCR_SCRAMBLER_DISABLE 0x0200 /* 1=Scrambler disable */
  12706. +#define M88E1000_PSCR_FORCE_LINK_GOOD 0x0400 /* 1=Force link good */
  12707. +#define M88E1000_PSCR_ASSERT_CRS_ON_TX 0x0800 /* 1=Assert CRS on Transmit */
  12708. +
  12709. +#define M88E1000_PSCR_POLARITY_REVERSAL_SHIFT 1
  12710. +#define M88E1000_PSCR_AUTO_X_MODE_SHIFT 5
  12711. +#define M88E1000_PSCR_10BT_EXT_DIST_ENABLE_SHIFT 7
  12712. +
  12713. +/* M88E1000 PHY Specific Status Register */
  12714. +#define M88E1000_PSSR_JABBER 0x0001 /* 1=Jabber */
  12715. +#define M88E1000_PSSR_REV_POLARITY 0x0002 /* 1=Polarity reversed */
  12716. +#define M88E1000_PSSR_DOWNSHIFT 0x0020 /* 1=Downshifted */
  12717. +#define M88E1000_PSSR_MDIX 0x0040 /* 1=MDIX; 0=MDI */
  12718. +#define M88E1000_PSSR_CABLE_LENGTH 0x0380 /* 0=<50M;1=50-80M;2=80-110M;
  12719. + * 3=110-140M;4=>140M */
  12720. +#define M88E1000_PSSR_LINK 0x0400 /* 1=Link up, 0=Link down */
  12721. +#define M88E1000_PSSR_SPD_DPLX_RESOLVED 0x0800 /* 1=Speed & Duplex resolved */
  12722. +#define M88E1000_PSSR_PAGE_RCVD 0x1000 /* 1=Page received */
  12723. +#define M88E1000_PSSR_DPLX 0x2000 /* 1=Duplex 0=Half Duplex */
  12724. +#define M88E1000_PSSR_SPEED 0xC000 /* Speed, bits 14:15 */
  12725. +#define M88E1000_PSSR_10MBS 0x0000 /* 00=10Mbs */
  12726. +#define M88E1000_PSSR_100MBS 0x4000 /* 01=100Mbs */
  12727. +#define M88E1000_PSSR_1000MBS 0x8000 /* 10=1000Mbs */
  12728. +
  12729. +#define M88E1000_PSSR_REV_POLARITY_SHIFT 1
  12730. +#define M88E1000_PSSR_DOWNSHIFT_SHIFT 5
  12731. +#define M88E1000_PSSR_MDIX_SHIFT 6
  12732. +#define M88E1000_PSSR_CABLE_LENGTH_SHIFT 7
  12733. +
  12734. +/* M88E1000 Extended PHY Specific Control Register */
  12735. +#define M88E1000_EPSCR_FIBER_LOOPBACK 0x4000 /* 1=Fiber loopback */
  12736. +#define M88E1000_EPSCR_DOWN_NO_IDLE 0x8000 /* 1=Lost lock detect enabled.
  12737. + * Will assert lost lock and bring
  12738. + * link down if idle not seen
  12739. + * within 1ms in 1000BASE-T
  12740. + */
  12741. +/* Number of times we will attempt to autonegotiate before downshifting if we
  12742. + * are the master */
  12743. +#define M88E1000_EPSCR_MASTER_DOWNSHIFT_MASK 0x0C00
  12744. +#define M88E1000_EPSCR_MASTER_DOWNSHIFT_1X 0x0000
  12745. +#define M88E1000_EPSCR_MASTER_DOWNSHIFT_2X 0x0400
  12746. +#define M88E1000_EPSCR_MASTER_DOWNSHIFT_3X 0x0800
  12747. +#define M88E1000_EPSCR_MASTER_DOWNSHIFT_4X 0x0C00
  12748. +/* Number of times we will attempt to autonegotiate before downshifting if we
  12749. + * are the slave */
  12750. +#define M88E1000_EPSCR_SLAVE_DOWNSHIFT_MASK 0x0300
  12751. +#define M88E1000_EPSCR_SLAVE_DOWNSHIFT_DIS 0x0000
  12752. +#define M88E1000_EPSCR_SLAVE_DOWNSHIFT_1X 0x0100
  12753. +#define M88E1000_EPSCR_SLAVE_DOWNSHIFT_2X 0x0200
  12754. +#define M88E1000_EPSCR_SLAVE_DOWNSHIFT_3X 0x0300
  12755. +#define M88E1000_EPSCR_TX_CLK_2_5 0x0060 /* 2.5 MHz TX_CLK */
  12756. +#define M88E1000_EPSCR_TX_CLK_25 0x0070 /* 25 MHz TX_CLK */
  12757. +#define M88E1000_EPSCR_TX_CLK_0 0x0000 /* NO TX_CLK */
  12758. +
  12759. +/* IGP01E1000 Specific Port Config Register - R/W */
  12760. +#define IGP01E1000_PSCFR_AUTO_MDIX_PAR_DETECT 0x0010
  12761. +#define IGP01E1000_PSCFR_PRE_EN 0x0020
  12762. +#define IGP01E1000_PSCFR_SMART_SPEED 0x0080
  12763. +#define IGP01E1000_PSCFR_DISABLE_TPLOOPBACK 0x0100
  12764. +#define IGP01E1000_PSCFR_DISABLE_JABBER 0x0400
  12765. +#define IGP01E1000_PSCFR_DISABLE_TRANSMIT 0x2000
  12766. +
  12767. +/* IGP01E1000 Specific Port Status Register - R/O */
  12768. +#define IGP01E1000_PSSR_AUTONEG_FAILED 0x0001 /* RO LH SC */
  12769. +#define IGP01E1000_PSSR_POLARITY_REVERSED 0x0002
  12770. +#define IGP01E1000_PSSR_CABLE_LENGTH 0x007C
  12771. +#define IGP01E1000_PSSR_FULL_DUPLEX 0x0200
  12772. +#define IGP01E1000_PSSR_LINK_UP 0x0400
  12773. +#define IGP01E1000_PSSR_MDIX 0x0800
  12774. +#define IGP01E1000_PSSR_SPEED_MASK 0xC000 /* speed bits mask */
  12775. +#define IGP01E1000_PSSR_SPEED_10MBPS 0x4000
  12776. +#define IGP01E1000_PSSR_SPEED_100MBPS 0x8000
  12777. +#define IGP01E1000_PSSR_SPEED_1000MBPS 0xC000
  12778. +#define IGP01E1000_PSSR_CABLE_LENGTH_SHIFT 0x0002 /* shift right 2 */
  12779. +#define IGP01E1000_PSSR_MDIX_SHIFT 0x000B /* shift right 11 */
  12780. +
  12781. +/* IGP01E1000 Specific Port Control Register - R/W */
  12782. +#define IGP01E1000_PSCR_TP_LOOPBACK 0x0001
  12783. +#define IGP01E1000_PSCR_CORRECT_NC_SCMBLR 0x0200
  12784. +#define IGP01E1000_PSCR_TEN_CRS_SELECT 0x0400
  12785. +#define IGP01E1000_PSCR_FLIP_CHIP 0x0800
  12786. +#define IGP01E1000_PSCR_AUTO_MDIX 0x1000
  12787. +#define IGP01E1000_PSCR_FORCE_MDI_MDIX 0x2000 /* 0-MDI, 1-MDIX */
  12788. +
  12789. +/* IGP01E1000 Specific Port Link Health Register */
  12790. +#define IGP01E1000_PLHR_SS_DOWNGRADE 0x8000
  12791. +#define IGP01E1000_PLHR_GIG_SCRAMBLER_ERROR 0x4000
  12792. +#define IGP01E1000_PLHR_GIG_REM_RCVR_NOK 0x0800 /* LH */
  12793. +#define IGP01E1000_PLHR_IDLE_ERROR_CNT_OFLOW 0x0400 /* LH */
  12794. +#define IGP01E1000_PLHR_DATA_ERR_1 0x0200 /* LH */
  12795. +#define IGP01E1000_PLHR_DATA_ERR_0 0x0100
  12796. +#define IGP01E1000_PLHR_AUTONEG_FAULT 0x0010
  12797. +#define IGP01E1000_PLHR_AUTONEG_ACTIVE 0x0008
  12798. +#define IGP01E1000_PLHR_VALID_CHANNEL_D 0x0004
  12799. +#define IGP01E1000_PLHR_VALID_CHANNEL_C 0x0002
  12800. +#define IGP01E1000_PLHR_VALID_CHANNEL_B 0x0001
  12801. +#define IGP01E1000_PLHR_VALID_CHANNEL_A 0x0000
  12802. +
  12803. +/* IGP01E1000 Channel Quality Register */
  12804. +#define IGP01E1000_MSE_CHANNEL_D 0x000F
  12805. +#define IGP01E1000_MSE_CHANNEL_C 0x00F0
  12806. +#define IGP01E1000_MSE_CHANNEL_B 0x0F00
  12807. +#define IGP01E1000_MSE_CHANNEL_A 0xF000
  12808. +
  12809. +/* IGP01E1000 DSP reset macros */
  12810. +#define DSP_RESET_ENABLE 0x0
  12811. +#define DSP_RESET_DISABLE 0x2
  12812. +#define E1000_MAX_DSP_RESETS 10
  12813. +
  12814. +/* IGP01E1000 AGC Registers */
  12815. +
  12816. +#define IGP01E1000_AGC_LENGTH_SHIFT 7 /* Coarse - 13:11, Fine - 10:7 */
  12817. +
  12818. +/* 7 bits (3 Coarse + 4 Fine) --> 128 optional values */
  12819. +#define IGP01E1000_AGC_LENGTH_TABLE_SIZE 128
  12820. +
  12821. +/* The precision of the length is +/- 10 meters */
  12822. +#define IGP01E1000_AGC_RANGE 10
  12823. +
  12824. +/* IGP01E1000 PCS Initialization register */
  12825. +/* bits 3:6 in the PCS registers stores the channels polarity */
  12826. +#define IGP01E1000_PHY_POLARITY_MASK 0x0078
  12827. +
  12828. +/* IGP01E1000 GMII FIFO Register */
  12829. +#define IGP01E1000_GMII_FLEX_SPD 0x10 /* Enable flexible speed
  12830. + * on Link-Up */
  12831. +#define IGP01E1000_GMII_SPD 0x20 /* Enable SPD */
  12832. +
  12833. +/* IGP01E1000 Analog Register */
  12834. +#define IGP01E1000_ANALOG_SPARE_FUSE_STATUS 0x20D1
  12835. +#define IGP01E1000_ANALOG_FUSE_STATUS 0x20D0
  12836. +#define IGP01E1000_ANALOG_FUSE_CONTROL 0x20DC
  12837. +#define IGP01E1000_ANALOG_FUSE_BYPASS 0x20DE
  12838. +
  12839. +#define IGP01E1000_ANALOG_FUSE_POLY_MASK 0xF000
  12840. +#define IGP01E1000_ANALOG_FUSE_FINE_MASK 0x0F80
  12841. +#define IGP01E1000_ANALOG_FUSE_COARSE_MASK 0x0070
  12842. +#define IGP01E1000_ANALOG_SPARE_FUSE_ENABLED 0x0100
  12843. +#define IGP01E1000_ANALOG_FUSE_ENABLE_SW_CONTROL 0x0002
  12844. +
  12845. +#define IGP01E1000_ANALOG_FUSE_COARSE_THRESH 0x0040
  12846. +#define IGP01E1000_ANALOG_FUSE_COARSE_10 0x0010
  12847. +#define IGP01E1000_ANALOG_FUSE_FINE_1 0x0080
  12848. +#define IGP01E1000_ANALOG_FUSE_FINE_10 0x0500
  12849. +
  12850. +/* Bit definitions for valid PHY IDs. */
  12851. +#define M88E1000_E_PHY_ID 0x01410C50
  12852. +#define M88E1000_I_PHY_ID 0x01410C30
  12853. +#define M88E1011_I_PHY_ID 0x01410C20
  12854. +#define IGP01E1000_I_PHY_ID 0x02A80380
  12855. +#define M88E1000_12_PHY_ID M88E1000_E_PHY_ID
  12856. +#define M88E1000_14_PHY_ID M88E1000_E_PHY_ID
  12857. +#define M88E1011_I_REV_4 0x04
  12858. +
  12859. +/* Miscellaneous PHY bit definitions. */
  12860. +#define PHY_PREAMBLE 0xFFFFFFFF
  12861. +#define PHY_SOF 0x01
  12862. +#define PHY_OP_READ 0x02
  12863. +#define PHY_OP_WRITE 0x01
  12864. +#define PHY_TURNAROUND 0x02
  12865. +#define PHY_PREAMBLE_SIZE 32
  12866. +#define MII_CR_SPEED_1000 0x0040
  12867. +#define MII_CR_SPEED_100 0x2000
  12868. +#define MII_CR_SPEED_10 0x0000
  12869. +#define E1000_PHY_ADDRESS 0x01
  12870. +#define PHY_AUTO_NEG_TIME 45 /* 4.5 Seconds */
  12871. +#define PHY_FORCE_TIME 20 /* 2.0 Seconds */
  12872. +#define PHY_REVISION_MASK 0xFFFFFFF0
  12873. +#define DEVICE_SPEED_MASK 0x00000300 /* Device Ctrl Reg Speed Mask */
  12874. +#define REG4_SPEED_MASK 0x01E0
  12875. +#define REG9_SPEED_MASK 0x0300
  12876. +#define ADVERTISE_10_HALF 0x0001
  12877. +#define ADVERTISE_10_FULL 0x0002
  12878. +#define ADVERTISE_100_HALF 0x0004
  12879. +#define ADVERTISE_100_FULL 0x0008
  12880. +#define ADVERTISE_1000_HALF 0x0010
  12881. +#define ADVERTISE_1000_FULL 0x0020
  12882. +#define AUTONEG_ADVERTISE_SPEED_DEFAULT 0x002F /* Everything but 1000-Half */
  12883. +#define AUTONEG_ADVERTISE_10_100_ALL 0x000F /* All 10/100 speeds*/
  12884. +#define AUTONEG_ADVERTISE_10_ALL 0x0003 /* 10Mbps Full & Half speeds*/
  12885. +
  12886. +#endif /* _E1000_HW_H_ */
  12887. diff -Naur grub-0.97.orig/netboot/eepro.c grub-0.97/netboot/eepro.c
  12888. --- grub-0.97.orig/netboot/eepro.c 2003-07-09 11:45:37.000000000 +0000
  12889. +++ grub-0.97/netboot/eepro.c 1970-01-01 00:00:00.000000000 +0000
  12890. @@ -1,586 +0,0 @@
  12891. -/**************************************************************************
  12892. -Etherboot - BOOTP/TFTP Bootstrap Program
  12893. -Intel EEPRO/10 NIC driver for Etherboot
  12894. -Adapted from Linux eepro.c from kernel 2.2.17
  12895. -
  12896. -This board accepts a 32 pin EEPROM (29C256), however a test with a
  12897. -27C010 shows that this EPROM also works in the socket, but it's not clear
  12898. -how repeatably. The two top address pins appear to be held low, thus
  12899. -the bottom 32kB of the 27C010 is visible in the CPU's address space.
  12900. -To be sure you could put 4 copies of the code in the 27C010, then
  12901. -it doesn't matter whether the extra lines are held low or high, just
  12902. -hopefully not floating as CMOS chips don't like floating inputs.
  12903. -
  12904. -Be careful with seating the EPROM as the socket on my board actually
  12905. -has 34 pins, the top row of 2 are not used.
  12906. -***************************************************************************/
  12907. -
  12908. -/*
  12909. - * This program is free software; you can redistribute it and/or
  12910. - * modify it under the terms of the GNU General Public License as
  12911. - * published by the Free Software Foundation; either version 2, or (at
  12912. - * your option) any later version.
  12913. - */
  12914. -
  12915. -/* to get some global routines like printf */
  12916. -#include "etherboot.h"
  12917. -/* to get the interface to the body of the program */
  12918. -#include "nic.h"
  12919. -/* to get our own prototype */
  12920. -#include "cards.h"
  12921. -/* we use timer2 for microsecond waits */
  12922. -#include "timer.h"
  12923. -
  12924. -#undef DEBUG /* only after include files */
  12925. -
  12926. -/* Different 82595 chips */
  12927. -#define LAN595 0
  12928. -#define LAN595TX 1
  12929. -#define LAN595FX 2
  12930. -#define LAN595FX_10ISA 3
  12931. -
  12932. -#define SLOW_DOWN inb(0x80);
  12933. -
  12934. -/* The station (ethernet) address prefix, used for IDing the board. */
  12935. -#define SA_ADDR0 0x00 /* Etherexpress Pro/10 */
  12936. -#define SA_ADDR1 0xaa
  12937. -#define SA_ADDR2 0x00
  12938. -
  12939. -#define GetBit(x,y) ((x & (1<<y))>>y)
  12940. -
  12941. -/* EEPROM Word 0: */
  12942. -#define ee_PnP 0 /* Plug 'n Play enable bit */
  12943. -#define ee_Word1 1 /* Word 1? */
  12944. -#define ee_BusWidth 2 /* 8/16 bit */
  12945. -#define ee_FlashAddr 3 /* Flash Address */
  12946. -#define ee_FlashMask 0x7 /* Mask */
  12947. -#define ee_AutoIO 6 /* */
  12948. -#define ee_reserved0 7 /* =0! */
  12949. -#define ee_Flash 8 /* Flash there? */
  12950. -#define ee_AutoNeg 9 /* Auto Negotiation enabled? */
  12951. -#define ee_IO0 10 /* IO Address LSB */
  12952. -#define ee_IO0Mask 0x /*...*/
  12953. -#define ee_IO1 15 /* IO MSB */
  12954. -
  12955. -/* EEPROM Word 1: */
  12956. -#define ee_IntSel 0 /* Interrupt */
  12957. -#define ee_IntMask 0x7
  12958. -#define ee_LI 3 /* Link Integrity 0= enabled */
  12959. -#define ee_PC 4 /* Polarity Correction 0= enabled */
  12960. -#define ee_TPE_AUI 5 /* PortSelection 1=TPE */
  12961. -#define ee_Jabber 6 /* Jabber prevention 0= enabled */
  12962. -#define ee_AutoPort 7 /* Auto Port Selection 1= Disabled */
  12963. -#define ee_SMOUT 8 /* SMout Pin Control 0= Input */
  12964. -#define ee_PROM 9 /* Flash EPROM / PROM 0=Flash */
  12965. -#define ee_reserved1 10 /* .. 12 =0! */
  12966. -#define ee_AltReady 13 /* Alternate Ready, 0=normal */
  12967. -#define ee_reserved2 14 /* =0! */
  12968. -#define ee_Duplex 15
  12969. -
  12970. -/* Word2,3,4: */
  12971. -#define ee_IA5 0 /*bit start for individual Addr Byte 5 */
  12972. -#define ee_IA4 8 /*bit start for individual Addr Byte 5 */
  12973. -#define ee_IA3 0 /*bit start for individual Addr Byte 5 */
  12974. -#define ee_IA2 8 /*bit start for individual Addr Byte 5 */
  12975. -#define ee_IA1 0 /*bit start for individual Addr Byte 5 */
  12976. -#define ee_IA0 8 /*bit start for individual Addr Byte 5 */
  12977. -
  12978. -/* Word 5: */
  12979. -#define ee_BNC_TPE 0 /* 0=TPE */
  12980. -#define ee_BootType 1 /* 00=None, 01=IPX, 10=ODI, 11=NDIS */
  12981. -#define ee_BootTypeMask 0x3
  12982. -#define ee_NumConn 3 /* Number of Connections 0= One or Two */
  12983. -#define ee_FlashSock 4 /* Presence of Flash Socket 0= Present */
  12984. -#define ee_PortTPE 5
  12985. -#define ee_PortBNC 6
  12986. -#define ee_PortAUI 7
  12987. -#define ee_PowerMgt 10 /* 0= disabled */
  12988. -#define ee_CP 13 /* Concurrent Processing */
  12989. -#define ee_CPMask 0x7
  12990. -
  12991. -/* Word 6: */
  12992. -#define ee_Stepping 0 /* Stepping info */
  12993. -#define ee_StepMask 0x0F
  12994. -#define ee_BoardID 4 /* Manucaturer Board ID, reserved */
  12995. -#define ee_BoardMask 0x0FFF
  12996. -
  12997. -/* Word 7: */
  12998. -#define ee_INT_TO_IRQ 0 /* int to IRQ Mapping = 0x1EB8 for Pro/10+ */
  12999. -#define ee_FX_INT2IRQ 0x1EB8 /* the _only_ mapping allowed for FX chips */
  13000. -
  13001. -/*..*/
  13002. -#define ee_SIZE 0x40 /* total EEprom Size */
  13003. -#define ee_Checksum 0xBABA /* initial and final value for adding checksum */
  13004. -
  13005. -
  13006. -/* Card identification via EEprom: */
  13007. -#define ee_addr_vendor 0x10 /* Word offset for EISA Vendor ID */
  13008. -#define ee_addr_id 0x11 /* Word offset for Card ID */
  13009. -#define ee_addr_SN 0x12 /* Serial Number */
  13010. -#define ee_addr_CRC_8 0x14 /* CRC over last thee Bytes */
  13011. -
  13012. -
  13013. -#define ee_vendor_intel0 0x25 /* Vendor ID Intel */
  13014. -#define ee_vendor_intel1 0xD4
  13015. -#define ee_id_eepro10p0 0x10 /* ID for eepro/10+ */
  13016. -#define ee_id_eepro10p1 0x31
  13017. -
  13018. -/* now this section could be used by both boards: the oldies and the ee10:
  13019. - * ee10 uses tx buffer before of rx buffer and the oldies the inverse.
  13020. - * (aris)
  13021. - */
  13022. -#define RAM_SIZE 0x8000
  13023. -
  13024. -#define RCV_HEADER 8
  13025. -#define RCV_DEFAULT_RAM 0x6000
  13026. -#define RCV_RAM rcv_ram
  13027. -
  13028. -static unsigned rcv_ram = RCV_DEFAULT_RAM;
  13029. -
  13030. -#define XMT_HEADER 8
  13031. -#define XMT_RAM (RAM_SIZE - RCV_RAM)
  13032. -
  13033. -#define XMT_START ((rcv_start + RCV_RAM) % RAM_SIZE)
  13034. -
  13035. -#define RCV_LOWER_LIMIT (rcv_start >> 8)
  13036. -#define RCV_UPPER_LIMIT (((rcv_start + RCV_RAM) - 2) >> 8)
  13037. -#define XMT_LOWER_LIMIT (XMT_START >> 8)
  13038. -#define XMT_UPPER_LIMIT (((XMT_START + XMT_RAM) - 2) >> 8)
  13039. -
  13040. -#define RCV_START_PRO 0x00
  13041. -#define RCV_START_10 XMT_RAM
  13042. - /* by default the old driver */
  13043. -static unsigned rcv_start = RCV_START_PRO;
  13044. -
  13045. -#define RCV_DONE 0x0008
  13046. -#define RX_OK 0x2000
  13047. -#define RX_ERROR 0x0d81
  13048. -
  13049. -#define TX_DONE_BIT 0x0080
  13050. -#define CHAIN_BIT 0x8000
  13051. -#define XMT_STATUS 0x02
  13052. -#define XMT_CHAIN 0x04
  13053. -#define XMT_COUNT 0x06
  13054. -
  13055. -#define BANK0_SELECT 0x00
  13056. -#define BANK1_SELECT 0x40
  13057. -#define BANK2_SELECT 0x80
  13058. -
  13059. -/* Bank 0 registers */
  13060. -#define COMMAND_REG 0x00 /* Register 0 */
  13061. -#define MC_SETUP 0x03
  13062. -#define XMT_CMD 0x04
  13063. -#define DIAGNOSE_CMD 0x07
  13064. -#define RCV_ENABLE_CMD 0x08
  13065. -#define RCV_DISABLE_CMD 0x0a
  13066. -#define STOP_RCV_CMD 0x0b
  13067. -#define RESET_CMD 0x0e
  13068. -#define POWER_DOWN_CMD 0x18
  13069. -#define RESUME_XMT_CMD 0x1c
  13070. -#define SEL_RESET_CMD 0x1e
  13071. -#define STATUS_REG 0x01 /* Register 1 */
  13072. -#define RX_INT 0x02
  13073. -#define TX_INT 0x04
  13074. -#define EXEC_STATUS 0x30
  13075. -#define ID_REG 0x02 /* Register 2 */
  13076. -#define R_ROBIN_BITS 0xc0 /* round robin counter */
  13077. -#define ID_REG_MASK 0x2c
  13078. -#define ID_REG_SIG 0x24
  13079. -#define AUTO_ENABLE 0x10
  13080. -#define INT_MASK_REG 0x03 /* Register 3 */
  13081. -#define RX_STOP_MASK 0x01
  13082. -#define RX_MASK 0x02
  13083. -#define TX_MASK 0x04
  13084. -#define EXEC_MASK 0x08
  13085. -#define ALL_MASK 0x0f
  13086. -#define IO_32_BIT 0x10
  13087. -#define RCV_BAR 0x04 /* The following are word (16-bit) registers */
  13088. -#define RCV_STOP 0x06
  13089. -
  13090. -#define XMT_BAR_PRO 0x0a
  13091. -#define XMT_BAR_10 0x0b
  13092. -static unsigned xmt_bar = XMT_BAR_PRO;
  13093. -
  13094. -#define HOST_ADDRESS_REG 0x0c
  13095. -#define IO_PORT 0x0e
  13096. -#define IO_PORT_32_BIT 0x0c
  13097. -
  13098. -/* Bank 1 registers */
  13099. -#define REG1 0x01
  13100. -#define WORD_WIDTH 0x02
  13101. -#define INT_ENABLE 0x80
  13102. -#define INT_NO_REG 0x02
  13103. -#define RCV_LOWER_LIMIT_REG 0x08
  13104. -#define RCV_UPPER_LIMIT_REG 0x09
  13105. -
  13106. -#define XMT_LOWER_LIMIT_REG_PRO 0x0a
  13107. -#define XMT_UPPER_LIMIT_REG_PRO 0x0b
  13108. -#define XMT_LOWER_LIMIT_REG_10 0x0b
  13109. -#define XMT_UPPER_LIMIT_REG_10 0x0a
  13110. -static unsigned xmt_lower_limit_reg = XMT_LOWER_LIMIT_REG_PRO;
  13111. -static unsigned xmt_upper_limit_reg = XMT_UPPER_LIMIT_REG_PRO;
  13112. -
  13113. -/* Bank 2 registers */
  13114. -#define XMT_Chain_Int 0x20 /* Interrupt at the end of the transmit chain */
  13115. -#define XMT_Chain_ErrStop 0x40 /* Interrupt at the end of the chain even if there are errors */
  13116. -#define RCV_Discard_BadFrame 0x80 /* Throw bad frames away, and continue to receive others */
  13117. -#define REG2 0x02
  13118. -#define PRMSC_Mode 0x01
  13119. -#define Multi_IA 0x20
  13120. -#define REG3 0x03
  13121. -#define TPE_BIT 0x04
  13122. -#define BNC_BIT 0x20
  13123. -#define REG13 0x0d
  13124. -#define FDX 0x00
  13125. -#define A_N_ENABLE 0x02
  13126. -
  13127. -#define I_ADD_REG0 0x04
  13128. -#define I_ADD_REG1 0x05
  13129. -#define I_ADD_REG2 0x06
  13130. -#define I_ADD_REG3 0x07
  13131. -#define I_ADD_REG4 0x08
  13132. -#define I_ADD_REG5 0x09
  13133. -
  13134. -#define EEPROM_REG_PRO 0x0a
  13135. -#define EEPROM_REG_10 0x0b
  13136. -static unsigned eeprom_reg = EEPROM_REG_PRO;
  13137. -
  13138. -#define EESK 0x01
  13139. -#define EECS 0x02
  13140. -#define EEDI 0x04
  13141. -#define EEDO 0x08
  13142. -
  13143. -/* The horrible routine to read a word from the serial EEPROM. */
  13144. -/* IMPORTANT - the 82595 will be set to Bank 0 after the eeprom is read */
  13145. -
  13146. -/* The delay between EEPROM clock transitions. */
  13147. -#define eeprom_delay() { udelay(40); }
  13148. -#define EE_READ_CMD (6 << 6)
  13149. -
  13150. -/* do a full reset */
  13151. -#define eepro_full_reset(ioaddr) outb(RESET_CMD, ioaddr); udelay(40);
  13152. -
  13153. -/* do a nice reset */
  13154. -#define eepro_sel_reset(ioaddr) { \
  13155. - outb(SEL_RESET_CMD, ioaddr); \
  13156. - SLOW_DOWN; \
  13157. - SLOW_DOWN; \
  13158. - }
  13159. -
  13160. -/* clear all interrupts */
  13161. -#define eepro_clear_int(ioaddr) outb(ALL_MASK, ioaddr + STATUS_REG)
  13162. -
  13163. -/* enable rx */
  13164. -#define eepro_en_rx(ioaddr) outb(RCV_ENABLE_CMD, ioaddr)
  13165. -
  13166. -/* disable rx */
  13167. -#define eepro_dis_rx(ioaddr) outb(RCV_DISABLE_CMD, ioaddr)
  13168. -
  13169. -/* switch bank */
  13170. -#define eepro_sw2bank0(ioaddr) outb(BANK0_SELECT, ioaddr)
  13171. -#define eepro_sw2bank1(ioaddr) outb(BANK1_SELECT, ioaddr)
  13172. -#define eepro_sw2bank2(ioaddr) outb(BANK2_SELECT, ioaddr)
  13173. -
  13174. -static unsigned int rx_start, tx_start;
  13175. -static int tx_last;
  13176. -static unsigned tx_end;
  13177. -static int eepro = 0;
  13178. -static unsigned short ioaddr = 0;
  13179. -static unsigned int mem_start, mem_end = RCV_DEFAULT_RAM / 1024;
  13180. -
  13181. -#define udelay(n) waiton_timer2(((n)*TICKS_PER_MS)/1000)
  13182. -
  13183. -/**************************************************************************
  13184. -RESET - Reset adapter
  13185. -***************************************************************************/
  13186. -static void eepro_reset(struct nic *nic)
  13187. -{
  13188. - int temp_reg, i;
  13189. -
  13190. - /* put the card in its initial state */
  13191. - eepro_sw2bank2(ioaddr); /* be careful, bank2 now */
  13192. - temp_reg = inb(ioaddr + eeprom_reg);
  13193. -#ifdef DEBUG
  13194. - printf("Stepping %d\n", temp_reg >> 5);
  13195. -#endif
  13196. - if (temp_reg & 0x10) /* check the TurnOff Enable bit */
  13197. - outb(temp_reg & 0xEF, ioaddr + eeprom_reg);
  13198. - for (i = 0; i < ETH_ALEN; i++) /* fill the MAC address */
  13199. - outb(nic->node_addr[i], ioaddr + I_ADD_REG0 + i);
  13200. - temp_reg = inb(ioaddr + REG1);
  13201. - /* setup Transmit Chaining and discard bad RCV frames */
  13202. - outb(temp_reg | XMT_Chain_Int | XMT_Chain_ErrStop
  13203. - | RCV_Discard_BadFrame, ioaddr + REG1);
  13204. - temp_reg = inb(ioaddr + REG2); /* match broadcast */
  13205. - outb(temp_reg | 0x14, ioaddr + REG2);
  13206. - temp_reg = inb(ioaddr + REG3);
  13207. - outb(temp_reg & 0x3F, ioaddr + REG3); /* clear test mode */
  13208. - /* set the receiving mode */
  13209. - eepro_sw2bank1(ioaddr); /* be careful, bank1 now */
  13210. - /* initialise the RCV and XMT upper and lower limits */
  13211. - outb(RCV_LOWER_LIMIT, ioaddr + RCV_LOWER_LIMIT_REG);
  13212. - outb(RCV_UPPER_LIMIT, ioaddr + RCV_UPPER_LIMIT_REG);
  13213. - outb(XMT_LOWER_LIMIT, ioaddr + xmt_lower_limit_reg);
  13214. - outb(XMT_UPPER_LIMIT, ioaddr + xmt_upper_limit_reg);
  13215. - eepro_sw2bank0(ioaddr); /* Switch back to bank 0 */
  13216. - eepro_clear_int(ioaddr);
  13217. - /* Initialise RCV */
  13218. - outw(rx_start = (RCV_LOWER_LIMIT << 8), ioaddr + RCV_BAR);
  13219. - outw(((RCV_UPPER_LIMIT << 8) | 0xFE), ioaddr + RCV_STOP);
  13220. - /* Intialise XMT */
  13221. - outw((XMT_LOWER_LIMIT << 8), ioaddr + xmt_bar);
  13222. - eepro_sel_reset(ioaddr);
  13223. - tx_start = tx_end = (XMT_LOWER_LIMIT << 8);
  13224. - tx_last = 0;
  13225. - eepro_en_rx(ioaddr);
  13226. -}
  13227. -
  13228. -/**************************************************************************
  13229. -POLL - Wait for a frame
  13230. -***************************************************************************/
  13231. -static int eepro_poll(struct nic *nic)
  13232. -{
  13233. - int i;
  13234. - unsigned int rcv_car = rx_start;
  13235. - unsigned int rcv_event, rcv_status, rcv_next_frame, rcv_size;
  13236. -
  13237. - /* return true if there's an ethernet packet ready to read */
  13238. - /* nic->packet should contain data on return */
  13239. - /* nic->packetlen should contain length of data */
  13240. -#if 0
  13241. - if ((inb(ioaddr + STATUS_REG) & 0x40) == 0)
  13242. - return (0);
  13243. - outb(0x40, ioaddr + STATUS_REG);
  13244. -#endif
  13245. - outw(rcv_car, ioaddr + HOST_ADDRESS_REG);
  13246. - rcv_event = inw(ioaddr + IO_PORT);
  13247. - if (rcv_event != RCV_DONE)
  13248. - return (0);
  13249. - rcv_status = inw(ioaddr + IO_PORT);
  13250. - rcv_next_frame = inw(ioaddr + IO_PORT);
  13251. - rcv_size = inw(ioaddr + IO_PORT);
  13252. -#if 0
  13253. - printf("%hX %hX %d %hhX\n", rcv_status, rcv_next_frame, rcv_size,
  13254. - inb(ioaddr + STATUS_REG));
  13255. -#endif
  13256. - if ((rcv_status & (RX_OK|RX_ERROR)) != RX_OK) {
  13257. - printf("Receive error %hX\n", rcv_status);
  13258. - return (0);
  13259. - }
  13260. - rcv_size &= 0x3FFF;
  13261. - insw(ioaddr + IO_PORT, nic->packet, ((rcv_size + 3) >> 1));
  13262. -#if 0
  13263. - for (i = 0; i < 48; i++) {
  13264. - printf("%hhX", nic->packet[i]);
  13265. - putchar(i % 16 == 15 ? '\n' : ' ');
  13266. - }
  13267. -#endif
  13268. - nic->packetlen = rcv_size;
  13269. - rcv_car = rx_start + RCV_HEADER + rcv_size;
  13270. - rx_start = rcv_next_frame;
  13271. - if (rcv_car == 0)
  13272. - rcv_car = ((RCV_UPPER_LIMIT << 8) | 0xff);
  13273. - outw(rcv_car - 1, ioaddr + RCV_STOP);
  13274. - return (1);
  13275. -}
  13276. -
  13277. -/**************************************************************************
  13278. -TRANSMIT - Transmit a frame
  13279. -***************************************************************************/
  13280. -static void eepro_transmit(
  13281. - struct nic *nic,
  13282. - const char *d, /* Destination */
  13283. - unsigned int t, /* Type */
  13284. - unsigned int s, /* size */
  13285. - const char *p) /* Packet */
  13286. -{
  13287. - unsigned int status, tx_available, last, end, length;
  13288. - unsigned short type;
  13289. - int boguscount = 20;
  13290. -
  13291. - length = s + ETH_HLEN;
  13292. - if (tx_end > tx_start)
  13293. - tx_available = XMT_RAM - (tx_end - tx_start);
  13294. - else if (tx_end < tx_start)
  13295. - tx_available = tx_start - tx_end;
  13296. - else
  13297. - tx_available = XMT_RAM;
  13298. - last = tx_end;
  13299. - end = last + (((length + 3) >> 1) << 1) + XMT_HEADER;
  13300. - if (end >= (XMT_UPPER_LIMIT << 8)) {
  13301. - last = (XMT_LOWER_LIMIT << 8);
  13302. - end = last + (((length + 3) >> 1) << 1) + XMT_HEADER;
  13303. - }
  13304. - outw(last, ioaddr + HOST_ADDRESS_REG);
  13305. - outw(XMT_CMD, ioaddr + IO_PORT);
  13306. - outw(0, ioaddr + IO_PORT);
  13307. - outw(end, ioaddr + IO_PORT);
  13308. - outw(length, ioaddr + IO_PORT);
  13309. - outsw(ioaddr + IO_PORT, d, ETH_ALEN / 2);
  13310. - outsw(ioaddr + IO_PORT, nic->node_addr, ETH_ALEN / 2);
  13311. - type = htons(t);
  13312. - outsw(ioaddr + IO_PORT, &type, sizeof(type) / 2);
  13313. - outsw(ioaddr + IO_PORT, p, (s + 3) >> 1);
  13314. - /* A dummy read to flush the DRAM write pipeline */
  13315. - status = inw(ioaddr + IO_PORT);
  13316. - outw(last, ioaddr + xmt_bar);
  13317. - outb(XMT_CMD, ioaddr);
  13318. - tx_start = last;
  13319. - tx_last = last;
  13320. - tx_end = end;
  13321. -#if 0
  13322. - printf("%d %d\n", tx_start, tx_end);
  13323. -#endif
  13324. - while (boguscount > 0) {
  13325. - if (((status = inw(ioaddr + IO_PORT)) & TX_DONE_BIT) == 0) {
  13326. - udelay(40);
  13327. - boguscount--;
  13328. - continue;
  13329. - }
  13330. -#if DEBUG
  13331. - if ((status & 0x2000) == 0)
  13332. - printf("Transmit status %hX\n", status);
  13333. -#endif
  13334. - }
  13335. -}
  13336. -
  13337. -/**************************************************************************
  13338. -DISABLE - Turn off ethernet interface
  13339. -***************************************************************************/
  13340. -static void eepro_disable(struct nic *nic)
  13341. -{
  13342. - eepro_sw2bank0(ioaddr); /* Switch to bank 0 */
  13343. - /* Flush the Tx and disable Rx */
  13344. - outb(STOP_RCV_CMD, ioaddr);
  13345. - tx_start = tx_end = (XMT_LOWER_LIMIT << 8);
  13346. - tx_last = 0;
  13347. - /* Reset the 82595 */
  13348. - eepro_full_reset(ioaddr);
  13349. -}
  13350. -
  13351. -static int read_eeprom(int location)
  13352. -{
  13353. - int i;
  13354. - unsigned short retval = 0;
  13355. - int ee_addr = ioaddr + eeprom_reg;
  13356. - int read_cmd = location | EE_READ_CMD;
  13357. - int ctrl_val = EECS;
  13358. -
  13359. - if (eepro == LAN595FX_10ISA) {
  13360. - eepro_sw2bank1(ioaddr);
  13361. - outb(0x00, ioaddr + STATUS_REG);
  13362. - }
  13363. - eepro_sw2bank2(ioaddr);
  13364. - outb(ctrl_val, ee_addr);
  13365. - /* shift the read command bits out */
  13366. - for (i = 8; i >= 0; i--) {
  13367. - short outval = (read_cmd & (1 << i)) ? ctrl_val | EEDI : ctrl_val;
  13368. - outb(outval, ee_addr);
  13369. - outb(outval | EESK, ee_addr); /* EEPROM clock tick */
  13370. - eeprom_delay();
  13371. - outb(outval, ee_addr); /* finish EEPROM clock tick */
  13372. - eeprom_delay();
  13373. - }
  13374. - outb(ctrl_val, ee_addr);
  13375. - for (i = 16; i > 0; i--) {
  13376. - outb(ctrl_val | EESK, ee_addr);
  13377. - eeprom_delay();
  13378. - retval = (retval << 1) | ((inb(ee_addr) & EEDO) ? 1 : 0);
  13379. - outb(ctrl_val, ee_addr);
  13380. - eeprom_delay();
  13381. - }
  13382. - /* terminate the EEPROM access */
  13383. - ctrl_val &= ~EECS;
  13384. - outb(ctrl_val | EESK, ee_addr);
  13385. - eeprom_delay();
  13386. - outb(ctrl_val, ee_addr);
  13387. - eeprom_delay();
  13388. - eepro_sw2bank0(ioaddr);
  13389. - return (retval);
  13390. -}
  13391. -
  13392. -static int eepro_probe1(struct nic *nic)
  13393. -{
  13394. - int i, id, counter, l_eepro = 0;
  13395. - union {
  13396. - unsigned char caddr[ETH_ALEN];
  13397. - unsigned short saddr[ETH_ALEN/2];
  13398. - } station_addr;
  13399. - char *name;
  13400. -
  13401. - id = inb(ioaddr + ID_REG);
  13402. - if ((id & ID_REG_MASK) != ID_REG_SIG)
  13403. - return (0);
  13404. - counter = id & R_ROBIN_BITS;
  13405. - if (((id = inb(ioaddr + ID_REG)) & R_ROBIN_BITS) != (counter + 0x40))
  13406. - return (0);
  13407. - /* yes the 82595 has been found */
  13408. - station_addr.saddr[2] = read_eeprom(2);
  13409. - if (station_addr.saddr[2] == 0x0000 || station_addr.saddr[2] == 0xFFFF) {
  13410. - l_eepro = 3;
  13411. - eepro = LAN595FX_10ISA;
  13412. - eeprom_reg= EEPROM_REG_10;
  13413. - rcv_start = RCV_START_10;
  13414. - xmt_lower_limit_reg = XMT_LOWER_LIMIT_REG_10;
  13415. - xmt_upper_limit_reg = XMT_UPPER_LIMIT_REG_10;
  13416. - station_addr.saddr[2] = read_eeprom(2);
  13417. - }
  13418. - station_addr.saddr[1] = read_eeprom(3);
  13419. - station_addr.saddr[0] = read_eeprom(4);
  13420. - if (l_eepro)
  13421. - name = "Intel EtherExpress 10 ISA";
  13422. - else if (read_eeprom(7) == ee_FX_INT2IRQ) {
  13423. - name = "Intel EtherExpress Pro/10+ ISA";
  13424. - l_eepro = 2;
  13425. - } else if (station_addr.saddr[0] == SA_ADDR1) {
  13426. - name = "Intel EtherExpress Pro/10 ISA";
  13427. - l_eepro = 1;
  13428. - } else {
  13429. - l_eepro = 0;
  13430. - name = "Intel 82595-based LAN card";
  13431. - }
  13432. - station_addr.saddr[0] = swap16(station_addr.saddr[0]);
  13433. - station_addr.saddr[1] = swap16(station_addr.saddr[1]);
  13434. - station_addr.saddr[2] = swap16(station_addr.saddr[2]);
  13435. - for (i = 0; i < ETH_ALEN; i++) {
  13436. - nic->node_addr[i] = station_addr.caddr[i];
  13437. - }
  13438. - printf("\n%s ioaddr %#hX, addr %!", name, ioaddr, nic->node_addr);
  13439. - mem_start = RCV_LOWER_LIMIT << 8;
  13440. - if ((mem_end & 0x3F) < 3 || (mem_end & 0x3F) > 29)
  13441. - mem_end = RCV_UPPER_LIMIT << 8;
  13442. - else {
  13443. - mem_end = mem_end * 1024 + (RCV_LOWER_LIMIT << 8);
  13444. - rcv_ram = mem_end - (RCV_LOWER_LIMIT << 8);
  13445. - }
  13446. - printf(", Rx mem %dK, if %s\n", (mem_end - mem_start) >> 10,
  13447. - GetBit(read_eeprom(5), ee_BNC_TPE) ? "BNC" : "TP");
  13448. - return (1);
  13449. -}
  13450. -
  13451. -/**************************************************************************
  13452. -PROBE - Look for an adapter, this routine's visible to the outside
  13453. -***************************************************************************/
  13454. -struct nic *eepro_probe(struct nic *nic, unsigned short *probe_addrs)
  13455. -{
  13456. - unsigned short *p;
  13457. - /* same probe list as the Linux driver */
  13458. - static unsigned short ioaddrs[] = {
  13459. - 0x300, 0x210, 0x240, 0x280, 0x2C0, 0x200, 0x320, 0x340, 0x360, 0};
  13460. -
  13461. - if (probe_addrs == 0 || probe_addrs[0] == 0)
  13462. - probe_addrs = ioaddrs;
  13463. - for (p = probe_addrs; (ioaddr = *p) != 0; p++) {
  13464. - if (eepro_probe1(nic))
  13465. - break;
  13466. - }
  13467. - if (*p == 0)
  13468. - return (0);
  13469. - eepro_reset(nic);
  13470. - /* point to NIC specific routines */
  13471. - nic->reset = eepro_reset;
  13472. - nic->poll = eepro_poll;
  13473. - nic->transmit = eepro_transmit;
  13474. - nic->disable = eepro_disable;
  13475. - return (nic);
  13476. -}
  13477. diff -Naur grub-0.97.orig/netboot/eepro100.c grub-0.97/netboot/eepro100.c
  13478. --- grub-0.97.orig/netboot/eepro100.c 2003-07-09 11:45:37.000000000 +0000
  13479. +++ grub-0.97/netboot/eepro100.c 2005-08-31 19:03:35.000000000 +0000
  13480. @@ -80,8 +80,8 @@
  13481. *
  13482. * Caveats:
  13483. *
  13484. - * The etherboot framework moves the code to the 32k segment from
  13485. - * 0x98000 to 0xa0000. There is just a little room between the end of
  13486. + * The Etherboot framework moves the code to the 48k segment from
  13487. + * 0x94000 to 0xa0000. There is just a little room between the end of
  13488. * this driver and the 0xa0000 address. If you compile in too many
  13489. * features, this will overflow.
  13490. * The number under "hex" in the output of size that scrolls by while
  13491. @@ -92,17 +92,13 @@
  13492. /* The etherboot authors seem to dislike the argument ordering in
  13493. * outb macros that Linux uses. I disklike the confusion that this
  13494. * has caused even more.... This file uses the Linux argument ordering. */
  13495. -/* Sorry not us. It's inherted code from FreeBSD. [The authors] */
  13496. +/* Sorry not us. It's inherited code from FreeBSD. [The authors] */
  13497. #include "etherboot.h"
  13498. #include "nic.h"
  13499. #include "pci.h"
  13500. -#include "cards.h"
  13501. #include "timer.h"
  13502. -#undef virt_to_bus
  13503. -#define virt_to_bus(x) ((unsigned long)x)
  13504. -
  13505. static int ioaddr;
  13506. typedef unsigned char u8;
  13507. @@ -121,6 +117,18 @@
  13508. SCBEarlyRx = 20, /* Early receive byte count. */
  13509. };
  13510. +enum SCBCmdBits {
  13511. + SCBMaskCmdDone=0x8000, SCBMaskRxDone=0x4000, SCBMaskCmdIdle=0x2000,
  13512. + SCBMaskRxSuspend=0x1000, SCBMaskEarlyRx=0x0800, SCBMaskFlowCtl=0x0400,
  13513. + SCBTriggerIntr=0x0200, SCBMaskAll=0x0100,
  13514. + /* The rest are Rx and Tx commands. */
  13515. + CUStart=0x0010, CUResume=0x0020, CUStatsAddr=0x0040, CUShowStats=0x0050,
  13516. + CUCmdBase=0x0060, /* CU Base address (set to zero) . */
  13517. + CUDumpStats=0x0070, /* Dump then reset stats counters. */
  13518. + RxStart=0x0001, RxResume=0x0002, RxAbort=0x0004, RxAddrLoad=0x0006,
  13519. + RxResumeNoResources=0x0007,
  13520. +};
  13521. +
  13522. static int do_eeprom_cmd(int cmd, int cmd_len);
  13523. void hd(void *where, int n);
  13524. @@ -139,8 +147,6 @@
  13525. #define EE_WRITE_1 0x4806
  13526. #define EE_ENB (0x4800 | EE_CS)
  13527. -#define udelay(n) waiton_timer2(((n)*TICKS_PER_MS)/1000)
  13528. -
  13529. /* The EEPROM commands include the alway-set leading bit. */
  13530. #define EE_READ_CMD 6
  13531. @@ -184,9 +190,18 @@
  13532. Typically this takes 0 ticks. */
  13533. static inline void wait_for_cmd_done(int cmd_ioaddr)
  13534. {
  13535. - short wait = 100;
  13536. - do ;
  13537. - while(inb(cmd_ioaddr) && --wait >= 0);
  13538. + int wait = 0;
  13539. + int delayed_cmd;
  13540. +
  13541. + do
  13542. + if (inb(cmd_ioaddr) == 0) return;
  13543. + while(++wait <= 100);
  13544. + delayed_cmd = inb(cmd_ioaddr);
  13545. + do
  13546. + if (inb(cmd_ioaddr) == 0) break;
  13547. + while(++wait <= 10000);
  13548. + printf("Command %2.2x was not immediately accepted, %d ticks!\n",
  13549. + delayed_cmd, wait);
  13550. }
  13551. /* Elements of the dump_statistics block. This block must be lword aligned. */
  13552. @@ -212,35 +227,30 @@
  13553. /* A speedo3 TX buffer descriptor with two buffers... */
  13554. static struct TxFD {
  13555. - volatile s16 status;
  13556. - s16 command;
  13557. - u32 link; /* void * */
  13558. - u32 tx_desc_addr; /* (almost) Always points to the tx_buf_addr element. */
  13559. - s32 count; /* # of TBD (=2), Tx start thresh., etc. */
  13560. - /* This constitutes two "TBD" entries: hdr and data */
  13561. - u32 tx_buf_addr0; /* void *, header of frame to be transmitted. */
  13562. - s32 tx_buf_size0; /* Length of Tx hdr. */
  13563. - u32 tx_buf_addr1; /* void *, data to be transmitted. */
  13564. - s32 tx_buf_size1; /* Length of Tx data. */
  13565. + volatile s16 status;
  13566. + s16 command;
  13567. + u32 link; /* void * */
  13568. + u32 tx_desc_addr; /* (almost) Always points to the tx_buf_addr element. */
  13569. + s32 count; /* # of TBD (=2), Tx start thresh., etc. */
  13570. + /* This constitutes two "TBD" entries: hdr and data */
  13571. + u32 tx_buf_addr0; /* void *, header of frame to be transmitted. */
  13572. + s32 tx_buf_size0; /* Length of Tx hdr. */
  13573. + u32 tx_buf_addr1; /* void *, data to be transmitted. */
  13574. + s32 tx_buf_size1; /* Length of Tx data. */
  13575. } txfd;
  13576. struct RxFD { /* Receive frame descriptor. */
  13577. - volatile s16 status;
  13578. - s16 command;
  13579. - u32 link; /* struct RxFD * */
  13580. - u32 rx_buf_addr; /* void * */
  13581. - u16 count;
  13582. - u16 size;
  13583. - char packet[1518];
  13584. + volatile s16 status;
  13585. + s16 command;
  13586. + u32 link; /* struct RxFD * */
  13587. + u32 rx_buf_addr; /* void * */
  13588. + u16 count;
  13589. + u16 size;
  13590. + char packet[1518];
  13591. };
  13592. -#ifdef USE_LOWMEM_BUFFER
  13593. -#define rxfd ((struct RxFD *)(0x10000 - sizeof(struct RxFD)))
  13594. -#define ACCESS(x) x->
  13595. -#else
  13596. static struct RxFD rxfd;
  13597. #define ACCESS(x) x.
  13598. -#endif
  13599. static int congenb = 0; /* Enable congestion control in the DP83840. */
  13600. static int txfifo = 8; /* Tx FIFO threshold in 4 byte units, 0-15 */
  13601. @@ -256,8 +266,7 @@
  13602. u32 link;
  13603. unsigned char data[22];
  13604. } confcmd = {
  13605. - 0, CmdConfigure,
  13606. - (u32) & txfd,
  13607. + 0, 0, 0, /* filled in later */
  13608. {22, 0x08, 0, 0, 0, 0x80, 0x32, 0x03, 1, /* 1=Use MII 0=Use AUI */
  13609. 0, 0x2E, 0, 0x60, 0,
  13610. 0xf2, 0x48, 0, 0x40, 0xf2, 0x80, /* 0x40=Force full-duplex */
  13611. @@ -276,19 +285,20 @@
  13612. static int mdio_write(int phy_id, int location, int value)
  13613. {
  13614. - int val, boguscnt = 64*4; /* <64 usec. to complete, typ 27 ticks */
  13615. + int val, boguscnt = 64*4; /* <64 usec. to complete, typ 27 ticks */
  13616. - outl(0x04000000 | (location<<16) | (phy_id<<21) | value,
  13617. - ioaddr + SCBCtrlMDI);
  13618. - do {
  13619. - udelay(16);
  13620. -
  13621. - val = inl(ioaddr + SCBCtrlMDI);
  13622. - if (--boguscnt < 0) {
  13623. - printf(" mdio_write() timed out with val = %X.\n", val);
  13624. - }
  13625. - } while (! (val & 0x10000000));
  13626. - return val & 0xffff;
  13627. + outl(0x04000000 | (location<<16) | (phy_id<<21) | value,
  13628. + ioaddr + SCBCtrlMDI);
  13629. + do {
  13630. + udelay(16);
  13631. +
  13632. + val = inl(ioaddr + SCBCtrlMDI);
  13633. + if (--boguscnt < 0) {
  13634. + printf(" mdio_write() timed out with val = %X.\n", val);
  13635. + break;
  13636. + }
  13637. + } while (! (val & 0x10000000));
  13638. + return val & 0xffff;
  13639. }
  13640. /* Support function: mdio_read
  13641. @@ -298,17 +308,19 @@
  13642. */
  13643. static int mdio_read(int phy_id, int location)
  13644. {
  13645. - int val, boguscnt = 64*4; /* <64 usec. to complete, typ 27 ticks */
  13646. - outl(0x08000000 | (location<<16) | (phy_id<<21), ioaddr + SCBCtrlMDI);
  13647. - do {
  13648. - udelay(16);
  13649. -
  13650. - val = inl(ioaddr + SCBCtrlMDI);
  13651. - if (--boguscnt < 0) {
  13652. - printf( " mdio_read() timed out with val = %X.\n", val);
  13653. - }
  13654. - } while (! (val & 0x10000000));
  13655. - return val & 0xffff;
  13656. + int val, boguscnt = 64*4; /* <64 usec. to complete, typ 27 ticks */
  13657. + outl(0x08000000 | (location<<16) | (phy_id<<21), ioaddr + SCBCtrlMDI);
  13658. + do {
  13659. + udelay(16);
  13660. +
  13661. + val = inl(ioaddr + SCBCtrlMDI);
  13662. +
  13663. + if (--boguscnt < 0) {
  13664. + printf( " mdio_read() timed out with val = %X.\n", val);
  13665. + break;
  13666. + }
  13667. + } while (! (val & 0x10000000));
  13668. + return val & 0xffff;
  13669. }
  13670. /* The fixes for the code were kindly provided by Dragan Stancevic
  13671. @@ -340,25 +352,26 @@
  13672. return retval;
  13673. }
  13674. +#if 0
  13675. static inline void whereami (const char *str)
  13676. {
  13677. -#if 0
  13678. printf ("%s\n", str);
  13679. sleep (2);
  13680. -#endif
  13681. }
  13682. +#else
  13683. +#define whereami(s)
  13684. +#endif
  13685. -/* function: eepro100_reset
  13686. - * resets the card. This is used to allow Etherboot to probe the card again
  13687. - * from a "virginal" state....
  13688. - * Arguments: none
  13689. - *
  13690. - * returns: void.
  13691. - */
  13692. -
  13693. -static void eepro100_reset(struct nic *nic)
  13694. +static void eepro100_irq(struct nic *nic __unused, irq_action_t action __unused)
  13695. {
  13696. - outl(0, ioaddr + SCBPort);
  13697. + switch ( action ) {
  13698. + case DISABLE :
  13699. + break;
  13700. + case ENABLE :
  13701. + break;
  13702. + case FORCE :
  13703. + break;
  13704. + }
  13705. }
  13706. /* function: eepro100_transmit
  13707. @@ -373,61 +386,87 @@
  13708. static void eepro100_transmit(struct nic *nic, const char *d, unsigned int t, unsigned int s, const char *p)
  13709. {
  13710. - struct eth_hdr {
  13711. - unsigned char dst_addr[ETH_ALEN];
  13712. - unsigned char src_addr[ETH_ALEN];
  13713. - unsigned short type;
  13714. - } hdr;
  13715. - unsigned short status;
  13716. - int to;
  13717. - int s1, s2;
  13718. -
  13719. - status = inw(ioaddr + SCBStatus);
  13720. - /* Acknowledge all of the current interrupt sources ASAP. */
  13721. - outw(status & 0xfc00, ioaddr + SCBStatus);
  13722. + struct eth_hdr {
  13723. + unsigned char dst_addr[ETH_ALEN];
  13724. + unsigned char src_addr[ETH_ALEN];
  13725. + unsigned short type;
  13726. + } hdr;
  13727. + unsigned short status;
  13728. + int s1, s2;
  13729. +
  13730. + status = inw(ioaddr + SCBStatus);
  13731. + /* Acknowledge all of the current interrupt sources ASAP. */
  13732. + outw(status & 0xfc00, ioaddr + SCBStatus);
  13733. #ifdef DEBUG
  13734. - printf ("transmitting type %hX packet (%d bytes). status = %hX, cmd=%hX\n",
  13735. - t, s, status, inw (ioaddr + SCBCmd));
  13736. + printf ("transmitting type %hX packet (%d bytes). status = %hX, cmd=%hX\n",
  13737. + t, s, status, inw (ioaddr + SCBCmd));
  13738. #endif
  13739. - memcpy (&hdr.dst_addr, d, ETH_ALEN);
  13740. - memcpy (&hdr.src_addr, nic->node_addr, ETH_ALEN);
  13741. + memcpy (&hdr.dst_addr, d, ETH_ALEN);
  13742. + memcpy (&hdr.src_addr, nic->node_addr, ETH_ALEN);
  13743. - hdr.type = htons (t);
  13744. + hdr.type = htons (t);
  13745. - txfd.status = 0;
  13746. - txfd.command = CmdSuspend | CmdTx | CmdTxFlex;
  13747. - txfd.link = virt_to_bus (&txfd);
  13748. - txfd.count = 0x02208000;
  13749. - txfd.tx_desc_addr = (u32)&txfd.tx_buf_addr0;
  13750. + txfd.status = 0;
  13751. + txfd.command = CmdSuspend | CmdTx | CmdTxFlex;
  13752. + txfd.link = virt_to_bus (&txfd);
  13753. + txfd.count = 0x02208000;
  13754. + txfd.tx_desc_addr = virt_to_bus(&txfd.tx_buf_addr0);
  13755. - txfd.tx_buf_addr0 = virt_to_bus (&hdr);
  13756. - txfd.tx_buf_size0 = sizeof (hdr);
  13757. + txfd.tx_buf_addr0 = virt_to_bus (&hdr);
  13758. + txfd.tx_buf_size0 = sizeof (hdr);
  13759. - txfd.tx_buf_addr1 = virt_to_bus (p);
  13760. - txfd.tx_buf_size1 = s;
  13761. + txfd.tx_buf_addr1 = virt_to_bus (p);
  13762. + txfd.tx_buf_size1 = s;
  13763. #ifdef DEBUG
  13764. - printf ("txfd: \n");
  13765. - hd (&txfd, sizeof (txfd));
  13766. + printf ("txfd: \n");
  13767. + hd (&txfd, sizeof (txfd));
  13768. #endif
  13769. - outl(virt_to_bus(&txfd), ioaddr + SCBPointer);
  13770. - outw(INT_MASK | CU_START, ioaddr + SCBCmd);
  13771. - wait_for_cmd_done(ioaddr + SCBCmd);
  13772. -
  13773. - s1 = inw (ioaddr + SCBStatus);
  13774. - load_timer2(10*TICKS_PER_MS); /* timeout 10 ms for transmit */
  13775. - while (!txfd.status && timer2_running())
  13776. - /* Wait */;
  13777. - s2 = inw (ioaddr + SCBStatus);
  13778. + outl(virt_to_bus(&txfd), ioaddr + SCBPointer);
  13779. + outw(INT_MASK | CU_START, ioaddr + SCBCmd);
  13780. + wait_for_cmd_done(ioaddr + SCBCmd);
  13781. +
  13782. + s1 = inw (ioaddr + SCBStatus);
  13783. + load_timer2(10*TICKS_PER_MS); /* timeout 10 ms for transmit */
  13784. + while (!txfd.status && timer2_running())
  13785. + /* Wait */;
  13786. + s2 = inw (ioaddr + SCBStatus);
  13787. #ifdef DEBUG
  13788. - printf ("s1 = %hX, s2 = %hX.\n", s1, s2);
  13789. + printf ("s1 = %hX, s2 = %hX.\n", s1, s2);
  13790. #endif
  13791. }
  13792. +/*
  13793. + * Sometimes the receiver stops making progress. This routine knows how to
  13794. + * get it going again, without losing packets or being otherwise nasty like
  13795. + * a chip reset would be. Previously the driver had a whole sequence
  13796. + * of if RxSuspended, if it's no buffers do one thing, if it's no resources,
  13797. + * do another, etc. But those things don't really matter. Separate logic
  13798. + * in the ISR provides for allocating buffers--the other half of operation
  13799. + * is just making sure the receiver is active. speedo_rx_soft_reset does that.
  13800. + * This problem with the old, more involved algorithm is shown up under
  13801. + * ping floods on the order of 60K packets/second on a 100Mbps fdx network.
  13802. + */
  13803. +static void
  13804. +speedo_rx_soft_reset(void)
  13805. +{
  13806. + wait_for_cmd_done(ioaddr + SCBCmd);
  13807. + /*
  13808. + * Put the hardware into a known state.
  13809. + */
  13810. + outb(RX_ABORT, ioaddr + SCBCmd);
  13811. +
  13812. + ACCESS(rxfd)rx_buf_addr = 0xffffffff;
  13813. +
  13814. + wait_for_cmd_done(ioaddr + SCBCmd);
  13815. +
  13816. + outb(RX_START, ioaddr + SCBCmd);
  13817. +}
  13818. +
  13819. /* function: eepro100_poll / eth_poll
  13820. * This recieves a packet from the network.
  13821. *
  13822. @@ -440,34 +479,87 @@
  13823. * returns the length of the packet in nic->packetlen.
  13824. */
  13825. -static int eepro100_poll(struct nic *nic)
  13826. +static int eepro100_poll(struct nic *nic, int retrieve)
  13827. {
  13828. - if (!ACCESS(rxfd)status)
  13829. - return 0;
  13830. + unsigned int status;
  13831. + status = inw(ioaddr + SCBStatus);
  13832. - /* Ok. We got a packet. Now restart the reciever.... */
  13833. - ACCESS(rxfd)status = 0;
  13834. - ACCESS(rxfd)command = 0xc000;
  13835. - outl(virt_to_bus(&(ACCESS(rxfd)status)), ioaddr + SCBPointer);
  13836. - outw(INT_MASK | RX_START, ioaddr + SCBCmd);
  13837. - wait_for_cmd_done(ioaddr + SCBCmd);
  13838. + if (!ACCESS(rxfd)status)
  13839. + return 0;
  13840. +
  13841. + /* There is a packet ready */
  13842. + if ( ! retrieve ) return 1;
  13843. +
  13844. + /*
  13845. + * The chip may have suspended reception for various reasons.
  13846. + * Check for that, and re-prime it should this be the case.
  13847. + */
  13848. + switch ((status >> 2) & 0xf) {
  13849. + case 0: /* Idle */
  13850. + break;
  13851. + case 1: /* Suspended */
  13852. + case 2: /* No resources (RxFDs) */
  13853. + case 9: /* Suspended with no more RBDs */
  13854. + case 10: /* No resources due to no RBDs */
  13855. + case 12: /* Ready with no RBDs */
  13856. + speedo_rx_soft_reset();
  13857. + break;
  13858. + case 3: case 5: case 6: case 7: case 8:
  13859. + case 11: case 13: case 14: case 15:
  13860. + /* these are all reserved values */
  13861. + break;
  13862. + }
  13863. +
  13864. + /* Ok. We got a packet. Now restart the reciever.... */
  13865. + ACCESS(rxfd)status = 0;
  13866. + ACCESS(rxfd)command = 0xc000;
  13867. + outl(virt_to_bus(&(ACCESS(rxfd)status)), ioaddr + SCBPointer);
  13868. + outw(INT_MASK | RX_START, ioaddr + SCBCmd);
  13869. + wait_for_cmd_done(ioaddr + SCBCmd);
  13870. #ifdef DEBUG
  13871. - printf ("Got a packet: Len = %d.\n", ACCESS(rxfd)count & 0x3fff);
  13872. + printf ("Got a packet: Len = %d.\n", ACCESS(rxfd)count & 0x3fff);
  13873. #endif
  13874. - nic->packetlen = ACCESS(rxfd)count & 0x3fff;
  13875. - memcpy (nic->packet, ACCESS(rxfd)packet, nic->packetlen);
  13876. + nic->packetlen = ACCESS(rxfd)count & 0x3fff;
  13877. + memcpy (nic->packet, ACCESS(rxfd)packet, nic->packetlen);
  13878. #ifdef DEBUG
  13879. - hd (nic->packet, 0x30);
  13880. + hd (nic->packet, 0x30);
  13881. #endif
  13882. - return 1;
  13883. + return 1;
  13884. }
  13885. -static void eepro100_disable(struct nic *nic)
  13886. +/* function: eepro100_disable
  13887. + * resets the card. This is used to allow Etherboot or Linux
  13888. + * to probe the card again from a "virginal" state....
  13889. + * Arguments: none
  13890. + *
  13891. + * returns: void.
  13892. + */
  13893. +static void eepro100_disable(struct dev *dev __unused)
  13894. {
  13895. - /* See if this PartialReset solves the problem with interfering with
  13896. - kernel operation after Etherboot hands over. - Ken 20001102 */
  13897. - outl(2, ioaddr + SCBPort);
  13898. +/* from eepro100_reset */
  13899. + outl(0, ioaddr + SCBPort);
  13900. +/* from eepro100_disable */
  13901. + /* See if this PartialReset solves the problem with interfering with
  13902. + kernel operation after Etherboot hands over. - Ken 20001102 */
  13903. + outl(2, ioaddr + SCBPort);
  13904. +
  13905. + /* The following is from the Intel e100 driver.
  13906. + * This hopefully solves the problem with hanging hard DOS images. */
  13907. +
  13908. + /* wait for the reset to take effect */
  13909. + udelay(20);
  13910. +
  13911. + /* Mask off our interrupt line -- it is unmasked after reset */
  13912. + {
  13913. + u16 intr_status;
  13914. + /* Disable interrupts on our PCI board by setting the mask bit */
  13915. + outw(INT_MASK, ioaddr + SCBCmd);
  13916. + intr_status = inw(ioaddr + SCBStatus);
  13917. + /* ack and clear intrs */
  13918. + outw(intr_status, ioaddr + SCBStatus);
  13919. + inw(ioaddr + SCBStatus);
  13920. + }
  13921. }
  13922. /* exported function: eepro100_probe / eth_probe
  13923. @@ -478,25 +570,30 @@
  13924. * leaves the 82557 initialized, and ready to recieve packets.
  13925. */
  13926. -struct nic *eepro100_probe(struct nic *nic, unsigned short *probeaddrs, struct pci_device *p)
  13927. +static int eepro100_probe(struct dev *dev, struct pci_device *p)
  13928. {
  13929. + struct nic *nic = (struct nic *)dev;
  13930. unsigned short sum = 0;
  13931. int i;
  13932. int read_cmd, ee_size;
  13933. - unsigned short value;
  13934. int options;
  13935. - int promisc;
  13936. + int rx_mode;
  13937. /* we cache only the first few words of the EEPROM data
  13938. be careful not to access beyond this array */
  13939. unsigned short eeprom[16];
  13940. - if (probeaddrs == 0 || probeaddrs[0] == 0)
  13941. + if (p->ioaddr == 0)
  13942. return 0;
  13943. - ioaddr = probeaddrs[0] & ~3; /* Mask the bit that says "this is an io addr" */
  13944. + ioaddr = p->ioaddr & ~3; /* Mask the bit that says "this is an io addr" */
  13945. + nic->ioaddr = ioaddr;
  13946. adjust_pci_device(p);
  13947. + /* Copy IRQ from PCI information */
  13948. + /* nic->irqno = pci->irq; */
  13949. + nic->irqno = 0;
  13950. +
  13951. if ((do_eeprom_cmd(EE_READ_CMD << 24, 27) & 0xffe0000)
  13952. == 0xffe0000) {
  13953. ee_size = 0x100;
  13954. @@ -513,123 +610,138 @@
  13955. sum += value;
  13956. }
  13957. - for (i=0;i<ETH_ALEN;i++) {
  13958. - nic->node_addr[i] = (eeprom[i/2] >> (8*(i&1))) & 0xff;
  13959. - }
  13960. - printf ("Ethernet addr: %!\n", nic->node_addr);
  13961. -
  13962. - if (sum != 0xBABA)
  13963. - printf("eepro100: Invalid EEPROM checksum %#hX, "
  13964. - "check settings before activating this device!\n", sum);
  13965. - outl(0, ioaddr + SCBPort);
  13966. - udelay (10000);
  13967. -
  13968. - whereami ("Got eeprom.");
  13969. -
  13970. - outl(virt_to_bus(&lstats), ioaddr + SCBPointer);
  13971. - outw(INT_MASK | CU_STATSADDR, ioaddr + SCBCmd);
  13972. - wait_for_cmd_done(ioaddr + SCBCmd);
  13973. -
  13974. - whereami ("set stats addr.");
  13975. - /* INIT RX stuff. */
  13976. -
  13977. - /* Base = 0 */
  13978. - outl(0, ioaddr + SCBPointer);
  13979. - outw(INT_MASK | RX_ADDR_LOAD, ioaddr + SCBCmd);
  13980. - wait_for_cmd_done(ioaddr + SCBCmd);
  13981. -
  13982. - whereami ("set rx base addr.");
  13983. -
  13984. - ACCESS(rxfd)status = 0x0001;
  13985. - ACCESS(rxfd)command = 0x0000;
  13986. - ACCESS(rxfd)link = virt_to_bus(&(ACCESS(rxfd)status));
  13987. - ACCESS(rxfd)rx_buf_addr = (int) &nic->packet;
  13988. - ACCESS(rxfd)count = 0;
  13989. - ACCESS(rxfd)size = 1528;
  13990. -
  13991. - outl(virt_to_bus(&(ACCESS(rxfd)status)), ioaddr + SCBPointer);
  13992. - outw(INT_MASK | RX_START, ioaddr + SCBCmd);
  13993. - wait_for_cmd_done(ioaddr + SCBCmd);
  13994. -
  13995. - whereami ("started RX process.");
  13996. -
  13997. - /* Start the reciever.... */
  13998. - ACCESS(rxfd)status = 0;
  13999. - ACCESS(rxfd)command = 0xc000;
  14000. - outl(virt_to_bus(&(ACCESS(rxfd)status)), ioaddr + SCBPointer);
  14001. - outw(INT_MASK | RX_START, ioaddr + SCBCmd);
  14002. -
  14003. - /* INIT TX stuff. */
  14004. -
  14005. - /* Base = 0 */
  14006. - outl(0, ioaddr + SCBPointer);
  14007. - outw(INT_MASK | CU_CMD_BASE, ioaddr + SCBCmd);
  14008. - wait_for_cmd_done(ioaddr + SCBCmd);
  14009. -
  14010. - whereami ("set TX base addr.");
  14011. -
  14012. - txfd.command = (CmdIASetup);
  14013. - txfd.status = 0x0000;
  14014. - txfd.link = virt_to_bus (&confcmd);
  14015. -
  14016. - {
  14017. - char *t = (char *)&txfd.tx_desc_addr;
  14018. + for (i=0;i<ETH_ALEN;i++) {
  14019. + nic->node_addr[i] = (eeprom[i/2] >> (8*(i&1))) & 0xff;
  14020. + }
  14021. + printf ("Ethernet addr: %!\n", nic->node_addr);
  14022. - for (i=0;i<ETH_ALEN;i++)
  14023. - t[i] = nic->node_addr[i];
  14024. - }
  14025. + if (sum != 0xBABA)
  14026. + printf("eepro100: Invalid EEPROM checksum %#hX, "
  14027. + "check settings before activating this device!\n", sum);
  14028. + outl(0, ioaddr + SCBPort);
  14029. + udelay (10000);
  14030. + whereami ("Got eeprom.");
  14031. +
  14032. + /* Base = 0 */
  14033. + outl(0, ioaddr + SCBPointer);
  14034. + outw(INT_MASK | RX_ADDR_LOAD, ioaddr + SCBCmd);
  14035. + wait_for_cmd_done(ioaddr + SCBCmd);
  14036. + whereami ("set rx base addr.");
  14037. +
  14038. + outl(virt_to_bus(&lstats), ioaddr + SCBPointer);
  14039. + outw(INT_MASK | CU_STATSADDR, ioaddr + SCBCmd);
  14040. + wait_for_cmd_done(ioaddr + SCBCmd);
  14041. + whereami ("set stats addr.");
  14042. +
  14043. + /* INIT RX stuff. */
  14044. + ACCESS(rxfd)status = 0x0001;
  14045. + ACCESS(rxfd)command = 0x0000;
  14046. + ACCESS(rxfd)link = virt_to_bus(&(ACCESS(rxfd)status));
  14047. + ACCESS(rxfd)rx_buf_addr = virt_to_bus(&nic->packet);
  14048. + ACCESS(rxfd)count = 0;
  14049. + ACCESS(rxfd)size = 1528;
  14050. +
  14051. + outl(virt_to_bus(&(ACCESS(rxfd)status)), ioaddr + SCBPointer);
  14052. + outw(INT_MASK | RX_START, ioaddr + SCBCmd);
  14053. + wait_for_cmd_done(ioaddr + SCBCmd);
  14054. +
  14055. + whereami ("started RX process.");
  14056. +
  14057. + /* Start the reciever.... */
  14058. + ACCESS(rxfd)status = 0;
  14059. + ACCESS(rxfd)command = 0xc000;
  14060. + outl(virt_to_bus(&(ACCESS(rxfd)status)), ioaddr + SCBPointer);
  14061. + outw(INT_MASK | RX_START, ioaddr + SCBCmd);
  14062. +
  14063. + /* INIT TX stuff. */
  14064. +
  14065. + /* Base = 0 */
  14066. + outl(0, ioaddr + SCBPointer);
  14067. + outw(INT_MASK | CU_CMD_BASE, ioaddr + SCBCmd);
  14068. + wait_for_cmd_done(ioaddr + SCBCmd);
  14069. +
  14070. + whereami ("set TX base addr.");
  14071. +
  14072. + txfd.command = (CmdIASetup);
  14073. + txfd.status = 0x0000;
  14074. + txfd.link = virt_to_bus (&confcmd);
  14075. +
  14076. + {
  14077. + char *t = (char *)&txfd.tx_desc_addr;
  14078. +
  14079. + for (i=0;i<ETH_ALEN;i++)
  14080. + t[i] = nic->node_addr[i];
  14081. + }
  14082. #ifdef DEBUG
  14083. - printf ("Setup_eaddr:\n");
  14084. - hd (&txfd, 0x20);
  14085. + printf ("Setup_eaddr:\n");
  14086. + hd (&txfd, 0x20);
  14087. #endif
  14088. - /* options = 0x40; */ /* 10mbps half duplex... */
  14089. - options = 0x00; /* Autosense */
  14090. -
  14091. - promisc = 0;
  14092. -
  14093. - if ( ((eeprom[6]>>8) & 0x3f) == DP83840
  14094. - || ((eeprom[6]>>8) & 0x3f) == DP83840A) {
  14095. - int mdi_reg23 = mdio_read(eeprom[6] & 0x1f, 23) | 0x0422;
  14096. - if (congenb)
  14097. - mdi_reg23 |= 0x0100;
  14098. - printf(" DP83840 specific setup, setting register 23 to %hX.\n",
  14099. - mdi_reg23);
  14100. - mdio_write(eeprom[6] & 0x1f, 23, mdi_reg23);
  14101. - }
  14102. - whereami ("Done DP8340 special setup.");
  14103. - if (options != 0) {
  14104. - mdio_write(eeprom[6] & 0x1f, 0,
  14105. - ((options & 0x20) ? 0x2000 : 0) | /* 100mbps? */
  14106. - ((options & 0x10) ? 0x0100 : 0)); /* Full duplex? */
  14107. - whereami ("set mdio_register.");
  14108. - }
  14109. + /* options = 0x40; */ /* 10mbps half duplex... */
  14110. + options = 0x00; /* Autosense */
  14111. - confcmd.command = CmdSuspend | CmdConfigure;
  14112. - confcmd.status = 0x0000;
  14113. - confcmd.link = virt_to_bus (&txfd);
  14114. - confcmd.data[1] = (txfifo << 4) | rxfifo;
  14115. - confcmd.data[4] = rxdmacount;
  14116. - confcmd.data[5] = txdmacount + 0x80;
  14117. - confcmd.data[15] = promisc ? 0x49: 0x48;
  14118. - confcmd.data[19] = (options & 0x10) ? 0xC0 : 0x80;
  14119. - confcmd.data[21] = promisc ? 0x0D: 0x05;
  14120. +#ifdef PROMISC
  14121. + rx_mode = 3;
  14122. +#elif ALLMULTI
  14123. + rx_mode = 1;
  14124. +#else
  14125. + rx_mode = 0;
  14126. +#endif
  14127. - outl(virt_to_bus(&txfd), ioaddr + SCBPointer);
  14128. - outw(INT_MASK | CU_START, ioaddr + SCBCmd);
  14129. - wait_for_cmd_done(ioaddr + SCBCmd);
  14130. + if ( ((eeprom[6]>>8) & 0x3f) == DP83840
  14131. + || ((eeprom[6]>>8) & 0x3f) == DP83840A) {
  14132. + int mdi_reg23 = mdio_read(eeprom[6] & 0x1f, 23) | 0x0422;
  14133. + if (congenb)
  14134. + mdi_reg23 |= 0x0100;
  14135. + printf(" DP83840 specific setup, setting register 23 to %hX.\n",
  14136. + mdi_reg23);
  14137. + mdio_write(eeprom[6] & 0x1f, 23, mdi_reg23);
  14138. + }
  14139. + whereami ("Done DP8340 special setup.");
  14140. + if (options != 0) {
  14141. + mdio_write(eeprom[6] & 0x1f, 0,
  14142. + ((options & 0x20) ? 0x2000 : 0) | /* 100mbps? */
  14143. + ((options & 0x10) ? 0x0100 : 0)); /* Full duplex? */
  14144. + whereami ("set mdio_register.");
  14145. + }
  14146. - whereami ("started TX thingy (config, iasetup).");
  14147. + confcmd.command = CmdSuspend | CmdConfigure;
  14148. + confcmd.status = 0x0000;
  14149. + confcmd.link = virt_to_bus (&txfd);
  14150. + confcmd.data[1] = (txfifo << 4) | rxfifo;
  14151. + confcmd.data[4] = rxdmacount;
  14152. + confcmd.data[5] = txdmacount + 0x80;
  14153. + confcmd.data[15] = (rx_mode & 2) ? 0x49: 0x48;
  14154. + confcmd.data[19] = (options & 0x10) ? 0xC0 : 0x80;
  14155. + confcmd.data[21] = (rx_mode & 1) ? 0x0D: 0x05;
  14156. +
  14157. + outl(virt_to_bus(&txfd), ioaddr + SCBPointer);
  14158. + outw(INT_MASK | CU_START, ioaddr + SCBCmd);
  14159. + wait_for_cmd_done(ioaddr + SCBCmd);
  14160. +
  14161. + whereami ("started TX thingy (config, iasetup).");
  14162. +
  14163. + load_timer2(10*TICKS_PER_MS);
  14164. + while (!txfd.status && timer2_running())
  14165. + /* Wait */;
  14166. +
  14167. + /* Read the status register once to disgard stale data */
  14168. + mdio_read(eeprom[6] & 0x1f, 1);
  14169. + /* Check to see if the network cable is plugged in.
  14170. + * This allows for faster failure if there is nothing
  14171. + * we can do.
  14172. + */
  14173. + if (!(mdio_read(eeprom[6] & 0x1f, 1) & (1 << 2))) {
  14174. + printf("Valid link not established\n");
  14175. + eepro100_disable(dev);
  14176. + return 0;
  14177. + }
  14178. - load_timer2(10*TICKS_PER_MS);
  14179. - while (!txfd.status && timer2_running())
  14180. - /* Wait */;
  14181. -
  14182. - nic->reset = eepro100_reset;
  14183. - nic->poll = eepro100_poll;
  14184. - nic->transmit = eepro100_transmit;
  14185. - nic->disable = eepro100_disable;
  14186. - return nic;
  14187. + dev->disable = eepro100_disable;
  14188. + nic->poll = eepro100_poll;
  14189. + nic->transmit = eepro100_transmit;
  14190. + nic->irq = eepro100_irq;
  14191. + return 1;
  14192. }
  14193. /*********************************************************************/
  14194. @@ -639,16 +751,59 @@
  14195. /* Hexdump a number of bytes from memory... */
  14196. void hd (void *where, int n)
  14197. {
  14198. - int i;
  14199. + int i;
  14200. - while (n > 0) {
  14201. - printf ("%X ", where);
  14202. - for (i=0;i < ( (n>16)?16:n);i++)
  14203. - printf (" %hhX", ((char *)where)[i]);
  14204. - printf ("\n");
  14205. - n -= 16;
  14206. - where += 16;
  14207. - }
  14208. + while (n > 0) {
  14209. + printf ("%X ", where);
  14210. + for (i=0;i < ( (n>16)?16:n);i++)
  14211. + printf (" %hhX", ((char *)where)[i]);
  14212. + printf ("\n");
  14213. + n -= 16;
  14214. + where += 16;
  14215. + }
  14216. }
  14217. #endif
  14218. +static struct pci_id eepro100_nics[] = {
  14219. +PCI_ROM(0x8086, 0x1029, "id1029", "Intel EtherExpressPro100 ID1029"),
  14220. +PCI_ROM(0x8086, 0x1030, "id1030", "Intel EtherExpressPro100 ID1030"),
  14221. +PCI_ROM(0x8086, 0x1031, "82801cam", "Intel 82801CAM (ICH3) Chipset Ethernet Controller"),
  14222. +PCI_ROM(0x8086, 0x1032, "eepro100-1032", "Intel PRO/100 VE Network Connection"),
  14223. +PCI_ROM(0x8086, 0x1033, "eepro100-1033", "Intel PRO/100 VM Network Connection"),
  14224. +PCI_ROM(0x8086, 0x1034, "eepro100-1034", "Intel PRO/100 VM Network Connection"),
  14225. +PCI_ROM(0x8086, 0x1035, "eepro100-1035", "Intel 82801CAM (ICH3) Chipset Ethernet Controller"),
  14226. +PCI_ROM(0x8086, 0x1036, "eepro100-1036", "Intel 82801CAM (ICH3) Chipset Ethernet Controller"),
  14227. +PCI_ROM(0x8086, 0x1037, "eepro100-1037", "Intel 82801CAM (ICH3) Chipset Ethernet Controller"),
  14228. +PCI_ROM(0x8086, 0x1038, "id1038", "Intel PRO/100 VM Network Connection"),
  14229. +PCI_ROM(0x8086, 0x1039, "82562et", "Intel PRO100 VE 82562ET"),
  14230. +PCI_ROM(0x8086, 0x103a, "id103a", "Intel Corporation 82559 InBusiness 10/100"),
  14231. +PCI_ROM(0x8086, 0x103b, "82562etb", "Intel PRO100 VE 82562ETB"),
  14232. +PCI_ROM(0x8086, 0x103c, "eepro100-103c", "Intel PRO/100 VM Network Connection"),
  14233. +PCI_ROM(0x8086, 0x103d, "eepro100-103d", "Intel PRO/100 VE Network Connection"),
  14234. +PCI_ROM(0x8086, 0x103e, "eepro100-103e", "Intel PRO/100 VM Network Connection"),
  14235. +PCI_ROM(0x8086, 0x1059, "82551qm", "Intel PRO/100 M Mobile Connection"),
  14236. +PCI_ROM(0x8086, 0x1209, "82559er", "Intel EtherExpressPro100 82559ER"),
  14237. +PCI_ROM(0x8086, 0x1227, "82865", "Intel 82865 EtherExpress PRO/100A"),
  14238. +PCI_ROM(0x8086, 0x1228, "82556", "Intel 82556 EtherExpress PRO/100 Smart"),
  14239. +PCI_ROM(0x8086, 0x1229, "eepro100", "Intel EtherExpressPro100"),
  14240. +PCI_ROM(0x8086, 0x2449, "82562em", "Intel EtherExpressPro100 82562EM"),
  14241. +PCI_ROM(0x8086, 0x2459, "82562-1", "Intel 82562 based Fast Ethernet Connection"),
  14242. +PCI_ROM(0x8086, 0x245d, "82562-2", "Intel 82562 based Fast Ethernet Connection"),
  14243. +PCI_ROM(0x8086, 0x1050, "82562ez", "Intel 82562EZ Network Connection"),
  14244. +PCI_ROM(0x8086, 0x5200, "eepro100-5200", "Intel EtherExpress PRO/100 Intelligent Server"),
  14245. +PCI_ROM(0x8086, 0x5201, "eepro100-5201", "Intel EtherExpress PRO/100 Intelligent Server"),
  14246. +};
  14247. +
  14248. +/* Cards with device ids 0x1030 to 0x103F, 0x2449, 0x2459 or 0x245D might need
  14249. + * a workaround for hardware bug on 10 mbit half duplex (see linux driver eepro100.c)
  14250. + * 2003/03/17 gbaum */
  14251. +
  14252. +
  14253. +struct pci_driver eepro100_driver = {
  14254. + .type = NIC_DRIVER,
  14255. + .name = "EEPRO100",
  14256. + .probe = eepro100_probe,
  14257. + .ids = eepro100_nics,
  14258. + .id_count = sizeof(eepro100_nics)/sizeof(eepro100_nics[0]),
  14259. + .class = 0
  14260. +};
  14261. diff -Naur grub-0.97.orig/netboot/elf.h grub-0.97/netboot/elf.h
  14262. --- grub-0.97.orig/netboot/elf.h 1970-01-01 00:00:00.000000000 +0000
  14263. +++ grub-0.97/netboot/elf.h 2005-08-31 19:03:35.000000000 +0000
  14264. @@ -0,0 +1,234 @@
  14265. +#ifndef ELF_H
  14266. +#define ELF_H
  14267. +
  14268. +#define EI_NIDENT 16 /* Size of e_ident array. */
  14269. +
  14270. +/* Values for e_type. */
  14271. +#define ET_NONE 0 /* No file type */
  14272. +#define ET_REL 1 /* Relocatable file */
  14273. +#define ET_EXEC 2 /* Executable file */
  14274. +#define ET_DYN 3 /* Shared object file */
  14275. +#define ET_CORE 4 /* Core file */
  14276. +
  14277. +/* Values for e_machine (architecute). */
  14278. +#define EM_NONE 0 /* No machine */
  14279. +#define EM_M32 1 /* AT&T WE 32100 */
  14280. +#define EM_SPARC 2 /* SUN SPARC */
  14281. +#define EM_386 3 /* Intel 80386+ */
  14282. +#define EM_68K 4 /* Motorola m68k family */
  14283. +#define EM_88K 5 /* Motorola m88k family */
  14284. +#define EM_486 6 /* Perhaps disused */
  14285. +#define EM_860 7 /* Intel 80860 */
  14286. +#define EM_MIPS 8 /* MIPS R3000 big-endian */
  14287. +#define EM_S370 9 /* IBM System/370 */
  14288. +#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */
  14289. +
  14290. +#define EM_PARISC 15 /* HPPA */
  14291. +#define EM_VPP500 17 /* Fujitsu VPP500 */
  14292. +#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
  14293. +#define EM_960 19 /* Intel 80960 */
  14294. +#define EM_PPC 20 /* PowerPC */
  14295. +#define EM_PPC64 21 /* PowerPC 64-bit */
  14296. +#define EM_S390 22 /* IBM S390 */
  14297. +
  14298. +#define EM_V800 36 /* NEC V800 series */
  14299. +#define EM_FR20 37 /* Fujitsu FR20 */
  14300. +#define EM_RH32 38 /* TRW RH-32 */
  14301. +#define EM_RCE 39 /* Motorola RCE */
  14302. +#define EM_ARM 40 /* ARM */
  14303. +#define EM_FAKE_ALPHA 41 /* Digital Alpha */
  14304. +#define EM_SH 42 /* Hitachi SH */
  14305. +#define EM_SPARCV9 43 /* SPARC v9 64-bit */
  14306. +#define EM_TRICORE 44 /* Siemens Tricore */
  14307. +#define EM_ARC 45 /* Argonaut RISC Core */
  14308. +#define EM_H8_300 46 /* Hitachi H8/300 */
  14309. +#define EM_H8_300H 47 /* Hitachi H8/300H */
  14310. +#define EM_H8S 48 /* Hitachi H8S */
  14311. +#define EM_H8_500 49 /* Hitachi H8/500 */
  14312. +#define EM_IA_64 50 /* Intel Merced */
  14313. +#define EM_MIPS_X 51 /* Stanford MIPS-X */
  14314. +#define EM_COLDFIRE 52 /* Motorola Coldfire */
  14315. +#define EM_68HC12 53 /* Motorola M68HC12 */
  14316. +#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/
  14317. +#define EM_PCP 55 /* Siemens PCP */
  14318. +#define EM_NCPU 56 /* Sony nCPU embeeded RISC */
  14319. +#define EM_NDR1 57 /* Denso NDR1 microprocessor */
  14320. +#define EM_STARCORE 58 /* Motorola Start*Core processor */
  14321. +#define EM_ME16 59 /* Toyota ME16 processor */
  14322. +#define EM_ST100 60 /* STMicroelectronic ST100 processor */
  14323. +#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/
  14324. +#define EM_X86_64 62 /* AMD x86-64 architecture */
  14325. +#define EM_PDSP 63 /* Sony DSP Processor */
  14326. +
  14327. +#define EM_FX66 66 /* Siemens FX66 microcontroller */
  14328. +#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */
  14329. +#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */
  14330. +#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */
  14331. +#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */
  14332. +#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */
  14333. +#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */
  14334. +#define EM_SVX 73 /* Silicon Graphics SVx */
  14335. +#define EM_AT19 74 /* STMicroelectronics ST19 8 bit mc */
  14336. +#define EM_VAX 75 /* Digital VAX */
  14337. +#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */
  14338. +#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */
  14339. +#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
  14340. +#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
  14341. +#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */
  14342. +#define EM_HUANY 81 /* Harvard University machine-independent object files */
  14343. +#define EM_PRISM 82 /* SiTera Prism */
  14344. +#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
  14345. +#define EM_FR30 84 /* Fujitsu FR30 */
  14346. +#define EM_D10V 85 /* Mitsubishi D10V */
  14347. +#define EM_D30V 86 /* Mitsubishi D30V */
  14348. +#define EM_V850 87 /* NEC v850 */
  14349. +#define EM_M32R 88 /* Mitsubishi M32R */
  14350. +#define EM_MN10300 89 /* Matsushita MN10300 */
  14351. +#define EM_MN10200 90 /* Matsushita MN10200 */
  14352. +#define EM_PJ 91 /* picoJava */
  14353. +#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
  14354. +#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */
  14355. +#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
  14356. +#define EM_NUM 95
  14357. +
  14358. +/* Values for p_type. */
  14359. +#define PT_NULL 0 /* Unused entry. */
  14360. +#define PT_LOAD 1 /* Loadable segment. */
  14361. +#define PT_DYNAMIC 2 /* Dynamic linking information segment. */
  14362. +#define PT_INTERP 3 /* Pathname of interpreter. */
  14363. +#define PT_NOTE 4 /* Auxiliary information. */
  14364. +#define PT_SHLIB 5 /* Reserved (not used). */
  14365. +#define PT_PHDR 6 /* Location of program header itself. */
  14366. +
  14367. +/* Values for p_flags. */
  14368. +#define PF_X 0x1 /* Executable. */
  14369. +#define PF_W 0x2 /* Writable. */
  14370. +#define PF_R 0x4 /* Readable. */
  14371. +
  14372. +
  14373. +#define ELF_PROGRAM_RETURNS_BIT 0x8000000 /* e_flags bit 31 */
  14374. +
  14375. +#define EI_MAG0 0
  14376. +#define ELFMAG0 0x7f
  14377. +
  14378. +#define EI_MAG1 1
  14379. +#define ELFMAG1 'E'
  14380. +
  14381. +#define EI_MAG2 2
  14382. +#define ELFMAG2 'L'
  14383. +
  14384. +#define EI_MAG3 3
  14385. +#define ELFMAG3 'F'
  14386. +
  14387. +#define ELFMAG "\177ELF"
  14388. +
  14389. +#define EI_CLASS 4 /* File class byte index */
  14390. +#define ELFCLASSNONE 0 /* Invalid class */
  14391. +#define ELFCLASS32 1 /* 32-bit objects */
  14392. +#define ELFCLASS64 2 /* 64-bit objects */
  14393. +
  14394. +#define EI_DATA 5 /* Data encodeing byte index */
  14395. +#define ELFDATANONE 0 /* Invalid data encoding */
  14396. +#define ELFDATA2LSB 1 /* 2's complement little endian */
  14397. +#define ELFDATA2MSB 2 /* 2's complement big endian */
  14398. +
  14399. +#define EI_VERSION 6 /* File version byte index */
  14400. + /* Value must be EV_CURRENT */
  14401. +
  14402. +#define EV_NONE 0 /* Invalid ELF Version */
  14403. +#define EV_CURRENT 1 /* Current version */
  14404. +
  14405. +#define ELF32_PHDR_SIZE (8*4) /* Size of an elf program header */
  14406. +
  14407. +#ifndef ASSEMBLY
  14408. +/*
  14409. + * ELF definitions common to all 32-bit architectures.
  14410. + */
  14411. +
  14412. +typedef uint32_t Elf32_Addr;
  14413. +typedef uint16_t Elf32_Half;
  14414. +typedef uint32_t Elf32_Off;
  14415. +typedef int32_t Elf32_Sword;
  14416. +typedef uint32_t Elf32_Word;
  14417. +typedef uint32_t Elf32_Size;
  14418. +
  14419. +typedef uint64_t Elf64_Addr;
  14420. +typedef uint16_t Elf64_Half;
  14421. +typedef uint64_t Elf64_Off;
  14422. +typedef int32_t Elf64_Sword;
  14423. +typedef uint32_t Elf64_Word;
  14424. +typedef uint64_t Elf64_Size;
  14425. +
  14426. +/*
  14427. + * ELF header.
  14428. + */
  14429. +typedef struct {
  14430. + unsigned char e_ident[EI_NIDENT]; /* File identification. */
  14431. + Elf32_Half e_type; /* File type. */
  14432. + Elf32_Half e_machine; /* Machine architecture. */
  14433. + Elf32_Word e_version; /* ELF format version. */
  14434. + Elf32_Addr e_entry; /* Entry point. */
  14435. + Elf32_Off e_phoff; /* Program header file offset. */
  14436. + Elf32_Off e_shoff; /* Section header file offset. */
  14437. + Elf32_Word e_flags; /* Architecture-specific flags. */
  14438. + Elf32_Half e_ehsize; /* Size of ELF header in bytes. */
  14439. + Elf32_Half e_phentsize; /* Size of program header entry. */
  14440. + Elf32_Half e_phnum; /* Number of program header entries. */
  14441. + Elf32_Half e_shentsize; /* Size of section header entry. */
  14442. + Elf32_Half e_shnum; /* Number of section header entries. */
  14443. + Elf32_Half e_shstrndx; /* Section name strings section. */
  14444. +} Elf32_Ehdr;
  14445. +
  14446. +typedef struct {
  14447. + unsigned char e_ident[EI_NIDENT]; /* File identification. */
  14448. + Elf64_Half e_type; /* File type. */
  14449. + Elf64_Half e_machine; /* Machine architecture. */
  14450. + Elf64_Word e_version; /* ELF format version. */
  14451. + Elf64_Addr e_entry; /* Entry point. */
  14452. + Elf64_Off e_phoff; /* Program header file offset. */
  14453. + Elf64_Off e_shoff; /* Section header file offset. */
  14454. + Elf64_Word e_flags; /* Architecture-specific flags. */
  14455. + Elf64_Half e_ehsize; /* Size of ELF header in bytes. */
  14456. + Elf64_Half e_phentsize; /* Size of program header entry. */
  14457. + Elf64_Half e_phnum; /* Number of program header entries. */
  14458. + Elf64_Half e_shentsize; /* Size of section header entry. */
  14459. + Elf64_Half e_shnum; /* Number of section header entries. */
  14460. + Elf64_Half e_shstrndx; /* Section name strings section. */
  14461. +} Elf64_Ehdr;
  14462. +
  14463. +/*
  14464. + * Program header.
  14465. + */
  14466. +typedef struct {
  14467. + Elf32_Word p_type; /* Entry type. */
  14468. + Elf32_Off p_offset; /* File offset of contents. */
  14469. + Elf32_Addr p_vaddr; /* Virtual address (not used). */
  14470. + Elf32_Addr p_paddr; /* Physical address. */
  14471. + Elf32_Size p_filesz; /* Size of contents in file. */
  14472. + Elf32_Size p_memsz; /* Size of contents in memory. */
  14473. + Elf32_Word p_flags; /* Access permission flags. */
  14474. + Elf32_Size p_align; /* Alignment in memory and file. */
  14475. +} Elf32_Phdr;
  14476. +
  14477. +typedef struct {
  14478. + Elf64_Word p_type; /* Entry type. */
  14479. + Elf64_Word p_flags; /* Access permission flags. */
  14480. + Elf64_Off p_offset; /* File offset of contents. */
  14481. + Elf64_Addr p_vaddr; /* Virtual address (not used). */
  14482. + Elf64_Addr p_paddr; /* Physical address. */
  14483. + Elf64_Size p_filesz; /* Size of contents in file. */
  14484. + Elf64_Size p_memsz; /* Size of contents in memory. */
  14485. + Elf64_Size p_align; /* Alignment in memory and file. */
  14486. +} Elf64_Phdr;
  14487. +
  14488. +/* Standardized Elf image notes for booting... The name for all of these is ELFBoot */
  14489. +
  14490. +
  14491. +/* ELF Defines for the current architecture */
  14492. +#include "i386_elf.h"
  14493. +
  14494. +#endif /* ASSEMBLY */
  14495. +
  14496. +//#include "elf_boot.h"
  14497. +
  14498. +#endif /* ELF_H */
  14499. diff -Naur grub-0.97.orig/netboot/endian.h grub-0.97/netboot/endian.h
  14500. --- grub-0.97.orig/netboot/endian.h 1970-01-01 00:00:00.000000000 +0000
  14501. +++ grub-0.97/netboot/endian.h 2005-08-31 19:03:35.000000000 +0000
  14502. @@ -0,0 +1,19 @@
  14503. +#ifndef ETHERBOOT_ENDIAN_H
  14504. +#define ETHERBOOT_ENDIAN_H
  14505. +
  14506. +/* Definitions for byte order, according to significance of bytes,
  14507. + from low addresses to high addresses. The value is what you get by
  14508. + putting '4' in the most significant byte, '3' in the second most
  14509. + significant byte, '2' in the second least significant byte, and '1'
  14510. + in the least significant byte, and then writing down one digit for
  14511. + each byte, starting with the byte at the lowest address at the left,
  14512. + and proceeding to the byte with the highest address at the right. */
  14513. +
  14514. +#define __LITTLE_ENDIAN 1234
  14515. +#define __BIG_ENDIAN 4321
  14516. +#define __PDP_ENDIAN 3412
  14517. +
  14518. +#include "i386_endian.h"
  14519. +
  14520. +
  14521. +#endif /* ETHERBOOT_ENDIAN_H */
  14522. diff -Naur grub-0.97.orig/netboot/epic100.c grub-0.97/netboot/epic100.c
  14523. --- grub-0.97.orig/netboot/epic100.c 2003-07-09 11:45:37.000000000 +0000
  14524. +++ grub-0.97/netboot/epic100.c 2005-08-31 19:03:35.000000000 +0000
  14525. @@ -1,15 +1,18 @@
  14526. +
  14527. /* epic100.c: A SMC 83c170 EPIC/100 fast ethernet driver for Etherboot */
  14528. +/* 05/06/2003 timlegge Fixed relocation and implemented Multicast */
  14529. #define LINUX_OUT_MACROS
  14530. #include "etherboot.h"
  14531. +#include "pci.h"
  14532. #include "nic.h"
  14533. -#include "cards.h"
  14534. #include "timer.h"
  14535. #include "epic100.h"
  14536. -#undef virt_to_bus
  14537. -#define virt_to_bus(x) ((unsigned long)x)
  14538. +/* Condensed operations for readability */
  14539. +#define virt_to_le32desc(addr) cpu_to_le32(virt_to_bus(addr))
  14540. +#define le32desc_to_virt(addr) bus_to_virt(le32_to_cpu(addr))
  14541. #define TX_RING_SIZE 2 /* use at least 2 buffers for TX */
  14542. #define RX_RING_SIZE 2
  14543. @@ -26,23 +29,18 @@
  14544. /* The EPIC100 Rx and Tx buffer descriptors. */
  14545. struct epic_rx_desc {
  14546. - unsigned short status;
  14547. - unsigned short rxlength;
  14548. - unsigned long bufaddr;
  14549. - unsigned short buflength;
  14550. - unsigned short control;
  14551. - unsigned long next;
  14552. + unsigned long status;
  14553. + unsigned long bufaddr;
  14554. + unsigned long buflength;
  14555. + unsigned long next;
  14556. };
  14557. -
  14558. /* description of the tx descriptors control bits commonly used */
  14559. #define TD_STDFLAGS TD_LASTDESC
  14560. struct epic_tx_desc {
  14561. - unsigned short status;
  14562. - unsigned short txlength;
  14563. - unsigned long bufaddr;
  14564. - unsigned short buflength;
  14565. - unsigned short control;
  14566. + unsigned long status;
  14567. + unsigned long bufaddr;
  14568. + unsigned long buflength;
  14569. unsigned long next;
  14570. };
  14571. @@ -51,12 +49,15 @@
  14572. static void epic100_open(void);
  14573. static void epic100_init_ring(void);
  14574. -static void epic100_disable(struct nic *nic);
  14575. -static int epic100_poll(struct nic *nic);
  14576. +static void epic100_disable(struct dev *dev);
  14577. +static int epic100_poll(struct nic *nic, int retrieve);
  14578. static void epic100_transmit(struct nic *nic, const char *destaddr,
  14579. unsigned int type, unsigned int len, const char *data);
  14580. +#ifdef DEBUG_EEPROM
  14581. static int read_eeprom(int location);
  14582. +#endif
  14583. static int mii_read(int phy_id, int location);
  14584. +static void epic100_irq(struct nic *nic, irq_action_t action);
  14585. static int ioaddr;
  14586. @@ -69,6 +70,7 @@
  14587. static int mmctl ;
  14588. static int mmdata ;
  14589. static int lan0 ;
  14590. +static int mc0 ;
  14591. static int rxcon ;
  14592. static int txcon ;
  14593. static int prcdar ;
  14594. @@ -80,37 +82,27 @@
  14595. static unsigned short eeprom[64];
  14596. #endif
  14597. static signed char phys[4]; /* MII device addresses. */
  14598. -static struct epic_rx_desc rx_ring[RX_RING_SIZE];
  14599. -static struct epic_tx_desc tx_ring[TX_RING_SIZE];
  14600. -#ifdef USE_LOWMEM_BUFFER
  14601. -#define rx_packet ((char *)0x10000 - PKT_BUF_SZ * RX_RING_SIZE)
  14602. -#define tx_packet ((char *)0x10000 - PKT_BUF_SZ * RX_RING_SIZE - PKT_BUF_SZ * TX_RING_SIZE)
  14603. -#else
  14604. -static char rx_packet[PKT_BUF_SZ * RX_RING_SIZE];
  14605. -static char tx_packet[PKT_BUF_SZ * TX_RING_SIZE];
  14606. -#endif
  14607. +static struct epic_rx_desc rx_ring[RX_RING_SIZE]
  14608. + __attribute__ ((aligned(4)));
  14609. +static struct epic_tx_desc tx_ring[TX_RING_SIZE]
  14610. + __attribute__ ((aligned(4)));
  14611. +static unsigned char rx_packet[PKT_BUF_SZ * RX_RING_SIZE];
  14612. +static unsigned char tx_packet[PKT_BUF_SZ * TX_RING_SIZE];
  14613. /***********************************************************************/
  14614. /* Externally visible functions */
  14615. /***********************************************************************/
  14616. - static void
  14617. -epic100_reset(struct nic *nic)
  14618. -{
  14619. - /* Soft reset the chip. */
  14620. - outl(GC_SOFT_RESET, genctl);
  14621. -}
  14622. - struct nic*
  14623. -epic100_probe(struct nic *nic, unsigned short *probeaddrs)
  14624. + static int
  14625. +epic100_probe(struct dev *dev, struct pci_device *pci)
  14626. {
  14627. - unsigned short sum = 0;
  14628. - unsigned short value;
  14629. + struct nic *nic = (struct nic *)dev;
  14630. int i;
  14631. unsigned short* ap;
  14632. unsigned int phy, phy_idx;
  14633. - if (probeaddrs == 0 || probeaddrs[0] == 0)
  14634. + if (pci->ioaddr == 0)
  14635. return 0;
  14636. /* Ideally we would detect all network cards in slot order. That would
  14637. @@ -118,7 +110,9 @@
  14638. well with the current structure. So instead we detect just the
  14639. Epic cards in slot order. */
  14640. - ioaddr = probeaddrs[0] & ~3; /* Mask the bit that says "this is an io addr" */
  14641. + ioaddr = pci->ioaddr;
  14642. + nic->irqno = 0;
  14643. + nic->ioaddr = pci->ioaddr & ~3;
  14644. /* compute all used static epic100 registers address */
  14645. command = ioaddr + COMMAND; /* Control Register */
  14646. @@ -130,6 +124,7 @@
  14647. mmctl = ioaddr + MMCTL; /* MII Management Interface Control */
  14648. mmdata = ioaddr + MMDATA; /* MII Management Interface Data */
  14649. lan0 = ioaddr + LAN0; /* MAC address. (0x40-0x48) */
  14650. + mc0 = ioaddr + MC0; /* Multicast Control */
  14651. rxcon = ioaddr + RXCON; /* Receive Control */
  14652. txcon = ioaddr + TXCON; /* Transmit Control */
  14653. prcdar = ioaddr + PRCDAR; /* PCI Receive Current Descr Address */
  14654. @@ -160,11 +155,15 @@
  14655. }
  14656. #ifdef DEBUG_EEPROM
  14657. +{
  14658. + unsigned short sum = 0;
  14659. + unsigned short value;
  14660. for (i = 0; i < 64; i++) {
  14661. value = read_eeprom(i);
  14662. eeprom[i] = value;
  14663. sum += value;
  14664. }
  14665. +}
  14666. #if (EPIC_DEBUG > 1)
  14667. printf("EEPROM contents\n");
  14668. @@ -202,15 +201,26 @@
  14669. epic100_open();
  14670. - nic->reset = epic100_reset;
  14671. + dev->disable = epic100_disable;
  14672. nic->poll = epic100_poll;
  14673. nic->transmit = epic100_transmit;
  14674. - nic->disable = epic100_disable;
  14675. + nic->irq = epic100_irq;
  14676. - return nic;
  14677. + return 1;
  14678. }
  14679. - static void
  14680. +static void set_rx_mode(void)
  14681. +{
  14682. + unsigned char mc_filter[8];
  14683. + int i;
  14684. + memset(mc_filter, 0xff, sizeof(mc_filter));
  14685. + outl(0x0C, rxcon);
  14686. + for(i = 0; i < 4; i++)
  14687. + outw(((unsigned short *)mc_filter)[i], mc0 + i*4);
  14688. + return;
  14689. +}
  14690. +
  14691. + static void
  14692. epic100_open(void)
  14693. {
  14694. int mii_reg5;
  14695. @@ -237,11 +247,11 @@
  14696. outl(tmp, txcon);
  14697. /* Give adress of RX and TX ring to the chip */
  14698. - outl(virt_to_bus(&rx_ring), prcdar);
  14699. - outl(virt_to_bus(&tx_ring), ptcdar);
  14700. + outl(virt_to_le32desc(&rx_ring), prcdar);
  14701. + outl(virt_to_le32desc(&tx_ring), ptcdar);
  14702. /* Start the chip's Rx process: receive unicast and broadcast */
  14703. - outl(0x04, rxcon);
  14704. + set_rx_mode();
  14705. outl(CR_START_RX | CR_QUEUE_RX, command);
  14706. putchar('\n');
  14707. @@ -252,34 +262,30 @@
  14708. epic100_init_ring(void)
  14709. {
  14710. int i;
  14711. - char* p;
  14712. cur_rx = cur_tx = 0;
  14713. - p = &rx_packet[0];
  14714. for (i = 0; i < RX_RING_SIZE; i++) {
  14715. - rx_ring[i].status = RRING_OWN; /* Owned by Epic chip */
  14716. - rx_ring[i].buflength = PKT_BUF_SZ;
  14717. - rx_ring[i].bufaddr = virt_to_bus(p + (PKT_BUF_SZ * i));
  14718. - rx_ring[i].control = 0;
  14719. - rx_ring[i].next = virt_to_bus(&(rx_ring[i + 1]) );
  14720. + rx_ring[i].status = cpu_to_le32(RRING_OWN); /* Owned by Epic chip */
  14721. + rx_ring[i].buflength = cpu_to_le32(PKT_BUF_SZ);
  14722. + rx_ring[i].bufaddr = virt_to_bus(&rx_packet[i * PKT_BUF_SZ]);
  14723. + rx_ring[i].next = virt_to_le32desc(&rx_ring[i + 1]) ;
  14724. }
  14725. /* Mark the last entry as wrapping the ring. */
  14726. - rx_ring[i-1].next = virt_to_bus(&rx_ring[0]);
  14727. + rx_ring[i-1].next = virt_to_le32desc(&rx_ring[0]);
  14728. /*
  14729. *The Tx buffer descriptor is filled in as needed,
  14730. * but we do need to clear the ownership bit.
  14731. */
  14732. - p = &tx_packet[0];
  14733. for (i = 0; i < TX_RING_SIZE; i++) {
  14734. - tx_ring[i].status = 0; /* Owned by CPU */
  14735. - tx_ring[i].bufaddr = virt_to_bus(p + (PKT_BUF_SZ * i));
  14736. - tx_ring[i].control = TD_STDFLAGS;
  14737. - tx_ring[i].next = virt_to_bus(&(tx_ring[i + 1]) );
  14738. + tx_ring[i].status = 0x0000; /* Owned by CPU */
  14739. + tx_ring[i].buflength = 0x0000 | cpu_to_le32(TD_STDFLAGS << 16);
  14740. + tx_ring[i].bufaddr = virt_to_bus(&tx_packet[i * PKT_BUF_SZ]);
  14741. + tx_ring[i].next = virt_to_le32desc(&tx_ring[i + 1]);
  14742. }
  14743. - tx_ring[i-1].next = virt_to_bus(&tx_ring[0]);
  14744. + tx_ring[i-1].next = virt_to_le32desc(&tx_ring[0]);
  14745. }
  14746. /* function: epic100_transmit
  14747. @@ -296,7 +302,7 @@
  14748. unsigned int len, const char *data)
  14749. {
  14750. unsigned short nstype;
  14751. - char* txp;
  14752. + unsigned char *txp;
  14753. int entry;
  14754. /* Calculate the next Tx descriptor entry. */
  14755. @@ -310,7 +316,7 @@
  14756. return;
  14757. }
  14758. - txp = (char*)tx_ring[entry].bufaddr;
  14759. + txp = tx_packet + (entry * PKT_BUF_SZ);
  14760. memcpy(txp, destaddr, ETH_ALEN);
  14761. memcpy(txp + ETH_ALEN, nic->node_addr, ETH_ALEN);
  14762. @@ -319,26 +325,29 @@
  14763. memcpy(txp + ETH_HLEN, data, len);
  14764. len += ETH_HLEN;
  14765. -
  14766. + len &= 0x0FFF;
  14767. + while(len < ETH_ZLEN)
  14768. + txp[len++] = '\0';
  14769. /*
  14770. * Caution: the write order is important here,
  14771. * set the base address with the "ownership"
  14772. * bits last.
  14773. */
  14774. - tx_ring[entry].txlength = (len >= 60 ? len : 60);
  14775. - tx_ring[entry].buflength = len;
  14776. - tx_ring[entry].status = TRING_OWN; /* Pass ownership to the chip. */
  14777. +
  14778. + tx_ring[entry].buflength |= cpu_to_le32(len);
  14779. + tx_ring[entry].status = cpu_to_le32(len << 16) |
  14780. + cpu_to_le32(TRING_OWN); /* Pass ownership to the chip. */
  14781. cur_tx++;
  14782. /* Trigger an immediate transmit demand. */
  14783. - outl(CR_QUEUE_TX, command);
  14784. -
  14785. + outl(CR_QUEUE_TX, command);
  14786. +
  14787. load_timer2(10*TICKS_PER_MS); /* timeout 10 ms for transmit */
  14788. - while ((tx_ring[entry].status & TRING_OWN) && timer2_running())
  14789. + while ((le32_to_cpu(tx_ring[entry].status) & (TRING_OWN)) && timer2_running())
  14790. /* Wait */;
  14791. - if ((tx_ring[entry].status & TRING_OWN) != 0)
  14792. + if ((le32_to_cpu(tx_ring[entry].status) & TRING_OWN) != 0)
  14793. printf("Oops, transmitter timeout, status=%hX\n",
  14794. tx_ring[entry].status);
  14795. }
  14796. @@ -356,17 +365,19 @@
  14797. */
  14798. static int
  14799. -epic100_poll(struct nic *nic)
  14800. +epic100_poll(struct nic *nic, int retrieve)
  14801. {
  14802. int entry;
  14803. - int status;
  14804. int retcode;
  14805. -
  14806. + int status;
  14807. entry = cur_rx % RX_RING_SIZE;
  14808. - if ((status = rx_ring[entry].status & RRING_OWN) == RRING_OWN)
  14809. + if ((rx_ring[entry].status & cpu_to_le32(RRING_OWN)) == RRING_OWN)
  14810. return (0);
  14811. + if ( ! retrieve ) return 1;
  14812. +
  14813. + status = le32_to_cpu(rx_ring[entry].status);
  14814. /* We own the next entry, it's a new packet. Send it up. */
  14815. #if (EPIC_DEBUG > 4)
  14816. @@ -383,8 +394,8 @@
  14817. retcode = 0;
  14818. } else {
  14819. /* Omit the four octet CRC from the length. */
  14820. - nic->packetlen = rx_ring[entry].rxlength - 4;
  14821. - memcpy(nic->packet, (char*)rx_ring[entry].bufaddr, nic->packetlen);
  14822. + nic->packetlen = le32_to_cpu((rx_ring[entry].buflength))- 4;
  14823. + memcpy(nic->packet, &rx_packet[entry * PKT_BUF_SZ], nic->packetlen);
  14824. retcode = 1;
  14825. }
  14826. @@ -395,17 +406,30 @@
  14827. rx_ring[entry].status = RRING_OWN;
  14828. /* Restart Receiver */
  14829. - outl(CR_START_RX | CR_QUEUE_RX, command);
  14830. + outl(CR_START_RX | CR_QUEUE_RX, command);
  14831. return retcode;
  14832. }
  14833. static void
  14834. -epic100_disable(struct nic *nic)
  14835. +epic100_disable(struct dev *dev __unused)
  14836. {
  14837. + /* Soft reset the chip. */
  14838. + outl(GC_SOFT_RESET, genctl);
  14839. }
  14840. +static void epic100_irq(struct nic *nic __unused, irq_action_t action __unused)
  14841. +{
  14842. + switch ( action ) {
  14843. + case DISABLE :
  14844. + break;
  14845. + case ENABLE :
  14846. + break;
  14847. + case FORCE :
  14848. + break;
  14849. + }
  14850. +}
  14851. #ifdef DEBUG_EEPROM
  14852. /* Serial EEPROM section. */
  14853. @@ -479,3 +503,18 @@
  14854. break;
  14855. return inw(mmdata);
  14856. }
  14857. +
  14858. +
  14859. +static struct pci_id epic100_nics[] = {
  14860. +PCI_ROM(0x10b8, 0x0005, "epic100", "SMC EtherPowerII"), /* SMC 83c170 EPIC/100 */
  14861. +PCI_ROM(0x10b8, 0x0006, "smc-83c175", "SMC EPIC/C 83c175"),
  14862. +};
  14863. +
  14864. +struct pci_driver epic100_driver = {
  14865. + .type = NIC_DRIVER,
  14866. + .name = "EPIC100",
  14867. + .probe = epic100_probe,
  14868. + .ids = epic100_nics,
  14869. + .id_count = sizeof(epic100_nics)/sizeof(epic100_nics[0]),
  14870. + .class = 0,
  14871. +};
  14872. diff -Naur grub-0.97.orig/netboot/etherboot.h grub-0.97/netboot/etherboot.h
  14873. --- grub-0.97.orig/netboot/etherboot.h 2003-07-09 11:45:37.000000000 +0000
  14874. +++ grub-0.97/netboot/etherboot.h 2005-08-31 19:03:35.000000000 +0000
  14875. @@ -1,6 +1,6 @@
  14876. /*
  14877. * GRUB -- GRand Unified Bootloader
  14878. - * Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
  14879. + * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
  14880. *
  14881. * This program is free software; you can redistribute it and/or modify
  14882. * it under the terms of the GNU General Public License as published by
  14883. @@ -17,531 +17,45 @@
  14884. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14885. */
  14886. -/* RULE: You must define the macro ``GRUB'' when including this header
  14887. - file in GRUB code. */
  14888. -
  14889. -/* Based on "src/etherboot.h" in etherboot-5.0.5. */
  14890. -
  14891. -/**************************************************************************
  14892. -ETHERBOOT - BOOTP/TFTP Bootstrap Program
  14893. -
  14894. -Author: Martin Renters
  14895. - Date: Dec/93
  14896. -
  14897. -**************************************************************************/
  14898. -
  14899. -/* Include GRUB-specific macros and prototypes here. */
  14900. -#include <shared.h>
  14901. -
  14902. -/* FIXME: For now, enable the DHCP support. Perhaps I should segregate
  14903. - the DHCP support from the BOOTP support, and permit both to
  14904. - co-exist. */
  14905. -#undef NO_DHCP_SUPPORT
  14906. -
  14907. -/* In GRUB, the relocated address in Etherboot doesn't have any sense.
  14908. - Just define it as a bogus value. */
  14909. -#define RELOC 0
  14910. -
  14911. -/* FIXME: Should be an option. */
  14912. -#define BACKOFF_LIMIT 7
  14913. -
  14914. -#include <osdep.h>
  14915. -
  14916. -#define CTRL_C 3
  14917. -
  14918. -#ifndef MAX_TFTP_RETRIES
  14919. -# define MAX_TFTP_RETRIES 20
  14920. -#endif
  14921. -
  14922. -#ifndef MAX_BOOTP_RETRIES
  14923. -# define MAX_BOOTP_RETRIES 20
  14924. -#endif
  14925. -
  14926. -#define MAX_BOOTP_EXTLEN (ETH_FRAME_LEN - ETH_HLEN - \
  14927. - sizeof (struct bootp_t))
  14928. +/*
  14929. + * Transport layer to use Etherboot NIC drivers in GRUB.
  14930. + */
  14931. -#ifndef MAX_ARP_RETRIES
  14932. -# define MAX_ARP_RETRIES 20
  14933. -#endif
  14934. +#ifndef ETHERBOOT_H
  14935. +#define ETHERBOOT_H
  14936. -#ifndef MAX_RPC_RETRIES
  14937. -# define MAX_RPC_RETRIES 20
  14938. +#include "shared.h"
  14939. +#include "osdep.h"
  14940. +#include "if_ether.h"
  14941. +#include "in.h"
  14942. +
  14943. +/* Link configuration time in tenths of a second */
  14944. +#ifndef VALID_LINK_TIMEOUT
  14945. +#define VALID_LINK_TIMEOUT 100 /* 10.0 seconds */
  14946. #endif
  14947. -#define TICKS_PER_SEC 18
  14948. -
  14949. -/* Inter-packet retry in ticks */
  14950. -#define TIMEOUT (10 * TICKS_PER_SEC)
  14951. -
  14952. -/* These settings have sense only if compiled with -DCONGESTED */
  14953. -/* total retransmission timeout in ticks */
  14954. -#define TFTP_TIMEOUT (30 * TICKS_PER_SEC)
  14955. -/* packet retransmission timeout in ticks */
  14956. -#define TFTP_REXMT (3 * TICKS_PER_SEC)
  14957. -
  14958. #ifndef NULL
  14959. -# define NULL ((void *) 0)
  14960. +#define NULL ((void *)0)
  14961. #endif
  14962. -/*
  14963. - I'm moving towards the defined names in linux/if_ether.h for clarity.
  14964. - The confusion between 60/64 and 1514/1518 arose because the NS8390
  14965. - counts the 4 byte frame checksum in the incoming packet, but not
  14966. - in the outgoing packet. 60/1514 are the correct numbers for most
  14967. - if not all of the other NIC controllers. I will be retiring the
  14968. - 64/1518 defines in the lead-up to 5.0.
  14969. -*/
  14970. -
  14971. -#define ETH_ALEN 6 /* Size of Ethernet address */
  14972. -#define ETH_HLEN 14 /* Size of ethernet header */
  14973. -#define ETH_ZLEN 60 /* Minimum packet */
  14974. -/*#define ETH_MIN_PACKET 64*/
  14975. -#define ETH_FRAME_LEN 1514 /* Maximum packet */
  14976. -/*#define ETH_MAX_PACKET 1518*/
  14977. -/* Because some DHCP/BOOTP servers don't treat the maximum length the same
  14978. - as Etherboot, subtract the size of an IP header and that of an UDP
  14979. - header. */
  14980. -#define ETH_MAX_MTU (ETH_FRAME_LEN - ETH_HLEN \
  14981. - - sizeof (struct iphdr) \
  14982. - - sizeof (struct udphdr))
  14983. -
  14984. -#define ARP_CLIENT 0
  14985. -#define ARP_SERVER 1
  14986. -#define ARP_GATEWAY 2
  14987. -#define ARP_ROOTSERVER 3
  14988. -#define ARP_SWAPSERVER 4
  14989. -#define MAX_ARP ARP_SWAPSERVER+1
  14990. -
  14991. -#define RARP_REQUEST 3
  14992. -#define RARP_REPLY 4
  14993. -
  14994. -#define IP 0x0800
  14995. -#define ARP 0x0806
  14996. -#define RARP 0x8035
  14997. -
  14998. -#define BOOTP_SERVER 67
  14999. -#define BOOTP_CLIENT 68
  15000. -#define TFTP_PORT 69
  15001. -#define SUNRPC_PORT 111
  15002. -
  15003. -#define IP_UDP 17
  15004. -/* Same after going through htonl */
  15005. -#define IP_BROADCAST 0xFFFFFFFF
  15006. -
  15007. -#define ARP_REQUEST 1
  15008. -#define ARP_REPLY 2
  15009. -
  15010. -#define BOOTP_REQUEST 1
  15011. -#define BOOTP_REPLY 2
  15012. -
  15013. -#define TAG_LEN(p) (*((p) + 1))
  15014. -#define RFC1533_COOKIE 99, 130, 83, 99
  15015. -#define RFC1533_PAD 0
  15016. -#define RFC1533_NETMASK 1
  15017. -#define RFC1533_TIMEOFFSET 2
  15018. -#define RFC1533_GATEWAY 3
  15019. -#define RFC1533_TIMESERVER 4
  15020. -#define RFC1533_IEN116NS 5
  15021. -#define RFC1533_DNS 6
  15022. -#define RFC1533_LOGSERVER 7
  15023. -#define RFC1533_COOKIESERVER 8
  15024. -#define RFC1533_LPRSERVER 9
  15025. -#define RFC1533_IMPRESSSERVER 10
  15026. -#define RFC1533_RESOURCESERVER 11
  15027. -#define RFC1533_HOSTNAME 12
  15028. -#define RFC1533_BOOTFILESIZE 13
  15029. -#define RFC1533_MERITDUMPFILE 14
  15030. -#define RFC1533_DOMAINNAME 15
  15031. -#define RFC1533_SWAPSERVER 16
  15032. -#define RFC1533_ROOTPATH 17
  15033. -#define RFC1533_EXTENSIONPATH 18
  15034. -#define RFC1533_IPFORWARDING 19
  15035. -#define RFC1533_IPSOURCEROUTING 20
  15036. -#define RFC1533_IPPOLICYFILTER 21
  15037. -#define RFC1533_IPMAXREASSEMBLY 22
  15038. -#define RFC1533_IPTTL 23
  15039. -#define RFC1533_IPMTU 24
  15040. -#define RFC1533_IPMTUPLATEAU 25
  15041. -#define RFC1533_INTMTU 26
  15042. -#define RFC1533_INTLOCALSUBNETS 27
  15043. -#define RFC1533_INTBROADCAST 28
  15044. -#define RFC1533_INTICMPDISCOVER 29
  15045. -#define RFC1533_INTICMPRESPOND 30
  15046. -#define RFC1533_INTROUTEDISCOVER 31
  15047. -#define RFC1533_INTROUTESOLICIT 32
  15048. -#define RFC1533_INTSTATICROUTES 33
  15049. -#define RFC1533_LLTRAILERENCAP 34
  15050. -#define RFC1533_LLARPCACHETMO 35
  15051. -#define RFC1533_LLETHERNETENCAP 36
  15052. -#define RFC1533_TCPTTL 37
  15053. -#define RFC1533_TCPKEEPALIVETMO 38
  15054. -#define RFC1533_TCPKEEPALIVEGB 39
  15055. -#define RFC1533_NISDOMAIN 40
  15056. -#define RFC1533_NISSERVER 41
  15057. -#define RFC1533_NTPSERVER 42
  15058. -#define RFC1533_VENDOR 43
  15059. -#define RFC1533_NBNS 44
  15060. -#define RFC1533_NBDD 45
  15061. -#define RFC1533_NBNT 46
  15062. -#define RFC1533_NBSCOPE 47
  15063. -#define RFC1533_XFS 48
  15064. -#define RFC1533_XDM 49
  15065. -#ifndef NO_DHCP_SUPPORT
  15066. -#define RFC2132_REQ_ADDR 50
  15067. -#define RFC2132_MSG_TYPE 53
  15068. -#define RFC2132_SRV_ID 54
  15069. -#define RFC2132_PARAM_LIST 55
  15070. -#define RFC2132_MAX_SIZE 57
  15071. -#define RFC2132_VENDOR_CLASS_ID 60
  15072. -
  15073. -#define DHCPDISCOVER 1
  15074. -#define DHCPOFFER 2
  15075. -#define DHCPREQUEST 3
  15076. -#define DHCPACK 5
  15077. -#endif /* NO_DHCP_SUPPORT */
  15078. -
  15079. -#define RFC1533_VENDOR_MAJOR 0
  15080. -#define RFC1533_VENDOR_MINOR 0
  15081. -
  15082. -#define RFC1533_VENDOR_MAGIC 128
  15083. -#define RFC1533_VENDOR_ADDPARM 129
  15084. -#define RFC1533_VENDOR_MNUOPTS 160
  15085. -#define RFC1533_VENDOR_SELECTION 176
  15086. -#define RFC1533_VENDOR_MOTD 184
  15087. -#define RFC1533_VENDOR_NUMOFMOTD 8
  15088. -#define RFC1533_VENDOR_IMG 192
  15089. -#define RFC1533_VENDOR_NUMOFIMG 16
  15090. -
  15091. -#define RFC1533_VENDOR_CONFIGFILE 150
  15092. -
  15093. -#define RFC1533_END 255
  15094. -
  15095. -#define BOOTP_VENDOR_LEN 64
  15096. -#ifndef NO_DHCP_SUPPORT
  15097. -#define DHCP_OPT_LEN 312
  15098. -#endif /* NO_DHCP_SUPPORT */
  15099. -
  15100. -#define TFTP_DEFAULTSIZE_PACKET 512
  15101. -#define TFTP_MAX_PACKET 1432 /* 512 */
  15102. -
  15103. -#define TFTP_RRQ 1
  15104. -#define TFTP_WRQ 2
  15105. -#define TFTP_DATA 3
  15106. -#define TFTP_ACK 4
  15107. -#define TFTP_ERROR 5
  15108. -#define TFTP_OACK 6
  15109. -
  15110. -#define TFTP_CODE_EOF 1
  15111. -#define TFTP_CODE_MORE 2
  15112. -#define TFTP_CODE_ERROR 3
  15113. -#define TFTP_CODE_BOOT 4
  15114. -#define TFTP_CODE_CFG 5
  15115. -
  15116. -#define AWAIT_ARP 0
  15117. -#define AWAIT_BOOTP 1
  15118. -#define AWAIT_TFTP 2
  15119. -#define AWAIT_RARP 3
  15120. -#define AWAIT_RPC 4
  15121. -#define AWAIT_QDRAIN 5 /* drain queue, process ARP requests */
  15122. -
  15123. -typedef struct
  15124. -{
  15125. - unsigned long s_addr;
  15126. -}
  15127. -in_addr;
  15128. -
  15129. -struct arptable_t
  15130. -{
  15131. - in_addr ipaddr;
  15132. - unsigned char node[6];
  15133. -};
  15134. -
  15135. -/*
  15136. - * A pity sipaddr and tipaddr are not longword aligned or we could use
  15137. - * in_addr. No, I don't want to use #pragma packed.
  15138. - */
  15139. -struct arprequest
  15140. -{
  15141. - unsigned short hwtype;
  15142. - unsigned short protocol;
  15143. - char hwlen;
  15144. - char protolen;
  15145. - unsigned short opcode;
  15146. - char shwaddr[6];
  15147. - char sipaddr[4];
  15148. - char thwaddr[6];
  15149. - char tipaddr[4];
  15150. -};
  15151. -
  15152. -struct iphdr
  15153. -{
  15154. - char verhdrlen;
  15155. - char service;
  15156. - unsigned short len;
  15157. - unsigned short ident;
  15158. - unsigned short frags;
  15159. - char ttl;
  15160. - char protocol;
  15161. - unsigned short chksum;
  15162. - in_addr src;
  15163. - in_addr dest;
  15164. -};
  15165. -
  15166. -struct udphdr
  15167. -{
  15168. - unsigned short src;
  15169. - unsigned short dest;
  15170. - unsigned short len;
  15171. - unsigned short chksum;
  15172. -};
  15173. -
  15174. -/* Format of a bootp packet. */
  15175. -struct bootp_t
  15176. -{
  15177. - char bp_op;
  15178. - char bp_htype;
  15179. - char bp_hlen;
  15180. - char bp_hops;
  15181. - unsigned long bp_xid;
  15182. - unsigned short bp_secs;
  15183. - unsigned short unused;
  15184. - in_addr bp_ciaddr;
  15185. - in_addr bp_yiaddr;
  15186. - in_addr bp_siaddr;
  15187. - in_addr bp_giaddr;
  15188. - char bp_hwaddr[16];
  15189. - char bp_sname[64];
  15190. - char bp_file[128];
  15191. -#ifdef NO_DHCP_SUPPORT
  15192. - char bp_vend[BOOTP_VENDOR_LEN];
  15193. -#else
  15194. - char bp_vend[DHCP_OPT_LEN];
  15195. -#endif /* NO_DHCP_SUPPORT */
  15196. -};
  15197. -
  15198. -/* Format of a bootp IP packet. */
  15199. -struct bootpip_t
  15200. -{
  15201. - struct iphdr ip;
  15202. - struct udphdr udp;
  15203. - struct bootp_t bp;
  15204. -};
  15205. -
  15206. -/* Format of bootp packet with extensions. */
  15207. -struct bootpd_t
  15208. -{
  15209. - struct bootp_t bootp_reply;
  15210. - unsigned char bootp_extension[MAX_BOOTP_EXTLEN];
  15211. -};
  15212. -
  15213. -struct tftp_t
  15214. -{
  15215. - struct iphdr ip;
  15216. - struct udphdr udp;
  15217. - unsigned short opcode;
  15218. - union
  15219. - {
  15220. - char rrq[TFTP_DEFAULTSIZE_PACKET];
  15221. -
  15222. - struct
  15223. - {
  15224. - unsigned short block;
  15225. - char download[TFTP_MAX_PACKET];
  15226. - }
  15227. - data;
  15228. -
  15229. - struct
  15230. - {
  15231. - unsigned short block;
  15232. - }
  15233. - ack;
  15234. -
  15235. - struct
  15236. - {
  15237. - unsigned short errcode;
  15238. - char errmsg[TFTP_DEFAULTSIZE_PACKET];
  15239. - }
  15240. - err;
  15241. -
  15242. - struct
  15243. - {
  15244. - char data[TFTP_DEFAULTSIZE_PACKET+2];
  15245. - }
  15246. - oack;
  15247. - }
  15248. - u;
  15249. -};
  15250. -
  15251. -/* Define a smaller tftp packet solely for making requests to conserve stack
  15252. - 512 bytes should be enough. */
  15253. -struct tftpreq_t
  15254. -{
  15255. - struct iphdr ip;
  15256. - struct udphdr udp;
  15257. - unsigned short opcode;
  15258. - union
  15259. - {
  15260. - char rrq[512];
  15261. -
  15262. - struct
  15263. - {
  15264. - unsigned short block;
  15265. - }
  15266. - ack;
  15267. -
  15268. - struct
  15269. - {
  15270. - unsigned short errcode;
  15271. - char errmsg[512-2];
  15272. - }
  15273. - err;
  15274. - }
  15275. - u;
  15276. -};
  15277. -
  15278. -#define TFTP_MIN_PACKET (sizeof(struct iphdr) + sizeof(struct udphdr) + 4)
  15279. -
  15280. -struct rpc_t
  15281. -{
  15282. - struct iphdr ip;
  15283. - struct udphdr udp;
  15284. - union
  15285. - {
  15286. - char data[300]; /* longest RPC call must fit!!!! */
  15287. -
  15288. - struct
  15289. - {
  15290. - long id;
  15291. - long type;
  15292. - long rpcvers;
  15293. - long prog;
  15294. - long vers;
  15295. - long proc;
  15296. - long data[1];
  15297. - }
  15298. - call;
  15299. -
  15300. - struct
  15301. - {
  15302. - long id;
  15303. - long type;
  15304. - long rstatus;
  15305. - long verifier;
  15306. - long v2;
  15307. - long astatus;
  15308. - long data[1];
  15309. - }
  15310. - reply;
  15311. - }
  15312. - u;
  15313. -};
  15314. -
  15315. -#define PROG_PORTMAP 100000
  15316. -#define PROG_NFS 100003
  15317. -#define PROG_MOUNT 100005
  15318. -
  15319. -#define MSG_CALL 0
  15320. -#define MSG_REPLY 1
  15321. -
  15322. -#define PORTMAP_GETPORT 3
  15323. -
  15324. -#define MOUNT_ADDENTRY 1
  15325. -#define MOUNT_UMOUNTALL 4
  15326. -
  15327. -#define NFS_LOOKUP 4
  15328. -#define NFS_READ 6
  15329. -
  15330. -#define NFS_FHSIZE 32
  15331. -
  15332. -#define NFSERR_PERM 1
  15333. -#define NFSERR_NOENT 2
  15334. -#define NFSERR_ACCES 13
  15335. -
  15336. -/* Block size used for NFS read accesses. A RPC reply packet (including all
  15337. - * headers) must fit within a single Ethernet frame to avoid fragmentation.
  15338. - * Chosen to be a power of two, as most NFS servers are optimized for this. */
  15339. -#define NFS_READ_SIZE 1024
  15340. -
  15341. -#define FLOPPY_BOOT_LOCATION 0x7c00
  15342. -/* Must match offsets in loader.S */
  15343. -#define ROM_SEGMENT 0x1fa
  15344. -#define ROM_LENGTH 0x1fc
  15345. -
  15346. -#define ROM_INFO_LOCATION (FLOPPY_BOOT_LOCATION + ROM_SEGMENT)
  15347. -/* at end of floppy boot block */
  15348. -
  15349. -struct rom_info
  15350. -{
  15351. - unsigned short rom_segment;
  15352. - unsigned short rom_length;
  15353. -};
  15354. -
  15355. -static inline int
  15356. -rom_address_ok (struct rom_info *rom, int assigned_rom_segment)
  15357. -{
  15358. - return (assigned_rom_segment < 0xC000
  15359. - || assigned_rom_segment == rom->rom_segment);
  15360. -}
  15361. -
  15362. -/* Define a type for passing info to a loaded program. */
  15363. -struct ebinfo
  15364. -{
  15365. - unsigned char major, minor; /* Version */
  15366. - unsigned short flags; /* Bit flags */
  15367. -};
  15368. -
  15369. -/***************************************************************************
  15370. -External prototypes
  15371. -***************************************************************************/
  15372. -/* main.c */
  15373. -extern void print_network_configuration (void);
  15374. -extern int ifconfig (char *ip, char *sm, char *gw, char *svr);
  15375. -extern int udp_transmit (unsigned long destip, unsigned int srcsock,
  15376. - unsigned int destsock, int len, const void *buf);
  15377. -extern int await_reply (int type, int ival, void *ptr, int timeout);
  15378. -extern int decode_rfc1533 (unsigned char *, int, int, int);
  15379. -extern long rfc2131_sleep_interval (int base, int exp);
  15380. -extern void cleanup (void);
  15381. -extern int rarp (void);
  15382. -extern int bootp (void);
  15383. -extern void cleanup_net (void);
  15384. -
  15385. -/* config.c */
  15386. -extern void print_config (void);
  15387. -extern void eth_reset (void);
  15388. -extern int eth_probe (void);
  15389. -extern int eth_poll (void);
  15390. -extern void eth_transmit (const char *d, unsigned int t,
  15391. - unsigned int s, const void *p);
  15392. -extern void eth_disable (void);
  15393. -
  15394. -/* misc.c */
  15395. -extern void twiddle (void);
  15396. -extern void sleep (int secs);
  15397. -extern int getdec (char **s);
  15398. -extern void etherboot_printf (const char *, ...);
  15399. -extern int etherboot_sprintf (char *, const char *, ...);
  15400. -extern int inet_aton (char *p, in_addr *i);
  15401. -
  15402. -/***************************************************************************
  15403. -External variables
  15404. -***************************************************************************/
  15405. -/* main.c */
  15406. -extern int ip_abort;
  15407. -extern int network_ready;
  15408. -extern struct rom_info rom;
  15409. -extern struct arptable_t arptable[MAX_ARP];
  15410. -extern struct bootpd_t bootp_data;
  15411. -#define BOOTP_DATA_ADDR (&bootp_data)
  15412. -extern unsigned char *end_of_rfc1533;
  15413. -/* config.c */
  15414. -extern struct nic nic;
  15415. +#define gateA20_set() gateA20(1)
  15416. +#define gateA20_unset() gateA20(0)
  15417. +#define EBDEBUG 0
  15418. +/* The 'rom_info' maybe arch depended. It must be moved to some other
  15419. + * place */
  15420. +struct rom_info {
  15421. + unsigned short rom_segment;
  15422. + unsigned short rom_length;
  15423. +};
  15424. +
  15425. +extern void poll_interruptions P((void));
  15426. +
  15427. +/* For UNDI drivers */
  15428. +extern void fake_irq ( uint8_t irq );
  15429. +extern void _trivial_irq_handler_start;
  15430. +extern uint32_t get_free_base_memory ( void );
  15431. +extern void forget_base_memory ( void*, size_t );
  15432. +extern void free_unused_base_memory ( void );
  15433. -/* Local hack - define some macros to use etherboot source files "as is". */
  15434. -#ifndef GRUB
  15435. -# undef printf
  15436. -# define printf etherboot_printf
  15437. -# undef sprintf
  15438. -# define sprintf etherboot_sprintf
  15439. -#endif /* GRUB */
  15440. +#endif /* ETHERBOOT_H */
  15441. diff -Naur grub-0.97.orig/netboot/fa311.c grub-0.97/netboot/fa311.c
  15442. --- grub-0.97.orig/netboot/fa311.c 2003-07-09 11:45:37.000000000 +0000
  15443. +++ grub-0.97/netboot/fa311.c 1970-01-01 00:00:00.000000000 +0000
  15444. @@ -1,421 +0,0 @@
  15445. -/*
  15446. - Driver for the National Semiconductor DP83810 Ethernet controller.
  15447. -
  15448. - Portions Copyright (C) 2001 Inprimis Technologies, Inc.
  15449. - http://www.inprimis.com/
  15450. -
  15451. - This driver is based (heavily) on the Linux driver for this chip
  15452. - which is copyright 1999-2001 by Donald Becker.
  15453. -
  15454. - This software has no warranties expressed or implied for any
  15455. - purpose.
  15456. -
  15457. - This software may be used and distributed according to the terms of
  15458. - the GNU General Public License (GPL), incorporated herein by reference.
  15459. - Drivers based on or derived from this code fall under the GPL and must
  15460. - retain the authorship, copyright and license notice. This file is not
  15461. - a complete program and may only be used when the entire operating
  15462. - system is licensed under the GPL. License for under other terms may be
  15463. - available. Contact the original author for details.
  15464. -
  15465. - The original author may be reached as becker@scyld.com, or at
  15466. - Scyld Computing Corporation
  15467. - 410 Severn Ave., Suite 210
  15468. - Annapolis MD 21403
  15469. -*/
  15470. -
  15471. -
  15472. -typedef unsigned char u8;
  15473. -typedef signed char s8;
  15474. -typedef unsigned short u16;
  15475. -typedef signed short s16;
  15476. -typedef unsigned int u32;
  15477. -typedef signed int s32;
  15478. -
  15479. -#include "etherboot.h"
  15480. -#include "nic.h"
  15481. -#include "pci.h"
  15482. -
  15483. -#undef virt_to_bus
  15484. -#define virt_to_bus(x) ((unsigned long)x)
  15485. -#define cpu_to_le32(val) (val)
  15486. -#define le32_to_cpu(val) (val)
  15487. -#define virt_to_le32desc(addr) cpu_to_le32(virt_to_bus(addr))
  15488. -#define le32desc_to_virt(addr) bus_to_virt(le32_to_cpu(addr))
  15489. -
  15490. -#define TX_RING_SIZE 1
  15491. -#define RX_RING_SIZE 4
  15492. -#define TIME_OUT 1000000
  15493. -#define PKT_BUF_SZ 1536
  15494. -
  15495. -/* Offsets to the device registers. */
  15496. -enum register_offsets {
  15497. - ChipCmd=0x00, ChipConfig=0x04, EECtrl=0x08, PCIBusCfg=0x0C,
  15498. - IntrStatus=0x10, IntrMask=0x14, IntrEnable=0x18,
  15499. - TxRingPtr=0x20, TxConfig=0x24,
  15500. - RxRingPtr=0x30, RxConfig=0x34,
  15501. - WOLCmd=0x40, PauseCmd=0x44, RxFilterAddr=0x48, RxFilterData=0x4C,
  15502. - BootRomAddr=0x50, BootRomData=0x54, StatsCtrl=0x5C, StatsData=0x60,
  15503. - RxPktErrs=0x60, RxMissed=0x68, RxCRCErrs=0x64,
  15504. -};
  15505. -
  15506. -/* Bit in ChipCmd. */
  15507. -enum ChipCmdBits {
  15508. - ChipReset=0x100, RxReset=0x20, TxReset=0x10, RxOff=0x08, RxOn=0x04,
  15509. - TxOff=0x02, TxOn=0x01,
  15510. -};
  15511. -
  15512. -/* Bits in the interrupt status/mask registers. */
  15513. -enum intr_status_bits {
  15514. - IntrRxDone=0x0001, IntrRxIntr=0x0002, IntrRxErr=0x0004, IntrRxEarly=0x0008,
  15515. - IntrRxIdle=0x0010, IntrRxOverrun=0x0020,
  15516. - IntrTxDone=0x0040, IntrTxIntr=0x0080, IntrTxErr=0x0100,
  15517. - IntrTxIdle=0x0200, IntrTxUnderrun=0x0400,
  15518. - StatsMax=0x0800, LinkChange=0x4000, WOLPkt=0x2000,
  15519. - RxResetDone=0x1000000, TxResetDone=0x2000000,
  15520. - IntrPCIErr=0x00f00000, IntrNormalSummary=0x0251, IntrAbnormalSummary=0xED20,
  15521. -};
  15522. -
  15523. -/* Bits in the RxMode register. */
  15524. -enum rx_mode_bits {
  15525. - AcceptErr=0x20, AcceptRunt=0x10, AcceptBroadcast=0xC0000000,
  15526. - AcceptMulticast=0x00200000, AcceptAllMulticast=0x20000000,
  15527. - AcceptAllPhys=0x10000000, AcceptMyPhys=0x08000000,
  15528. -};
  15529. -
  15530. -/* Bits in network_desc.status */
  15531. -enum desc_status_bits {
  15532. - DescOwn=0x80000000, DescMore=0x40000000, DescIntr=0x20000000,
  15533. - DescNoCRC=0x10000000,
  15534. - DescPktOK=0x08000000, RxTooLong=0x00400000,
  15535. -};
  15536. -
  15537. -/* The Rx and Tx buffer descriptors. */
  15538. -struct netdev_desc {
  15539. - u32 next_desc;
  15540. - s32 cmd_status;
  15541. - u32 addr;
  15542. -};
  15543. -
  15544. -static struct FA311_DEV {
  15545. - unsigned int ioaddr;
  15546. - unsigned short vendor;
  15547. - unsigned short device;
  15548. - unsigned int cur_rx;
  15549. - unsigned int cur_tx;
  15550. - unsigned int rx_buf_sz;
  15551. - volatile struct netdev_desc *rx_head_desc;
  15552. - volatile struct netdev_desc rx_ring[RX_RING_SIZE] __attribute__ ((aligned (4)));
  15553. - volatile struct netdev_desc tx_ring[TX_RING_SIZE] __attribute__ ((aligned (4)));
  15554. -} fa311_dev;
  15555. -
  15556. -static int eeprom_read(long ioaddr, int location);
  15557. -static void init_ring(struct FA311_DEV *dev);
  15558. -static void fa311_reset(struct nic *nic);
  15559. -static int fa311_poll(struct nic *nic);
  15560. -static void fa311_transmit(struct nic *nic, const char *d, unsigned int t, unsigned int s, const char *p);
  15561. -static void fa311_disable(struct nic *nic);
  15562. -
  15563. -static char rx_packet[PKT_BUF_SZ * RX_RING_SIZE] __attribute__ ((aligned (4)));
  15564. -static char tx_packet[PKT_BUF_SZ * TX_RING_SIZE] __attribute__ ((aligned (4)));
  15565. -
  15566. -struct nic * fa311_probe(struct nic *nic, unsigned short *io_addrs, struct pci_device *pci)
  15567. -{
  15568. -int prev_eedata;
  15569. -int i;
  15570. -int duplex;
  15571. -int tx_config;
  15572. -int rx_config;
  15573. -unsigned char macaddr[6];
  15574. -unsigned char mactest;
  15575. -unsigned char pci_bus = 0;
  15576. -struct FA311_DEV* dev = &fa311_dev;
  15577. -
  15578. - if (io_addrs == 0 || *io_addrs == 0)
  15579. - return (0);
  15580. - memset(dev, 0, sizeof(*dev));
  15581. - dev->vendor = pci->vendor;
  15582. - dev->device = pci->dev_id;
  15583. - dev->ioaddr = pci->membase;
  15584. -
  15585. - /* Work around the dropped serial bit. */
  15586. - prev_eedata = eeprom_read(dev->ioaddr, 6);
  15587. - for (i = 0; i < 3; i++) {
  15588. - int eedata = eeprom_read(dev->ioaddr, i + 7);
  15589. - macaddr[i*2] = (eedata << 1) + (prev_eedata >> 15);
  15590. - macaddr[i*2+1] = eedata >> 7;
  15591. - prev_eedata = eedata;
  15592. - }
  15593. - mactest = 0;
  15594. - for (i = 0; i < 6; i++)
  15595. - mactest |= macaddr[i];
  15596. - if (mactest == 0)
  15597. - return (0);
  15598. - for (i = 0; i < 6; i++)
  15599. - nic->node_addr[i] = macaddr[i];
  15600. - printf("%! ", nic->node_addr);
  15601. -
  15602. - adjust_pci_device(pci);
  15603. -
  15604. - fa311_reset(nic);
  15605. -
  15606. - nic->reset = fa311_reset;
  15607. - nic->disable = fa311_disable;
  15608. - nic->poll = fa311_poll;
  15609. - nic->transmit = fa311_transmit;
  15610. -
  15611. - init_ring(dev);
  15612. -
  15613. - writel(virt_to_bus(dev->rx_ring), dev->ioaddr + RxRingPtr);
  15614. - writel(virt_to_bus(dev->tx_ring), dev->ioaddr + TxRingPtr);
  15615. -
  15616. - for (i = 0; i < 6; i += 2)
  15617. - {
  15618. - writel(i, dev->ioaddr + RxFilterAddr);
  15619. - writew(macaddr[i] + (macaddr[i+1] << 8),
  15620. - dev->ioaddr + RxFilterData);
  15621. - }
  15622. -
  15623. - /* Initialize other registers. */
  15624. - /* Configure for standard, in-spec Ethernet. */
  15625. - if (readl(dev->ioaddr + ChipConfig) & 0x20000000)
  15626. - { /* Full duplex */
  15627. - tx_config = 0xD0801002;
  15628. - rx_config = 0x10000020;
  15629. - }
  15630. - else
  15631. - {
  15632. - tx_config = 0x10801002;
  15633. - rx_config = 0x0020;
  15634. - }
  15635. - writel(tx_config, dev->ioaddr + TxConfig);
  15636. - writel(rx_config, dev->ioaddr + RxConfig);
  15637. -
  15638. - duplex = readl(dev->ioaddr + ChipConfig) & 0x20000000 ? 1 : 0;
  15639. - if (duplex) {
  15640. - rx_config |= 0x10000000;
  15641. - tx_config |= 0xC0000000;
  15642. - } else {
  15643. - rx_config &= ~0x10000000;
  15644. - tx_config &= ~0xC0000000;
  15645. - }
  15646. - writew(tx_config, dev->ioaddr + TxConfig);
  15647. - writew(rx_config, dev->ioaddr + RxConfig);
  15648. -
  15649. - writel(AcceptBroadcast | AcceptAllMulticast | AcceptMyPhys,
  15650. - dev->ioaddr + RxFilterAddr);
  15651. -
  15652. - writel(RxOn | TxOn, dev->ioaddr + ChipCmd);
  15653. - writel(4, dev->ioaddr + StatsCtrl); /* Clear Stats */
  15654. - return nic;
  15655. -
  15656. -}
  15657. -
  15658. -static void fa311_reset(struct nic *nic)
  15659. -{
  15660. -u32 chip_config;
  15661. -struct FA311_DEV* dev = &fa311_dev;
  15662. -
  15663. - /* Reset the chip to erase previous misconfiguration. */
  15664. - outl(ChipReset, dev->ioaddr + ChipCmd);
  15665. -
  15666. - if ((readl(dev->ioaddr + ChipConfig) & 0xe000) != 0xe000)
  15667. - {
  15668. - chip_config = readl(dev->ioaddr + ChipConfig);
  15669. - }
  15670. -}
  15671. -
  15672. -static int fa311_poll(struct nic *nic)
  15673. -{
  15674. -s32 desc_status;
  15675. -int to;
  15676. -int entry;
  15677. -int retcode;
  15678. -struct FA311_DEV* dev = &fa311_dev;
  15679. -
  15680. - retcode = 0;
  15681. - entry = dev->cur_rx;
  15682. - to = TIME_OUT;
  15683. - while (to != 0)
  15684. - {
  15685. - desc_status = dev->rx_ring[entry].cmd_status;
  15686. - if ((desc_status & DescOwn) != 0)
  15687. - break;
  15688. - else
  15689. - --to;
  15690. - }
  15691. - if (to != 0)
  15692. - {
  15693. - readl(dev->ioaddr + IntrStatus); /* clear interrrupt bits */
  15694. - /* driver owns the next entry it's a new packet. Send it up. */
  15695. - if ((desc_status & (DescMore|DescPktOK|RxTooLong)) == DescPktOK)
  15696. - {
  15697. - nic->packetlen = (desc_status & 0x0fff) - 4; /* Omit CRC size. */
  15698. - memcpy(nic->packet, (char*)(dev->rx_ring[entry].addr), nic->packetlen);
  15699. - retcode = 1;
  15700. - }
  15701. - /* Give the descriptor back to the chip */
  15702. - dev->rx_ring[entry].cmd_status = cpu_to_le32(dev->rx_buf_sz);
  15703. - dev->cur_rx++;
  15704. - if (dev->cur_rx >= RX_RING_SIZE)
  15705. - dev->cur_rx = 0;
  15706. - dev->rx_head_desc = &dev->rx_ring[dev->cur_rx];
  15707. - }
  15708. - /* Restart Rx engine if stopped. */
  15709. - writel(RxOn, dev->ioaddr + ChipCmd);
  15710. - return retcode;
  15711. -}
  15712. -
  15713. -static void fa311_transmit(struct nic *nic, const char *destaddr, unsigned int type, unsigned int len, const char *data)
  15714. -{
  15715. -unsigned short nstype;
  15716. -s32 desc_status;
  15717. -int to;
  15718. -int entry;
  15719. -char* txp;
  15720. -unsigned char* s;
  15721. -struct FA311_DEV* dev = &fa311_dev;
  15722. -
  15723. - /* Calculate the next Tx descriptor entry. */
  15724. - entry = dev->cur_tx;
  15725. - txp = (char*)(dev->tx_ring[entry].addr);
  15726. -
  15727. - memcpy(txp, destaddr, ETH_ALEN);
  15728. - memcpy(txp + ETH_ALEN, nic->node_addr, ETH_ALEN);
  15729. - nstype = htons(type);
  15730. - memcpy(txp + 12, (char*)&nstype, 2);
  15731. - memcpy(txp + ETH_HLEN, data, len);
  15732. - len += ETH_HLEN;
  15733. - /* pad frame */
  15734. - if (len < ETH_ZLEN)
  15735. - {
  15736. - s = (unsigned char*)(txp+len);
  15737. - while (s < (unsigned char*)(txp+ETH_ZLEN))
  15738. - *s++ = 0;
  15739. - len = ETH_ZLEN;
  15740. - }
  15741. - dev->tx_ring[entry].cmd_status = cpu_to_le32(DescOwn | len);
  15742. - dev->cur_tx++;
  15743. - if (dev->cur_tx >= TX_RING_SIZE)
  15744. - dev->cur_tx = 0;
  15745. -
  15746. - /* Wake the potentially-idle transmit channel. */
  15747. - writel(TxOn, dev->ioaddr + ChipCmd);
  15748. -
  15749. - /* wait for tranmission to complete */
  15750. - to = TIME_OUT;
  15751. - while (to != 0)
  15752. - {
  15753. - desc_status = dev->tx_ring[entry].cmd_status;
  15754. - if ((desc_status & DescOwn) == 0)
  15755. - break;
  15756. - else
  15757. - --to;
  15758. - }
  15759. -
  15760. - readl(dev->ioaddr + IntrStatus); /* clear interrrupt bits */
  15761. - return;
  15762. -}
  15763. -
  15764. -static void fa311_disable(struct nic *nic)
  15765. -{
  15766. -struct FA311_DEV* dev = &fa311_dev;
  15767. -
  15768. - /* Stop the chip's Tx and Rx processes. */
  15769. - writel(RxOff | TxOff, dev->ioaddr + ChipCmd);
  15770. -}
  15771. -
  15772. -
  15773. -/* Read the EEPROM and MII Management Data I/O (MDIO) interfaces.
  15774. - The EEPROM code is for the common 93c06/46 EEPROMs with 6 bit addresses. */
  15775. -
  15776. -/* Delay between EEPROM clock transitions.
  15777. - No extra delay is needed with 33Mhz PCI, but future 66Mhz access may need
  15778. - a delay. Note that pre-2.0.34 kernels had a cache-alignment bug that
  15779. - made udelay() unreliable.
  15780. - The old method of using an ISA access as a delay, __SLOW_DOWN_IO__, is
  15781. - depricated.
  15782. -*/
  15783. -#define eeprom_delay(ee_addr) inl(ee_addr)
  15784. -
  15785. -enum EEPROM_Ctrl_Bits {
  15786. - EE_ShiftClk=0x04, EE_DataIn=0x01, EE_ChipSelect=0x08, EE_DataOut=0x02,
  15787. -};
  15788. -#define EE_Write0 (EE_ChipSelect)
  15789. -#define EE_Write1 (EE_ChipSelect | EE_DataIn)
  15790. -
  15791. -/* The EEPROM commands include the alway-set leading bit. */
  15792. -enum EEPROM_Cmds {
  15793. - EE_WriteCmd=(5 << 6), EE_ReadCmd=(6 << 6), EE_EraseCmd=(7 << 6),
  15794. -};
  15795. -
  15796. -
  15797. -static int eeprom_read(long addr, int location)
  15798. -{
  15799. - int i;
  15800. - int retval = 0;
  15801. - int ee_addr = addr + EECtrl;
  15802. - int read_cmd = location | EE_ReadCmd;
  15803. - writel(EE_Write0, ee_addr);
  15804. -
  15805. - /* Shift the read command bits out. */
  15806. - for (i = 10; i >= 0; i--) {
  15807. - short dataval = (read_cmd & (1 << i)) ? EE_Write1 : EE_Write0;
  15808. - writel(dataval, ee_addr);
  15809. - eeprom_delay(ee_addr);
  15810. - writel(dataval | EE_ShiftClk, ee_addr);
  15811. - eeprom_delay(ee_addr);
  15812. - }
  15813. - writel(EE_ChipSelect, ee_addr);
  15814. - eeprom_delay(ee_addr);
  15815. -
  15816. - for (i = 0; i < 16; i++) {
  15817. - writel(EE_ChipSelect | EE_ShiftClk, ee_addr);
  15818. - eeprom_delay(ee_addr);
  15819. - retval |= (readl(ee_addr) & EE_DataOut) ? 1 << i : 0;
  15820. - writel(EE_ChipSelect, ee_addr);
  15821. - eeprom_delay(ee_addr);
  15822. - }
  15823. -
  15824. - /* Terminate the EEPROM access. */
  15825. - writel(EE_Write0, ee_addr);
  15826. - writel(0, ee_addr);
  15827. - return retval;
  15828. -}
  15829. -
  15830. -/* Initialize the Rx and Tx rings, along with various 'dev' bits. */
  15831. -static void init_ring(struct FA311_DEV *dev)
  15832. -{
  15833. - int i;
  15834. -
  15835. - dev->cur_rx = 0;
  15836. - dev->cur_tx = 0;
  15837. -
  15838. - dev->rx_buf_sz = PKT_BUF_SZ;
  15839. - dev->rx_head_desc = &dev->rx_ring[0];
  15840. -
  15841. - /* Initialize all Rx descriptors. */
  15842. - for (i = 0; i < RX_RING_SIZE; i++) {
  15843. - dev->rx_ring[i].next_desc = virt_to_le32desc(&dev->rx_ring[i+1]);
  15844. - dev->rx_ring[i].cmd_status = DescOwn;
  15845. - }
  15846. - /* Mark the last entry as wrapping the ring. */
  15847. - dev->rx_ring[i-1].next_desc = virt_to_le32desc(&dev->rx_ring[0]);
  15848. -
  15849. - /* Fill in the Rx buffers. Handle allocation failure gracefully. */
  15850. - for (i = 0; i < RX_RING_SIZE; i++) {
  15851. - dev->rx_ring[i].addr = (u32)(&rx_packet[PKT_BUF_SZ * i]);
  15852. - dev->rx_ring[i].cmd_status = cpu_to_le32(dev->rx_buf_sz);
  15853. - }
  15854. -
  15855. - for (i = 0; i < TX_RING_SIZE; i++) {
  15856. - dev->tx_ring[i].next_desc = virt_to_le32desc(&dev->tx_ring[i+1]);
  15857. - dev->tx_ring[i].cmd_status = 0;
  15858. - }
  15859. - dev->tx_ring[i-1].next_desc = virt_to_le32desc(&dev->tx_ring[0]);
  15860. -
  15861. - for (i = 0; i < TX_RING_SIZE; i++)
  15862. - dev->tx_ring[i].addr = (u32)(&tx_packet[PKT_BUF_SZ * i]);
  15863. - return;
  15864. -}
  15865. -
  15866. diff -Naur grub-0.97.orig/netboot/forcedeth.c grub-0.97/netboot/forcedeth.c
  15867. --- grub-0.97.orig/netboot/forcedeth.c 1970-01-01 00:00:00.000000000 +0000
  15868. +++ grub-0.97/netboot/forcedeth.c 2005-08-31 19:03:35.000000000 +0000
  15869. @@ -0,0 +1,1039 @@
  15870. +/**************************************************************************
  15871. +* forcedeth.c -- Etherboot device driver for the NVIDIA nForce
  15872. +* media access controllers.
  15873. +*
  15874. +* Note: This driver is based on the Linux driver that was based on
  15875. +* a cleanroom reimplementation which was based on reverse
  15876. +* engineered documentation written by Carl-Daniel Hailfinger
  15877. +* and Andrew de Quincey. It's neither supported nor endorsed
  15878. +* by NVIDIA Corp. Use at your own risk.
  15879. +*
  15880. +* Written 2004 by Timothy Legge <tlegge@rogers.com>
  15881. +*
  15882. +* This program is free software; you can redistribute it and/or modify
  15883. +* it under the terms of the GNU General Public License as published by
  15884. +* the Free Software Foundation; either version 2 of the License, or
  15885. +* (at your option) any later version.
  15886. +*
  15887. +* This program is distributed in the hope that it will be useful,
  15888. +* but WITHOUT ANY WARRANTY; without even the implied warranty of
  15889. +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15890. +* GNU General Public License for more details.
  15891. +*
  15892. +* You should have received a copy of the GNU General Public License
  15893. +* along with this program; if not, write to the Free Software
  15894. +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15895. +*
  15896. +* Portions of this code based on:
  15897. +* forcedeth: Ethernet driver for NVIDIA nForce media access controllers:
  15898. +*
  15899. +* (C) 2003 Manfred Spraul
  15900. +* See Linux Driver for full information
  15901. +*
  15902. +* Linux Driver Version 0.22, 19 Jan 2004
  15903. +*
  15904. +*
  15905. +* REVISION HISTORY:
  15906. +* ================
  15907. +* v1.0 01-31-2004 timlegge Initial port of Linux driver
  15908. +* v1.1 02-03-2004 timlegge Large Clean up, first release
  15909. +*
  15910. +* Indent Options: indent -kr -i8
  15911. +***************************************************************************/
  15912. +
  15913. +/* to get some global routines like printf */
  15914. +#include "etherboot.h"
  15915. +/* to get the interface to the body of the program */
  15916. +#include "nic.h"
  15917. +/* to get the PCI support functions, if this is a PCI NIC */
  15918. +#include "pci.h"
  15919. +/* Include timer support functions */
  15920. +#include "timer.h"
  15921. +
  15922. +#define drv_version "v1.1"
  15923. +#define drv_date "02-03-2004"
  15924. +
  15925. +//#define TFTM_DEBUG
  15926. +#ifdef TFTM_DEBUG
  15927. +#define dprintf(x) printf x
  15928. +#else
  15929. +#define dprintf(x)
  15930. +#endif
  15931. +
  15932. +typedef unsigned char u8;
  15933. +typedef signed char s8;
  15934. +typedef unsigned short u16;
  15935. +typedef signed short s16;
  15936. +typedef unsigned int u32;
  15937. +typedef signed int s32;
  15938. +
  15939. +/* Condensed operations for readability. */
  15940. +#define virt_to_le32desc(addr) cpu_to_le32(virt_to_bus(addr))
  15941. +#define le32desc_to_virt(addr) bus_to_virt(le32_to_cpu(addr))
  15942. +
  15943. +unsigned long BASE;
  15944. +/* NIC specific static variables go here */
  15945. +
  15946. +
  15947. +/*
  15948. + * Hardware access:
  15949. + */
  15950. +
  15951. +#define DEV_NEED_LASTPACKET1 0x0001
  15952. +#define DEV_IRQMASK_1 0x0002
  15953. +#define DEV_IRQMASK_2 0x0004
  15954. +#define DEV_NEED_TIMERIRQ 0x0008
  15955. +
  15956. +enum {
  15957. + NvRegIrqStatus = 0x000,
  15958. +#define NVREG_IRQSTAT_MIIEVENT 0040
  15959. +#define NVREG_IRQSTAT_MASK 0x1ff
  15960. + NvRegIrqMask = 0x004,
  15961. +#define NVREG_IRQ_RX 0x0002
  15962. +#define NVREG_IRQ_RX_NOBUF 0x0004
  15963. +#define NVREG_IRQ_TX_ERR 0x0008
  15964. +#define NVREG_IRQ_TX2 0x0010
  15965. +#define NVREG_IRQ_TIMER 0x0020
  15966. +#define NVREG_IRQ_LINK 0x0040
  15967. +#define NVREG_IRQ_TX1 0x0100
  15968. +#define NVREG_IRQMASK_WANTED_1 0x005f
  15969. +#define NVREG_IRQMASK_WANTED_2 0x0147
  15970. +#define NVREG_IRQ_UNKNOWN (~(NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF|NVREG_IRQ_TX_ERR|NVREG_IRQ_TX2|NVREG_IRQ_TIMER|NVREG_IRQ_LINK|NVREG_IRQ_TX1))
  15971. +
  15972. + NvRegUnknownSetupReg6 = 0x008,
  15973. +#define NVREG_UNKSETUP6_VAL 3
  15974. +
  15975. +/*
  15976. + * NVREG_POLL_DEFAULT is the interval length of the timer source on the nic
  15977. + * NVREG_POLL_DEFAULT=97 would result in an interval length of 1 ms
  15978. + */
  15979. + NvRegPollingInterval = 0x00c,
  15980. +#define NVREG_POLL_DEFAULT 970
  15981. + NvRegMisc1 = 0x080,
  15982. +#define NVREG_MISC1_HD 0x02
  15983. +#define NVREG_MISC1_FORCE 0x3b0f3c
  15984. +
  15985. + NvRegTransmitterControl = 0x084,
  15986. +#define NVREG_XMITCTL_START 0x01
  15987. + NvRegTransmitterStatus = 0x088,
  15988. +#define NVREG_XMITSTAT_BUSY 0x01
  15989. +
  15990. + NvRegPacketFilterFlags = 0x8c,
  15991. +#define NVREG_PFF_ALWAYS 0x7F0008
  15992. +#define NVREG_PFF_PROMISC 0x80
  15993. +#define NVREG_PFF_MYADDR 0x20
  15994. +
  15995. + NvRegOffloadConfig = 0x90,
  15996. +#define NVREG_OFFLOAD_HOMEPHY 0x601
  15997. +#define NVREG_OFFLOAD_NORMAL 0x5ee
  15998. + NvRegReceiverControl = 0x094,
  15999. +#define NVREG_RCVCTL_START 0x01
  16000. + NvRegReceiverStatus = 0x98,
  16001. +#define NVREG_RCVSTAT_BUSY 0x01
  16002. +
  16003. + NvRegRandomSeed = 0x9c,
  16004. +#define NVREG_RNDSEED_MASK 0x00ff
  16005. +#define NVREG_RNDSEED_FORCE 0x7f00
  16006. +
  16007. + NvRegUnknownSetupReg1 = 0xA0,
  16008. +#define NVREG_UNKSETUP1_VAL 0x16070f
  16009. + NvRegUnknownSetupReg2 = 0xA4,
  16010. +#define NVREG_UNKSETUP2_VAL 0x16
  16011. + NvRegMacAddrA = 0xA8,
  16012. + NvRegMacAddrB = 0xAC,
  16013. + NvRegMulticastAddrA = 0xB0,
  16014. +#define NVREG_MCASTADDRA_FORCE 0x01
  16015. + NvRegMulticastAddrB = 0xB4,
  16016. + NvRegMulticastMaskA = 0xB8,
  16017. + NvRegMulticastMaskB = 0xBC,
  16018. +
  16019. + NvRegTxRingPhysAddr = 0x100,
  16020. + NvRegRxRingPhysAddr = 0x104,
  16021. + NvRegRingSizes = 0x108,
  16022. +#define NVREG_RINGSZ_TXSHIFT 0
  16023. +#define NVREG_RINGSZ_RXSHIFT 16
  16024. + NvRegUnknownTransmitterReg = 0x10c,
  16025. + NvRegLinkSpeed = 0x110,
  16026. +#define NVREG_LINKSPEED_FORCE 0x10000
  16027. +#define NVREG_LINKSPEED_10 10
  16028. +#define NVREG_LINKSPEED_100 100
  16029. +#define NVREG_LINKSPEED_1000 1000
  16030. + NvRegUnknownSetupReg5 = 0x130,
  16031. +#define NVREG_UNKSETUP5_BIT31 (1<<31)
  16032. + NvRegUnknownSetupReg3 = 0x134,
  16033. +#define NVREG_UNKSETUP3_VAL1 0x200010
  16034. + NvRegTxRxControl = 0x144,
  16035. +#define NVREG_TXRXCTL_KICK 0x0001
  16036. +#define NVREG_TXRXCTL_BIT1 0x0002
  16037. +#define NVREG_TXRXCTL_BIT2 0x0004
  16038. +#define NVREG_TXRXCTL_IDLE 0x0008
  16039. +#define NVREG_TXRXCTL_RESET 0x0010
  16040. + NvRegMIIStatus = 0x180,
  16041. +#define NVREG_MIISTAT_ERROR 0x0001
  16042. +#define NVREG_MIISTAT_LINKCHANGE 0x0008
  16043. +#define NVREG_MIISTAT_MASK 0x000f
  16044. +#define NVREG_MIISTAT_MASK2 0x000f
  16045. + NvRegUnknownSetupReg4 = 0x184,
  16046. +#define NVREG_UNKSETUP4_VAL 8
  16047. +
  16048. + NvRegAdapterControl = 0x188,
  16049. +#define NVREG_ADAPTCTL_START 0x02
  16050. +#define NVREG_ADAPTCTL_LINKUP 0x04
  16051. +#define NVREG_ADAPTCTL_PHYVALID 0x4000
  16052. +#define NVREG_ADAPTCTL_RUNNING 0x100000
  16053. +#define NVREG_ADAPTCTL_PHYSHIFT 24
  16054. + NvRegMIISpeed = 0x18c,
  16055. +#define NVREG_MIISPEED_BIT8 (1<<8)
  16056. +#define NVREG_MIIDELAY 5
  16057. + NvRegMIIControl = 0x190,
  16058. +#define NVREG_MIICTL_INUSE 0x10000
  16059. +#define NVREG_MIICTL_WRITE 0x08000
  16060. +#define NVREG_MIICTL_ADDRSHIFT 5
  16061. + NvRegMIIData = 0x194,
  16062. + NvRegWakeUpFlags = 0x200,
  16063. +#define NVREG_WAKEUPFLAGS_VAL 0x7770
  16064. +#define NVREG_WAKEUPFLAGS_BUSYSHIFT 24
  16065. +#define NVREG_WAKEUPFLAGS_ENABLESHIFT 16
  16066. +#define NVREG_WAKEUPFLAGS_D3SHIFT 12
  16067. +#define NVREG_WAKEUPFLAGS_D2SHIFT 8
  16068. +#define NVREG_WAKEUPFLAGS_D1SHIFT 4
  16069. +#define NVREG_WAKEUPFLAGS_D0SHIFT 0
  16070. +#define NVREG_WAKEUPFLAGS_ACCEPT_MAGPAT 0x01
  16071. +#define NVREG_WAKEUPFLAGS_ACCEPT_WAKEUPPAT 0x02
  16072. +#define NVREG_WAKEUPFLAGS_ACCEPT_LINKCHANGE 0x04
  16073. +
  16074. + NvRegPatternCRC = 0x204,
  16075. + NvRegPatternMask = 0x208,
  16076. + NvRegPowerCap = 0x268,
  16077. +#define NVREG_POWERCAP_D3SUPP (1<<30)
  16078. +#define NVREG_POWERCAP_D2SUPP (1<<26)
  16079. +#define NVREG_POWERCAP_D1SUPP (1<<25)
  16080. + NvRegPowerState = 0x26c,
  16081. +#define NVREG_POWERSTATE_POWEREDUP 0x8000
  16082. +#define NVREG_POWERSTATE_VALID 0x0100
  16083. +#define NVREG_POWERSTATE_MASK 0x0003
  16084. +#define NVREG_POWERSTATE_D0 0x0000
  16085. +#define NVREG_POWERSTATE_D1 0x0001
  16086. +#define NVREG_POWERSTATE_D2 0x0002
  16087. +#define NVREG_POWERSTATE_D3 0x0003
  16088. +};
  16089. +
  16090. +
  16091. +
  16092. +#define NV_TX_LASTPACKET (1<<0)
  16093. +#define NV_TX_RETRYERROR (1<<3)
  16094. +#define NV_TX_LASTPACKET1 (1<<8)
  16095. +#define NV_TX_DEFERRED (1<<10)
  16096. +#define NV_TX_CARRIERLOST (1<<11)
  16097. +#define NV_TX_LATECOLLISION (1<<12)
  16098. +#define NV_TX_UNDERFLOW (1<<13)
  16099. +#define NV_TX_ERROR (1<<14)
  16100. +#define NV_TX_VALID (1<<15)
  16101. +
  16102. +#define NV_RX_DESCRIPTORVALID (1<<0)
  16103. +#define NV_RX_MISSEDFRAME (1<<1)
  16104. +#define NV_RX_SUBSTRACT1 (1<<3)
  16105. +#define NV_RX_ERROR1 (1<<7)
  16106. +#define NV_RX_ERROR2 (1<<8)
  16107. +#define NV_RX_ERROR3 (1<<9)
  16108. +#define NV_RX_ERROR4 (1<<10)
  16109. +#define NV_RX_CRCERR (1<<11)
  16110. +#define NV_RX_OVERFLOW (1<<12)
  16111. +#define NV_RX_FRAMINGERR (1<<13)
  16112. +#define NV_RX_ERROR (1<<14)
  16113. +#define NV_RX_AVAIL (1<<15)
  16114. +
  16115. +/* Miscelaneous hardware related defines: */
  16116. +#define NV_PCI_REGSZ 0x270
  16117. +
  16118. +/* various timeout delays: all in usec */
  16119. +#define NV_TXRX_RESET_DELAY 4
  16120. +#define NV_TXSTOP_DELAY1 10
  16121. +#define NV_TXSTOP_DELAY1MAX 500000
  16122. +#define NV_TXSTOP_DELAY2 100
  16123. +#define NV_RXSTOP_DELAY1 10
  16124. +#define NV_RXSTOP_DELAY1MAX 500000
  16125. +#define NV_RXSTOP_DELAY2 100
  16126. +#define NV_SETUP5_DELAY 5
  16127. +#define NV_SETUP5_DELAYMAX 50000
  16128. +#define NV_POWERUP_DELAY 5
  16129. +#define NV_POWERUP_DELAYMAX 5000
  16130. +#define NV_MIIBUSY_DELAY 50
  16131. +#define NV_MIIPHY_DELAY 10
  16132. +#define NV_MIIPHY_DELAYMAX 10000
  16133. +
  16134. +#define NV_WAKEUPPATTERNS 5
  16135. +#define NV_WAKEUPMASKENTRIES 4
  16136. +
  16137. +/* General driver defaults */
  16138. +#define NV_WATCHDOG_TIMEO (2*HZ)
  16139. +#define DEFAULT_MTU 1500 /* also maximum supported, at least for now */
  16140. +
  16141. +#define RX_RING 4
  16142. +#define TX_RING 2
  16143. +/* limited to 1 packet until we understand NV_TX_LASTPACKET */
  16144. +#define TX_LIMIT_STOP 10
  16145. +#define TX_LIMIT_START 5
  16146. +
  16147. +/* rx/tx mac addr + type + vlan + align + slack*/
  16148. +#define RX_NIC_BUFSIZE (DEFAULT_MTU + 64)
  16149. +/* even more slack */
  16150. +#define RX_ALLOC_BUFSIZE (DEFAULT_MTU + 128)
  16151. +
  16152. +#define OOM_REFILL (1+HZ/20)
  16153. +#define POLL_WAIT (1+HZ/100)
  16154. +
  16155. +struct ring_desc {
  16156. + u32 PacketBuffer;
  16157. + u16 Length;
  16158. + u16 Flags;
  16159. +};
  16160. +
  16161. +
  16162. +/* Define the TX Descriptor */
  16163. +static struct ring_desc tx_ring[TX_RING];
  16164. +
  16165. +/* Create a static buffer of size RX_BUF_SZ for each
  16166. +TX Descriptor. All descriptors point to a
  16167. +part of this buffer */
  16168. +static unsigned char txb[TX_RING * RX_NIC_BUFSIZE];
  16169. +
  16170. +/* Define the TX Descriptor */
  16171. +static struct ring_desc rx_ring[RX_RING];
  16172. +
  16173. +/* Create a static buffer of size RX_BUF_SZ for each
  16174. +RX Descriptor All descriptors point to a
  16175. +part of this buffer */
  16176. +static unsigned char rxb[RX_RING * RX_NIC_BUFSIZE];
  16177. +
  16178. +/* Private Storage for the NIC */
  16179. +struct forcedeth_private {
  16180. + /* General data:
  16181. + * Locking: spin_lock(&np->lock); */
  16182. + int in_shutdown;
  16183. + u32 linkspeed;
  16184. + int duplex;
  16185. + int phyaddr;
  16186. +
  16187. + /* General data: RO fields */
  16188. + u8 *ring_addr;
  16189. + u32 orig_mac[2];
  16190. + u32 irqmask;
  16191. + /* rx specific fields.
  16192. + * Locking: Within irq hander or disable_irq+spin_lock(&np->lock);
  16193. + */
  16194. + struct ring_desc *rx_ring;
  16195. + unsigned int cur_rx, refill_rx;
  16196. + struct sk_buff *rx_skbuff[RX_RING];
  16197. + u32 rx_dma[RX_RING];
  16198. + unsigned int rx_buf_sz;
  16199. +
  16200. + /*
  16201. + * tx specific fields.
  16202. + */
  16203. + struct ring_desc *tx_ring;
  16204. + unsigned int next_tx, nic_tx;
  16205. + struct sk_buff *tx_skbuff[TX_RING];
  16206. + u32 tx_dma[TX_RING];
  16207. + u16 tx_flags;
  16208. +} npx;
  16209. +
  16210. +static struct forcedeth_private *np;
  16211. +
  16212. +static inline void pci_push(u8 * base)
  16213. +{
  16214. + /* force out pending posted writes */
  16215. + readl(base);
  16216. +}
  16217. +static int reg_delay(int offset, u32 mask,
  16218. + u32 target, int delay, int delaymax, const char *msg)
  16219. +{
  16220. + u8 *base = (u8 *) BASE;
  16221. +
  16222. + pci_push(base);
  16223. + do {
  16224. + udelay(delay);
  16225. + delaymax -= delay;
  16226. + if (delaymax < 0) {
  16227. + if (msg)
  16228. + printf(msg);
  16229. + return 1;
  16230. + }
  16231. + } while ((readl(base + offset) & mask) != target);
  16232. + return 0;
  16233. +}
  16234. +
  16235. +#define MII_READ (-1)
  16236. +#define MII_PHYSID1 0x02 /* PHYS ID 1 */
  16237. +#define MII_PHYSID2 0x03 /* PHYS ID 2 */
  16238. +#define MII_BMCR 0x00 /* Basic mode control register */
  16239. +#define MII_BMSR 0x01 /* Basic mode status register */
  16240. +#define MII_ADVERTISE 0x04 /* Advertisement control reg */
  16241. +#define MII_LPA 0x05 /* Link partner ability reg */
  16242. +
  16243. +#define BMSR_ANEGCOMPLETE 0x0020 /* Auto-negotiation complete */
  16244. +
  16245. +/* Link partner ability register. */
  16246. +#define LPA_SLCT 0x001f /* Same as advertise selector */
  16247. +#define LPA_10HALF 0x0020 /* Can do 10mbps half-duplex */
  16248. +#define LPA_10FULL 0x0040 /* Can do 10mbps full-duplex */
  16249. +#define LPA_100HALF 0x0080 /* Can do 100mbps half-duplex */
  16250. +#define LPA_100FULL 0x0100 /* Can do 100mbps full-duplex */
  16251. +#define LPA_100BASE4 0x0200 /* Can do 100mbps 4k packets */
  16252. +#define LPA_RESV 0x1c00 /* Unused... */
  16253. +#define LPA_RFAULT 0x2000 /* Link partner faulted */
  16254. +#define LPA_LPACK 0x4000 /* Link partner acked us */
  16255. +#define LPA_NPAGE 0x8000 /* Next page bit */
  16256. +
  16257. +/* mii_rw: read/write a register on the PHY.
  16258. + *
  16259. + * Caller must guarantee serialization
  16260. + */
  16261. +static int mii_rw(struct nic *nic __unused, int addr, int miireg,
  16262. + int value)
  16263. +{
  16264. + u8 *base = (u8 *) BASE;
  16265. + int was_running;
  16266. + u32 reg;
  16267. + int retval;
  16268. +
  16269. + writel(NVREG_MIISTAT_MASK, base + NvRegMIIStatus);
  16270. + was_running = 0;
  16271. + reg = readl(base + NvRegAdapterControl);
  16272. + if (reg & NVREG_ADAPTCTL_RUNNING) {
  16273. + was_running = 1;
  16274. + writel(reg & ~NVREG_ADAPTCTL_RUNNING,
  16275. + base + NvRegAdapterControl);
  16276. + }
  16277. + reg = readl(base + NvRegMIIControl);
  16278. + if (reg & NVREG_MIICTL_INUSE) {
  16279. + writel(NVREG_MIICTL_INUSE, base + NvRegMIIControl);
  16280. + udelay(NV_MIIBUSY_DELAY);
  16281. + }
  16282. +
  16283. + reg =
  16284. + NVREG_MIICTL_INUSE | (addr << NVREG_MIICTL_ADDRSHIFT) | miireg;
  16285. + if (value != MII_READ) {
  16286. + writel(value, base + NvRegMIIData);
  16287. + reg |= NVREG_MIICTL_WRITE;
  16288. + }
  16289. + writel(reg, base + NvRegMIIControl);
  16290. +
  16291. + if (reg_delay(NvRegMIIControl, NVREG_MIICTL_INUSE, 0,
  16292. + NV_MIIPHY_DELAY, NV_MIIPHY_DELAYMAX, NULL)) {
  16293. + dprintf(("mii_rw of reg %d at PHY %d timed out.\n",
  16294. + miireg, addr));
  16295. + retval = -1;
  16296. + } else if (value != MII_READ) {
  16297. + /* it was a write operation - fewer failures are detectable */
  16298. + dprintf(("mii_rw wrote 0x%x to reg %d at PHY %d\n",
  16299. + value, miireg, addr));
  16300. + retval = 0;
  16301. + } else if (readl(base + NvRegMIIStatus) & NVREG_MIISTAT_ERROR) {
  16302. + dprintf(("mii_rw of reg %d at PHY %d failed.\n",
  16303. + miireg, addr));
  16304. + retval = -1;
  16305. + } else {
  16306. + /* FIXME: why is that required? */
  16307. + udelay(50);
  16308. + retval = readl(base + NvRegMIIData);
  16309. + dprintf(("mii_rw read from reg %d at PHY %d: 0x%x.\n",
  16310. + miireg, addr, retval));
  16311. + }
  16312. + if (was_running) {
  16313. + reg = readl(base + NvRegAdapterControl);
  16314. + writel(reg | NVREG_ADAPTCTL_RUNNING,
  16315. + base + NvRegAdapterControl);
  16316. + }
  16317. + return retval;
  16318. +}
  16319. +
  16320. +static void start_rx(struct nic *nic __unused)
  16321. +{
  16322. + u8 *base = (u8 *) BASE;
  16323. +
  16324. + dprintf(("start_rx\n"));
  16325. + /* Already running? Stop it. */
  16326. + if (readl(base + NvRegReceiverControl) & NVREG_RCVCTL_START) {
  16327. + writel(0, base + NvRegReceiverControl);
  16328. + pci_push(base);
  16329. + }
  16330. + writel(np->linkspeed, base + NvRegLinkSpeed);
  16331. + pci_push(base);
  16332. + writel(NVREG_RCVCTL_START, base + NvRegReceiverControl);
  16333. + pci_push(base);
  16334. +}
  16335. +
  16336. +static void stop_rx(void)
  16337. +{
  16338. + u8 *base = (u8 *) BASE;
  16339. +
  16340. + dprintf(("stop_rx\n"));
  16341. + writel(0, base + NvRegReceiverControl);
  16342. + reg_delay(NvRegReceiverStatus, NVREG_RCVSTAT_BUSY, 0,
  16343. + NV_RXSTOP_DELAY1, NV_RXSTOP_DELAY1MAX,
  16344. + "stop_rx: ReceiverStatus remained busy");
  16345. +
  16346. + udelay(NV_RXSTOP_DELAY2);
  16347. + writel(0, base + NvRegLinkSpeed);
  16348. +}
  16349. +
  16350. +static void start_tx(struct nic *nic __unused)
  16351. +{
  16352. + u8 *base = (u8 *) BASE;
  16353. +
  16354. + dprintf(("start_tx\n"));
  16355. + writel(NVREG_XMITCTL_START, base + NvRegTransmitterControl);
  16356. + pci_push(base);
  16357. +}
  16358. +
  16359. +static void stop_tx(void)
  16360. +{
  16361. + u8 *base = (u8 *) BASE;
  16362. +
  16363. + dprintf(("stop_tx\n"));
  16364. + writel(0, base + NvRegTransmitterControl);
  16365. + reg_delay(NvRegTransmitterStatus, NVREG_XMITSTAT_BUSY, 0,
  16366. + NV_TXSTOP_DELAY1, NV_TXSTOP_DELAY1MAX,
  16367. + "stop_tx: TransmitterStatus remained busy");
  16368. +
  16369. + udelay(NV_TXSTOP_DELAY2);
  16370. + writel(0, base + NvRegUnknownTransmitterReg);
  16371. +}
  16372. +
  16373. +
  16374. +static void txrx_reset(struct nic *nic __unused)
  16375. +{
  16376. + u8 *base = (u8 *) BASE;
  16377. +
  16378. + dprintf(("txrx_reset\n"));
  16379. + writel(NVREG_TXRXCTL_BIT2 | NVREG_TXRXCTL_RESET,
  16380. + base + NvRegTxRxControl);
  16381. + pci_push(base);
  16382. + udelay(NV_TXRX_RESET_DELAY);
  16383. + writel(NVREG_TXRXCTL_BIT2, base + NvRegTxRxControl);
  16384. + pci_push(base);
  16385. +}
  16386. +
  16387. +/*
  16388. + * alloc_rx: fill rx ring entries.
  16389. + * Return 1 if the allocations for the skbs failed and the
  16390. + * rx engine is without Available descriptors
  16391. + */
  16392. +static int alloc_rx(struct nic *nic __unused)
  16393. +{
  16394. + unsigned int refill_rx = np->refill_rx;
  16395. + int i;
  16396. + //while (np->cur_rx != refill_rx) {
  16397. + for (i = 0; i < RX_RING; i++) {
  16398. + //int nr = refill_rx % RX_RING;
  16399. + rx_ring[i].PacketBuffer =
  16400. + virt_to_le32desc(&rxb[i * RX_NIC_BUFSIZE]);
  16401. + rx_ring[i].Length = cpu_to_le16(RX_NIC_BUFSIZE);
  16402. + wmb();
  16403. + rx_ring[i].Flags = cpu_to_le16(NV_RX_AVAIL);
  16404. + /* printf("alloc_rx: Packet %d marked as Available\n",
  16405. + refill_rx); */
  16406. + refill_rx++;
  16407. + }
  16408. + np->refill_rx = refill_rx;
  16409. + if (np->cur_rx - refill_rx == RX_RING)
  16410. + return 1;
  16411. + return 0;
  16412. +}
  16413. +
  16414. +static int update_linkspeed(struct nic *nic)
  16415. +{
  16416. + int adv, lpa, newdup;
  16417. + u32 newls;
  16418. + adv = mii_rw(nic, np->phyaddr, MII_ADVERTISE, MII_READ);
  16419. + lpa = mii_rw(nic, np->phyaddr, MII_LPA, MII_READ);
  16420. + dprintf(("update_linkspeed: PHY advertises 0x%hX, lpa 0x%hX.\n",
  16421. + adv, lpa));
  16422. +
  16423. + /* FIXME: handle parallel detection properly, handle gigabit ethernet */
  16424. + lpa = lpa & adv;
  16425. + if (lpa & LPA_100FULL) {
  16426. + newls = NVREG_LINKSPEED_FORCE | NVREG_LINKSPEED_100;
  16427. + newdup = 1;
  16428. + } else if (lpa & LPA_100HALF) {
  16429. + newls = NVREG_LINKSPEED_FORCE | NVREG_LINKSPEED_100;
  16430. + newdup = 0;
  16431. + } else if (lpa & LPA_10FULL) {
  16432. + newls = NVREG_LINKSPEED_FORCE | NVREG_LINKSPEED_10;
  16433. + newdup = 1;
  16434. + } else if (lpa & LPA_10HALF) {
  16435. + newls = NVREG_LINKSPEED_FORCE | NVREG_LINKSPEED_10;
  16436. + newdup = 0;
  16437. + } else {
  16438. + printf("bad ability %hX - falling back to 10HD.\n", lpa);
  16439. + newls = NVREG_LINKSPEED_FORCE | NVREG_LINKSPEED_10;
  16440. + newdup = 0;
  16441. + }
  16442. + if (np->duplex != newdup || np->linkspeed != newls) {
  16443. + np->duplex = newdup;
  16444. + np->linkspeed = newls;
  16445. + return 1;
  16446. + }
  16447. + return 0;
  16448. +}
  16449. +
  16450. +
  16451. +
  16452. +static int init_ring(struct nic *nic)
  16453. +{
  16454. + int i;
  16455. +
  16456. + np->next_tx = np->nic_tx = 0;
  16457. + for (i = 0; i < TX_RING; i++) {
  16458. + tx_ring[i].Flags = 0;
  16459. + }
  16460. +
  16461. + np->cur_rx = 0;
  16462. + np->refill_rx = 0;
  16463. + for (i = 0; i < RX_RING; i++) {
  16464. + rx_ring[i].Flags = 0;
  16465. + }
  16466. + return alloc_rx(nic);
  16467. +}
  16468. +
  16469. +static void set_multicast(struct nic *nic)
  16470. +{
  16471. +
  16472. + u8 *base = (u8 *) BASE;
  16473. + u32 addr[2];
  16474. + u32 mask[2];
  16475. + u32 pff;
  16476. + u32 alwaysOff[2];
  16477. + u32 alwaysOn[2];
  16478. +
  16479. + memset(addr, 0, sizeof(addr));
  16480. + memset(mask, 0, sizeof(mask));
  16481. +
  16482. + pff = NVREG_PFF_MYADDR;
  16483. +
  16484. + alwaysOn[0] = alwaysOn[1] = alwaysOff[0] = alwaysOff[1] = 0;
  16485. +
  16486. + addr[0] = alwaysOn[0];
  16487. + addr[1] = alwaysOn[1];
  16488. + mask[0] = alwaysOn[0] | alwaysOff[0];
  16489. + mask[1] = alwaysOn[1] | alwaysOff[1];
  16490. +
  16491. + addr[0] |= NVREG_MCASTADDRA_FORCE;
  16492. + pff |= NVREG_PFF_ALWAYS;
  16493. + stop_rx();
  16494. + writel(addr[0], base + NvRegMulticastAddrA);
  16495. + writel(addr[1], base + NvRegMulticastAddrB);
  16496. + writel(mask[0], base + NvRegMulticastMaskA);
  16497. + writel(mask[1], base + NvRegMulticastMaskB);
  16498. + writel(pff, base + NvRegPacketFilterFlags);
  16499. + start_rx(nic);
  16500. +}
  16501. +
  16502. +/**************************************************************************
  16503. +RESET - Reset the NIC to prepare for use
  16504. +***************************************************************************/
  16505. +static int forcedeth_reset(struct nic *nic)
  16506. +{
  16507. + u8 *base = (u8 *) BASE;
  16508. + int ret, oom, i;
  16509. + ret = 0;
  16510. + dprintf(("forcedeth: open\n"));
  16511. +
  16512. + /* 1) erase previous misconfiguration */
  16513. + /* 4.1-1: stop adapter: ignored, 4.3 seems to be overkill */
  16514. + writel(NVREG_MCASTADDRA_FORCE, base + NvRegMulticastAddrA);
  16515. + writel(0, base + NvRegMulticastAddrB);
  16516. + writel(0, base + NvRegMulticastMaskA);
  16517. + writel(0, base + NvRegMulticastMaskB);
  16518. + writel(0, base + NvRegPacketFilterFlags);
  16519. + writel(0, base + NvRegAdapterControl);
  16520. + writel(0, base + NvRegLinkSpeed);
  16521. + writel(0, base + NvRegUnknownTransmitterReg);
  16522. + txrx_reset(nic);
  16523. + writel(0, base + NvRegUnknownSetupReg6);
  16524. +
  16525. + /* 2) initialize descriptor rings */
  16526. + np->in_shutdown = 0;
  16527. + oom = init_ring(nic);
  16528. +
  16529. + /* 3) set mac address */
  16530. + {
  16531. + u32 mac[2];
  16532. +
  16533. + mac[0] =
  16534. + (nic->node_addr[0] << 0) + (nic->node_addr[1] << 8) +
  16535. + (nic->node_addr[2] << 16) + (nic->node_addr[3] << 24);
  16536. + mac[1] =
  16537. + (nic->node_addr[4] << 0) + (nic->node_addr[5] << 8);
  16538. +
  16539. + writel(mac[0], base + NvRegMacAddrA);
  16540. + writel(mac[1], base + NvRegMacAddrB);
  16541. + }
  16542. +
  16543. + /* 4) continue setup */
  16544. + np->linkspeed = NVREG_LINKSPEED_FORCE | NVREG_LINKSPEED_10;
  16545. + np->duplex = 0;
  16546. + writel(NVREG_UNKSETUP3_VAL1, base + NvRegUnknownSetupReg3);
  16547. + writel(0, base + NvRegTxRxControl);
  16548. + pci_push(base);
  16549. + writel(NVREG_TXRXCTL_BIT1, base + NvRegTxRxControl);
  16550. +
  16551. + reg_delay(NvRegUnknownSetupReg5, NVREG_UNKSETUP5_BIT31,
  16552. + NVREG_UNKSETUP5_BIT31, NV_SETUP5_DELAY,
  16553. + NV_SETUP5_DELAYMAX,
  16554. + "open: SetupReg5, Bit 31 remained off\n");
  16555. + writel(0, base + NvRegUnknownSetupReg4);
  16556. +
  16557. + /* 5) Find a suitable PHY */
  16558. + writel(NVREG_MIISPEED_BIT8 | NVREG_MIIDELAY, base + NvRegMIISpeed);
  16559. + for (i = 1; i < 32; i++) {
  16560. + int id1, id2;
  16561. +
  16562. + id1 = mii_rw(nic, i, MII_PHYSID1, MII_READ);
  16563. + if (id1 < 0)
  16564. + continue;
  16565. + id2 = mii_rw(nic, i, MII_PHYSID2, MII_READ);
  16566. + if (id2 < 0)
  16567. + continue;
  16568. + dprintf(("open: Found PHY %04x:%04x at address %d.\n",
  16569. + id1, id2, i));
  16570. + np->phyaddr = i;
  16571. +
  16572. + update_linkspeed(nic);
  16573. +
  16574. + break;
  16575. + }
  16576. + if (i == 32) {
  16577. + printf("open: failing due to lack of suitable PHY.\n");
  16578. + ret = -1;
  16579. + goto out_drain;
  16580. + }
  16581. +
  16582. + printf("%d-Mbs Link, %s-Duplex\n",
  16583. + np->linkspeed & NVREG_LINKSPEED_10 ? 10 : 100,
  16584. + np->duplex ? "Full" : "Half");
  16585. + /* 6) continue setup */
  16586. + writel(NVREG_MISC1_FORCE | (np->duplex ? 0 : NVREG_MISC1_HD),
  16587. + base + NvRegMisc1);
  16588. + writel(readl(base + NvRegTransmitterStatus),
  16589. + base + NvRegTransmitterStatus);
  16590. + writel(NVREG_PFF_ALWAYS, base + NvRegPacketFilterFlags);
  16591. + writel(NVREG_OFFLOAD_NORMAL, base + NvRegOffloadConfig);
  16592. +
  16593. + writel(readl(base + NvRegReceiverStatus),
  16594. + base + NvRegReceiverStatus);
  16595. +
  16596. + /* FIXME: I cheated and used the calculator to get a random number */
  16597. + i = 75963081;
  16598. + writel(NVREG_RNDSEED_FORCE | (i & NVREG_RNDSEED_MASK),
  16599. + base + NvRegRandomSeed);
  16600. + writel(NVREG_UNKSETUP1_VAL, base + NvRegUnknownSetupReg1);
  16601. + writel(NVREG_UNKSETUP2_VAL, base + NvRegUnknownSetupReg2);
  16602. + writel(NVREG_POLL_DEFAULT, base + NvRegPollingInterval);
  16603. + writel(NVREG_UNKSETUP6_VAL, base + NvRegUnknownSetupReg6);
  16604. + writel((np->
  16605. + phyaddr << NVREG_ADAPTCTL_PHYSHIFT) |
  16606. + NVREG_ADAPTCTL_PHYVALID, base + NvRegAdapterControl);
  16607. + writel(NVREG_UNKSETUP4_VAL, base + NvRegUnknownSetupReg4);
  16608. + writel(NVREG_WAKEUPFLAGS_VAL, base + NvRegWakeUpFlags);
  16609. +
  16610. + /* 7) start packet processing */
  16611. + writel((u32) virt_to_le32desc(&rx_ring[0]),
  16612. + base + NvRegRxRingPhysAddr);
  16613. + writel((u32) virt_to_le32desc(&tx_ring[0]),
  16614. + base + NvRegTxRingPhysAddr);
  16615. +
  16616. +
  16617. + writel(((RX_RING - 1) << NVREG_RINGSZ_RXSHIFT) +
  16618. + ((TX_RING - 1) << NVREG_RINGSZ_TXSHIFT),
  16619. + base + NvRegRingSizes);
  16620. +
  16621. + i = readl(base + NvRegPowerState);
  16622. + if ((i & NVREG_POWERSTATE_POWEREDUP) == 0) {
  16623. + writel(NVREG_POWERSTATE_POWEREDUP | i,
  16624. + base + NvRegPowerState);
  16625. + }
  16626. + pci_push(base);
  16627. + udelay(10);
  16628. + writel(readl(base + NvRegPowerState) | NVREG_POWERSTATE_VALID,
  16629. + base + NvRegPowerState);
  16630. + writel(NVREG_ADAPTCTL_RUNNING, base + NvRegAdapterControl);
  16631. +
  16632. + writel(0, base + NvRegIrqMask);
  16633. + pci_push(base);
  16634. + writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus);
  16635. + pci_push(base);
  16636. + writel(NVREG_MIISTAT_MASK2, base + NvRegMIIStatus);
  16637. + writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus);
  16638. + pci_push(base);
  16639. +/*
  16640. + writel(np->irqmask, base + NvRegIrqMask);
  16641. +*/
  16642. + writel(NVREG_MCASTADDRA_FORCE, base + NvRegMulticastAddrA);
  16643. + writel(0, base + NvRegMulticastAddrB);
  16644. + writel(0, base + NvRegMulticastMaskA);
  16645. + writel(0, base + NvRegMulticastMaskB);
  16646. + writel(NVREG_PFF_ALWAYS | NVREG_PFF_MYADDR,
  16647. + base + NvRegPacketFilterFlags);
  16648. +
  16649. + set_multicast(nic);
  16650. + //start_rx(nic);
  16651. + start_tx(nic);
  16652. +
  16653. + if (!
  16654. + (mii_rw(nic, np->phyaddr, MII_BMSR, MII_READ) &
  16655. + BMSR_ANEGCOMPLETE)) {
  16656. + printf("no link during initialization.\n");
  16657. + }
  16658. +
  16659. + udelay(10000);
  16660. + out_drain:
  16661. + return ret;
  16662. +}
  16663. +
  16664. +//extern void hex_dump(const char *data, const unsigned int len);
  16665. +
  16666. +/**************************************************************************
  16667. +POLL - Wait for a frame
  16668. +***************************************************************************/
  16669. +static int forcedeth_poll(struct nic *nic, int retrieve)
  16670. +{
  16671. + /* return true if there's an ethernet packet ready to read */
  16672. + /* nic->packet should contain data on return */
  16673. + /* nic->packetlen should contain length of data */
  16674. +
  16675. + struct ring_desc *prd;
  16676. + int len;
  16677. + int i;
  16678. +
  16679. + i = np->cur_rx % RX_RING;
  16680. + prd = &rx_ring[i];
  16681. +
  16682. + if ( ! (prd->Flags & cpu_to_le16(NV_RX_DESCRIPTORVALID)) ) {
  16683. + return 0;
  16684. + }
  16685. +
  16686. + if ( ! retrieve ) return 1;
  16687. +
  16688. + /* got a valid packet - forward it to the network core */
  16689. + len = cpu_to_le16(prd->Length);
  16690. + nic->packetlen = len;
  16691. + //hex_dump(rxb + (i * RX_NIC_BUFSIZE), len);
  16692. + memcpy(nic->packet, rxb +
  16693. + (i * RX_NIC_BUFSIZE), nic->packetlen);
  16694. +
  16695. + wmb();
  16696. + np->cur_rx++;
  16697. + alloc_rx(nic);
  16698. + return 1;
  16699. +}
  16700. +
  16701. +
  16702. +/**************************************************************************
  16703. +TRANSMIT - Transmit a frame
  16704. +***************************************************************************/
  16705. +static void forcedeth_transmit(struct nic *nic, const char *d, /* Destination */
  16706. + unsigned int t, /* Type */
  16707. + unsigned int s, /* size */
  16708. + const char *p)
  16709. +{ /* Packet */
  16710. + /* send the packet to destination */
  16711. + u8 *ptxb;
  16712. + u16 nstype;
  16713. + //u16 status;
  16714. + u8 *base = (u8 *) BASE;
  16715. + int nr = np->next_tx % TX_RING;
  16716. +
  16717. + /* point to the current txb incase multiple tx_rings are used */
  16718. + ptxb = txb + (nr * RX_NIC_BUFSIZE);
  16719. + //np->tx_skbuff[nr] = ptxb;
  16720. +
  16721. + /* copy the packet to ring buffer */
  16722. + memcpy(ptxb, d, ETH_ALEN); /* dst */
  16723. + memcpy(ptxb + ETH_ALEN, nic->node_addr, ETH_ALEN); /* src */
  16724. + nstype = htons((u16) t); /* type */
  16725. + memcpy(ptxb + 2 * ETH_ALEN, (u8 *) & nstype, 2); /* type */
  16726. + memcpy(ptxb + ETH_HLEN, p, s);
  16727. +
  16728. + s += ETH_HLEN;
  16729. + while (s < ETH_ZLEN) /* pad to min length */
  16730. + ptxb[s++] = '\0';
  16731. +
  16732. + tx_ring[nr].PacketBuffer = (u32) virt_to_le32desc(ptxb);
  16733. + tx_ring[nr].Length = cpu_to_le16(s - 1);
  16734. +
  16735. + wmb();
  16736. + tx_ring[nr].Flags = np->tx_flags;
  16737. +
  16738. + writel(NVREG_TXRXCTL_KICK, base + NvRegTxRxControl);
  16739. + pci_push(base);
  16740. + tx_ring[nr].Flags = np->tx_flags;
  16741. + np->next_tx++;
  16742. +}
  16743. +
  16744. +/**************************************************************************
  16745. +DISABLE - Turn off ethernet interface
  16746. +***************************************************************************/
  16747. +static void forcedeth_disable(struct dev *dev __unused)
  16748. +{
  16749. + /* put the card in its initial state */
  16750. + /* This function serves 3 purposes.
  16751. + * This disables DMA and interrupts so we don't receive
  16752. + * unexpected packets or interrupts from the card after
  16753. + * etherboot has finished.
  16754. + * This frees resources so etherboot may use
  16755. + * this driver on another interface
  16756. + * This allows etherboot to reinitialize the interface
  16757. + * if something is something goes wrong.
  16758. + */
  16759. + u8 *base = (u8 *) BASE;
  16760. + np->in_shutdown = 1;
  16761. + stop_tx();
  16762. + stop_rx();
  16763. +
  16764. + /* disable interrupts on the nic or we will lock up */
  16765. + writel(0, base + NvRegIrqMask);
  16766. + pci_push(base);
  16767. + dprintf(("Irqmask is zero again\n"));
  16768. +
  16769. + /* specia op:o write back the misordered MAC address - otherwise
  16770. + * the next probe_nic would see a wrong address.
  16771. + */
  16772. + writel(np->orig_mac[0], base + NvRegMacAddrA);
  16773. + writel(np->orig_mac[1], base + NvRegMacAddrB);
  16774. +}
  16775. +
  16776. +/**************************************************************************
  16777. +IRQ - Enable, Disable, or Force interrupts
  16778. +***************************************************************************/
  16779. +static void forcedeth_irq(struct nic *nic __unused, irq_action_t action __unused)
  16780. +{
  16781. + switch ( action ) {
  16782. + case DISABLE :
  16783. + break;
  16784. + case ENABLE :
  16785. + break;
  16786. + case FORCE :
  16787. + break;
  16788. + }
  16789. +}
  16790. +
  16791. +/**************************************************************************
  16792. +PROBE - Look for an adapter, this routine's visible to the outside
  16793. +***************************************************************************/
  16794. +#define IORESOURCE_MEM 0x00000200
  16795. +#define board_found 1
  16796. +#define valid_link 0
  16797. +static int forcedeth_probe(struct dev *dev, struct pci_device *pci)
  16798. +{
  16799. + struct nic *nic = (struct nic *) dev;
  16800. + unsigned long addr;
  16801. + int sz;
  16802. + u8 *base;
  16803. +
  16804. + if (pci->ioaddr == 0)
  16805. + return 0;
  16806. +
  16807. + printf("forcedeth.c: Found %s, vendor=0x%hX, device=0x%hX\n",
  16808. + pci->name, pci->vendor, pci->dev_id);
  16809. +
  16810. + nic->irqno = 0;
  16811. + nic->ioaddr = pci->ioaddr & ~3;
  16812. +
  16813. + /* point to private storage */
  16814. + np = &npx;
  16815. +
  16816. + adjust_pci_device(pci);
  16817. +
  16818. + addr = pci_bar_start(pci, PCI_BASE_ADDRESS_0);
  16819. + sz = pci_bar_size(pci, PCI_BASE_ADDRESS_0);
  16820. +
  16821. + /* BASE is used throughout to address the card */
  16822. + BASE = (unsigned long) ioremap(addr, sz);
  16823. + if (!BASE)
  16824. + return 0;
  16825. + //rx_ring[0] = rx_ring;
  16826. + //tx_ring[0] = tx_ring;
  16827. +
  16828. + /* read the mac address */
  16829. + base = (u8 *) BASE;
  16830. + np->orig_mac[0] = readl(base + NvRegMacAddrA);
  16831. + np->orig_mac[1] = readl(base + NvRegMacAddrB);
  16832. +
  16833. + nic->node_addr[0] = (np->orig_mac[1] >> 8) & 0xff;
  16834. + nic->node_addr[1] = (np->orig_mac[1] >> 0) & 0xff;
  16835. + nic->node_addr[2] = (np->orig_mac[0] >> 24) & 0xff;
  16836. + nic->node_addr[3] = (np->orig_mac[0] >> 16) & 0xff;
  16837. + nic->node_addr[4] = (np->orig_mac[0] >> 8) & 0xff;
  16838. + nic->node_addr[5] = (np->orig_mac[0] >> 0) & 0xff;
  16839. +#ifdef LINUX
  16840. + if (!is_valid_ether_addr(dev->dev_addr)) {
  16841. + /*
  16842. + * Bad mac address. At least one bios sets the mac address
  16843. + * to 01:23:45:67:89:ab
  16844. + */
  16845. + printk(KERN_ERR
  16846. + "%s: Invalid Mac address detected: %02x:%02x:%02x:%02x:%02x:%02x\n",
  16847. + pci_name(pci_dev), dev->dev_addr[0],
  16848. + dev->dev_addr[1], dev->dev_addr[2],
  16849. + dev->dev_addr[3], dev->dev_addr[4],
  16850. + dev->dev_addr[5]);
  16851. + printk(KERN_ERR
  16852. + "Please complain to your hardware vendor. Switching to a random MAC.\n");
  16853. + dev->dev_addr[0] = 0x00;
  16854. + dev->dev_addr[1] = 0x00;
  16855. + dev->dev_addr[2] = 0x6c;
  16856. + get_random_bytes(&dev->dev_addr[3], 3);
  16857. + }
  16858. +#endif
  16859. + printf("%s: MAC Address %!, ", pci->name, nic->node_addr);
  16860. +
  16861. + np->tx_flags =
  16862. + cpu_to_le16(NV_TX_LASTPACKET | NV_TX_LASTPACKET1 |
  16863. + NV_TX_VALID);
  16864. + switch (pci->dev_id) {
  16865. + case 0x01C3: // nforce
  16866. + np->irqmask = NVREG_IRQMASK_WANTED_2;
  16867. + np->irqmask |= NVREG_IRQ_TIMER;
  16868. + break;
  16869. + case 0x0066: // nforce2
  16870. + np->tx_flags |= cpu_to_le16(NV_TX_LASTPACKET1);
  16871. + np->irqmask = NVREG_IRQMASK_WANTED_2;
  16872. + np->irqmask |= NVREG_IRQ_TIMER;
  16873. + break;
  16874. + case 0x00D6: // nforce3
  16875. + np->tx_flags |= cpu_to_le16(NV_TX_LASTPACKET1);
  16876. + np->irqmask = NVREG_IRQMASK_WANTED_2;
  16877. + np->irqmask |= NVREG_IRQ_TIMER;
  16878. +
  16879. + }
  16880. + dprintf(("%s: forcedeth.c: subsystem: %hX:%hX bound to %s\n",
  16881. + pci->name, pci->vendor, pci->dev_id, pci->name));
  16882. +
  16883. + forcedeth_reset(nic);
  16884. +// if (board_found && valid_link)
  16885. + /* point to NIC specific routines */
  16886. + dev->disable = forcedeth_disable;
  16887. + nic->poll = forcedeth_poll;
  16888. + nic->transmit = forcedeth_transmit;
  16889. + nic->irq = forcedeth_irq;
  16890. + return 1;
  16891. +// }
  16892. + /* else */
  16893. +}
  16894. +
  16895. +static struct pci_id forcedeth_nics[] = {
  16896. + PCI_ROM(0x10de, 0x01C3, "nforce", "nForce Ethernet Controller"),
  16897. + PCI_ROM(0x10de, 0x0066, "nforce2", "nForce2 Ethernet Controller"),
  16898. + PCI_ROM(0x10de, 0x00D6, "nforce3", "nForce3 Ethernet Controller"),
  16899. +};
  16900. +
  16901. +struct pci_driver forcedeth_driver = {
  16902. + .type = NIC_DRIVER,
  16903. + .name = "forcedeth",
  16904. + .probe = forcedeth_probe,
  16905. + .ids = forcedeth_nics,
  16906. + .id_count = sizeof(forcedeth_nics) / sizeof(forcedeth_nics[0]),
  16907. + .class = 0,
  16908. +};
  16909. diff -Naur grub-0.97.orig/netboot/fsys_tftp.c grub-0.97/netboot/fsys_tftp.c
  16910. --- grub-0.97.orig/netboot/fsys_tftp.c 2004-04-15 11:38:40.000000000 +0000
  16911. +++ grub-0.97/netboot/fsys_tftp.c 2005-08-31 19:03:35.000000000 +0000
  16912. @@ -29,14 +29,15 @@
  16913. /* #define TFTP_DEBUG 1 */
  16914. #include <filesys.h>
  16915. +#include <shared.h>
  16916. -#define GRUB 1
  16917. -#include <etherboot.h>
  16918. -#include <nic.h>
  16919. +#include "grub.h"
  16920. +#include "tftp.h"
  16921. +#include "nic.h"
  16922. static int retry;
  16923. static unsigned short iport = 2000;
  16924. -static unsigned short oport;
  16925. +static unsigned short oport = 0;
  16926. static unsigned short block, prevblock;
  16927. static int bcounter;
  16928. static struct tftp_t tp, saved_tp;
  16929. @@ -46,6 +47,172 @@
  16930. static unsigned short len, saved_len;
  16931. static char *buf;
  16932. +/**
  16933. + * tftp_read
  16934. + *
  16935. + * Read file with _name_, data handled by _fnc_. In fact, grub never
  16936. + * use it, we just use it to read dhcp config file.
  16937. + */
  16938. +static int await_tftp(int ival, void *ptr __unused,
  16939. + unsigned short ptype __unused, struct iphdr *ip,
  16940. + struct udphdr *udp)
  16941. +{
  16942. + if (!udp) {
  16943. + return 0;
  16944. + }
  16945. + if (arptable[ARP_CLIENT].ipaddr.s_addr != ip->dest.s_addr)
  16946. + return 0;
  16947. + if (ntohs(udp->dest) != ival)
  16948. + return 0;
  16949. + return 1;
  16950. +}
  16951. +
  16952. +int tftp_file_read(const char *name, int (*fnc)(unsigned char *, unsigned int, unsigned int, int))
  16953. +{
  16954. + struct tftpreq_t tp;
  16955. + struct tftp_t *tr;
  16956. + int rc;
  16957. +
  16958. + retry = 0;
  16959. + block = 0;
  16960. + prevblock = 0;
  16961. + bcounter = 0;
  16962. +
  16963. +
  16964. + rx_qdrain();
  16965. +
  16966. + tp.opcode = htons(TFTP_RRQ);
  16967. + /* Warning: the following assumes the layout of bootp_t.
  16968. + But that's fixed by the IP, UDP and BOOTP specs. */
  16969. + len = sizeof(tp.ip) + sizeof(tp.udp) + sizeof(tp.opcode) +
  16970. + sprintf((char *)tp.u.rrq, "%s%coctet%cblksize%c%d",
  16971. + name, 0, 0, 0, TFTP_MAX_PACKET) + 1;
  16972. + if (!udp_transmit(arptable[ARP_SERVER].ipaddr.s_addr, ++iport,
  16973. + TFTP_PORT, len, &tp))
  16974. + return (0);
  16975. + for (;;)
  16976. + {
  16977. + long timeout;
  16978. +#ifdef CONGESTED
  16979. + timeout = rfc2131_sleep_interval(block?TFTP_REXMT: TIMEOUT, retry);
  16980. +#else
  16981. + timeout = rfc2131_sleep_interval(TIMEOUT, retry);
  16982. +#endif
  16983. + if (!await_reply(await_tftp, iport, NULL, timeout))
  16984. + {
  16985. + if (!block && retry++ < MAX_TFTP_RETRIES)
  16986. + { /* maybe initial request was lost */
  16987. + if (!udp_transmit(arptable[ARP_SERVER].ipaddr.s_addr,
  16988. + ++iport, TFTP_PORT, len, &tp))
  16989. + return (0);
  16990. + continue;
  16991. + }
  16992. +#ifdef CONGESTED
  16993. + if (block && ((retry += TFTP_REXMT) < TFTP_TIMEOUT))
  16994. + { /* we resend our last ack */
  16995. +#ifdef MDEBUG
  16996. + printf("<REXMT>\n");
  16997. +#endif
  16998. + udp_transmit(arptable[ARP_SERVER].ipaddr.s_addr,
  16999. + iport, oport,
  17000. + TFTP_MIN_PACKET, &tp);
  17001. + continue;
  17002. + }
  17003. +#endif
  17004. + break; /* timeout */
  17005. + }
  17006. + tr = (struct tftp_t *)&nic.packet[ETH_HLEN];
  17007. + if (tr->opcode == ntohs(TFTP_ERROR))
  17008. + {
  17009. + printf("TFTP error %d (%s)\n",
  17010. + ntohs(tr->u.err.errcode),
  17011. + tr->u.err.errmsg);
  17012. + break;
  17013. + }
  17014. +
  17015. + if (tr->opcode == ntohs(TFTP_OACK)) {
  17016. + char *p = tr->u.oack.data, *e;
  17017. +
  17018. + if (prevblock) /* shouldn't happen */
  17019. + continue; /* ignore it */
  17020. + len = ntohs(tr->udp.len) - sizeof(struct udphdr) - 2;
  17021. + if (len > TFTP_MAX_PACKET)
  17022. + goto noak;
  17023. + e = p + len;
  17024. + while (*p != '\0' && p < e) {
  17025. +/* if (!strcasecmp("blksize", p)) { */
  17026. + if (!grub_strcmp("blksize", p)) {
  17027. + p += 8;
  17028. +/* if ((packetsize = strtoul(p, &p, 10)) < */
  17029. + if ((packetsize = getdec(&p)) < TFTP_DEFAULTSIZE_PACKET)
  17030. + goto noak;
  17031. + while (p < e && *p) p++;
  17032. + if (p < e)
  17033. + p++;
  17034. + }
  17035. + else {
  17036. + noak:
  17037. + tp.opcode = htons(TFTP_ERROR);
  17038. + tp.u.err.errcode = 8;
  17039. +/*
  17040. + * Warning: the following assumes the layout of bootp_t.
  17041. + * But that's fixed by the IP, UDP and BOOTP specs.
  17042. + */
  17043. + len = sizeof(tp.ip) + sizeof(tp.udp) + sizeof(tp.opcode) + sizeof(tp.u.err.errcode) +
  17044. +/*
  17045. + * Normally bad form to omit the format string, but in this case
  17046. + * the string we are copying from is fixed. sprintf is just being
  17047. + * used as a strcpy and strlen.
  17048. + */
  17049. + sprintf((char *)tp.u.err.errmsg,
  17050. + "RFC1782 error") + 1;
  17051. + udp_transmit(arptable[ARP_SERVER].ipaddr.s_addr,
  17052. + iport, ntohs(tr->udp.src),
  17053. + len, &tp);
  17054. + return (0);
  17055. + }
  17056. + }
  17057. + if (p > e)
  17058. + goto noak;
  17059. + block = tp.u.ack.block = 0; /* this ensures, that */
  17060. + /* the packet does not get */
  17061. + /* processed as data! */
  17062. + }
  17063. + else if (tr->opcode == htons(TFTP_DATA)) {
  17064. + len = ntohs(tr->udp.len) - sizeof(struct udphdr) - 4;
  17065. + if (len > packetsize) /* shouldn't happen */
  17066. + continue; /* ignore it */
  17067. + block = ntohs(tp.u.ack.block = tr->u.data.block); }
  17068. + else {/* neither TFTP_OACK nor TFTP_DATA */
  17069. + break;
  17070. + }
  17071. +
  17072. + if ((block || bcounter) && (block != (unsigned short)(prevblock+1))) {
  17073. + /* Block order should be continuous */
  17074. + tp.u.ack.block = htons(block = prevblock);
  17075. + }
  17076. + tp.opcode = htons(TFTP_ACK);
  17077. + oport = ntohs(tr->udp.src);
  17078. + udp_transmit(arptable[ARP_SERVER].ipaddr.s_addr, iport,
  17079. + oport, TFTP_MIN_PACKET, &tp); /* ack */
  17080. + if ((unsigned short)(block-prevblock) != 1) {
  17081. + /* Retransmission or OACK, don't process via callback
  17082. + * and don't change the value of prevblock. */
  17083. + continue;
  17084. + }
  17085. + prevblock = block;
  17086. + retry = 0; /* It's the right place to zero the timer? */
  17087. + if ((rc = fnc(tr->u.data.download,
  17088. + ++bcounter, len, len < packetsize)) <= 0)
  17089. + return(rc);
  17090. + if (len < packetsize) { /* End of data --- fnc should not have returned */
  17091. + printf("tftp download complete, but\n");
  17092. + return (1);
  17093. + }
  17094. + }
  17095. + return (0);
  17096. +}
  17097. +
  17098. /* Fill the buffer by receiving the data via the TFTP protocol. */
  17099. static int
  17100. buf_fill (int abort)
  17101. @@ -65,9 +232,9 @@
  17102. timeout = rfc2131_sleep_interval (TIMEOUT, retry);
  17103. #endif
  17104. - if (! await_reply (AWAIT_TFTP, iport, NULL, timeout))
  17105. + if (! await_reply (await_tftp, iport, NULL, timeout))
  17106. {
  17107. - if (ip_abort)
  17108. + if (user_abort)
  17109. return 0;
  17110. if (! block && retry++ < MAX_TFTP_RETRIES)
  17111. @@ -270,13 +437,7 @@
  17112. buf_read = 0;
  17113. saved_filepos = 0;
  17114. - /* Clear out the Rx queue first. It contains nothing of interest,
  17115. - * except possibly ARP requests from the DHCP/TFTP server. We use
  17116. - * polling throughout Etherboot, so some time may have passed since we
  17117. - * last polled the receive queue, which may now be filled with
  17118. - * broadcast packets. This will cause the reply to the packets we are
  17119. - * about to send to be lost immediately. Not very clever. */
  17120. - await_reply (AWAIT_QDRAIN, 0, NULL, 0);
  17121. + rx_qdrain();
  17122. #ifdef TFTP_DEBUG
  17123. grub_printf ("send_rrq ()\n");
  17124. diff -Naur grub-0.97.orig/netboot/grub.h grub-0.97/netboot/grub.h
  17125. --- grub-0.97.orig/netboot/grub.h 1970-01-01 00:00:00.000000000 +0000
  17126. +++ grub-0.97/netboot/grub.h 2005-08-31 19:03:35.000000000 +0000
  17127. @@ -0,0 +1,171 @@
  17128. +#ifndef GRUB_H
  17129. +#define GRUB_H
  17130. +
  17131. +#include "osdep.h"
  17132. +#include "byteswap.h"
  17133. +#include "in.h"
  17134. +#include "ip.h"
  17135. +#include "udp.h"
  17136. +#include "if_ether.h"
  17137. +#include "latch.h"
  17138. +#include "io.h"
  17139. +#include "nic.h"
  17140. +#include <shared.h>
  17141. +
  17142. +#define K_ESC '\033'
  17143. +#define K_EOF '\04' /* Ctrl-D */
  17144. +#define K_INTR '\03' /* Ctrl-C */
  17145. +
  17146. +#ifndef MAX_RPC_RETRIES
  17147. +#define MAX_RPC_RETRIES 20
  17148. +#endif
  17149. +
  17150. +
  17151. +/* Inter-packet retry in ticks */
  17152. +#ifndef TIMEOUT
  17153. +#define TIMEOUT (10*TICKS_PER_SEC)
  17154. +#endif
  17155. +
  17156. +#ifndef NULL
  17157. +#define NULL ((void *)0)
  17158. +#endif
  17159. +
  17160. +
  17161. +#define ARP_CLIENT 0
  17162. +#define ARP_SERVER 1
  17163. +#define ARP_GATEWAY 2
  17164. +#define MAX_ARP ARP_GATEWAY+1
  17165. +
  17166. +#define IGMP_SERVER 0
  17167. +#define MAX_IGMP IGMP_SERVER+1
  17168. +
  17169. +#define RARP_REQUEST 3
  17170. +#define RARP_REPLY 4
  17171. +
  17172. +
  17173. +#define MULTICAST_MASK 0xF0000000
  17174. +#define MULTICAST_NETWORK 0xE0000000
  17175. +
  17176. +struct arptable_t {
  17177. + in_addr ipaddr;
  17178. + uint8_t node[6];
  17179. +};
  17180. +
  17181. +struct igmptable_t {
  17182. + in_addr group;
  17183. + unsigned long time;
  17184. +};
  17185. +
  17186. +#define KERNEL_BUF (BOOTP_DATA_ADDR->bootp_reply.bp_file)
  17187. +
  17188. +#define FLOPPY_BOOT_LOCATION 0x7c00
  17189. +/* Must match offsets in loader.S */
  17190. +#define ROM_SEGMENT 0x1fa
  17191. +#define ROM_LENGTH 0x1fc
  17192. +
  17193. +#define ROM_INFO_LOCATION (FLOPPY_BOOT_LOCATION+ROM_SEGMENT)
  17194. +/* at end of floppy boot block */
  17195. +
  17196. +
  17197. +
  17198. +/* Define a type for passing info to a loaded program */
  17199. +struct ebinfo {
  17200. + uint8_t major, minor; /* Version */
  17201. + uint16_t flags; /* Bit flags */
  17202. +};
  17203. +
  17204. +/***************************************************************************
  17205. +External prototypes
  17206. +***************************************************************************/
  17207. +extern void rx_qdrain P((void));
  17208. +extern int tftp P((const char *name, int (*)(unsigned char *, unsigned int, unsigned int, int)));
  17209. +extern int ip_transmit P((int len, const void *buf));
  17210. +extern void build_ip_hdr P((unsigned long destip, int ttl, int protocol,
  17211. + int option_len, int len, const void *buf));
  17212. +extern void build_udp_hdr P((unsigned long destip,
  17213. + unsigned int srcsock, unsigned int destsock, int ttl,
  17214. + int len, const void *buf));
  17215. +extern int udp_transmit P((unsigned long destip, unsigned int srcsock,
  17216. + unsigned int destsock, int len, const void *buf));
  17217. +typedef int (*reply_t)(int ival, void *ptr, unsigned short ptype, struct iphdr *ip, struct udphdr *udp);
  17218. +extern int await_reply P((reply_t reply, int ival, void *ptr, long timeout));
  17219. +extern int decode_rfc1533 P((unsigned char *, unsigned int, unsigned int, int));
  17220. +extern void join_group(int slot, unsigned long group);
  17221. +extern void leave_group(int slot);
  17222. +#define RAND_MAX 2147483647L
  17223. +extern uint16_t ipchksum P((const void *ip, unsigned long len));
  17224. +extern uint16_t add_ipchksums P((unsigned long offset, uint16_t sum, uint16_t new));
  17225. +extern int32_t random P((void));
  17226. +extern long rfc2131_sleep_interval P((long base, int exp));
  17227. +extern long rfc1112_sleep_interval P((long base, int exp));
  17228. +#ifndef DOWNLOAD_PROTO_TFTP
  17229. +#define tftp(fname, load_block) 0
  17230. +#endif
  17231. +extern void cleanup P((void));
  17232. +
  17233. +/* misc.c */
  17234. +extern void twiddle P((void));
  17235. +extern void sleep P((int secs));
  17236. +extern void interruptible_sleep P((int secs));
  17237. +extern void poll_interruptions P((void));
  17238. +extern int strcasecmp P((const char *a, const char *b));
  17239. +extern char *substr P((const char *a, const char *b));
  17240. +extern unsigned long strtoul P((const char *p, const char **, int base));
  17241. +extern void printf P((const char *, ...));
  17242. +extern int sprintf P((char *, const char *, ...));
  17243. +extern int inet_aton P((char *p, in_addr *i));
  17244. +extern void putchar P((int));
  17245. +extern int getchar P((void));
  17246. +extern int iskey P((void));
  17247. +
  17248. +extern void grub_printf(const char *, ...);
  17249. +extern char config_file[128];
  17250. +extern void etherboot_printf(const char *, ...);
  17251. +extern int etherboot_sprintf(char *, const char *, ...);
  17252. +extern int getdec(char **s);
  17253. +extern void cleanup_net(void);
  17254. +extern void print_network_configuration (void);
  17255. +extern int ifconfig (char *, char *, char *, char *);
  17256. +extern struct arptable_t arptable[MAX_ARP];
  17257. +
  17258. +#undef printf
  17259. +#undef sprintf
  17260. +#define printf etherboot_printf
  17261. +#define sprintf etherboot_sprintf
  17262. +
  17263. +#ifdef DEBUG
  17264. +#define EnterFunction(func) printf("Enter: " func "\n");
  17265. +#define LeaveFunction(func) printf("Leave: " func "\n");
  17266. +#else
  17267. +#define EnterFunction(func)
  17268. +#define LeaveFunction(func)
  17269. +#endif
  17270. +
  17271. +/*
  17272. + * Some codes from etherboot use a level in DEBUG. Define it to be
  17273. + * zero means no debug info output, that will make them silence in
  17274. + * compiling. Up it as you want.
  17275. + */
  17276. +#ifndef DEBUG
  17277. +# define DEBUG 0
  17278. +#endif
  17279. +
  17280. +/*#define RPC_DEBUG*/
  17281. +
  17282. +extern char *hostname;
  17283. +
  17284. +extern int hostnamelen;
  17285. +/* Whether network is ready */
  17286. +extern int network_ready;
  17287. +
  17288. +/* User aborted in await_reply if not zero */
  17289. +extern int user_abort;
  17290. +
  17291. +extern int rarp(void);
  17292. +extern int grub_eth_probe(void);
  17293. +extern int bootp(void);
  17294. +
  17295. +extern int dhcp(void);
  17296. +
  17297. +extern struct nic nic;
  17298. +#endif /* GRUB_H */
  17299. diff -Naur grub-0.97.orig/netboot/i386_byteswap.h grub-0.97/netboot/i386_byteswap.h
  17300. --- grub-0.97.orig/netboot/i386_byteswap.h 1970-01-01 00:00:00.000000000 +0000
  17301. +++ grub-0.97/netboot/i386_byteswap.h 2005-08-31 19:03:35.000000000 +0000
  17302. @@ -0,0 +1,46 @@
  17303. +#ifndef ETHERBOOT_BITS_BYTESWAP_H
  17304. +#define ETHERBOOT_BITS_BYTESWAP_H
  17305. +
  17306. +#include "types.h"
  17307. +static inline uint16_t __i386_bswap_16(uint16_t x)
  17308. +{
  17309. + __asm__("xchgb %b0,%h0\n\t"
  17310. + : "=q" (x)
  17311. + : "0" (x));
  17312. + return x;
  17313. +}
  17314. +
  17315. +static inline uint32_t __i386_bswap_32(uint32_t x)
  17316. +{
  17317. + __asm__("xchgb %b0,%h0\n\t"
  17318. + "rorl $16,%0\n\t"
  17319. + "xchgb %b0,%h0"
  17320. + : "=q" (x)
  17321. + : "0" (x));
  17322. + return x;
  17323. +}
  17324. +
  17325. +
  17326. +#define __bswap_constant_16(x) \
  17327. + ((uint16_t)((((uint16_t)(x) & 0x00ff) << 8) | \
  17328. + (((uint16_t)(x) & 0xff00) >> 8)))
  17329. +
  17330. +#define __bswap_constant_32(x) \
  17331. + ((uint32_t)((((uint32_t)(x) & 0x000000ffU) << 24) | \
  17332. + (((uint32_t)(x) & 0x0000ff00U) << 8) | \
  17333. + (((uint32_t)(x) & 0x00ff0000U) >> 8) | \
  17334. + (((uint32_t)(x) & 0xff000000U) >> 24)))
  17335. +
  17336. +#define __bswap_16(x) \
  17337. + (__builtin_constant_p(x) ? \
  17338. + __bswap_constant_16(x) : \
  17339. + __i386_bswap_16(x))
  17340. +
  17341. +
  17342. +#define __bswap_32(x) \
  17343. + (__builtin_constant_p(x) ? \
  17344. + __bswap_constant_32(x) : \
  17345. + __i386_bswap_32(x))
  17346. +
  17347. +
  17348. +#endif /* ETHERBOOT_BITS_BYTESWAP_H */
  17349. diff -Naur grub-0.97.orig/netboot/i386_elf.h grub-0.97/netboot/i386_elf.h
  17350. --- grub-0.97.orig/netboot/i386_elf.h 1970-01-01 00:00:00.000000000 +0000
  17351. +++ grub-0.97/netboot/i386_elf.h 2005-08-31 19:03:35.000000000 +0000
  17352. @@ -0,0 +1,91 @@
  17353. +#ifndef I386_BITS_ELF_H
  17354. +#define I386_BITS_ELF_H
  17355. +
  17356. +#include "cpu.h"
  17357. +
  17358. +#ifdef CONFIG_X86_64
  17359. +/* ELF Defines for the 64bit version of the current architecture */
  17360. +#define EM_CURRENT_64 EM_X86_64
  17361. +#define EM_CURRENT_64_PRESENT ( \
  17362. + CPU_FEATURE_P(cpu_info.x86_capability, LM) && \
  17363. + CPU_FEATURE_P(cpu_info.x86_capability, PAE) && \
  17364. + CPU_FEATURE_P(cpu_info.x86_capability, PSE))
  17365. +
  17366. +#define ELF_CHECK_X86_64_ARCH(x) \
  17367. + (EM_CURRENT_64_PRESENT && ((x).e_machine == EM_X86_64))
  17368. +#define __unused_i386
  17369. +#else
  17370. +#define ELF_CHECK_X86_64_ARCH(x) 0
  17371. +#define __unused_i386 __unused
  17372. +#endif
  17373. +
  17374. +
  17375. +/* ELF Defines for the current architecture */
  17376. +#define EM_CURRENT EM_386
  17377. +#define ELFDATA_CURRENT ELFDATA2LSB
  17378. +
  17379. +#define ELF_CHECK_I386_ARCH(x) \
  17380. + (((x).e_machine == EM_386) || ((x).e_machine == EM_486))
  17381. +
  17382. +#define ELF_CHECK_ARCH(x) \
  17383. + ((ELF_CHECK_I386_ARCH(x) || ELF_CHECK_X86_64_ARCH(x)) && \
  17384. + ((x).e_entry <= 0xffffffffUL))
  17385. +
  17386. +#ifdef IMAGE_FREEBSD
  17387. +/*
  17388. + * FreeBSD has this rather strange "feature" of its design.
  17389. + * At some point in its evolution, FreeBSD started to rely
  17390. + * externally on private/static/debug internal symbol information.
  17391. + * That is, some of the interfaces that software uses to access
  17392. + * and work with the FreeBSD kernel are made available not
  17393. + * via the shared library symbol information (the .DYNAMIC section)
  17394. + * but rather the debug symbols. This means that any symbol, not
  17395. + * just publicly defined symbols can be (and are) used by system
  17396. + * tools to make the system work. (such as top, swapinfo, swapon,
  17397. + * etc)
  17398. + *
  17399. + * Even worse, however, is the fact that standard ELF loaders do
  17400. + * not know how to load the symbols since they are not within
  17401. + * an ELF PT_LOAD section. The kernel needs these symbols to
  17402. + * operate so the following changes/additions to the boot
  17403. + * loading of EtherBoot have been made to get the kernel to load.
  17404. + * All of the changes are within IMAGE_FREEBSD such that the
  17405. + * extra/changed code only compiles when FREEBSD support is
  17406. + * enabled.
  17407. + */
  17408. +
  17409. +/*
  17410. + * Section header for FreeBSD (debug symbol kludge!) support
  17411. + */
  17412. +typedef struct {
  17413. + Elf32_Word sh_name; /* Section name (index into the
  17414. + section header string table). */
  17415. + Elf32_Word sh_type; /* Section type. */
  17416. + Elf32_Word sh_flags; /* Section flags. */
  17417. + Elf32_Addr sh_addr; /* Address in memory image. */
  17418. + Elf32_Off sh_offset; /* Offset in file. */
  17419. + Elf32_Size sh_size; /* Size in bytes. */
  17420. + Elf32_Word sh_link; /* Index of a related section. */
  17421. + Elf32_Word sh_info; /* Depends on section type. */
  17422. + Elf32_Size sh_addralign; /* Alignment in bytes. */
  17423. + Elf32_Size sh_entsize; /* Size of each entry in section. */
  17424. +} Elf32_Shdr;
  17425. +
  17426. +/* sh_type */
  17427. +#define SHT_SYMTAB 2 /* symbol table section */
  17428. +#define SHT_STRTAB 3 /* string table section */
  17429. +
  17430. +/*
  17431. + * Module information subtypes (for the metadata that we need to build)
  17432. + */
  17433. +#define MODINFO_END 0x0000 /* End of list */
  17434. +#define MODINFO_NAME 0x0001 /* Name of module (string) */
  17435. +#define MODINFO_TYPE 0x0002 /* Type of module (string) */
  17436. +#define MODINFO_METADATA 0x8000 /* Module-specfic */
  17437. +
  17438. +#define MODINFOMD_SSYM 0x0003 /* start of symbols */
  17439. +#define MODINFOMD_ESYM 0x0004 /* end of symbols */
  17440. +
  17441. +#endif /* IMAGE_FREEBSD */
  17442. +
  17443. +#endif /* I386_BITS_ELF_H */
  17444. diff -Naur grub-0.97.orig/netboot/i386_endian.h grub-0.97/netboot/i386_endian.h
  17445. --- grub-0.97.orig/netboot/i386_endian.h 1970-01-01 00:00:00.000000000 +0000
  17446. +++ grub-0.97/netboot/i386_endian.h 2005-08-31 19:03:35.000000000 +0000
  17447. @@ -0,0 +1,6 @@
  17448. +#ifndef ETHERBOOT_BITS_ENDIAN_H
  17449. +#define ETHERBOOT_BITS_ENDIAN_H
  17450. +
  17451. +#define __BYTE_ORDER __LITTLE_ENDIAN
  17452. +
  17453. +#endif /* ETHERBOOT_BITS_ENDIAN_H */
  17454. diff -Naur grub-0.97.orig/netboot/i386_timer.c grub-0.97/netboot/i386_timer.c
  17455. --- grub-0.97.orig/netboot/i386_timer.c 1970-01-01 00:00:00.000000000 +0000
  17456. +++ grub-0.97/netboot/i386_timer.c 2005-08-31 19:03:35.000000000 +0000
  17457. @@ -0,0 +1,192 @@
  17458. +/* A couple of routines to implement a low-overhead timer for drivers */
  17459. +
  17460. + /*
  17461. + * This program is free software; you can redistribute it and/or
  17462. + * modify it under the terms of the GNU General Public License as
  17463. + * published by the Free Software Foundation; either version 2, or (at
  17464. + * your option) any later version.
  17465. + */
  17466. +#include "grub.h"
  17467. +#include "osdep.h"
  17468. +#include "io.h"
  17469. +#include "timer.h"
  17470. +#include "latch.h"
  17471. +
  17472. +void __load_timer2(unsigned int ticks)
  17473. +{
  17474. + /*
  17475. + * Now let's take care of PPC channel 2
  17476. + *
  17477. + * Set the Gate high, program PPC channel 2 for mode 0,
  17478. + * (interrupt on terminal count mode), binary count,
  17479. + * load 5 * LATCH count, (LSB and MSB) to begin countdown.
  17480. + *
  17481. + * Note some implementations have a bug where the high bits byte
  17482. + * of channel 2 is ignored.
  17483. + */
  17484. + /* Set up the timer gate, turn off the speaker */
  17485. + /* Set the Gate high, disable speaker */
  17486. + outb((inb(PPC_PORTB) & ~PPCB_SPKR) | PPCB_T2GATE, PPC_PORTB);
  17487. + /* binary, mode 0, LSB/MSB, Ch 2 */
  17488. + outb(TIMER2_SEL|WORD_ACCESS|MODE0|BINARY_COUNT, TIMER_MODE_PORT);
  17489. + /* LSB of ticks */
  17490. + outb(ticks & 0xFF, TIMER2_PORT);
  17491. + /* MSB of ticks */
  17492. + outb(ticks >> 8, TIMER2_PORT);
  17493. +}
  17494. +
  17495. +static int __timer2_running(void)
  17496. +{
  17497. + return ((inb(PPC_PORTB) & PPCB_T2OUT) == 0);
  17498. +}
  17499. +
  17500. +#if !defined(CONFIG_TSC_CURRTICKS)
  17501. +void setup_timers(void)
  17502. +{
  17503. + return;
  17504. +}
  17505. +
  17506. +void load_timer2(unsigned int ticks)
  17507. +{
  17508. + return __load_timer2(ticks);
  17509. +}
  17510. +
  17511. +int timer2_running(void)
  17512. +{
  17513. + return __timer2_running();
  17514. +}
  17515. +
  17516. +void ndelay(unsigned int nsecs)
  17517. +{
  17518. + waiton_timer2((nsecs * CLOCK_TICK_RATE)/1000000000);
  17519. +}
  17520. +void udelay(unsigned int usecs)
  17521. +{
  17522. + waiton_timer2((usecs * TICKS_PER_MS)/1000);
  17523. +}
  17524. +#endif /* !defined(CONFIG_TSC_CURRTICKS) */
  17525. +
  17526. +#if defined(CONFIG_TSC_CURRTICKS)
  17527. +
  17528. +#define rdtsc(low,high) \
  17529. + __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))
  17530. +
  17531. +#define rdtscll(val) \
  17532. + __asm__ __volatile__ ("rdtsc" : "=A" (val))
  17533. +
  17534. +
  17535. +/* Number of clock ticks to time with the rtc */
  17536. +#define LATCH 0xFF
  17537. +
  17538. +#define LATCHES_PER_SEC ((CLOCK_TICK_RATE + (LATCH/2))/LATCH)
  17539. +#define TICKS_PER_LATCH ((LATCHES_PER_SEC + (TICKS_PER_SEC/2))/TICKS_PER_SEC)
  17540. +
  17541. +static void sleep_latch(void)
  17542. +{
  17543. + __load_timer2(LATCH);
  17544. + while(__timer2_running());
  17545. +}
  17546. +
  17547. +/* ------ Calibrate the TSC -------
  17548. + * Time how long it takes to excute a loop that runs in known time.
  17549. + * And find the convertion needed to get to CLOCK_TICK_RATE
  17550. + */
  17551. +
  17552. +
  17553. +static unsigned long long calibrate_tsc(void)
  17554. +{
  17555. + unsigned long startlow, starthigh;
  17556. + unsigned long endlow, endhigh;
  17557. +
  17558. + rdtsc(startlow,starthigh);
  17559. + sleep_latch();
  17560. + rdtsc(endlow,endhigh);
  17561. +
  17562. + /* 64-bit subtract - gcc just messes up with long longs */
  17563. + __asm__("subl %2,%0\n\t"
  17564. + "sbbl %3,%1"
  17565. + :"=a" (endlow), "=d" (endhigh)
  17566. + :"g" (startlow), "g" (starthigh),
  17567. + "0" (endlow), "1" (endhigh));
  17568. +
  17569. + /* Error: ECPUTOOFAST */
  17570. + if (endhigh)
  17571. + goto bad_ctc;
  17572. +
  17573. + endlow *= TICKS_PER_LATCH;
  17574. + return endlow;
  17575. +
  17576. + /*
  17577. + * The CTC wasn't reliable: we got a hit on the very first read,
  17578. + * or the CPU was so fast/slow that the quotient wouldn't fit in
  17579. + * 32 bits..
  17580. + */
  17581. +bad_ctc:
  17582. + printf("bad_ctc\n");
  17583. + return 0;
  17584. +}
  17585. +
  17586. +static unsigned long clocks_per_tick;
  17587. +void setup_timers(void)
  17588. +{
  17589. + if (!clocks_per_tick) {
  17590. + clocks_per_tick = calibrate_tsc();
  17591. + /* Display the CPU Mhz to easily test if the calibration was bad */
  17592. + printf("CPU %ld Mhz\n", (clocks_per_tick/1000 * TICKS_PER_SEC)/1000);
  17593. + }
  17594. +}
  17595. +
  17596. +unsigned long currticks(void)
  17597. +{
  17598. + unsigned long clocks_high, clocks_low;
  17599. + unsigned long currticks;
  17600. + /* Read the Time Stamp Counter */
  17601. + rdtsc(clocks_low, clocks_high);
  17602. +
  17603. + /* currticks = clocks / clocks_per_tick; */
  17604. + __asm__("divl %1"
  17605. + :"=a" (currticks)
  17606. + :"r" (clocks_per_tick), "0" (clocks_low), "d" (clocks_high));
  17607. +
  17608. +
  17609. + return currticks;
  17610. +}
  17611. +
  17612. +static unsigned long long timer_timeout;
  17613. +static int __timer_running(void)
  17614. +{
  17615. + unsigned long long now;
  17616. + rdtscll(now);
  17617. + return now < timer_timeout;
  17618. +}
  17619. +
  17620. +void udelay(unsigned int usecs)
  17621. +{
  17622. + unsigned long long now;
  17623. + rdtscll(now);
  17624. + timer_timeout = now + usecs * ((clocks_per_tick * TICKS_PER_SEC)/(1000*1000));
  17625. + while(__timer_running());
  17626. +}
  17627. +void ndelay(unsigned int nsecs)
  17628. +{
  17629. + unsigned long long now;
  17630. + rdtscll(now);
  17631. + timer_timeout = now + nsecs * ((clocks_per_tick * TICKS_PER_SEC)/(1000*1000*1000));
  17632. + while(__timer_running());
  17633. +}
  17634. +
  17635. +void load_timer2(unsigned int timer2_ticks)
  17636. +{
  17637. + unsigned long long now;
  17638. + unsigned long clocks;
  17639. + rdtscll(now);
  17640. + clocks = timer2_ticks * ((clocks_per_tick * TICKS_PER_SEC)/CLOCK_TICK_RATE);
  17641. + timer_timeout = now + clocks;
  17642. +}
  17643. +
  17644. +int timer2_running(void)
  17645. +{
  17646. + return __timer_running();
  17647. +}
  17648. +
  17649. +#endif /* RTC_CURRTICKS */
  17650. diff -Naur grub-0.97.orig/netboot/i82586.c grub-0.97/netboot/i82586.c
  17651. --- grub-0.97.orig/netboot/i82586.c 2003-07-09 11:45:37.000000000 +0000
  17652. +++ grub-0.97/netboot/i82586.c 1970-01-01 00:00:00.000000000 +0000
  17653. @@ -1,825 +0,0 @@
  17654. -/**************************************************************************
  17655. -Etherboot - BOOTP/TFTP Bootstrap Program
  17656. -i82586 NIC driver for Etherboot
  17657. -Ken Yap, January 1998
  17658. -***************************************************************************/
  17659. -
  17660. -/*
  17661. - * This program is free software; you can redistribute it and/or
  17662. - * modify it under the terms of the GNU General Public License as
  17663. - * published by the Free Software Foundation; either version 2, or (at
  17664. - * your option) any later version.
  17665. - */
  17666. -
  17667. -#include "etherboot.h"
  17668. -#include "nic.h"
  17669. -#include "cards.h"
  17670. -#include "timer.h"
  17671. -
  17672. -#define udelay(n) waiton_timer2(((n)*TICKS_PER_MS)/1000)
  17673. -
  17674. -/* Sources of information:
  17675. -
  17676. - Donald Becker's excellent 3c507 driver in Linux
  17677. - Intel 82596 data sheet (yes, 82596; it has a 586 compatibility mode)
  17678. -*/
  17679. -
  17680. -/* Code below mostly stolen wholesale from 3c507.c driver in Linux */
  17681. -
  17682. -/*
  17683. - Details of the i82586.
  17684. -
  17685. - You'll really need the databook to understand the details of this part,
  17686. - but the outline is that the i82586 has two separate processing units.
  17687. - Both are started from a list of three configuration tables, of which only
  17688. - the last, the System Control Block (SCB), is used after reset-time. The SCB
  17689. - has the following fields:
  17690. - Status word
  17691. - Command word
  17692. - Tx/Command block addr.
  17693. - Rx block addr.
  17694. - The command word accepts the following controls for the Tx and Rx units:
  17695. - */
  17696. -
  17697. -#define CUC_START 0x0100
  17698. -#define CUC_RESUME 0x0200
  17699. -#define CUC_SUSPEND 0x0300
  17700. -#define RX_START 0x0010
  17701. -#define RX_RESUME 0x0020
  17702. -#define RX_SUSPEND 0x0030
  17703. -
  17704. -/* The Rx unit uses a list of frame descriptors and a list of data buffer
  17705. - descriptors. We use full-sized (1518 byte) data buffers, so there is
  17706. - a one-to-one pairing of frame descriptors to buffer descriptors.
  17707. -
  17708. - The Tx ("command") unit executes a list of commands that look like:
  17709. - Status word Written by the 82586 when the command is done.
  17710. - Command word Command in lower 3 bits, post-command action in upper 3
  17711. - Link word The address of the next command.
  17712. - Parameters (as needed).
  17713. -
  17714. - Some definitions related to the Command Word are:
  17715. - */
  17716. -#define CMD_EOL 0x8000 /* The last command of the list, stop. */
  17717. -#define CMD_SUSP 0x4000 /* Suspend after doing cmd. */
  17718. -#define CMD_INTR 0x2000 /* Interrupt after doing cmd. */
  17719. -
  17720. -enum commands {
  17721. - CmdNOp = 0, CmdSASetup = 1, CmdConfigure = 2, CmdMulticastList = 3,
  17722. - CmdTx = 4, CmdTDR = 5, CmdDump = 6, CmdDiagnose = 7};
  17723. -
  17724. -/*
  17725. - Details of the EtherLink16 Implementation
  17726. -
  17727. - The 3c507 and NI5210 are generic shared-memory i82586 implementations.
  17728. - 3c507: The host can map 16K, 32K, 48K, or 64K of the 64K memory into
  17729. - 0x0[CD][08]0000, or all 64K into 0xF[02468]0000.
  17730. - NI5210: The host can map 8k or 16k at 0x[CDE][048C]000 but we
  17731. - assume 8k because to have 16k you cannot put a ROM on the NIC.
  17732. - */
  17733. -
  17734. -/* Offsets from the base I/O address. */
  17735. -
  17736. -#ifdef INCLUDE_3C507
  17737. -
  17738. -#define SA_DATA 0 /* Station address data, or 3Com signature. */
  17739. -#define MISC_CTRL 6 /* Switch the SA_DATA banks, and bus config bits. */
  17740. -#define RESET_IRQ 10 /* Reset the latched IRQ line. */
  17741. -#define I82586_ATTN 11 /* Frob the 82586 Channel Attention line. */
  17742. -#define ROM_CONFIG 13
  17743. -#define MEM_CONFIG 14
  17744. -#define IRQ_CONFIG 15
  17745. -#define EL16_IO_EXTENT 16
  17746. -
  17747. -/* The ID port is used at boot-time to locate the ethercard. */
  17748. -#define ID_PORT 0x100
  17749. -
  17750. -#endif
  17751. -
  17752. -#ifdef INCLUDE_NI5210
  17753. -
  17754. -#define NI52_RESET 0 /* writing to this address, resets the i82586 */
  17755. -#define I82586_ATTN 1 /* channel attention, kick the 586 */
  17756. -
  17757. -#endif
  17758. -
  17759. -#ifdef INCLUDE_EXOS205
  17760. -
  17761. -#define EXOS205_RESET 0 /* writing to this address, resets the i82586 */
  17762. -#define I82586_ATTN 1 /* channel attention, kick the 586 */
  17763. -
  17764. -#endif
  17765. -
  17766. -/* Offsets to registers in the mailbox (SCB). */
  17767. -#define iSCB_STATUS 0x8
  17768. -#define iSCB_CMD 0xA
  17769. -#define iSCB_CBL 0xC /* Command BLock offset. */
  17770. -#define iSCB_RFA 0xE /* Rx Frame Area offset. */
  17771. -
  17772. -/* Since the 3c507 maps the shared memory window so that the last byte is
  17773. -at 82586 address FFFF, the first byte is at 82586 address 0, 16K, 32K, or
  17774. -48K corresponding to window sizes of 64K, 48K, 32K and 16K respectively.
  17775. -We can account for this be setting the 'SBC Base' entry in the ISCP table
  17776. -below for all the 16 bit offset addresses, and also adding the 'SCB Base'
  17777. -value to all 24 bit physical addresses (in the SCP table and the TX and RX
  17778. -Buffer Descriptors).
  17779. - -Mark
  17780. -*/
  17781. -
  17782. -/*
  17783. - What follows in 'init_words[]' is the "program" that is downloaded to the
  17784. - 82586 memory. It's mostly tables and command blocks, and starts at the
  17785. - reset address 0xfffff6. This is designed to be similar to the EtherExpress,
  17786. - thus the unusual location of the SCB at 0x0008.
  17787. -
  17788. - Even with the additional "don't care" values, doing it this way takes less
  17789. - program space than initializing the individual tables, and I feel it's much
  17790. - cleaner.
  17791. -
  17792. - The databook is particularly useless for the first two structures, I had
  17793. - to use the Crynwr driver as an example.
  17794. -
  17795. - The memory setup is as follows:
  17796. -*/
  17797. -
  17798. -#define CONFIG_CMD 0x18
  17799. -#define SET_SA_CMD 0x24
  17800. -#define SA_OFFSET 0x2A
  17801. -#define IDLELOOP 0x30
  17802. -#define TDR_CMD 0x38
  17803. -#define TDR_TIME 0x3C
  17804. -#define DUMP_CMD 0x40
  17805. -#define DIAG_CMD 0x48
  17806. -#define SET_MC_CMD 0x4E
  17807. -#define DUMP_DATA 0x56 /* A 170 byte buffer for dump and Set-MC into. */
  17808. -
  17809. -#define TX_BUF_START 0x0100
  17810. -#define TX_BUF_SIZE (1518+14+20+16) /* packet+header+TBD */
  17811. -
  17812. -#define RX_BUF_START 0x1000
  17813. -#define RX_BUF_SIZE (1518+14+18) /* packet+header+RBD */
  17814. -#define RX_BUF_END (mem_end - mem_start - 20)
  17815. -
  17816. -/*
  17817. - That's it: only 86 bytes to set up the beast, including every extra
  17818. - command available. The 170 byte buffer at DUMP_DATA is shared between the
  17819. - Dump command (called only by the diagnostic program) and the SetMulticastList
  17820. - command.
  17821. -
  17822. - To complete the memory setup you only have to write the station address at
  17823. - SA_OFFSET and create the Tx & Rx buffer lists.
  17824. -
  17825. - The Tx command chain and buffer list is setup as follows:
  17826. - A Tx command table, with the data buffer pointing to...
  17827. - A Tx data buffer descriptor. The packet is in a single buffer, rather than
  17828. - chaining together several smaller buffers.
  17829. - A NoOp command, which initially points to itself,
  17830. - And the packet data.
  17831. -
  17832. - A transmit is done by filling in the Tx command table and data buffer,
  17833. - re-writing the NoOp command, and finally changing the offset of the last
  17834. - command to point to the current Tx command. When the Tx command is finished,
  17835. - it jumps to the NoOp, when it loops until the next Tx command changes the
  17836. - "link offset" in the NoOp. This way the 82586 never has to go through the
  17837. - slow restart sequence.
  17838. -
  17839. - The Rx buffer list is set up in the obvious ring structure. We have enough
  17840. - memory (and low enough interrupt latency) that we can avoid the complicated
  17841. - Rx buffer linked lists by alway associating a full-size Rx data buffer with
  17842. - each Rx data frame.
  17843. -
  17844. - I currently use one transmit buffer starting at TX_BUF_START (0x0100), and
  17845. - use the rest of memory, from RX_BUF_START to RX_BUF_END, for Rx buffers.
  17846. -
  17847. - */
  17848. -
  17849. -static unsigned short init_words[] = {
  17850. - /* System Configuration Pointer (SCP). */
  17851. -#if defined(INCLUDE_3C507)
  17852. - 0x0000, /* Set bus size to 16 bits. */
  17853. -#else
  17854. - 0x0001, /* Set bus size to 8 bits */
  17855. -#endif
  17856. - 0,0, /* pad words. */
  17857. - 0x0000,0x0000, /* ISCP phys addr, set in init_82586_mem(). */
  17858. -
  17859. - /* Intermediate System Configuration Pointer (ISCP). */
  17860. - 0x0001, /* Status word that's cleared when init is done. */
  17861. - 0x0008,0,0, /* SCB offset, (skip, skip) */
  17862. -
  17863. - /* System Control Block (SCB). */
  17864. - 0,0xf000|RX_START|CUC_START, /* SCB status and cmd. */
  17865. - CONFIG_CMD, /* Command list pointer, points to Configure. */
  17866. - RX_BUF_START, /* Rx block list. */
  17867. - 0,0,0,0, /* Error count: CRC, align, buffer, overrun. */
  17868. -
  17869. - /* 0x0018: Configure command. Change to put MAC data with packet. */
  17870. - 0, CmdConfigure, /* Status, command. */
  17871. - SET_SA_CMD, /* Next command is Set Station Addr. */
  17872. - 0x0804, /* "4" bytes of config data, 8 byte FIFO. */
  17873. - 0x2e40, /* Magic values, including MAC data location. */
  17874. - 0, /* Unused pad word. */
  17875. -
  17876. - /* 0x0024: Setup station address command. */
  17877. - 0, CmdSASetup,
  17878. - SET_MC_CMD, /* Next command. */
  17879. - 0xaa00,0xb000,0x0bad, /* Station address (to be filled in) */
  17880. -
  17881. - /* 0x0030: NOP, looping back to itself. Point to first Tx buffer to Tx. */
  17882. - 0, CmdNOp, IDLELOOP, 0 /* pad */,
  17883. -
  17884. - /* 0x0038: A unused Time-Domain Reflectometer command. */
  17885. - 0, CmdTDR, IDLELOOP, 0,
  17886. -
  17887. - /* 0x0040: An unused Dump State command. */
  17888. - 0, CmdDump, IDLELOOP, DUMP_DATA,
  17889. -
  17890. - /* 0x0048: An unused Diagnose command. */
  17891. - 0, CmdDiagnose, IDLELOOP,
  17892. -
  17893. - /* 0x004E: An empty set-multicast-list command. */
  17894. - 0, CmdMulticastList, IDLELOOP, 0,
  17895. -};
  17896. -
  17897. -/* NIC specific static variables go here */
  17898. -
  17899. -static unsigned short ioaddr, irq, scb_base;
  17900. -static Address mem_start, mem_end;
  17901. -static unsigned short rx_head, rx_tail;
  17902. -
  17903. -#define read_mem(m,s) fmemcpy((char *)s, m, sizeof(s))
  17904. -
  17905. -static void setup_rx_buffers(struct nic *nic)
  17906. -{
  17907. - Address write_ptr;
  17908. - unsigned short cur_rx_buf;
  17909. - static unsigned short rx_cmd[16] = {
  17910. - 0x0000, /* Rx status */
  17911. - 0x0000, /* Rx command, only and last */
  17912. - RX_BUF_START, /* Link (will be adjusted) */
  17913. - RX_BUF_START + 22, /* Buffer offset (will be adjusted) */
  17914. - 0x0000, 0x0000, 0x0000, /* Pad for dest addr */
  17915. - 0x0000, 0x0000, 0x0000, /* Pad for source addr */
  17916. - 0x0000, /* Pad for protocol */
  17917. - 0x0000, /* Buffer: Actual count */
  17918. - -1, /* Buffer: Next (none) */
  17919. - RX_BUF_START + 0x20, /* Buffer: Address low (+ scb_base) (will be adjusted) */
  17920. - 0x0000, /* Buffer: Address high */
  17921. - 0x8000 | (RX_BUF_SIZE - 0x20)
  17922. - };
  17923. -
  17924. - cur_rx_buf = rx_head = RX_BUF_START;
  17925. - do { /* While there is room for one more buffer */
  17926. - write_ptr = mem_start + cur_rx_buf;
  17927. - /* adjust some contents */
  17928. - rx_cmd[1] = 0x0000;
  17929. - rx_cmd[2] = cur_rx_buf + RX_BUF_SIZE;
  17930. - rx_cmd[3] = cur_rx_buf + 22;
  17931. - rx_cmd[13] = cur_rx_buf + 0x20 + scb_base;
  17932. - memcpy((char *)write_ptr, (char *)rx_cmd, sizeof(rx_cmd));
  17933. - rx_tail = cur_rx_buf;
  17934. - cur_rx_buf += RX_BUF_SIZE;
  17935. - } while (cur_rx_buf <= RX_BUF_END - RX_BUF_SIZE);
  17936. - /* Terminate the list by setting the EOL bit and wrap ther pointer
  17937. - to make the list a ring. */
  17938. - write_ptr = mem_start + rx_tail;
  17939. - rx_cmd[1] = 0xC000;
  17940. - rx_cmd[2] = rx_head;
  17941. - memcpy((char *)write_ptr, (char *)rx_cmd, sizeof(unsigned short) * 3);
  17942. -}
  17943. -
  17944. -static void ack_status(void)
  17945. -{
  17946. - unsigned short cmd, status;
  17947. - unsigned short *shmem = (short *)mem_start;
  17948. -
  17949. - cmd = (status = shmem[iSCB_STATUS>>1]) & 0xf000;
  17950. - if (status & 0x100) /* CU suspended? */
  17951. - cmd |= CUC_RESUME;
  17952. - if ((status & 0x200) == 0) /* CU not active? */
  17953. - cmd |= CUC_START;
  17954. - if (status & 0x010) /* RU suspended? */
  17955. - cmd |= RX_RESUME;
  17956. - else if ((status & 0x040) == 0) /* RU not active? */
  17957. - cmd |= RX_START;
  17958. - if (cmd == 0) /* Nothing to do */
  17959. - return;
  17960. - shmem[iSCB_CMD>>1] = cmd;
  17961. -#if defined(DEBUG)
  17962. - printf("Status %hX Command %hX\n", status, cmd);
  17963. -#endif
  17964. - outb(0, ioaddr + I82586_ATTN);
  17965. -}
  17966. -
  17967. -/**************************************************************************
  17968. -RESET - Reset adapter
  17969. -***************************************************************************/
  17970. -
  17971. -static void i82586_reset(struct nic *nic)
  17972. -{
  17973. - unsigned long time;
  17974. - unsigned short *shmem = (short *)mem_start;
  17975. -
  17976. - /* put the card in its initial state */
  17977. -
  17978. -#ifdef INCLUDE_3C507
  17979. - /* Enable loopback to protect the wire while starting up,
  17980. - and hold the 586 in reset during the memory initialisation. */
  17981. - outb(0x20, ioaddr + MISC_CTRL);
  17982. -#endif
  17983. -
  17984. - /* Fix the ISCP address and base. */
  17985. - init_words[3] = scb_base;
  17986. - init_words[7] = scb_base;
  17987. -
  17988. - /* Write the words at 0xfff6. */
  17989. - /* Write the words at 0x0000. */
  17990. - /* Fill in the station address. */
  17991. - memcpy((char *)(mem_end - 10), (char *)init_words, 10);
  17992. - memcpy((char *)mem_start, (char *)&init_words[5], sizeof(init_words) - 10);
  17993. - memcpy((char *)mem_start + SA_OFFSET, nic->node_addr, ETH_ALEN);
  17994. - setup_rx_buffers(nic);
  17995. -
  17996. -#ifdef INCLUDE_3C507
  17997. - /* Start the 586 by releasing the reset line, but leave loopback. */
  17998. - outb(0xA0, ioaddr + MISC_CTRL);
  17999. -#endif
  18000. -
  18001. - /* This was time consuming to track down; you need to give two channel
  18002. - attention signals to reliably start up the i82586. */
  18003. - outb(0, ioaddr + I82586_ATTN);
  18004. - time = currticks() + TICKS_PER_SEC; /* allow 1 second to init */
  18005. - while (
  18006. - shmem[iSCB_STATUS>>1] == 0)
  18007. - {
  18008. - if (currticks() > time)
  18009. - {
  18010. - printf("i82586 initialisation timed out with status %hX, cmd %hX\n",
  18011. - shmem[iSCB_STATUS>>1], shmem[iSCB_CMD>>1]);
  18012. - break;
  18013. - }
  18014. - }
  18015. - /* Issue channel-attn -- the 82586 won't start. */
  18016. - outb(0, ioaddr + I82586_ATTN);
  18017. -
  18018. -#ifdef INCLUDE_3C507
  18019. - /* Disable loopback. */
  18020. - outb(0x80, ioaddr + MISC_CTRL);
  18021. -#endif
  18022. -#if defined(DEBUG)
  18023. - printf("i82586 status %hX, cmd %hX\n",
  18024. - shmem[iSCB_STATUS>>1], shmem[iSCB_CMD>>1]);
  18025. -#endif
  18026. -}
  18027. -
  18028. -/**************************************************************************
  18029. - POLL - Wait for a frame
  18030. - ***************************************************************************/
  18031. -static int i82586_poll(struct nic *nic)
  18032. -{
  18033. - int status;
  18034. - unsigned short rfd_cmd, next_rx_frame, data_buffer_addr,
  18035. - frame_status, pkt_len;
  18036. - unsigned short *shmem = (short *)mem_start + rx_head;
  18037. -
  18038. - /* return true if there's an ethernet packet ready to read */
  18039. - if (
  18040. - ((frame_status = shmem[0]) & 0x8000) == 0)
  18041. - return (0); /* nope */
  18042. - rfd_cmd = shmem[1];
  18043. - next_rx_frame = shmem[2];
  18044. - data_buffer_addr = shmem[3];
  18045. - pkt_len = shmem[11];
  18046. - status = 0;
  18047. - if (rfd_cmd != 0 || data_buffer_addr != rx_head + 22
  18048. - || (pkt_len & 0xC000) != 0xC000)
  18049. - printf("\nRx frame corrupt, discarded");
  18050. - else if ((frame_status & 0x2000) == 0)
  18051. - printf("\nRx frame had error");
  18052. - else
  18053. - {
  18054. - /* We have a frame, copy it to our buffer */
  18055. - pkt_len &= 0x3FFF;
  18056. - memcpy(nic->packet, (char *)mem_start + rx_head + 0x20, pkt_len);
  18057. - /* Only packets not from ourself */
  18058. - if (memcmp(nic->packet + ETH_ALEN, nic->node_addr, ETH_ALEN) != 0)
  18059. - {
  18060. - nic->packetlen = pkt_len;
  18061. - status = 1;
  18062. - }
  18063. - }
  18064. - /* Clear the status word and set EOL on Rx frame */
  18065. - shmem[0] = 0;
  18066. - shmem[1] = 0xC000;
  18067. - *(short *)(mem_start + rx_tail + 2) = 0;
  18068. - rx_tail = rx_head;
  18069. - rx_head = next_rx_frame;
  18070. - ack_status();
  18071. - return (status);
  18072. -}
  18073. -
  18074. -/**************************************************************************
  18075. - TRANSMIT - Transmit a frame
  18076. - ***************************************************************************/
  18077. -static void i82586_transmit(
  18078. - struct nic *nic,
  18079. - const char *d, /* Destination */
  18080. - unsigned int t, /* Type */
  18081. - unsigned int s, /* size */
  18082. - const char *p) /* Packet */
  18083. -{
  18084. - Address bptr;
  18085. - unsigned short type, z;
  18086. - static unsigned short tx_cmd[11] = {
  18087. - 0x0, /* Tx status */
  18088. - CmdTx, /* Tx command */
  18089. - TX_BUF_START+16, /* Next command is a NoOp */
  18090. - TX_BUF_START+8, /* Data Buffer offset */
  18091. - 0x8000, /* | with size */
  18092. - 0xffff, /* No next data buffer */
  18093. - TX_BUF_START+22, /* + scb_base */
  18094. - 0x0, /* Buffer address high bits (always zero) */
  18095. - 0x0, /* Nop status */
  18096. - CmdNOp, /* Nop command */
  18097. - TX_BUF_START+16 /* Next is myself */
  18098. - };
  18099. - unsigned short *shmem = (short *)mem_start + TX_BUF_START;
  18100. -
  18101. - /* send the packet to destination */
  18102. - /* adjust some contents */
  18103. - type = htons(t);
  18104. - if (s < ETH_ZLEN)
  18105. - s = ETH_ZLEN;
  18106. - tx_cmd[4] = (s + ETH_HLEN) | 0x8000;
  18107. - tx_cmd[6] = TX_BUF_START + 22 + scb_base;
  18108. - bptr = mem_start + TX_BUF_START;
  18109. - memcpy((char *)bptr, (char *)tx_cmd, sizeof(tx_cmd));
  18110. - bptr += sizeof(tx_cmd);
  18111. - memcpy((char *)bptr, d, ETH_ALEN);
  18112. - bptr += ETH_ALEN;
  18113. - memcpy((char *)bptr, nic->node_addr, ETH_ALEN);
  18114. - bptr += ETH_ALEN;
  18115. - memcpy((char *)bptr, (char *)&type, sizeof(type));
  18116. - bptr += sizeof(type);
  18117. - memcpy((char *)bptr, p, s);
  18118. - /* Change the offset in the IDLELOOP */
  18119. - *(unsigned short *)(mem_start + IDLELOOP + 4) = TX_BUF_START;
  18120. - /* Wait for transmit completion */
  18121. - while (
  18122. - (shmem[0] & 0x2000) == 0)
  18123. - ;
  18124. - /* Change the offset in the IDLELOOP back and
  18125. - change the final loop to point here */
  18126. - *(unsigned short *)(mem_start + IDLELOOP + 4) = IDLELOOP;
  18127. - *(unsigned short *)(mem_start + TX_BUF_START + 20) = IDLELOOP;
  18128. - ack_status();
  18129. -}
  18130. -
  18131. -/**************************************************************************
  18132. - DISABLE - Turn off ethernet interface
  18133. - ***************************************************************************/
  18134. -static void i82586_disable(struct nic *nic)
  18135. -{
  18136. - unsigned short *shmem = (short *)mem_start;
  18137. -
  18138. -#if 0
  18139. - /* Flush the Tx and disable Rx. */
  18140. - shmem[iSCB_CMD>>1] = RX_SUSPEND | CUC_SUSPEND;
  18141. - outb(0, ioaddr + I82586_ATTN);
  18142. -#ifdef INCLUDE_NI5210
  18143. - outb(0, ioaddr + NI52_RESET);
  18144. -#endif
  18145. -#endif /* 0 */
  18146. -}
  18147. -
  18148. -#ifdef INCLUDE_3C507
  18149. -
  18150. -static int t507_probe1(struct nic *nic, unsigned short ioaddr)
  18151. -{
  18152. - int i;
  18153. - Address size;
  18154. - char mem_config;
  18155. - char if_port;
  18156. -
  18157. - if (inb(ioaddr) != '*' || inb(ioaddr+1) != '3'
  18158. - || inb(ioaddr+2) != 'C' || inb(ioaddr+3) != 'O')
  18159. - return (0);
  18160. - irq = inb(ioaddr + IRQ_CONFIG) & 0x0f;
  18161. - mem_config = inb(ioaddr + MEM_CONFIG);
  18162. - if (mem_config & 0x20)
  18163. - {
  18164. - size = 65536L;
  18165. - mem_start = 0xf00000L + (mem_config & 0x08 ? 0x080000L
  18166. - : (((Address)mem_config & 0x3) << 17));
  18167. - }
  18168. - else
  18169. - {
  18170. - size = ((((Address)mem_config & 0x3) + 1) << 14);
  18171. - mem_start = 0x0c0000L + (((Address)mem_config & 0x18) << 12);
  18172. - }
  18173. - mem_end = mem_start + size;
  18174. - scb_base = 65536L - size;
  18175. - if_port = inb(ioaddr + ROM_CONFIG) & 0x80;
  18176. - /* Get station address */
  18177. - outb(0x01, ioaddr + MISC_CTRL);
  18178. - for (i = 0; i < ETH_ALEN; ++i)
  18179. - {
  18180. - nic->node_addr[i] = inb(ioaddr+i);
  18181. - }
  18182. - printf("\n3c507 ioaddr %#hX, IRQ %d, mem [%#X-%#X], %sternal xcvr, addr %!\n",
  18183. - ioaddr, irq, mem_start, mem_end, if_port ? "in" : "ex", nic->node_addr);
  18184. - return (1);
  18185. -}
  18186. -
  18187. -/**************************************************************************
  18188. -PROBE - Look for an adapter, this routine's visible to the outside
  18189. -***************************************************************************/
  18190. -
  18191. -struct nic *t507_probe(struct nic *nic, unsigned short *probe_addrs)
  18192. -{
  18193. - static unsigned char init_ID_done = 0;
  18194. - unsigned short lrs_state = 0xff;
  18195. - static unsigned short io_addrs[] = { 0x300, 0x320, 0x340, 0x280, 0 };
  18196. - unsigned short *p;
  18197. - int i;
  18198. -
  18199. - if (init_ID_done == 0)
  18200. - {
  18201. - /* Send the ID sequence to the ID_PORT to enable the board */
  18202. - outb(0x00, ID_PORT);
  18203. - for (i = 0; i < 255; ++i)
  18204. - {
  18205. - outb(lrs_state, ID_PORT);
  18206. - lrs_state <<= 1;
  18207. - if (lrs_state & 0x100)
  18208. - lrs_state ^= 0xe7;
  18209. - }
  18210. - outb(0x00, ID_PORT);
  18211. - init_ID_done = 1;
  18212. - }
  18213. - /* if probe_addrs is 0, then routine can use a hardwired default */
  18214. - if (probe_addrs == 0)
  18215. - probe_addrs = io_addrs;
  18216. - for (p = probe_addrs; (ioaddr = *p) != 0; ++p)
  18217. - if (t507_probe1(nic, ioaddr))
  18218. - break;
  18219. - if (ioaddr != 0)
  18220. - {
  18221. - /* point to NIC specific routines */
  18222. - i82586_reset(nic);
  18223. - nic->reset = i82586_reset;
  18224. - nic->poll = i82586_poll;
  18225. - nic->transmit = i82586_transmit;
  18226. - nic->disable = i82586_disable;
  18227. - return nic;
  18228. - }
  18229. - /* else */
  18230. - {
  18231. - return 0;
  18232. - }
  18233. -}
  18234. -
  18235. -#endif
  18236. -
  18237. -#ifdef INCLUDE_NI5210
  18238. -
  18239. -static int ni5210_probe2(void)
  18240. -{
  18241. - unsigned short i;
  18242. - unsigned short shmem[10];
  18243. -
  18244. - /* Fix the ISCP address and base. */
  18245. - init_words[3] = scb_base;
  18246. - init_words[7] = scb_base;
  18247. -
  18248. - /* Write the words at 0xfff6. */
  18249. - /* Write the words at 0x0000. */
  18250. - memcpy((char *)(mem_end - 10), (char *)init_words, 10);
  18251. - memcpy((char *)mem_start, (char *)&init_words[5], sizeof(init_words) - 10);
  18252. - if (*(unsigned short *)mem_start != 1)
  18253. - return (0);
  18254. - outb(0, ioaddr + NI52_RESET);
  18255. - outb(0, ioaddr + I82586_ATTN);
  18256. - udelay(32);
  18257. - i = 50;
  18258. - while (
  18259. - shmem[iSCB_STATUS>>1] == 0)
  18260. - {
  18261. - if (--i == 0)
  18262. - {
  18263. - printf("i82586 initialisation timed out with status %hX, cmd %hX\n",
  18264. - shmem[iSCB_STATUS>>1], shmem[iSCB_CMD>>1]);
  18265. - break;
  18266. - }
  18267. - }
  18268. - /* Issue channel-attn -- the 82586 won't start. */
  18269. - outb(0, ioaddr + I82586_ATTN);
  18270. - if (*(unsigned short *)mem_start != 0)
  18271. - return (0);
  18272. - return (1);
  18273. -}
  18274. -
  18275. -static int ni5210_probe1(struct nic *nic)
  18276. -{
  18277. - int i;
  18278. - static Address mem_addrs[] = {
  18279. - 0xc0000, 0xc4000, 0xc8000, 0xcc000,
  18280. - 0xd0000, 0xd4000, 0xd8000, 0xdc000,
  18281. - 0xe0000, 0xe4000, 0xe8000, 0xec000,
  18282. - 0 };
  18283. - Address *p;
  18284. -
  18285. - if (inb(ioaddr + 6) != 0x0 || inb(ioaddr + 7) != 0x55)
  18286. - return (0);
  18287. - scb_base = -8192; /* assume 8k memory */
  18288. - for (p = mem_addrs; (mem_start = *p) != 0; ++p)
  18289. - if (mem_end = mem_start + 8192, ni5210_probe2())
  18290. - break;
  18291. - if (mem_start == 0)
  18292. - return (0);
  18293. - /* Get station address */
  18294. - for (i = 0; i < ETH_ALEN; ++i)
  18295. - {
  18296. - nic->node_addr[i] = inb(ioaddr+i);
  18297. - }
  18298. - printf("\nNI5210 ioaddr %#hX, mem [%#X-%#X], addr %!\n",
  18299. - ioaddr, mem_start, mem_end, nic->node_addr);
  18300. - return (1);
  18301. -}
  18302. -
  18303. -struct nic *ni5210_probe(struct nic *nic, unsigned short *probe_addrs)
  18304. -{
  18305. - /* missing entries are addresses usually already used */
  18306. - static unsigned short io_addrs[] = {
  18307. - 0x200, 0x208, 0x210, 0x218, 0x220, 0x228, 0x230, 0x238,
  18308. - 0x240, 0x248, 0x250, 0x258, 0x260, 0x268, 0x270, /*Par*/
  18309. - 0x280, 0x288, 0x290, 0x298, 0x2A0, 0x2A8, 0x2B0, 0x2B8,
  18310. - 0x2C0, 0x2C8, 0x2D0, 0x2D8, 0x2E0, 0x2E8, 0x2F0, /*Ser*/
  18311. - 0x300, 0x308, 0x310, 0x318, 0x320, 0x328, 0x330, 0x338,
  18312. - 0x340, 0x348, 0x350, 0x358, 0x360, 0x368, 0x370, /*Par*/
  18313. - 0x380, 0x388, 0x390, 0x398, 0x3A0, 0x3A8, /*Vid,Par*/
  18314. - 0x3C0, 0x3C8, 0x3D0, 0x3D8, 0x3E0, 0x3E8, /*Ser*/
  18315. - 0x0
  18316. - };
  18317. - unsigned short *p;
  18318. - int i;
  18319. -
  18320. - /* if probe_addrs is 0, then routine can use a hardwired default */
  18321. - if (probe_addrs == 0)
  18322. - probe_addrs = io_addrs;
  18323. - for (p = probe_addrs; (ioaddr = *p) != 0; ++p)
  18324. - if (ni5210_probe1(nic))
  18325. - break;
  18326. - if (ioaddr != 0)
  18327. - {
  18328. - /* point to NIC specific routines */
  18329. - i82586_reset(nic);
  18330. - nic->reset = i82586_reset;
  18331. - nic->poll = i82586_poll;
  18332. - nic->transmit = i82586_transmit;
  18333. - nic->disable = i82586_disable;
  18334. - return nic;
  18335. - }
  18336. - /* else */
  18337. - {
  18338. - return 0;
  18339. - }
  18340. -}
  18341. -#endif
  18342. -
  18343. -#ifdef INCLUDE_EXOS205
  18344. -
  18345. -/*
  18346. - * Code to download to I186 in EXOS205
  18347. - */
  18348. -
  18349. -static unsigned char exos_i186_init[] =
  18350. -{
  18351. -0x08,0x00,0x14,0x00,0x00,0x00,0xaa,0xfa,0x33,0xc0,0xba,0xfe,0xff,0xef,0xb8,0xf8,
  18352. -0xff,0xe7,0xa0,0xb8,0x7c,0x00,0xe7,0xa4,0xb8,0xbc,0x80,0xe7,0xa8,0x8c,0xc8,0x8e,
  18353. -0xd8,0xbb,0x2f,0x0e,0xc6,0x07,0xa5,0x33,0xc9,0xeb,0x00,0xeb,0x00,0xeb,0x00,0xe2,
  18354. -0xf8,0xbe,0x2c,0x0e,0xba,0x02,0x05,0x33,0xdb,0xb9,0x03,0x00,0xec,0x24,0x0f,0x8a,
  18355. -0xe0,0x02,0xd8,0x42,0x42,0xec,0x02,0xd8,0xd0,0xe0,0xd0,0xe0,0xd0,0xe0,0xd0,0xe0,
  18356. -0x0a,0xc4,0x88,0x04,0x42,0x42,0x46,0xe2,0xe3,0x8a,0xe3,0xd0,0xec,0xd0,0xec,0xd0,
  18357. -0xec,0xd0,0xec,0x80,0xe3,0x0f,0x02,0xe3,0x80,0xf4,0x05,0xec,0x3a,0xe0,0x74,0x05,
  18358. -0xc6,0x04,0x5a,0xeb,0xfe,0xc6,0x04,0x55,0x33,0xc0,0x8e,0xd8,0xbe,0x38,0x00,0xc7,
  18359. -0x04,0xce,0x0e,0x46,0x46,0xc7,0x04,0x00,0xff,0xfb,0xba,0x3c,0x00,0xb8,0x03,0x00,
  18360. -0xef,0x33,0xdb,0x33,0xc9,0xbd,0x04,0x0f,0x90,0x90,0x90,0x90,0xe2,0xfa,0x43,0x2e,
  18361. -0x89,0x5e,0x00,0xeb,0xf3,0x52,0xba,0x00,0x06,0xef,0x50,0x53,0x55,0xbd,0xf8,0x0e,
  18362. -0x2e,0x8b,0x5e,0x00,0x43,0x2e,0x89,0x5e,0x00,0xba,0x22,0x00,0xb8,0x00,0x80,0xef,
  18363. -0x5d,0x5b,0x58,0x5a,0xcf,0x49,0x4e,0x54,0x52,0x20,0x63,0x6e,0x74,0x2d,0x3e,0x00,
  18364. -0x00,0x4c,0x4f,0x4f,0x50,0x20,0x63,0x6e,0x74,0x2d,0x3e,0x00,0x00,0x00,0x00,0x00,
  18365. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18366. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18367. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18368. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18369. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18370. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18371. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18372. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18373. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18374. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18375. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18376. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18377. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18378. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  18379. -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xea,0x30,0x0e,0x00,0xff,0x00,0x00,0x00,0x00,
  18380. -0x00,0x00,0x00,0x00,0x00,0x00,00
  18381. -};
  18382. -
  18383. -/* These offsets are from the end of the i186 download code */
  18384. -
  18385. -#define OFFSET_SEMA 0x1D1
  18386. -#define OFFSET_ADDR 0x1D7
  18387. -
  18388. -static int exos205_probe2(void)
  18389. -{
  18390. - unsigned short i;
  18391. - unsigned short shmem[10];
  18392. -
  18393. - /* Fix the ISCP address and base. */
  18394. - init_words[3] = scb_base;
  18395. - init_words[7] = scb_base;
  18396. -
  18397. - /* Write the words at 0xfff6. */
  18398. - /* Write the words at 0x0000. */
  18399. - memcpy((char *)(mem_end - 10), (char *)init_words, 10);
  18400. - memcpy((char *)mem_start, (char *)&init_words[5], sizeof(init_words) - 10);
  18401. - if (*(unsigned short *)mem_start != 1)
  18402. - return (0);
  18403. - outb(0, ioaddr + EXOS205_RESET);
  18404. - outb(0, ioaddr + I82586_ATTN);
  18405. - i = 50;
  18406. - while (
  18407. - shmem[iSCB_STATUS>>1] == 0)
  18408. - {
  18409. - if (--i == 0)
  18410. - {
  18411. - printf("i82586 initialisation timed out with status %hX, cmd %hX\n",
  18412. - shmem[iSCB_STATUS>>1], shmem[iSCB_CMD>>1]);
  18413. - break;
  18414. - }
  18415. - }
  18416. - /* Issue channel-attn -- the 82586 won't start. */
  18417. - outb(0, ioaddr + I82586_ATTN);
  18418. - if (*(unsigned short *)mem_start != 0)
  18419. - return (0);
  18420. - return (1);
  18421. -}
  18422. -
  18423. -static int exos205_probe1(struct nic *nic)
  18424. -{
  18425. - int i;
  18426. - /* If you know the other addresses please let me know */
  18427. - static Address mem_addrs[] = {
  18428. - 0xcc000, 0 };
  18429. - Address *p;
  18430. -
  18431. - scb_base = -16384; /* assume 8k memory */
  18432. - for (p = mem_addrs; (mem_start = *p) != 0; ++p)
  18433. - if (mem_end = mem_start + 16384, exos205_probe2())
  18434. - break;
  18435. - if (mem_start == 0)
  18436. - return (0);
  18437. - /* Get station address */
  18438. - for (i = 0; i < ETH_ALEN; ++i)
  18439. - {
  18440. - nic->node_addr[i] = inb(ioaddr+i);
  18441. - }
  18442. - printf("\nEXOS205 ioaddr %#hX, mem [%#X-%#X], addr %!\n",
  18443. - ioaddr, mem_start, mem_end, nic->node_addr);
  18444. - return (1);
  18445. -}
  18446. -
  18447. -struct nic *exos205_probe(struct nic *nic, unsigned short *probe_addrs)
  18448. -{
  18449. - /* If you know the other addresses, please let me know */
  18450. - static unsigned short io_addrs[] = {
  18451. - 0x310, 0x0
  18452. - };
  18453. - unsigned short *p;
  18454. - int i;
  18455. -
  18456. - /* if probe_addrs is 0, then routine can use a hardwired default */
  18457. - if (probe_addrs == 0)
  18458. - probe_addrs = io_addrs;
  18459. - for (p = probe_addrs; (ioaddr = *p) != 0; ++p)
  18460. - if (exos205_probe1(nic))
  18461. - break;
  18462. - if (ioaddr != 0)
  18463. - {
  18464. - /* point to NIC specific routines */
  18465. - i82586_reset(nic);
  18466. - nic->reset = i82586_reset;
  18467. - nic->poll = i82586_poll;
  18468. - nic->transmit = i82586_transmit;
  18469. - nic->disable = i82586_disable;
  18470. - return nic;
  18471. - }
  18472. - /* else */
  18473. - {
  18474. - return 0;
  18475. - }
  18476. -}
  18477. -
  18478. -#endif
  18479. diff -Naur grub-0.97.orig/netboot/if_arp.h grub-0.97/netboot/if_arp.h
  18480. --- grub-0.97.orig/netboot/if_arp.h 1970-01-01 00:00:00.000000000 +0000
  18481. +++ grub-0.97/netboot/if_arp.h 2005-08-31 19:03:35.000000000 +0000
  18482. @@ -0,0 +1,29 @@
  18483. +#ifndef _IF_ARP_H
  18484. +#define _IF_ARP_H
  18485. +
  18486. +#include "types.h"
  18487. +
  18488. +#define ARP_REQUEST 1
  18489. +#define ARP_REPLY 2
  18490. +
  18491. +#ifndef MAX_ARP_RETRIES
  18492. +#define MAX_ARP_RETRIES 20
  18493. +#endif
  18494. +
  18495. +/*
  18496. + * A pity sipaddr and tipaddr are not longword aligned or we could use
  18497. + * in_addr. No, I don't want to use #pragma packed.
  18498. + */
  18499. +struct arprequest {
  18500. + uint16_t hwtype;
  18501. + uint16_t protocol;
  18502. + uint8_t hwlen;
  18503. + uint8_t protolen;
  18504. + uint16_t opcode;
  18505. + uint8_t shwaddr[6];
  18506. + uint8_t sipaddr[4];
  18507. + uint8_t thwaddr[6];
  18508. + uint8_t tipaddr[4];
  18509. +};
  18510. +
  18511. +#endif /* _IF_ARP_H */
  18512. diff -Naur grub-0.97.orig/netboot/if_ether.h grub-0.97/netboot/if_ether.h
  18513. --- grub-0.97.orig/netboot/if_ether.h 1970-01-01 00:00:00.000000000 +0000
  18514. +++ grub-0.97/netboot/if_ether.h 2005-08-31 19:03:35.000000000 +0000
  18515. @@ -0,0 +1,21 @@
  18516. +#ifndef _IF_ETHER_H
  18517. +#define _IF_ETHER_H
  18518. +
  18519. +/*
  18520. + I'm moving towards the defined names in linux/if_ether.h for clarity.
  18521. + The confusion between 60/64 and 1514/1518 arose because the NS8390
  18522. + counts the 4 byte frame checksum in the incoming packet, but not
  18523. + in the outgoing packet. 60/1514 are the correct numbers for most
  18524. + if not all of the other NIC controllers.
  18525. +*/
  18526. +
  18527. +#define ETH_ALEN 6 /* Size of Ethernet address */
  18528. +#define ETH_HLEN 14 /* Size of ethernet header */
  18529. +#define ETH_ZLEN 60 /* Minimum packet */
  18530. +#define ETH_FRAME_LEN 1514 /* Maximum packet */
  18531. +#define ETH_DATA_ALIGN 2 /* Amount needed to align the data after an ethernet header */
  18532. +#ifndef ETH_MAX_MTU
  18533. +#define ETH_MAX_MTU (ETH_FRAME_LEN-ETH_HLEN)
  18534. +#endif
  18535. +
  18536. +#endif /* _IF_ETHER_H */
  18537. diff -Naur grub-0.97.orig/netboot/igmp.h grub-0.97/netboot/igmp.h
  18538. --- grub-0.97.orig/netboot/igmp.h 1970-01-01 00:00:00.000000000 +0000
  18539. +++ grub-0.97/netboot/igmp.h 2005-08-31 19:03:35.000000000 +0000
  18540. @@ -0,0 +1,27 @@
  18541. +#ifndef _IGMP_H
  18542. +#define _IGMP_H
  18543. +
  18544. +/* Max interval between IGMP packets */
  18545. +#define IGMP_INTERVAL (10*TICKS_PER_SEC)
  18546. +#define IGMPv1_ROUTER_PRESENT_TIMEOUT (400*TICKS_PER_SEC)
  18547. +
  18548. +#define IGMP_QUERY 0x11
  18549. +#define IGMPv1_REPORT 0x12
  18550. +#define IGMPv2_REPORT 0x16
  18551. +#define IGMP_LEAVE 0x17
  18552. +#define GROUP_ALL_HOSTS 0xe0000001 /* 224.0.0.1 Host byte order */
  18553. +
  18554. +struct igmp {
  18555. + uint8_t type;
  18556. + uint8_t response_time;
  18557. + uint16_t chksum;
  18558. + in_addr group;
  18559. +};
  18560. +
  18561. +struct igmp_ip_t { /* Format of an igmp ip packet */
  18562. + struct iphdr ip;
  18563. + uint8_t router_alert[4]; /* Router alert option */
  18564. + struct igmp igmp;
  18565. +};
  18566. +
  18567. +#endif /* _IGMP_H */
  18568. diff -Naur grub-0.97.orig/netboot/in.h grub-0.97/netboot/in.h
  18569. --- grub-0.97.orig/netboot/in.h 1970-01-01 00:00:00.000000000 +0000
  18570. +++ grub-0.97/netboot/in.h 2005-08-31 19:03:35.000000000 +0000
  18571. @@ -0,0 +1,21 @@
  18572. +#ifndef _IN_H
  18573. +#define _IN_H
  18574. +
  18575. +#include "types.h"
  18576. +
  18577. +#define IP 0x0800
  18578. +#define ARP 0x0806
  18579. +#define RARP 0x8035
  18580. +
  18581. +#define IP_ICMP 1
  18582. +#define IP_IGMP 2
  18583. +#define IP_UDP 17
  18584. +
  18585. +/* Same after going through htonl */
  18586. +#define IP_BROADCAST 0xFFFFFFFF
  18587. +
  18588. +typedef struct {
  18589. + uint32_t s_addr;
  18590. +} in_addr;
  18591. +
  18592. +#endif /* _IN_H */
  18593. diff -Naur grub-0.97.orig/netboot/io.h grub-0.97/netboot/io.h
  18594. --- grub-0.97.orig/netboot/io.h 1970-01-01 00:00:00.000000000 +0000
  18595. +++ grub-0.97/netboot/io.h 2005-08-31 19:03:35.000000000 +0000
  18596. @@ -0,0 +1,239 @@
  18597. +#ifndef IO_H
  18598. +#define IO_H
  18599. +
  18600. +
  18601. +/* Amount of relocation etherboot is experiencing */
  18602. +extern unsigned long virt_offset;
  18603. +
  18604. +/* Don't require identity mapped physical memory,
  18605. + * osloader.c is the only valid user at the moment.
  18606. + */
  18607. +unsigned long virt_to_phys(volatile const void *virt_addr);
  18608. +void *phys_to_virt(unsigned long phys_addr);
  18609. +
  18610. +/* virt_to_bus converts an addresss inside of etherboot [_start, _end]
  18611. + * into a memory access cards can use.
  18612. + */
  18613. +#define virt_to_bus virt_to_phys
  18614. +
  18615. +
  18616. +/* bus_to_virt reverses virt_to_bus, the address must be output
  18617. + * from virt_to_bus to be valid. This function does not work on
  18618. + * all bus addresses.
  18619. + */
  18620. +#define bus_to_virt phys_to_virt
  18621. +
  18622. +/* ioremap converts a random 32bit bus address into something
  18623. + * etherboot can access.
  18624. + */
  18625. +static inline void *ioremap(unsigned long bus_addr, unsigned long length __unused)
  18626. +{
  18627. + return bus_to_virt(bus_addr);
  18628. +}
  18629. +
  18630. +/* iounmap cleans up anything ioremap had to setup */
  18631. +static inline void iounmap(void *virt_addr __unused)
  18632. +{
  18633. + return;
  18634. +}
  18635. +
  18636. +/*
  18637. + * This file contains the definitions for the x86 IO instructions
  18638. + * inb/inw/inl/outb/outw/outl and the "string versions" of the same
  18639. + * (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing"
  18640. + * versions of the single-IO instructions (inb_p/inw_p/..).
  18641. + *
  18642. + * This file is not meant to be obfuscating: it's just complicated
  18643. + * to (a) handle it all in a way that makes gcc able to optimize it
  18644. + * as well as possible and (b) trying to avoid writing the same thing
  18645. + * over and over again with slight variations and possibly making a
  18646. + * mistake somewhere.
  18647. + */
  18648. +
  18649. +/*
  18650. + * Thanks to James van Artsdalen for a better timing-fix than
  18651. + * the two short jumps: using outb's to a nonexistent port seems
  18652. + * to guarantee better timings even on fast machines.
  18653. + *
  18654. + * On the other hand, I'd like to be sure of a non-existent port:
  18655. + * I feel a bit unsafe about using 0x80 (should be safe, though)
  18656. + *
  18657. + * Linus
  18658. + */
  18659. +
  18660. +#ifdef SLOW_IO_BY_JUMPING
  18661. +#define __SLOW_DOWN_IO __asm__ __volatile__("jmp 1f\n1:\tjmp 1f\n1:")
  18662. +#else
  18663. +#define __SLOW_DOWN_IO __asm__ __volatile__("outb %al,$0x80")
  18664. +#endif
  18665. +
  18666. +#ifdef REALLY_SLOW_IO
  18667. +#define SLOW_DOWN_IO { __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; }
  18668. +#else
  18669. +#define SLOW_DOWN_IO __SLOW_DOWN_IO
  18670. +#endif
  18671. +
  18672. +/*
  18673. + * readX/writeX() are used to access memory mapped devices. On some
  18674. + * architectures the memory mapped IO stuff needs to be accessed
  18675. + * differently. On the x86 architecture, we just read/write the
  18676. + * memory location directly.
  18677. + */
  18678. +#define readb(addr) (*(volatile unsigned char *) (addr))
  18679. +#define readw(addr) (*(volatile unsigned short *) (addr))
  18680. +#define readl(addr) (*(volatile unsigned int *) (addr))
  18681. +
  18682. +#define writeb(b,addr) ((*(volatile unsigned char *) (addr)) = (b))
  18683. +#define writew(b,addr) ((*(volatile unsigned short *) (addr)) = (b))
  18684. +#define writel(b,addr) ((*(volatile unsigned int *) (addr)) = (b))
  18685. +
  18686. +#define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c))
  18687. +#define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c))
  18688. +
  18689. +/*
  18690. + * Force strict CPU ordering.
  18691. + * And yes, this is required on UP too when we're talking
  18692. + * to devices.
  18693. + *
  18694. + * For now, "wmb()" doesn't actually do anything, as all
  18695. + * Intel CPU's follow what Intel calls a *Processor Order*,
  18696. + * in which all writes are seen in the program order even
  18697. + * outside the CPU.
  18698. + *
  18699. + * I expect future Intel CPU's to have a weaker ordering,
  18700. + * but I'd also expect them to finally get their act together
  18701. + * and add some real memory barriers if so.
  18702. + *
  18703. + * Some non intel clones support out of order store. wmb() ceases to be a
  18704. + * nop for these.
  18705. + */
  18706. +
  18707. +#define mb() __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory")
  18708. +#define rmb() mb()
  18709. +#define wmb() mb();
  18710. +
  18711. +
  18712. +/*
  18713. + * Talk about misusing macros..
  18714. + */
  18715. +
  18716. +#define __OUT1(s,x) \
  18717. +extern void __out##s(unsigned x value, unsigned short port); \
  18718. +extern inline void __out##s(unsigned x value, unsigned short port) {
  18719. +
  18720. +#define __OUT2(s,s1,s2) \
  18721. +__asm__ __volatile__ ("out" #s " %" s1 "0,%" s2 "1"
  18722. +
  18723. +#define __OUT(s,s1,x) \
  18724. +__OUT1(s,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); } \
  18725. +__OUT1(s##c,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); } \
  18726. +__OUT1(s##_p,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); SLOW_DOWN_IO; } \
  18727. +__OUT1(s##c_p,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); SLOW_DOWN_IO; }
  18728. +
  18729. +#define __IN1(s,x) \
  18730. +extern unsigned x __in##s(unsigned short port); \
  18731. +extern inline unsigned x __in##s(unsigned short port) { unsigned x _v;
  18732. +
  18733. +#define __IN2(s,s1,s2) \
  18734. +__asm__ __volatile__ ("in" #s " %" s2 "1,%" s1 "0"
  18735. +
  18736. +#define __IN(s,s1,x,i...) \
  18737. +__IN1(s,x) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); return _v; } \
  18738. +__IN1(s##c,x) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); return _v; } \
  18739. +__IN1(s##_p,x) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); SLOW_DOWN_IO; return _v; } \
  18740. +__IN1(s##c_p,x) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); SLOW_DOWN_IO; return _v; }
  18741. +
  18742. +#define __INS(s) \
  18743. +extern void ins##s(unsigned short port, void * addr, unsigned long count); \
  18744. +extern inline void ins##s(unsigned short port, void * addr, unsigned long count) \
  18745. +{ __asm__ __volatile__ ("cld ; rep ; ins" #s \
  18746. +: "=D" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
  18747. +
  18748. +#define __OUTS(s) \
  18749. +extern void outs##s(unsigned short port, const void * addr, unsigned long count); \
  18750. +extern inline void outs##s(unsigned short port, const void * addr, unsigned long count) \
  18751. +{ __asm__ __volatile__ ("cld ; rep ; outs" #s \
  18752. +: "=S" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
  18753. +
  18754. +__IN(b,"", char)
  18755. +__IN(w,"",short)
  18756. +__IN(l,"", long)
  18757. +
  18758. +__OUT(b,"b",char)
  18759. +__OUT(w,"w",short)
  18760. +__OUT(l,,int)
  18761. +
  18762. +__INS(b)
  18763. +__INS(w)
  18764. +__INS(l)
  18765. +
  18766. +__OUTS(b)
  18767. +__OUTS(w)
  18768. +__OUTS(l)
  18769. +
  18770. +/*
  18771. + * Note that due to the way __builtin_constant_p() works, you
  18772. + * - can't use it inside a inline function (it will never be true)
  18773. + * - you don't have to worry about side effects within the __builtin..
  18774. + */
  18775. +#define outb(val,port) \
  18776. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18777. + __outbc((val),(port)) : \
  18778. + __outb((val),(port)))
  18779. +
  18780. +#define inb(port) \
  18781. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18782. + __inbc(port) : \
  18783. + __inb(port))
  18784. +
  18785. +#define outb_p(val,port) \
  18786. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18787. + __outbc_p((val),(port)) : \
  18788. + __outb_p((val),(port)))
  18789. +
  18790. +#define inb_p(port) \
  18791. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18792. + __inbc_p(port) : \
  18793. + __inb_p(port))
  18794. +
  18795. +#define outw(val,port) \
  18796. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18797. + __outwc((val),(port)) : \
  18798. + __outw((val),(port)))
  18799. +
  18800. +#define inw(port) \
  18801. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18802. + __inwc(port) : \
  18803. + __inw(port))
  18804. +
  18805. +#define outw_p(val,port) \
  18806. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18807. + __outwc_p((val),(port)) : \
  18808. + __outw_p((val),(port)))
  18809. +
  18810. +#define inw_p(port) \
  18811. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18812. + __inwc_p(port) : \
  18813. + __inw_p(port))
  18814. +
  18815. +#define outl(val,port) \
  18816. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18817. + __outlc((val),(port)) : \
  18818. + __outl((val),(port)))
  18819. +
  18820. +#define inl(port) \
  18821. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18822. + __inlc(port) : \
  18823. + __inl(port))
  18824. +
  18825. +#define outl_p(val,port) \
  18826. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18827. + __outlc_p((val),(port)) : \
  18828. + __outl_p((val),(port)))
  18829. +
  18830. +#define inl_p(port) \
  18831. +((__builtin_constant_p((port)) && (port) < 256) ? \
  18832. + __inlc_p(port) : \
  18833. + __inl_p(port))
  18834. +
  18835. +#endif /* ETHERBOOT_IO_H */
  18836. diff -Naur grub-0.97.orig/netboot/ip.h grub-0.97/netboot/ip.h
  18837. --- grub-0.97.orig/netboot/ip.h 1970-01-01 00:00:00.000000000 +0000
  18838. +++ grub-0.97/netboot/ip.h 2005-08-31 19:03:35.000000000 +0000
  18839. @@ -0,0 +1,36 @@
  18840. +#ifndef _IP_H
  18841. +#define _IP_H
  18842. +
  18843. +/* We need 'uint16_t' */
  18844. +#include "types.h"
  18845. +/* We need 'in_addr' */
  18846. +#include "in.h"
  18847. +
  18848. +struct iphdr {
  18849. + uint8_t verhdrlen;
  18850. + uint8_t service;
  18851. + uint16_t len;
  18852. + uint16_t ident;
  18853. + uint16_t frags;
  18854. + uint8_t ttl;
  18855. + uint8_t protocol;
  18856. + uint16_t chksum;
  18857. + in_addr src;
  18858. + in_addr dest;
  18859. +};
  18860. +
  18861. +extern void build_ip_hdr(unsigned long __destip, int __ttl, int __protocol,
  18862. + int __option_len, int __len, const void * __buf);
  18863. +
  18864. +extern int ip_transmit(int __len, const void * __buf);
  18865. +
  18866. +extern uint16_t ipchksum(const void * __data, unsigned long __length);
  18867. +
  18868. +extern uint16_t add_ipchksums(unsigned long __offset, uint16_t __sum,
  18869. + uint16_t __new);
  18870. +
  18871. +
  18872. +
  18873. +
  18874. +
  18875. +#endif /* _IP_H */
  18876. diff -Naur grub-0.97.orig/netboot/isa.h grub-0.97/netboot/isa.h
  18877. --- grub-0.97.orig/netboot/isa.h 1970-01-01 00:00:00.000000000 +0000
  18878. +++ grub-0.97/netboot/isa.h 2005-08-31 19:03:35.000000000 +0000
  18879. @@ -0,0 +1,27 @@
  18880. +#if !defined(ISA_H) && defined(CONFIG_ISA)
  18881. +#define ISA_H
  18882. +
  18883. +struct dev;
  18884. +
  18885. +#define ISAPNP_VENDOR(a,b,c) (((((a)-'A'+1)&0x3f)<<2)|\
  18886. + ((((b)-'A'+1)&0x18)>>3)|((((b)-'A'+1)&7)<<13)|\
  18887. + ((((c)-'A'+1)&0x1f)<<8))
  18888. +
  18889. +#define GENERIC_ISAPNP_VENDOR ISAPNP_VENDOR('P','N','P')
  18890. +
  18891. +struct isa_driver
  18892. +{
  18893. + int type;
  18894. + const char *name;
  18895. + int (*probe)(struct dev *, unsigned short *);
  18896. + unsigned short *ioaddrs;
  18897. +};
  18898. +
  18899. +#define __isa_driver __attribute__ ((unused,__section__(".drivers.isa")))
  18900. +extern const struct isa_driver isa_drivers[];
  18901. +extern const struct isa_driver isa_drivers_end[];
  18902. +
  18903. +#define ISA_ROM(IMAGE, DESCRIPTION)
  18904. +
  18905. +#endif /* ISA_H */
  18906. +
  18907. diff -Naur grub-0.97.orig/netboot/lance.c grub-0.97/netboot/lance.c
  18908. --- grub-0.97.orig/netboot/lance.c 2003-07-09 11:45:37.000000000 +0000
  18909. +++ grub-0.97/netboot/lance.c 1970-01-01 00:00:00.000000000 +0000
  18910. @@ -1,564 +0,0 @@
  18911. -/**************************************************************************
  18912. -Etherboot - BOOTP/TFTP Bootstrap Program
  18913. -LANCE NIC driver for Etherboot
  18914. -Large portions borrowed from the Linux LANCE driver by Donald Becker
  18915. -Ken Yap, July 1997
  18916. -***************************************************************************/
  18917. -
  18918. -/*
  18919. - * This program is free software; you can redistribute it and/or
  18920. - * modify it under the terms of the GNU General Public License as
  18921. - * published by the Free Software Foundation; either version 2, or (at
  18922. - * your option) any later version.
  18923. - */
  18924. -
  18925. -/* to get some global routines like printf */
  18926. -#include "etherboot.h"
  18927. -/* to get the interface to the body of the program */
  18928. -#include "nic.h"
  18929. -#ifdef INCLUDE_LANCE
  18930. -#include "pci.h"
  18931. -#endif
  18932. -#include "cards.h"
  18933. -
  18934. -/* Offsets from base I/O address */
  18935. -#if defined(INCLUDE_NE2100) || defined(INCLUDE_LANCE)
  18936. -#define LANCE_ETH_ADDR 0x0
  18937. -#define LANCE_DATA 0x10
  18938. -#define LANCE_ADDR 0x12
  18939. -#define LANCE_RESET 0x14
  18940. -#define LANCE_BUS_IF 0x16
  18941. -#define LANCE_TOTAL_SIZE 0x18
  18942. -#endif
  18943. -#ifdef INCLUDE_NI6510
  18944. -#define LANCE_ETH_ADDR 0x8
  18945. -#define LANCE_DATA 0x0
  18946. -#define LANCE_ADDR 0x2
  18947. -#define LANCE_RESET 0x4
  18948. -#define LANCE_BUS_IF 0x6
  18949. -#define LANCE_TOTAL_SIZE 0x10
  18950. -#endif
  18951. -
  18952. -/* lance_poll() now can use multiple Rx buffers to prevent packet loss. Set
  18953. - * Set LANCE_LOG_RX_BUFFERS to 0..7 for 1, 2, 4, 8, 16, 32, 64 or 128 Rx
  18954. - * buffers. Usually 4 (=16 Rx buffers) is a good value. (Andreas Neuhaus)
  18955. - * Decreased to 2 (=4 Rx buffers) (Ken Yap, 20010305) */
  18956. -
  18957. -#define LANCE_LOG_RX_BUFFERS 2 /* Use 2^2=4 Rx buffers */
  18958. -
  18959. -#define RX_RING_SIZE (1 << (LANCE_LOG_RX_BUFFERS))
  18960. -#define RX_RING_MOD_MASK (RX_RING_SIZE - 1)
  18961. -#define RX_RING_LEN_BITS ((LANCE_LOG_RX_BUFFERS) << 29)
  18962. -
  18963. -struct lance_init_block
  18964. -{
  18965. - unsigned short mode;
  18966. - unsigned char phys_addr[ETH_ALEN];
  18967. - unsigned long filter[2];
  18968. - Address rx_ring;
  18969. - Address tx_ring;
  18970. -};
  18971. -
  18972. -struct lance_rx_head
  18973. -{
  18974. - union {
  18975. - Address base;
  18976. - unsigned char addr[4];
  18977. - } u;
  18978. - short buf_length; /* 2s complement */
  18979. - short msg_length;
  18980. -};
  18981. -
  18982. -struct lance_tx_head
  18983. -{
  18984. - union {
  18985. - Address base;
  18986. - unsigned char addr[4];
  18987. - } u;
  18988. - short buf_length; /* 2s complement */
  18989. - short misc;
  18990. -};
  18991. -
  18992. -struct lance_interface
  18993. -{
  18994. - struct lance_init_block init_block;
  18995. - struct lance_rx_head rx_ring[RX_RING_SIZE];
  18996. - struct lance_tx_head tx_ring;
  18997. - unsigned char rbuf[RX_RING_SIZE][ETH_FRAME_LEN+4];
  18998. - unsigned char tbuf[ETH_FRAME_LEN];
  18999. - /*
  19000. - * Do not alter the order of the struct members above;
  19001. - * the hardware depends on the correct alignment.
  19002. - */
  19003. - int rx_idx;
  19004. -};
  19005. -
  19006. -#define LANCE_MUST_PAD 0x00000001
  19007. -#define LANCE_ENABLE_AUTOSELECT 0x00000002
  19008. -#define LANCE_SELECT_PHONELINE 0x00000004
  19009. -#define LANCE_MUST_UNRESET 0x00000008
  19010. -
  19011. -/* A mapping from the chip ID number to the part number and features.
  19012. - These are from the datasheets -- in real life the '970 version
  19013. - reportedly has the same ID as the '965. */
  19014. -static const struct lance_chip_type
  19015. -{
  19016. - int id_number;
  19017. - const char *name;
  19018. - int flags;
  19019. -} chip_table[] = {
  19020. - {0x0000, "LANCE 7990", /* Ancient lance chip. */
  19021. - LANCE_MUST_PAD + LANCE_MUST_UNRESET},
  19022. - {0x0003, "PCnet/ISA 79C960", /* 79C960 PCnet/ISA. */
  19023. - LANCE_ENABLE_AUTOSELECT},
  19024. - {0x2260, "PCnet/ISA+ 79C961", /* 79C961 PCnet/ISA+, Plug-n-Play. */
  19025. - LANCE_ENABLE_AUTOSELECT},
  19026. - {0x2420, "PCnet/PCI 79C970", /* 79C970 or 79C974 PCnet-SCSI, PCI. */
  19027. - LANCE_ENABLE_AUTOSELECT},
  19028. - /* Bug: the PCnet/PCI actually uses the PCnet/VLB ID number, so just call
  19029. - it the PCnet32. */
  19030. - {0x2430, "PCnet32", /* 79C965 PCnet for VL bus. */
  19031. - LANCE_ENABLE_AUTOSELECT},
  19032. - {0x2621, "PCnet/PCI-II 79C970A", /* 79C970A PCInetPCI II. */
  19033. - LANCE_ENABLE_AUTOSELECT},
  19034. - {0x2625, "PCnet-FAST III 79C973", /* 79C973 PCInet-FAST III. */
  19035. - LANCE_ENABLE_AUTOSELECT},
  19036. - {0x2626, "PCnet/HomePNA 79C978",
  19037. - LANCE_ENABLE_AUTOSELECT|LANCE_SELECT_PHONELINE},
  19038. - {0x0, "PCnet (unknown)",
  19039. - LANCE_ENABLE_AUTOSELECT},
  19040. -};
  19041. -
  19042. -/* Define a macro for converting program addresses to real addresses */
  19043. -#undef virt_to_bus
  19044. -#define virt_to_bus(x) ((unsigned long)x)
  19045. -
  19046. -static int chip_version;
  19047. -static int lance_version;
  19048. -static unsigned short ioaddr;
  19049. -#ifndef INCLUDE_LANCE
  19050. -static int dma;
  19051. -#endif
  19052. -static struct lance_interface *lp;
  19053. -
  19054. -/* additional 8 bytes for 8-byte alignment space */
  19055. -#ifdef USE_LOWMEM_BUFFER
  19056. -#define lance ((char *)0x10000 - (sizeof(struct lance_interface)+8))
  19057. -#else
  19058. -static char lance[sizeof(struct lance_interface)+8];
  19059. -#endif
  19060. -
  19061. -#ifndef INCLUDE_LANCE
  19062. -/* DMA defines and helper routines */
  19063. -
  19064. -/* DMA controller registers */
  19065. -#define DMA1_CMD_REG 0x08 /* command register (w) */
  19066. -#define DMA1_STAT_REG 0x08 /* status register (r) */
  19067. -#define DMA1_REQ_REG 0x09 /* request register (w) */
  19068. -#define DMA1_MASK_REG 0x0A /* single-channel mask (w) */
  19069. -#define DMA1_MODE_REG 0x0B /* mode register (w) */
  19070. -#define DMA1_CLEAR_FF_REG 0x0C /* clear pointer flip-flop (w) */
  19071. -#define DMA1_TEMP_REG 0x0D /* Temporary Register (r) */
  19072. -#define DMA1_RESET_REG 0x0D /* Master Clear (w) */
  19073. -#define DMA1_CLR_MASK_REG 0x0E /* Clear Mask */
  19074. -#define DMA1_MASK_ALL_REG 0x0F /* all-channels mask (w) */
  19075. -
  19076. -#define DMA2_CMD_REG 0xD0 /* command register (w) */
  19077. -#define DMA2_STAT_REG 0xD0 /* status register (r) */
  19078. -#define DMA2_REQ_REG 0xD2 /* request register (w) */
  19079. -#define DMA2_MASK_REG 0xD4 /* single-channel mask (w) */
  19080. -#define DMA2_MODE_REG 0xD6 /* mode register (w) */
  19081. -#define DMA2_CLEAR_FF_REG 0xD8 /* clear pointer flip-flop (w) */
  19082. -#define DMA2_TEMP_REG 0xDA /* Temporary Register (r) */
  19083. -#define DMA2_RESET_REG 0xDA /* Master Clear (w) */
  19084. -#define DMA2_CLR_MASK_REG 0xDC /* Clear Mask */
  19085. -#define DMA2_MASK_ALL_REG 0xDE /* all-channels mask (w) */
  19086. -
  19087. -
  19088. -#define DMA_MODE_READ 0x44 /* I/O to memory, no autoinit, increment, single mode */
  19089. -#define DMA_MODE_WRITE 0x48 /* memory to I/O, no autoinit, increment, single mode */
  19090. -#define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */
  19091. -
  19092. -/* enable/disable a specific DMA channel */
  19093. -static void enable_dma(unsigned int dmanr)
  19094. -{
  19095. - if (dmanr <= 3)
  19096. - outb_p(dmanr, DMA1_MASK_REG);
  19097. - else
  19098. - outb_p(dmanr & 3, DMA2_MASK_REG);
  19099. -}
  19100. -
  19101. -static void disable_dma(unsigned int dmanr)
  19102. -{
  19103. - if (dmanr <= 3)
  19104. - outb_p(dmanr | 4, DMA1_MASK_REG);
  19105. - else
  19106. - outb_p((dmanr & 3) | 4, DMA2_MASK_REG);
  19107. -}
  19108. -
  19109. -/* set mode (above) for a specific DMA channel */
  19110. -static void set_dma_mode(unsigned int dmanr, char mode)
  19111. -{
  19112. - if (dmanr <= 3)
  19113. - outb_p(mode | dmanr, DMA1_MODE_REG);
  19114. - else
  19115. - outb_p(mode | (dmanr&3), DMA2_MODE_REG);
  19116. -}
  19117. -#endif /* !INCLUDE_LANCE */
  19118. -
  19119. -/**************************************************************************
  19120. -RESET - Reset adapter
  19121. -***************************************************************************/
  19122. -static void lance_reset(struct nic *nic)
  19123. -{
  19124. - int i;
  19125. - Address l;
  19126. -
  19127. - /* Reset the LANCE */
  19128. - (void)inw(ioaddr+LANCE_RESET);
  19129. - /* Un-Reset the LANCE, needed only for the NE2100 */
  19130. - if (chip_table[lance_version].flags & LANCE_MUST_UNRESET)
  19131. - outw(0, ioaddr+LANCE_RESET);
  19132. - if (chip_table[lance_version].flags & LANCE_ENABLE_AUTOSELECT)
  19133. - {
  19134. - /* This is 79C960 specific; Turn on auto-select of media
  19135. - (AUI, BNC). */
  19136. - outw(0x2, ioaddr+LANCE_ADDR);
  19137. - /* Don't touch 10base2 power bit. */
  19138. - outw(inw(ioaddr+LANCE_BUS_IF) | 0x2, ioaddr+LANCE_BUS_IF);
  19139. - }
  19140. - /* HomePNA cards need to explicitly pick the phoneline interface.
  19141. - * Some of these cards have ethernet interfaces as well, this
  19142. - * code might require some modification for those.
  19143. - */
  19144. - if (chip_table[lance_version].flags & LANCE_SELECT_PHONELINE) {
  19145. - short media, check ;
  19146. - /* this is specific to HomePNA cards... */
  19147. - outw(49, ioaddr+0x12) ;
  19148. - media = inw(ioaddr+0x16) ;
  19149. -#ifdef DEBUG
  19150. - printf("media was %d\n", media) ;
  19151. -#endif
  19152. - media &= ~3 ;
  19153. - media |= 1 ;
  19154. -#ifdef DEBUG
  19155. - printf("media changed to %d\n", media) ;
  19156. -#endif
  19157. - media &= ~3 ;
  19158. - media |= 1 ;
  19159. - outw(49, ioaddr+0x12) ;
  19160. - outw(media, ioaddr+0x16) ;
  19161. - outw(49, ioaddr+0x12) ;
  19162. - check = inw(ioaddr+0x16) ;
  19163. -#ifdef DEBUG
  19164. - printf("check %s, media was set properly\n",
  19165. - check == media ? "passed" : "FAILED" ) ;
  19166. -#endif
  19167. - }
  19168. -
  19169. - /* Re-initialise the LANCE, and start it when done. */
  19170. - /* Set station address */
  19171. - for (i = 0; i < ETH_ALEN; ++i)
  19172. - lp->init_block.phys_addr[i] = nic->node_addr[i];
  19173. - /* Preset the receive ring headers */
  19174. - for (i=0; i<RX_RING_SIZE; i++) {
  19175. - lp->rx_ring[i].buf_length = -ETH_FRAME_LEN-4;
  19176. - /* OWN */
  19177. - lp->rx_ring[i].u.base = virt_to_bus(lp->rbuf[i]) & 0xffffff;
  19178. - /* we set the top byte as the very last thing */
  19179. - lp->rx_ring[i].u.addr[3] = 0x80;
  19180. - }
  19181. - lp->rx_idx = 0;
  19182. - lp->init_block.mode = 0x0; /* enable Rx and Tx */
  19183. - l = (Address)virt_to_bus(&lp->init_block);
  19184. - outw(0x1, ioaddr+LANCE_ADDR);
  19185. - (void)inw(ioaddr+LANCE_ADDR);
  19186. - outw((short)l, ioaddr+LANCE_DATA);
  19187. - outw(0x2, ioaddr+LANCE_ADDR);
  19188. - (void)inw(ioaddr+LANCE_ADDR);
  19189. - outw((short)(l >> 16), ioaddr+LANCE_DATA);
  19190. - outw(0x4, ioaddr+LANCE_ADDR);
  19191. - (void)inw(ioaddr+LANCE_ADDR);
  19192. - outw(0x915, ioaddr+LANCE_DATA);
  19193. - outw(0x0, ioaddr+LANCE_ADDR);
  19194. - (void)inw(ioaddr+LANCE_ADDR);
  19195. - outw(0x4, ioaddr+LANCE_DATA); /* stop */
  19196. - outw(0x1, ioaddr+LANCE_DATA); /* init */
  19197. - for (i = 10000; i > 0; --i)
  19198. - if (inw(ioaddr+LANCE_DATA) & 0x100)
  19199. - break;
  19200. -#ifdef DEBUG
  19201. - if (i <= 0)
  19202. - printf("Init timed out\n");
  19203. -#endif
  19204. - /* Apparently clearing the InitDone bit here triggers a bug
  19205. - in the '974. (Mark Stockton) */
  19206. - outw(0x2, ioaddr+LANCE_DATA); /* start */
  19207. -}
  19208. -
  19209. -/**************************************************************************
  19210. -POLL - Wait for a frame
  19211. -***************************************************************************/
  19212. -static int lance_poll(struct nic *nic)
  19213. -{
  19214. - int status;
  19215. -
  19216. - status = lp->rx_ring[lp->rx_idx].u.base >> 24;
  19217. - if (status & 0x80)
  19218. - return (0);
  19219. -#ifdef DEBUG
  19220. - printf("LANCE packet received rx_ring.u.base %X mcnt %hX csr0 %hX\n",
  19221. - lp->rx_ring[lp->rx_idx].u.base, lp->rx_ring[lp->rx_idx].msg_length,
  19222. - inw(ioaddr+LANCE_DATA));
  19223. -#endif
  19224. - if (status == 0x3)
  19225. - memcpy(nic->packet, lp->rbuf[lp->rx_idx], nic->packetlen = lp->rx_ring[lp->rx_idx].msg_length);
  19226. - /* Andrew Boyd of QNX reports that some revs of the 79C765
  19227. - clear the buffer length */
  19228. - lp->rx_ring[lp->rx_idx].buf_length = -ETH_FRAME_LEN-4;
  19229. - lp->rx_ring[lp->rx_idx].u.addr[3] |= 0x80; /* prime for next receive */
  19230. -
  19231. - /* I'm not sure if the following is still ok with multiple Rx buffers, but it works */
  19232. - outw(0x0, ioaddr+LANCE_ADDR);
  19233. - (void)inw(ioaddr+LANCE_ADDR);
  19234. - outw(0x500, ioaddr+LANCE_DATA); /* clear receive + InitDone */
  19235. -
  19236. - /* Switch to the next Rx ring buffer */
  19237. - lp->rx_idx = (lp->rx_idx + 1) & RX_RING_MOD_MASK;
  19238. -
  19239. - return (status == 0x3);
  19240. -}
  19241. -
  19242. -/**************************************************************************
  19243. -TRANSMIT - Transmit a frame
  19244. -***************************************************************************/
  19245. -static void lance_transmit(
  19246. - struct nic *nic,
  19247. - const char *d, /* Destination */
  19248. - unsigned int t, /* Type */
  19249. - unsigned int s, /* size */
  19250. - const char *p) /* Packet */
  19251. -{
  19252. - unsigned long time;
  19253. -
  19254. - /* copy the packet to ring buffer */
  19255. - memcpy(lp->tbuf, d, ETH_ALEN); /* dst */
  19256. - memcpy(&lp->tbuf[ETH_ALEN], nic->node_addr, ETH_ALEN); /* src */
  19257. - lp->tbuf[ETH_ALEN+ETH_ALEN] = t >> 8; /* type */
  19258. - lp->tbuf[ETH_ALEN+ETH_ALEN+1] = t; /* type */
  19259. - memcpy(&lp->tbuf[ETH_HLEN], p, s);
  19260. - s += ETH_HLEN;
  19261. - if (chip_table[chip_version].flags & LANCE_MUST_PAD)
  19262. - while (s < ETH_ZLEN) /* pad to min length */
  19263. - lp->tbuf[s++] = 0;
  19264. - lp->tx_ring.buf_length = -s;
  19265. - lp->tx_ring.misc = 0x0;
  19266. - /* OWN, STP, ENP */
  19267. - lp->tx_ring.u.base = virt_to_bus(lp->tbuf) & 0xffffff;
  19268. - /* we set the top byte as the very last thing */
  19269. - lp->tx_ring.u.addr[3] = 0x83;
  19270. - /* Trigger an immediate send poll */
  19271. - outw(0x0, ioaddr+LANCE_ADDR);
  19272. - (void)inw(ioaddr+LANCE_ADDR); /* as in the datasheets... */
  19273. - /* Klaus Espenlaub: the value below was 0x48, but that enabled the
  19274. - * interrupt line, causing a hang if for some reasone the interrupt
  19275. - * controller had the LANCE interrupt enabled. I have no idea why
  19276. - * nobody ran into this before... */
  19277. - outw(0x08, ioaddr+LANCE_DATA);
  19278. - /* wait for transmit complete */
  19279. - time = currticks() + TICKS_PER_SEC; /* wait one second */
  19280. - while (currticks() < time && (lp->tx_ring.u.base & 0x80000000) != 0)
  19281. - ;
  19282. - if ((lp->tx_ring.u.base & 0x80000000) != 0)
  19283. - printf("LANCE timed out on transmit\n");
  19284. - (void)inw(ioaddr+LANCE_ADDR);
  19285. - outw(0x200, ioaddr+LANCE_DATA); /* clear transmit + InitDone */
  19286. -#ifdef DEBUG
  19287. - printf("tx_ring.u.base %X tx_ring.buf_length %hX tx_ring.misc %hX csr0 %hX\n",
  19288. - lp->tx_ring.u.base, lp->tx_ring.buf_length, lp->tx_ring.misc,
  19289. - inw(ioaddr+LANCE_DATA));
  19290. -#endif
  19291. -}
  19292. -
  19293. -static void lance_disable(struct nic *nic)
  19294. -{
  19295. - (void)inw(ioaddr+LANCE_RESET);
  19296. - if (chip_table[lance_version].flags & LANCE_MUST_UNRESET)
  19297. - outw(0, ioaddr+LANCE_RESET);
  19298. -
  19299. - outw(0, ioaddr+LANCE_ADDR);
  19300. - outw(0x0004, ioaddr+LANCE_DATA); /* stop the LANCE */
  19301. -
  19302. -#ifndef INCLUDE_LANCE
  19303. - disable_dma(dma);
  19304. -#endif
  19305. -}
  19306. -
  19307. -#ifdef INCLUDE_LANCE
  19308. -static int lance_probe1(struct nic *nic, struct pci_device *pci)
  19309. -#else
  19310. -static int lance_probe1(struct nic *nic)
  19311. -#endif
  19312. -{
  19313. - int reset_val ;
  19314. - unsigned int i;
  19315. - Address l;
  19316. - short dma_channels;
  19317. -#ifndef INCLUDE_LANCE
  19318. - static const char dmas[] = { 5, 6, 7, 3 };
  19319. -#endif
  19320. -
  19321. - reset_val = inw(ioaddr+LANCE_RESET);
  19322. - outw(reset_val, ioaddr+LANCE_RESET);
  19323. -#if 1 /* Klaus Espenlaub -- was #ifdef INCLUDE_NE2100*/
  19324. - outw(0x0, ioaddr+LANCE_ADDR); /* Switch to window 0 */
  19325. - if (inw(ioaddr+LANCE_DATA) != 0x4)
  19326. - return (-1);
  19327. -#endif
  19328. - outw(88, ioaddr+LANCE_ADDR); /* Get the version of the chip */
  19329. - if (inw(ioaddr+LANCE_ADDR) != 88)
  19330. - lance_version = 0;
  19331. - else
  19332. - {
  19333. - chip_version = inw(ioaddr+LANCE_DATA);
  19334. - outw(89, ioaddr+LANCE_ADDR);
  19335. - chip_version |= inw(ioaddr+LANCE_DATA) << 16;
  19336. - if ((chip_version & 0xfff) != 0x3)
  19337. - return (-1);
  19338. - chip_version = (chip_version >> 12) & 0xffff;
  19339. - for (lance_version = 1; chip_table[lance_version].id_number != 0; ++lance_version)
  19340. - if (chip_table[lance_version].id_number == chip_version)
  19341. - break;
  19342. - }
  19343. - /* make sure data structure is 8-byte aligned */
  19344. - l = ((Address)lance + 7) & ~7;
  19345. - lp = (struct lance_interface *)l;
  19346. - lp->init_block.mode = 0x3; /* disable Rx and Tx */
  19347. - lp->init_block.filter[0] = lp->init_block.filter[1] = 0x0;
  19348. - /* using multiple Rx buffer and a single Tx buffer */
  19349. - lp->init_block.rx_ring = (virt_to_bus(&lp->rx_ring) & 0xffffff) | RX_RING_LEN_BITS;
  19350. - lp->init_block.tx_ring = virt_to_bus(&lp->tx_ring) & 0xffffff;
  19351. - l = virt_to_bus(&lp->init_block);
  19352. - outw(0x1, ioaddr+LANCE_ADDR);
  19353. - (void)inw(ioaddr+LANCE_ADDR);
  19354. - outw((unsigned short)l, ioaddr+LANCE_DATA);
  19355. - outw(0x2, ioaddr+LANCE_ADDR);
  19356. - (void)inw(ioaddr+LANCE_ADDR);
  19357. - outw((unsigned short)(l >> 16), ioaddr+LANCE_DATA);
  19358. - outw(0x4, ioaddr+LANCE_ADDR);
  19359. - (void)inw(ioaddr+LANCE_ADDR);
  19360. - outw(0x915, ioaddr+LANCE_DATA);
  19361. - outw(0x0, ioaddr+LANCE_ADDR);
  19362. - (void)inw(ioaddr+LANCE_ADDR);
  19363. - /* Get station address */
  19364. - for (i = 0; i < ETH_ALEN; ++i) {
  19365. - nic->node_addr[i] = inb(ioaddr+LANCE_ETH_ADDR+i);
  19366. - }
  19367. -#ifndef INCLUDE_LANCE
  19368. - /* now probe for DMA channel */
  19369. - dma_channels = ((inb(DMA1_STAT_REG) >> 4) & 0xf) |
  19370. - (inb(DMA2_STAT_REG) & 0xf0);
  19371. - /* need to fix when PCI provides DMA info */
  19372. - for (i = 0; i < (sizeof(dmas)/sizeof(dmas[0])); ++i)
  19373. - {
  19374. - int j;
  19375. -
  19376. - dma = dmas[i];
  19377. - /* Don't enable a permanently busy DMA channel,
  19378. - or the machine will hang */
  19379. - if (dma_channels & (1 << dma))
  19380. - continue;
  19381. - outw(0x7f04, ioaddr+LANCE_DATA); /* clear memory error bits */
  19382. - set_dma_mode(dma, DMA_MODE_CASCADE);
  19383. - enable_dma(dma);
  19384. - outw(0x1, ioaddr+LANCE_DATA); /* init */
  19385. - for (j = 100; j > 0; --j)
  19386. - if (inw(ioaddr+LANCE_DATA) & 0x900)
  19387. - break;
  19388. - if (inw(ioaddr+LANCE_DATA) & 0x100)
  19389. - break;
  19390. - else
  19391. - disable_dma(dma);
  19392. - }
  19393. - if (i >= (sizeof(dmas)/sizeof(dmas[0])))
  19394. - dma = 0;
  19395. - printf("\n%s base %#X, DMA %d, addr %!\n",
  19396. - chip_table[lance_version].name, ioaddr, dma, nic->node_addr);
  19397. -#else
  19398. - printf(" %s base %#hX, addr %!\n", chip_table[lance_version].name, ioaddr, nic->node_addr);
  19399. -#endif
  19400. - if (chip_table[chip_version].flags & LANCE_ENABLE_AUTOSELECT) {
  19401. - /* Turn on auto-select of media (10baseT or BNC) so that the
  19402. - * user watch the LEDs. */
  19403. - outw(0x0002, ioaddr+LANCE_ADDR);
  19404. - /* Don't touch 10base2 power bit. */
  19405. - outw(inw(ioaddr+LANCE_BUS_IF) | 0x0002, ioaddr+LANCE_BUS_IF);
  19406. - }
  19407. - return (lance_version);
  19408. -}
  19409. -
  19410. -/**************************************************************************
  19411. -PROBE - Look for an adapter, this routine's visible to the outside
  19412. -***************************************************************************/
  19413. -
  19414. -#ifdef INCLUDE_LANCE
  19415. -struct nic *lancepci_probe(struct nic *nic, unsigned short *probe_addrs, struct pci_device *pci)
  19416. -#endif
  19417. -#ifdef INCLUDE_NE2100
  19418. -struct nic *ne2100_probe(struct nic *nic, unsigned short *probe_addrs)
  19419. -#endif
  19420. -#ifdef INCLUDE_NI6510
  19421. -struct nic *ni6510_probe(struct nic *nic, unsigned short *probe_addrs)
  19422. -#endif
  19423. -{
  19424. - unsigned short *p;
  19425. -#ifndef INCLUDE_LANCE
  19426. - static unsigned short io_addrs[] = { 0x300, 0x320, 0x340, 0x360, 0 };
  19427. -#endif
  19428. -
  19429. - /* if probe_addrs is 0, then routine can use a hardwired default */
  19430. - if (probe_addrs == 0) {
  19431. -#ifdef INCLUDE_LANCE
  19432. - return 0;
  19433. -#else
  19434. - probe_addrs = io_addrs;
  19435. -#endif
  19436. - }
  19437. - for (p = probe_addrs; (ioaddr = *p) != 0; ++p)
  19438. - {
  19439. - char offset15, offset14 = inb(ioaddr + 14);
  19440. - unsigned short pci_cmd;
  19441. -
  19442. -#ifdef INCLUDE_NE2100
  19443. - if ((offset14 == 0x52 || offset14 == 0x57) &&
  19444. - ((offset15 = inb(ioaddr + 15)) == 0x57 || offset15 == 0x44))
  19445. - if (lance_probe1(nic) >= 0)
  19446. - break;
  19447. -#endif
  19448. -#ifdef INCLUDE_NI6510
  19449. - if ((offset14 == 0x00 || offset14 == 0x52) &&
  19450. - ((offset15 = inb(ioaddr + 15)) == 0x55 || offset15 == 0x44))
  19451. - if (lance_probe1(nic) >= 0)
  19452. - break;
  19453. -#endif
  19454. -#ifdef INCLUDE_LANCE
  19455. - adjust_pci_device(pci);
  19456. - if (lance_probe1(nic, pci) >= 0)
  19457. - break;
  19458. -#endif
  19459. - }
  19460. - /* if board found */
  19461. - if (ioaddr != 0)
  19462. - {
  19463. - /* point to NIC specific routines */
  19464. - lance_reset(nic);
  19465. - nic->reset = lance_reset;
  19466. - nic->poll = lance_poll;
  19467. - nic->transmit = lance_transmit;
  19468. - nic->disable = lance_disable;
  19469. - return nic;
  19470. - }
  19471. -
  19472. - /* no board found */
  19473. - return 0;
  19474. -}
  19475. diff -Naur grub-0.97.orig/netboot/latch.h grub-0.97/netboot/latch.h
  19476. --- grub-0.97.orig/netboot/latch.h 1970-01-01 00:00:00.000000000 +0000
  19477. +++ grub-0.97/netboot/latch.h 2005-08-31 19:03:35.000000000 +0000
  19478. @@ -0,0 +1,10 @@
  19479. +#ifndef LATCH_H
  19480. +#define LATCH_H
  19481. +
  19482. +#define TICKS_PER_SEC 18
  19483. +
  19484. +/* For different calibrators of the TSC move the declaration of
  19485. + * sleep_latch and the definitions of it's length here...
  19486. + */
  19487. +
  19488. +#endif /* LATCH_H */
  19489. diff -Naur grub-0.97.orig/netboot/linux-asm-io.h grub-0.97/netboot/linux-asm-io.h
  19490. --- grub-0.97.orig/netboot/linux-asm-io.h 2003-07-09 11:45:37.000000000 +0000
  19491. +++ grub-0.97/netboot/linux-asm-io.h 1970-01-01 00:00:00.000000000 +0000
  19492. @@ -1,187 +0,0 @@
  19493. -#ifndef _ASM_IO_H
  19494. -#define _ASM_IO_H
  19495. -
  19496. -/*
  19497. - * This file contains the definitions for the x86 IO instructions
  19498. - * inb/inw/inl/outb/outw/outl and the "string versions" of the same
  19499. - * (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing"
  19500. - * versions of the single-IO instructions (inb_p/inw_p/..).
  19501. - *
  19502. - * This file is not meant to be obfuscating: it's just complicated
  19503. - * to (a) handle it all in a way that makes gcc able to optimize it
  19504. - * as well as possible and (b) trying to avoid writing the same thing
  19505. - * over and over again with slight variations and possibly making a
  19506. - * mistake somewhere.
  19507. - */
  19508. -
  19509. -/*
  19510. - * Thanks to James van Artsdalen for a better timing-fix than
  19511. - * the two short jumps: using outb's to a nonexistent port seems
  19512. - * to guarantee better timings even on fast machines.
  19513. - *
  19514. - * On the other hand, I'd like to be sure of a non-existent port:
  19515. - * I feel a bit unsafe about using 0x80 (should be safe, though)
  19516. - *
  19517. - * Linus
  19518. - */
  19519. -
  19520. -#ifdef SLOW_IO_BY_JUMPING
  19521. -#define __SLOW_DOWN_IO __asm__ __volatile__("jmp 1f\n1:\tjmp 1f\n1:")
  19522. -#else
  19523. -#define __SLOW_DOWN_IO __asm__ __volatile__("outb %al,$0x80")
  19524. -#endif
  19525. -
  19526. -#ifdef REALLY_SLOW_IO
  19527. -#define SLOW_DOWN_IO { __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; }
  19528. -#else
  19529. -#define SLOW_DOWN_IO __SLOW_DOWN_IO
  19530. -#endif
  19531. -
  19532. -/*
  19533. - * readX/writeX() are used to access memory mapped devices. On some
  19534. - * architectures the memory mapped IO stuff needs to be accessed
  19535. - * differently. On the x86 architecture, we just read/write the
  19536. - * memory location directly.
  19537. - */
  19538. -#define readb(addr) (*(volatile unsigned char *) (addr))
  19539. -#define readw(addr) (*(volatile unsigned short *) (addr))
  19540. -#define readl(addr) (*(volatile unsigned int *) (addr))
  19541. -
  19542. -#define writeb(b,addr) ((*(volatile unsigned char *) (addr)) = (b))
  19543. -#define writew(b,addr) ((*(volatile unsigned short *) (addr)) = (b))
  19544. -#define writel(b,addr) ((*(volatile unsigned int *) (addr)) = (b))
  19545. -
  19546. -#define memset_io(a,b,c) memset((void *)(a),(b),(c))
  19547. -#define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c))
  19548. -#define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c))
  19549. -
  19550. -/*
  19551. - * Again, i386 does not require mem IO specific function.
  19552. - */
  19553. -
  19554. -#define eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(void *)(b),(c),(d))
  19555. -
  19556. -/*
  19557. - * Talk about misusing macros..
  19558. - */
  19559. -
  19560. -#define __OUT1(s,x) \
  19561. -extern void __out##s(unsigned x value, unsigned short port); \
  19562. -extern inline void __out##s(unsigned x value, unsigned short port) {
  19563. -
  19564. -#define __OUT2(s,s1,s2) \
  19565. -__asm__ __volatile__ ("out" #s " %" s1 "0,%" s2 "1"
  19566. -
  19567. -#define __OUT(s,s1,x) \
  19568. -__OUT1(s,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); } \
  19569. -__OUT1(s##c,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); } \
  19570. -__OUT1(s##_p,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); SLOW_DOWN_IO; } \
  19571. -__OUT1(s##c_p,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); SLOW_DOWN_IO; }
  19572. -
  19573. -#define __IN1(s,x) \
  19574. -extern unsigned x __in##s(unsigned short port); \
  19575. -extern inline unsigned x __in##s(unsigned short port) { unsigned x _v;
  19576. -
  19577. -#define __IN2(s,s1,s2) \
  19578. -__asm__ __volatile__ ("in" #s " %" s2 "1,%" s1 "0"
  19579. -
  19580. -#define __IN(s,s1,x,i...) \
  19581. -__IN1(s,x) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); return _v; } \
  19582. -__IN1(s##c,x) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); return _v; } \
  19583. -__IN1(s##_p,x) __IN2(s,s1,"w") : "=a" (_v) : "d" (port) ,##i ); SLOW_DOWN_IO; return _v; } \
  19584. -__IN1(s##c_p,x) __IN2(s,s1,"") : "=a" (_v) : "id" (port) ,##i ); SLOW_DOWN_IO; return _v; }
  19585. -
  19586. -#define __INS(s) \
  19587. -extern void ins##s(unsigned short port, void * addr, unsigned long count); \
  19588. -extern inline void ins##s(unsigned short port, void * addr, unsigned long count) \
  19589. -{ __asm__ __volatile__ ("cld ; rep ; ins" #s \
  19590. -: "=D" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
  19591. -
  19592. -#define __OUTS(s) \
  19593. -extern void outs##s(unsigned short port, const void * addr, unsigned long count); \
  19594. -extern inline void outs##s(unsigned short port, const void * addr, unsigned long count) \
  19595. -{ __asm__ __volatile__ ("cld ; rep ; outs" #s \
  19596. -: "=S" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }
  19597. -
  19598. -__IN(b,"", char)
  19599. -__IN(w,"",short)
  19600. -__IN(l,"", long)
  19601. -
  19602. -__OUT(b,"b",char)
  19603. -__OUT(w,"w",short)
  19604. -__OUT(l,,int)
  19605. -
  19606. -__INS(b)
  19607. -__INS(w)
  19608. -__INS(l)
  19609. -
  19610. -__OUTS(b)
  19611. -__OUTS(w)
  19612. -__OUTS(l)
  19613. -
  19614. -/*
  19615. - * Note that due to the way __builtin_constant_p() works, you
  19616. - * - can't use it inside a inline function (it will never be true)
  19617. - * - you don't have to worry about side effects within the __builtin..
  19618. - */
  19619. -#define outb(val,port) \
  19620. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19621. - __outbc((val),(port)) : \
  19622. - __outb((val),(port)))
  19623. -
  19624. -#define inb(port) \
  19625. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19626. - __inbc(port) : \
  19627. - __inb(port))
  19628. -
  19629. -#define outb_p(val,port) \
  19630. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19631. - __outbc_p((val),(port)) : \
  19632. - __outb_p((val),(port)))
  19633. -
  19634. -#define inb_p(port) \
  19635. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19636. - __inbc_p(port) : \
  19637. - __inb_p(port))
  19638. -
  19639. -#define outw(val,port) \
  19640. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19641. - __outwc((val),(port)) : \
  19642. - __outw((val),(port)))
  19643. -
  19644. -#define inw(port) \
  19645. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19646. - __inwc(port) : \
  19647. - __inw(port))
  19648. -
  19649. -#define outw_p(val,port) \
  19650. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19651. - __outwc_p((val),(port)) : \
  19652. - __outw_p((val),(port)))
  19653. -
  19654. -#define inw_p(port) \
  19655. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19656. - __inwc_p(port) : \
  19657. - __inw_p(port))
  19658. -
  19659. -#define outl(val,port) \
  19660. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19661. - __outlc((val),(port)) : \
  19662. - __outl((val),(port)))
  19663. -
  19664. -#define inl(port) \
  19665. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19666. - __inlc(port) : \
  19667. - __inl(port))
  19668. -
  19669. -#define outl_p(val,port) \
  19670. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19671. - __outlc_p((val),(port)) : \
  19672. - __outl_p((val),(port)))
  19673. -
  19674. -#define inl_p(port) \
  19675. -((__builtin_constant_p((port)) && (port) < 256) ? \
  19676. - __inlc_p(port) : \
  19677. - __inl_p(port))
  19678. -
  19679. -#endif
  19680. diff -Naur grub-0.97.orig/netboot/linux-asm-string.h grub-0.97/netboot/linux-asm-string.h
  19681. --- grub-0.97.orig/netboot/linux-asm-string.h 2003-07-09 11:45:37.000000000 +0000
  19682. +++ grub-0.97/netboot/linux-asm-string.h 1970-01-01 00:00:00.000000000 +0000
  19683. @@ -1,291 +0,0 @@
  19684. -/*
  19685. - * Taken from Linux /usr/include/asm/string.h
  19686. - * All except memcpy, memmove, memset and memcmp removed.
  19687. - */
  19688. -
  19689. -#ifndef _I386_STRING_H_
  19690. -#define _I386_STRING_H_
  19691. -
  19692. -/*
  19693. - * This string-include defines all string functions as inline
  19694. - * functions. Use gcc. It also assumes ds=es=data space, this should be
  19695. - * normal. Most of the string-functions are rather heavily hand-optimized,
  19696. - * see especially strtok,strstr,str[c]spn. They should work, but are not
  19697. - * very easy to understand. Everything is done entirely within the register
  19698. - * set, making the functions fast and clean. String instructions have been
  19699. - * used through-out, making for "slightly" unclear code :-)
  19700. - *
  19701. - * NO Copyright (C) 1991, 1992 Linus Torvalds,
  19702. - * consider these trivial functions to be PD.
  19703. - */
  19704. -
  19705. -typedef int size_t;
  19706. -
  19707. -extern void *__memcpy(void * to, const void * from, size_t n);
  19708. -extern void *__constant_memcpy(void * to, const void * from, size_t n);
  19709. -extern void *memmove(void * dest,const void * src, size_t n);
  19710. -extern void *__memset_generic(void * s, char c,size_t count);
  19711. -extern void *__constant_c_memset(void * s, unsigned long c, size_t count);
  19712. -extern void *__constant_c_and_count_memset(void * s, unsigned long pattern, size_t count);
  19713. -
  19714. -
  19715. -extern inline void * __memcpy(void * to, const void * from, size_t n)
  19716. -{
  19717. -int d0, d1, d2;
  19718. -__asm__ __volatile__(
  19719. - "cld\n\t"
  19720. - "rep ; movsl\n\t"
  19721. - "testb $2,%b4\n\t"
  19722. - "je 1f\n\t"
  19723. - "movsw\n"
  19724. - "1:\ttestb $1,%b4\n\t"
  19725. - "je 2f\n\t"
  19726. - "movsb\n"
  19727. - "2:"
  19728. - : "=&c" (d0), "=&D" (d1), "=&S" (d2)
  19729. - :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
  19730. - : "memory");
  19731. -return (to);
  19732. -}
  19733. -
  19734. -/*
  19735. - * This looks horribly ugly, but the compiler can optimize it totally,
  19736. - * as the count is constant.
  19737. - */
  19738. -extern inline void * __constant_memcpy(void * to, const void * from, size_t n)
  19739. -{
  19740. - switch (n) {
  19741. - case 0:
  19742. - return to;
  19743. - case 1:
  19744. - *(unsigned char *)to = *(const unsigned char *)from;
  19745. - return to;
  19746. - case 2:
  19747. - *(unsigned short *)to = *(const unsigned short *)from;
  19748. - return to;
  19749. - case 3:
  19750. - *(unsigned short *)to = *(const unsigned short *)from;
  19751. - *(2+(unsigned char *)to) = *(2+(const unsigned char *)from);
  19752. - return to;
  19753. - case 4:
  19754. - *(unsigned long *)to = *(const unsigned long *)from;
  19755. - return to;
  19756. - case 6: /* for Ethernet addresses */
  19757. - *(unsigned long *)to = *(const unsigned long *)from;
  19758. - *(2+(unsigned short *)to) = *(2+(const unsigned short *)from);
  19759. - return to;
  19760. - case 8:
  19761. - *(unsigned long *)to = *(const unsigned long *)from;
  19762. - *(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
  19763. - return to;
  19764. - case 12:
  19765. - *(unsigned long *)to = *(const unsigned long *)from;
  19766. - *(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
  19767. - *(2+(unsigned long *)to) = *(2+(const unsigned long *)from);
  19768. - return to;
  19769. - case 16:
  19770. - *(unsigned long *)to = *(const unsigned long *)from;
  19771. - *(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
  19772. - *(2+(unsigned long *)to) = *(2+(const unsigned long *)from);
  19773. - *(3+(unsigned long *)to) = *(3+(const unsigned long *)from);
  19774. - return to;
  19775. - case 20:
  19776. - *(unsigned long *)to = *(const unsigned long *)from;
  19777. - *(1+(unsigned long *)to) = *(1+(const unsigned long *)from);
  19778. - *(2+(unsigned long *)to) = *(2+(const unsigned long *)from);
  19779. - *(3+(unsigned long *)to) = *(3+(const unsigned long *)from);
  19780. - *(4+(unsigned long *)to) = *(4+(const unsigned long *)from);
  19781. - return to;
  19782. - }
  19783. -#define COMMON(x) \
  19784. -__asm__ __volatile__( \
  19785. - "cld\n\t" \
  19786. - "rep ; movsl" \
  19787. - x \
  19788. - : "=&c" (d0), "=&D" (d1), "=&S" (d2) \
  19789. - : "0" (n/4),"1" ((long) to),"2" ((long) from) \
  19790. - : "memory");
  19791. -{
  19792. - int d0, d1, d2;
  19793. - switch (n % 4) {
  19794. - case 0: COMMON(""); return to;
  19795. - case 1: COMMON("\n\tmovsb"); return to;
  19796. - case 2: COMMON("\n\tmovsw"); return to;
  19797. - default: COMMON("\n\tmovsw\n\tmovsb"); return to;
  19798. - }
  19799. -}
  19800. -
  19801. -#undef COMMON
  19802. -}
  19803. -
  19804. -#define __HAVE_ARCH_MEMCPY
  19805. -#define memcpy(t, f, n) \
  19806. -(__builtin_constant_p(n) ? \
  19807. - __constant_memcpy((t),(f),(n)) : \
  19808. - __memcpy((t),(f),(n)))
  19809. -
  19810. -#define __HAVE_ARCH_MEMMOVE
  19811. -extern inline void * memmove(void * dest,const void * src, size_t n)
  19812. -{
  19813. -int d0, d1, d2;
  19814. -if (dest<src)
  19815. -__asm__ __volatile__(
  19816. - "cld\n\t"
  19817. - "rep\n\t"
  19818. - "movsb"
  19819. - : "=&c" (d0), "=&S" (d1), "=&D" (d2)
  19820. - :"0" (n),"1" (src),"2" (dest)
  19821. - : "memory");
  19822. -else
  19823. -__asm__ __volatile__(
  19824. - "std\n\t"
  19825. - "rep\n\t"
  19826. - "movsb\n\t"
  19827. - "cld"
  19828. - : "=&c" (d0), "=&S" (d1), "=&D" (d2)
  19829. - :"0" (n),
  19830. - "1" (n-1+(const char *)src),
  19831. - "2" (n-1+(char *)dest)
  19832. - :"memory");
  19833. -return dest;
  19834. -}
  19835. -
  19836. -#define memcmp __builtin_memcmp
  19837. -
  19838. -extern inline void * __memset_generic(void * s, char c,size_t count)
  19839. -{
  19840. -int d0, d1;
  19841. -__asm__ __volatile__(
  19842. - "cld\n\t"
  19843. - "rep\n\t"
  19844. - "stosb"
  19845. - : "=&c" (d0), "=&D" (d1)
  19846. - :"a" (c),"1" (s),"0" (count)
  19847. - :"memory");
  19848. -return s;
  19849. -}
  19850. -
  19851. -/* we might want to write optimized versions of these later */
  19852. -#define __constant_count_memset(s,c,count) __memset_generic((s),(c),(count))
  19853. -
  19854. -/*
  19855. - * memset(x,0,y) is a reasonably common thing to do, so we want to fill
  19856. - * things 32 bits at a time even when we don't know the size of the
  19857. - * area at compile-time..
  19858. - */
  19859. -extern inline void * __constant_c_memset(void * s, unsigned long c, size_t count)
  19860. -{
  19861. -int d0, d1;
  19862. -__asm__ __volatile__(
  19863. - "cld\n\t"
  19864. - "rep ; stosl\n\t"
  19865. - "testb $2,%b3\n\t"
  19866. - "je 1f\n\t"
  19867. - "stosw\n"
  19868. - "1:\ttestb $1,%b3\n\t"
  19869. - "je 2f\n\t"
  19870. - "stosb\n"
  19871. - "2:"
  19872. - : "=&c" (d0), "=&D" (d1)
  19873. - :"a" (c), "q" (count), "0" (count/4), "1" ((long) s)
  19874. - :"memory");
  19875. -return (s);
  19876. -}
  19877. -
  19878. -/*
  19879. - * This looks horribly ugly, but the compiler can optimize it totally,
  19880. - * as we by now know that both pattern and count is constant..
  19881. - */
  19882. -extern inline void * __constant_c_and_count_memset(void * s, unsigned long pattern, size_t count)
  19883. -{
  19884. - switch (count) {
  19885. - case 0:
  19886. - return s;
  19887. - case 1:
  19888. - *(unsigned char *)s = pattern;
  19889. - return s;
  19890. - case 2:
  19891. - *(unsigned short *)s = pattern;
  19892. - return s;
  19893. - case 3:
  19894. - *(unsigned short *)s = pattern;
  19895. - *(2+(unsigned char *)s) = pattern;
  19896. - return s;
  19897. - case 4:
  19898. - *(unsigned long *)s = pattern;
  19899. - return s;
  19900. - }
  19901. -#define COMMON(x) \
  19902. -__asm__ __volatile__("cld\n\t" \
  19903. - "rep ; stosl" \
  19904. - x \
  19905. - : "=&c" (d0), "=&D" (d1) \
  19906. - : "a" (pattern),"0" (count/4),"1" ((long) s) \
  19907. - : "memory")
  19908. -{
  19909. - int d0, d1;
  19910. - switch (count % 4) {
  19911. - case 0: COMMON(""); return s;
  19912. - case 1: COMMON("\n\tstosb"); return s;
  19913. - case 2: COMMON("\n\tstosw"); return s;
  19914. - default: COMMON("\n\tstosw\n\tstosb"); return s;
  19915. - }
  19916. -}
  19917. -
  19918. -#undef COMMON
  19919. -}
  19920. -
  19921. -#define __constant_c_x_memset(s, c, count) \
  19922. -(__builtin_constant_p(count) ? \
  19923. - __constant_c_and_count_memset((s),(c),(count)) : \
  19924. - __constant_c_memset((s),(c),(count)))
  19925. -
  19926. -#define __memset(s, c, count) \
  19927. -(__builtin_constant_p(count) ? \
  19928. - __constant_count_memset((s),(c),(count)) : \
  19929. - __memset_generic((s),(c),(count)))
  19930. -
  19931. -#define __HAVE_ARCH_MEMSET
  19932. -#define memset(s, c, count) \
  19933. -(__builtin_constant_p(c) ? \
  19934. - __constant_c_x_memset((s),(c),(count)) : \
  19935. - __memset((s),(c),(count)))
  19936. -
  19937. -#define __HAVE_ARCH_STRNCMP
  19938. -static inline int strncmp(const char * cs,const char * ct,size_t count)
  19939. -{
  19940. -register int __res;
  19941. -int d0, d1, d2;
  19942. -__asm__ __volatile__(
  19943. - "1:\tdecl %3\n\t"
  19944. - "js 2f\n\t"
  19945. - "lodsb\n\t"
  19946. - "scasb\n\t"
  19947. - "jne 3f\n\t"
  19948. - "testb %%al,%%al\n\t"
  19949. - "jne 1b\n"
  19950. - "2:\txorl %%eax,%%eax\n\t"
  19951. - "jmp 4f\n"
  19952. - "3:\tsbbl %%eax,%%eax\n\t"
  19953. - "orb $1,%%al\n"
  19954. - "4:"
  19955. - :"=a" (__res), "=&S" (d0), "=&D" (d1), "=&c" (d2)
  19956. - :"1" (cs),"2" (ct),"3" (count));
  19957. -return __res;
  19958. -}
  19959. -
  19960. -#define __HAVE_ARCH_STRLEN
  19961. -static inline size_t strlen(const char * s)
  19962. -{
  19963. -int d0;
  19964. -register int __res;
  19965. -__asm__ __volatile__(
  19966. - "repne\n\t"
  19967. - "scasb\n\t"
  19968. - "notl %0\n\t"
  19969. - "decl %0"
  19970. - :"=c" (__res), "=&D" (d0) :"1" (s),"a" (0), "0" (0xffffffff));
  19971. -return __res;
  19972. -}
  19973. -
  19974. -#endif
  19975. diff -Naur grub-0.97.orig/netboot/little_bswap.h grub-0.97/netboot/little_bswap.h
  19976. --- grub-0.97.orig/netboot/little_bswap.h 1970-01-01 00:00:00.000000000 +0000
  19977. +++ grub-0.97/netboot/little_bswap.h 2005-08-31 19:03:35.000000000 +0000
  19978. @@ -0,0 +1,17 @@
  19979. +#ifndef ETHERBOOT_LITTLE_BSWAP_H
  19980. +#define ETHERBOOT_LITTLE_BSWAP_H
  19981. +
  19982. +#define ntohl(x) __bswap_32(x)
  19983. +#define htonl(x) __bswap_32(x)
  19984. +#define ntohs(x) __bswap_16(x)
  19985. +#define htons(x) __bswap_16(x)
  19986. +#define cpu_to_le32(x) (x)
  19987. +#define cpu_to_le16(x) (x)
  19988. +#define cpu_to_be32(x) __bswap_32(x)
  19989. +#define cpu_to_be16(x) __bswap_16(x)
  19990. +#define le32_to_cpu(x) (x)
  19991. +#define le16_to_cpu(x) (x)
  19992. +#define be32_to_cpu(x) __bswap_32(x)
  19993. +#define be16_to_cpu(x) __bswap_16(x)
  19994. +
  19995. +#endif /* ETHERBOOT_LITTLE_BSWAP_H */
  19996. diff -Naur grub-0.97.orig/netboot/main.c grub-0.97/netboot/main.c
  19997. --- grub-0.97.orig/netboot/main.c 2004-05-20 22:19:33.000000000 +0000
  19998. +++ grub-0.97/netboot/main.c 1970-01-01 00:00:00.000000000 +0000
  19999. @@ -1,1171 +0,0 @@
  20000. -/*
  20001. - * GRUB -- GRand Unified Bootloader
  20002. - * Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
  20003. - *
  20004. - * This program is free software; you can redistribute it and/or modify
  20005. - * it under the terms of the GNU General Public License as published by
  20006. - * the Free Software Foundation; either version 2 of the License, or
  20007. - * (at your option) any later version.
  20008. - *
  20009. - * This program is distributed in the hope that it will be useful,
  20010. - * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20011. - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20012. - * GNU General Public License for more details.
  20013. - *
  20014. - * You should have received a copy of the GNU General Public License
  20015. - * along with this program; if not, write to the Free Software
  20016. - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20017. - */
  20018. -
  20019. -/* Based on "src/main.c" in etherboot-5.0.5. */
  20020. -
  20021. -/**************************************************************************
  20022. -ETHERBOOT - BOOTP/TFTP Bootstrap Program
  20023. -
  20024. -Author: Martin Renters
  20025. - Date: Dec/93
  20026. -
  20027. -Literature dealing with the network protocols:
  20028. - ARP - RFC826
  20029. - RARP - RFC903
  20030. - UDP - RFC768
  20031. - BOOTP - RFC951, RFC2132 (vendor extensions)
  20032. - DHCP - RFC2131, RFC2132 (options)
  20033. - TFTP - RFC1350, RFC2347 (options), RFC2348 (blocksize), RFC2349 (tsize)
  20034. - RPC - RFC1831, RFC1832 (XDR), RFC1833 (rpcbind/portmapper)
  20035. - NFS - RFC1094, RFC1813 (v3, useful for clarifications, not implemented)
  20036. -
  20037. -**************************************************************************/
  20038. -
  20039. -#define GRUB 1
  20040. -#include <etherboot.h>
  20041. -#include <nic.h>
  20042. -
  20043. -/* #define DEBUG 1 */
  20044. -
  20045. -struct arptable_t arptable[MAX_ARP];
  20046. -
  20047. -/* Set if the user pushes Control-C. */
  20048. -int ip_abort = 0;
  20049. -/* Set if an ethernet card is probed and IP addresses are set. */
  20050. -int network_ready = 0;
  20051. -
  20052. -struct rom_info rom;
  20053. -
  20054. -static int vendorext_isvalid;
  20055. -static unsigned long netmask;
  20056. -static struct bootpd_t bootp_data;
  20057. -static unsigned long xid;
  20058. -static unsigned char *end_of_rfc1533 = NULL;
  20059. -
  20060. -#ifndef NO_DHCP_SUPPORT
  20061. -#endif /* NO_DHCP_SUPPORT */
  20062. -
  20063. -/* äEth */
  20064. -static unsigned char vendorext_magic[] = {0xE4, 0x45, 0x74, 0x68};
  20065. -static const unsigned char broadcast[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
  20066. -
  20067. -#ifdef NO_DHCP_SUPPORT
  20068. -
  20069. -static unsigned char rfc1533_cookie[5] = {RFC1533_COOKIE, RFC1533_END};
  20070. -
  20071. -#else /* ! NO_DHCP_SUPPORT */
  20072. -
  20073. -static int dhcp_reply;
  20074. -static in_addr dhcp_server = {0L};
  20075. -static in_addr dhcp_addr = {0L};
  20076. -static unsigned char rfc1533_cookie[] = {RFC1533_COOKIE};
  20077. -static unsigned char rfc1533_end[] = {RFC1533_END};
  20078. -
  20079. -static const unsigned char dhcpdiscover[] =
  20080. -{
  20081. - RFC2132_MSG_TYPE, 1, DHCPDISCOVER,
  20082. - RFC2132_MAX_SIZE,2, /* request as much as we can */
  20083. - ETH_MAX_MTU / 256, ETH_MAX_MTU % 256,
  20084. - RFC2132_PARAM_LIST, 4, RFC1533_NETMASK, RFC1533_GATEWAY,
  20085. - RFC1533_HOSTNAME, RFC1533_EXTENSIONPATH
  20086. -};
  20087. -
  20088. -static const unsigned char dhcprequest[] =
  20089. -{
  20090. - RFC2132_MSG_TYPE, 1, DHCPREQUEST,
  20091. - RFC2132_SRV_ID, 4, 0, 0, 0, 0,
  20092. - RFC2132_REQ_ADDR, 4, 0, 0, 0, 0,
  20093. - RFC2132_MAX_SIZE, 2, /* request as much as we can */
  20094. - ETH_MAX_MTU / 256, ETH_MAX_MTU % 256,
  20095. - /* request parameters */
  20096. - RFC2132_PARAM_LIST,
  20097. - /* 4 standard + 2 vendortags */
  20098. - 4 + 2,
  20099. - /* Standard parameters */
  20100. - RFC1533_NETMASK, RFC1533_GATEWAY,
  20101. - RFC1533_HOSTNAME, RFC1533_EXTENSIONPATH,
  20102. - /* Etherboot vendortags */
  20103. - RFC1533_VENDOR_MAGIC,
  20104. - RFC1533_VENDOR_CONFIGFILE,
  20105. -};
  20106. -
  20107. -#endif /* ! NO_DHCP_SUPPORT */
  20108. -
  20109. -static unsigned short ipchksum (unsigned short *ip, int len);
  20110. -static unsigned short udpchksum (struct iphdr *packet);
  20111. -
  20112. -void
  20113. -print_network_configuration (void)
  20114. -{
  20115. - if (! eth_probe ())
  20116. - grub_printf ("No ethernet card found.\n");
  20117. - else if (! network_ready)
  20118. - grub_printf ("Not initialized yet.\n");
  20119. - else
  20120. - {
  20121. - etherboot_printf ("Address: %@\n", arptable[ARP_CLIENT].ipaddr.s_addr);
  20122. - etherboot_printf ("Netmask: %@\n", netmask);
  20123. - etherboot_printf ("Server: %@\n", arptable[ARP_SERVER].ipaddr.s_addr);
  20124. - etherboot_printf ("Gateway: %@\n", arptable[ARP_GATEWAY].ipaddr.s_addr);
  20125. - }
  20126. -}
  20127. -
  20128. -
  20129. -/**************************************************************************
  20130. -DEFAULT_NETMASK - Return default netmask for IP address
  20131. -**************************************************************************/
  20132. -static inline unsigned long
  20133. -default_netmask (void)
  20134. -{
  20135. - int net = ntohl (arptable[ARP_CLIENT].ipaddr.s_addr) >> 24;
  20136. - if (net <= 127)
  20137. - return (htonl (0xff000000));
  20138. - else if (net < 192)
  20139. - return (htonl (0xffff0000));
  20140. - else
  20141. - return (htonl (0xffffff00));
  20142. -}
  20143. -
  20144. -/* ifconfig - configure network interface. */
  20145. -int
  20146. -ifconfig (char *ip, char *sm, char *gw, char *svr)
  20147. -{
  20148. - in_addr tmp;
  20149. -
  20150. - if (sm)
  20151. - {
  20152. - if (! inet_aton (sm, &tmp))
  20153. - return 0;
  20154. -
  20155. - netmask = tmp.s_addr;
  20156. - }
  20157. -
  20158. - if (ip)
  20159. - {
  20160. - if (! inet_aton (ip, &arptable[ARP_CLIENT].ipaddr))
  20161. - return 0;
  20162. -
  20163. - if (! netmask && ! sm)
  20164. - netmask = default_netmask ();
  20165. - }
  20166. -
  20167. - if (gw && ! inet_aton (gw, &arptable[ARP_GATEWAY].ipaddr))
  20168. - return 0;
  20169. -
  20170. - /* Clear out the ARP entry. */
  20171. - grub_memset (arptable[ARP_GATEWAY].node, 0, ETH_ALEN);
  20172. -
  20173. - if (svr && ! inet_aton (svr, &arptable[ARP_SERVER].ipaddr))
  20174. - return 0;
  20175. -
  20176. - /* Likewise. */
  20177. - grub_memset (arptable[ARP_SERVER].node, 0, ETH_ALEN);
  20178. -
  20179. - if (ip || sm)
  20180. - {
  20181. - if (IP_BROADCAST == (netmask | arptable[ARP_CLIENT].ipaddr.s_addr)
  20182. - || netmask == (netmask | arptable[ARP_CLIENT].ipaddr.s_addr)
  20183. - || ! netmask)
  20184. - network_ready = 0;
  20185. - else
  20186. - network_ready = 1;
  20187. - }
  20188. -
  20189. - return 1;
  20190. -}
  20191. -
  20192. -
  20193. -/**************************************************************************
  20194. -UDP_TRANSMIT - Send a UDP datagram
  20195. -**************************************************************************/
  20196. -int
  20197. -udp_transmit (unsigned long destip, unsigned int srcsock,
  20198. - unsigned int destsock, int len, const void *buf)
  20199. -{
  20200. - struct iphdr *ip;
  20201. - struct udphdr *udp;
  20202. - struct arprequest arpreq;
  20203. - int arpentry, i;
  20204. - int retry;
  20205. -
  20206. - ip = (struct iphdr *) buf;
  20207. - udp = (struct udphdr *) ((unsigned long) buf + sizeof (struct iphdr));
  20208. - ip->verhdrlen = 0x45;
  20209. - ip->service = 0;
  20210. - ip->len = htons (len);
  20211. - ip->ident = 0;
  20212. - ip->frags = 0;
  20213. - ip->ttl = 60;
  20214. - ip->protocol = IP_UDP;
  20215. - ip->chksum = 0;
  20216. - ip->src.s_addr = arptable[ARP_CLIENT].ipaddr.s_addr;
  20217. - ip->dest.s_addr = destip;
  20218. - ip->chksum = ipchksum ((unsigned short *) buf, sizeof (struct iphdr));
  20219. - udp->src = htons (srcsock);
  20220. - udp->dest = htons (destsock);
  20221. - udp->len = htons (len - sizeof (struct iphdr));
  20222. - udp->chksum = 0;
  20223. - udp->chksum = htons (udpchksum (ip));
  20224. -
  20225. - if (udp->chksum == 0)
  20226. - udp->chksum = 0xffff;
  20227. -
  20228. - if (destip == IP_BROADCAST)
  20229. - {
  20230. - eth_transmit (broadcast, IP, len, buf);
  20231. - }
  20232. - else
  20233. - {
  20234. - if (((destip & netmask)
  20235. - != (arptable[ARP_CLIENT].ipaddr.s_addr & netmask))
  20236. - && arptable[ARP_GATEWAY].ipaddr.s_addr)
  20237. - destip = arptable[ARP_GATEWAY].ipaddr.s_addr;
  20238. -
  20239. - for (arpentry = 0; arpentry < MAX_ARP; arpentry++)
  20240. - if (arptable[arpentry].ipaddr.s_addr == destip)
  20241. - break;
  20242. -
  20243. - if (arpentry == MAX_ARP)
  20244. - {
  20245. - etherboot_printf ("%@ is not in my arp table!\n", destip);
  20246. - return 0;
  20247. - }
  20248. -
  20249. - for (i = 0; i < ETH_ALEN; i++)
  20250. - if (arptable[arpentry].node[i])
  20251. - break;
  20252. -
  20253. - if (i == ETH_ALEN)
  20254. - {
  20255. - /* Need to do arp request. */
  20256. -#ifdef DEBUG
  20257. - grub_printf ("arp request.\n");
  20258. -#endif
  20259. - arpreq.hwtype = htons (1);
  20260. - arpreq.protocol = htons (IP);
  20261. - arpreq.hwlen = ETH_ALEN;
  20262. - arpreq.protolen = 4;
  20263. - arpreq.opcode = htons (ARP_REQUEST);
  20264. - grub_memmove (arpreq.shwaddr, arptable[ARP_CLIENT].node,
  20265. - ETH_ALEN);
  20266. - grub_memmove (arpreq.sipaddr, (char *) &arptable[ARP_CLIENT].ipaddr,
  20267. - sizeof (in_addr));
  20268. - grub_memset (arpreq.thwaddr, 0, ETH_ALEN);
  20269. - grub_memmove (arpreq.tipaddr, (char *) &destip, sizeof (in_addr));
  20270. -
  20271. - for (retry = 1; retry <= MAX_ARP_RETRIES; retry++)
  20272. - {
  20273. - long timeout;
  20274. -
  20275. - eth_transmit (broadcast, ARP, sizeof (arpreq), &arpreq);
  20276. - timeout = rfc2131_sleep_interval (TIMEOUT, retry);
  20277. -
  20278. - if (await_reply (AWAIT_ARP, arpentry, arpreq.tipaddr, timeout))
  20279. - goto xmit;
  20280. -
  20281. - if (ip_abort)
  20282. - return 0;
  20283. - }
  20284. -
  20285. - return 0;
  20286. - }
  20287. -
  20288. - xmit:
  20289. - eth_transmit (arptable[arpentry].node, IP, len, buf);
  20290. - }
  20291. -
  20292. - return 1;
  20293. -}
  20294. -
  20295. -/**************************************************************************
  20296. -TFTP - Download extended BOOTP data, or kernel image
  20297. -**************************************************************************/
  20298. -static int
  20299. -tftp (const char *name, int (*fnc) (unsigned char *, int, int, int))
  20300. -{
  20301. - int retry = 0;
  20302. - static unsigned short iport = 2000;
  20303. - unsigned short oport = 0;
  20304. - unsigned short len, block = 0, prevblock = 0;
  20305. - int bcounter = 0;
  20306. - struct tftp_t *tr;
  20307. - struct tftpreq_t tp;
  20308. - int rc;
  20309. - int packetsize = TFTP_DEFAULTSIZE_PACKET;
  20310. -
  20311. - /* Clear out the Rx queue first. It contains nothing of interest,
  20312. - * except possibly ARP requests from the DHCP/TFTP server. We use
  20313. - * polling throughout Etherboot, so some time may have passed since we
  20314. - * last polled the receive queue, which may now be filled with
  20315. - * broadcast packets. This will cause the reply to the packets we are
  20316. - * about to send to be lost immediately. Not very clever. */
  20317. - await_reply (AWAIT_QDRAIN, 0, NULL, 0);
  20318. -
  20319. - tp.opcode = htons (TFTP_RRQ);
  20320. - len = (grub_sprintf ((char *) tp.u.rrq, "%s%coctet%cblksize%c%d",
  20321. - name, 0, 0, 0, TFTP_MAX_PACKET)
  20322. - + sizeof (tp.ip) + sizeof (tp.udp) + sizeof (tp.opcode) + 1);
  20323. - if (! udp_transmit (arptable[ARP_SERVER].ipaddr.s_addr, ++iport,
  20324. - TFTP_PORT, len, &tp))
  20325. - return 0;
  20326. -
  20327. - for (;;)
  20328. - {
  20329. - long timeout;
  20330. -
  20331. -#ifdef CONGESTED
  20332. - timeout = rfc2131_sleep_interval (block ? TFTP_REXMT : TIMEOUT, retry);
  20333. -#else
  20334. - timeout = rfc2131_sleep_interval (TIMEOUT, retry);
  20335. -#endif
  20336. -
  20337. - if (! await_reply (AWAIT_TFTP, iport, NULL, timeout))
  20338. - {
  20339. - if (! block && retry++ < MAX_TFTP_RETRIES)
  20340. - {
  20341. - /* Maybe initial request was lost. */
  20342. - if (! udp_transmit (arptable[ARP_SERVER].ipaddr.s_addr,
  20343. - ++iport, TFTP_PORT, len, &tp))
  20344. - return 0;
  20345. -
  20346. - continue;
  20347. - }
  20348. -
  20349. -#ifdef CONGESTED
  20350. - if (block && ((retry += TFTP_REXMT) < TFTP_TIMEOUT))
  20351. - {
  20352. - /* We resend our last ack. */
  20353. -#ifdef MDEBUG
  20354. - grub_printf ("<REXMT>\n");
  20355. -#endif
  20356. - udp_transmit (arptable[ARP_SERVER].ipaddr.s_addr,
  20357. - iport, oport,
  20358. - TFTP_MIN_PACKET, &tp);
  20359. - continue;
  20360. - }
  20361. -#endif
  20362. - /* Timeout. */
  20363. - break;
  20364. - }
  20365. -
  20366. - tr = (struct tftp_t *) &nic.packet[ETH_HLEN];
  20367. - if (tr->opcode == ntohs (TFTP_ERROR))
  20368. - {
  20369. - grub_printf ("TFTP error %d (%s)\n",
  20370. - ntohs (tr->u.err.errcode),
  20371. - tr->u.err.errmsg);
  20372. - break;
  20373. - }
  20374. -
  20375. - if (tr->opcode == ntohs (TFTP_OACK))
  20376. - {
  20377. - char *p = tr->u.oack.data, *e;
  20378. -
  20379. - /* Shouldn't happen. */
  20380. - if (prevblock)
  20381. - /* Ignore it. */
  20382. - continue;
  20383. -
  20384. - len = ntohs (tr->udp.len) - sizeof (struct udphdr) - 2;
  20385. - if (len > TFTP_MAX_PACKET)
  20386. - goto noak;
  20387. -
  20388. - e = p + len;
  20389. - while (*p != '\000' && p < e)
  20390. - {
  20391. - if (! grub_strcmp ("blksize", p))
  20392. - {
  20393. - p += 8;
  20394. - if ((packetsize = getdec (&p)) < TFTP_DEFAULTSIZE_PACKET)
  20395. - goto noak;
  20396. -
  20397. - while (p < e && *p)
  20398. - p++;
  20399. -
  20400. - if (p < e)
  20401. - p++;
  20402. - }
  20403. - else
  20404. - {
  20405. - noak:
  20406. - tp.opcode = htons (TFTP_ERROR);
  20407. - tp.u.err.errcode = 8;
  20408. - len = (grub_sprintf ((char *) tp.u.err.errmsg,
  20409. - "RFC1782 error")
  20410. - + sizeof (tp.ip) + sizeof (tp.udp)
  20411. - + sizeof (tp.opcode) + sizeof (tp.u.err.errcode)
  20412. - + 1);
  20413. - udp_transmit (arptable[ARP_SERVER].ipaddr.s_addr,
  20414. - iport, ntohs (tr->udp.src),
  20415. - len, &tp);
  20416. - return 0;
  20417. - }
  20418. - }
  20419. -
  20420. - if (p > e)
  20421. - goto noak;
  20422. -
  20423. - /* This ensures that the packet does not get processed as data! */
  20424. - block = tp.u.ack.block = 0;
  20425. - }
  20426. - else if (tr->opcode == ntohs (TFTP_DATA))
  20427. - {
  20428. - len = ntohs (tr->udp.len) - sizeof (struct udphdr) - 4;
  20429. - /* Shouldn't happen. */
  20430. - if (len > packetsize)
  20431. - /* Ignore it. */
  20432. - continue;
  20433. -
  20434. - block = ntohs (tp.u.ack.block = tr->u.data.block);
  20435. - }
  20436. - else
  20437. - /* Neither TFTP_OACK nor TFTP_DATA. */
  20438. - break;
  20439. -
  20440. - if ((block || bcounter) && (block != prevblock + 1))
  20441. - /* Block order should be continuous */
  20442. - tp.u.ack.block = htons (block = prevblock);
  20443. -
  20444. - /* Should be continuous. */
  20445. - tp.opcode = htons (TFTP_ACK);
  20446. - oport = ntohs (tr->udp.src);
  20447. - /* Ack. */
  20448. - udp_transmit (arptable[ARP_SERVER].ipaddr.s_addr, iport,
  20449. - oport, TFTP_MIN_PACKET, &tp);
  20450. -
  20451. - if ((unsigned short) (block - prevblock) != 1)
  20452. - /* Retransmission or OACK, don't process via callback
  20453. - * and don't change the value of prevblock. */
  20454. - continue;
  20455. -
  20456. - prevblock = block;
  20457. - /* Is it the right place to zero the timer? */
  20458. - retry = 0;
  20459. -
  20460. - if ((rc = fnc (tr->u.data.download,
  20461. - ++bcounter, len, len < packetsize)) >= 0)
  20462. - return rc;
  20463. -
  20464. - /* End of data. */
  20465. - if (len < packetsize)
  20466. - return 1;
  20467. - }
  20468. -
  20469. - return 0;
  20470. -}
  20471. -
  20472. -/**************************************************************************
  20473. -RARP - Get my IP address and load information
  20474. -**************************************************************************/
  20475. -int
  20476. -rarp (void)
  20477. -{
  20478. - int retry;
  20479. -
  20480. - /* arp and rarp requests share the same packet structure. */
  20481. - struct arprequest rarpreq;
  20482. -
  20483. - /* Make sure that an ethernet is probed. */
  20484. - if (! eth_probe ())
  20485. - return 0;
  20486. -
  20487. - /* Clear the ready flag. */
  20488. - network_ready = 0;
  20489. -
  20490. - grub_memset (&rarpreq, 0, sizeof (rarpreq));
  20491. -
  20492. - rarpreq.hwtype = htons (1);
  20493. - rarpreq.protocol = htons (IP);
  20494. - rarpreq.hwlen = ETH_ALEN;
  20495. - rarpreq.protolen = 4;
  20496. - rarpreq.opcode = htons (RARP_REQUEST);
  20497. - grub_memmove ((char *) &rarpreq.shwaddr, arptable[ARP_CLIENT].node,
  20498. - ETH_ALEN);
  20499. - /* sipaddr is already zeroed out */
  20500. - grub_memmove ((char *) &rarpreq.thwaddr, arptable[ARP_CLIENT].node,
  20501. - ETH_ALEN);
  20502. - /* tipaddr is already zeroed out */
  20503. -
  20504. - for (retry = 0; retry < MAX_ARP_RETRIES; ++retry)
  20505. - {
  20506. - long timeout;
  20507. -
  20508. - eth_transmit (broadcast, RARP, sizeof (rarpreq), &rarpreq);
  20509. -
  20510. - timeout = rfc2131_sleep_interval (TIMEOUT, retry);
  20511. - if (await_reply (AWAIT_RARP, 0, rarpreq.shwaddr, timeout))
  20512. - break;
  20513. -
  20514. - if (ip_abort)
  20515. - return 0;
  20516. - }
  20517. -
  20518. - if (retry < MAX_ARP_RETRIES)
  20519. - {
  20520. - network_ready = 1;
  20521. - return 1;
  20522. - }
  20523. -
  20524. - return 0;
  20525. -}
  20526. -
  20527. -/**************************************************************************
  20528. -BOOTP - Get my IP address and load information
  20529. -**************************************************************************/
  20530. -int
  20531. -bootp (void)
  20532. -{
  20533. - int retry;
  20534. -#ifndef NO_DHCP_SUPPORT
  20535. - int reqretry;
  20536. -#endif /* ! NO_DHCP_SUPPORT */
  20537. - struct bootpip_t ip;
  20538. - unsigned long starttime;
  20539. -
  20540. - /* Make sure that an ethernet is probed. */
  20541. - if (! eth_probe ())
  20542. - return 0;
  20543. -
  20544. - /* Clear the ready flag. */
  20545. - network_ready = 0;
  20546. -
  20547. -#ifdef DEBUG
  20548. - grub_printf ("network is ready.\n");
  20549. -#endif
  20550. -
  20551. - grub_memset (&ip, 0, sizeof (struct bootpip_t));
  20552. - ip.bp.bp_op = BOOTP_REQUEST;
  20553. - ip.bp.bp_htype = 1;
  20554. - ip.bp.bp_hlen = ETH_ALEN;
  20555. - starttime = currticks ();
  20556. - /* Use lower 32 bits of node address, more likely to be
  20557. - distinct than the time since booting */
  20558. - grub_memmove (&xid, &arptable[ARP_CLIENT].node[2], sizeof(xid));
  20559. - ip.bp.bp_xid = xid += htonl (starttime);
  20560. - grub_memmove (ip.bp.bp_hwaddr, arptable[ARP_CLIENT].node, ETH_ALEN);
  20561. -#ifdef DEBUG
  20562. - etherboot_printf ("bp_op = %d\n", ip.bp.bp_op);
  20563. - etherboot_printf ("bp_htype = %d\n", ip.bp.bp_htype);
  20564. - etherboot_printf ("bp_hlen = %d\n", ip.bp.bp_hlen);
  20565. - etherboot_printf ("bp_xid = %d\n", ip.bp.bp_xid);
  20566. - etherboot_printf ("bp_hwaddr = %!\n", ip.bp.bp_hwaddr);
  20567. - etherboot_printf ("bp_hops = %d\n", (int) ip.bp.bp_hops);
  20568. - etherboot_printf ("bp_secs = %d\n", (int) ip.bp.bp_hwaddr);
  20569. -#endif
  20570. -
  20571. -#ifdef NO_DHCP_SUPPORT
  20572. - /* Request RFC-style options. */
  20573. - grub_memmove (ip.bp.bp_vend, rfc1533_cookie, 5);
  20574. -#else
  20575. - /* Request RFC-style options. */
  20576. - grub_memmove (ip.bp.bp_vend, rfc1533_cookie, sizeof rfc1533_cookie);
  20577. - grub_memmove (ip.bp.bp_vend + sizeof rfc1533_cookie, dhcpdiscover,
  20578. - sizeof dhcpdiscover);
  20579. - grub_memmove (ip.bp.bp_vend + sizeof rfc1533_cookie + sizeof dhcpdiscover,
  20580. - rfc1533_end, sizeof rfc1533_end);
  20581. -#endif /* ! NO_DHCP_SUPPORT */
  20582. -
  20583. - for (retry = 0; retry < MAX_BOOTP_RETRIES;)
  20584. - {
  20585. - long timeout;
  20586. -
  20587. -#ifdef DEBUG
  20588. - grub_printf ("retry = %d\n", retry);
  20589. -#endif
  20590. -
  20591. - /* Clear out the Rx queue first. It contains nothing of
  20592. - * interest, except possibly ARP requests from the DHCP/TFTP
  20593. - * server. We use polling throughout Etherboot, so some time
  20594. - * may have passed since we last polled the receive queue,
  20595. - * which may now be filled with broadcast packets. This will
  20596. - * cause the reply to the packets we are about to send to be
  20597. - * lost immediately. Not very clever. */
  20598. - await_reply (AWAIT_QDRAIN, 0, NULL, 0);
  20599. -
  20600. - udp_transmit (IP_BROADCAST, BOOTP_CLIENT, BOOTP_SERVER,
  20601. - sizeof (struct bootpip_t), &ip);
  20602. - timeout = rfc2131_sleep_interval (TIMEOUT, retry++);
  20603. -#ifdef NO_DHCP_SUPPORT
  20604. - if (await_reply (AWAIT_BOOTP, 0, NULL, timeout))
  20605. - {
  20606. - network_ready = 1;
  20607. - return 1;
  20608. - }
  20609. -#else /* ! NO_DHCP_SUPPORT */
  20610. - if (await_reply (AWAIT_BOOTP, 0, NULL, timeout))
  20611. - {
  20612. - if (dhcp_reply != DHCPOFFER)
  20613. - {
  20614. - network_ready = 1;
  20615. - return 1;
  20616. - }
  20617. -
  20618. - dhcp_reply = 0;
  20619. -#ifdef DEBUG
  20620. - etherboot_printf ("bp_op = %d\n", (int) ip.bp.bp_op);
  20621. - etherboot_printf ("bp_htype = %d\n", (int) ip.bp.bp_htype);
  20622. - etherboot_printf ("bp_hlen = %d\n", (int) ip.bp.bp_hlen);
  20623. - etherboot_printf ("bp_xid = %d\n", (int) ip.bp.bp_xid);
  20624. - etherboot_printf ("bp_hwaddr = %!\n", ip.bp.bp_hwaddr);
  20625. - etherboot_printf ("bp_hops = %d\n", (int) ip.bp.bp_hops);
  20626. - etherboot_printf ("bp_secs = %d\n", (int) ip.bp.bp_hwaddr);
  20627. -#endif
  20628. - grub_memmove (ip.bp.bp_vend, rfc1533_cookie, sizeof rfc1533_cookie);
  20629. - grub_memmove (ip.bp.bp_vend + sizeof rfc1533_cookie,
  20630. - dhcprequest, sizeof dhcprequest);
  20631. - grub_memmove (ip.bp.bp_vend + sizeof rfc1533_cookie
  20632. - + sizeof dhcprequest,
  20633. - rfc1533_end, sizeof rfc1533_end);
  20634. - grub_memmove (ip.bp.bp_vend + 9, (char *) &dhcp_server,
  20635. - sizeof (in_addr));
  20636. - grub_memmove (ip.bp.bp_vend + 15, (char *) &dhcp_addr,
  20637. - sizeof (in_addr));
  20638. -#ifdef DEBUG
  20639. - grub_printf ("errnum = %d\n", errnum);
  20640. -#endif
  20641. - for (reqretry = 0; reqretry < MAX_BOOTP_RETRIES;)
  20642. - {
  20643. - int ret;
  20644. -#ifdef DEBUG
  20645. - grub_printf ("reqretry = %d\n", reqretry);
  20646. -#endif
  20647. -
  20648. - ret = udp_transmit (IP_BROADCAST, BOOTP_CLIENT, BOOTP_SERVER,
  20649. - sizeof (struct bootpip_t), &ip);
  20650. - if (! ret)
  20651. - grub_printf ("udp_transmit failed.\n");
  20652. -
  20653. - dhcp_reply = 0;
  20654. - timeout = rfc2131_sleep_interval (TIMEOUT, reqretry++);
  20655. - if (await_reply (AWAIT_BOOTP, 0, NULL, timeout))
  20656. - if (dhcp_reply == DHCPACK)
  20657. - {
  20658. - network_ready = 1;
  20659. - return 1;
  20660. - }
  20661. -
  20662. -#ifdef DEBUG
  20663. - grub_printf ("dhcp_reply = %d\n", dhcp_reply);
  20664. -#endif
  20665. -
  20666. - if (ip_abort)
  20667. - return 0;
  20668. - }
  20669. - }
  20670. -#endif /* ! NO_DHCP_SUPPORT */
  20671. -
  20672. - if (ip_abort)
  20673. - return 0;
  20674. -
  20675. - ip.bp.bp_secs = htons ((currticks () - starttime) / TICKS_PER_SEC);
  20676. - }
  20677. -
  20678. - /* Timeout. */
  20679. - return 0;
  20680. -}
  20681. -
  20682. -/**************************************************************************
  20683. -UDPCHKSUM - Checksum UDP Packet (one of the rare cases when assembly is
  20684. - actually simpler...)
  20685. - RETURNS: checksum, 0 on checksum error. This
  20686. - allows for using the same routine for RX and TX summing:
  20687. - RX if (packet->udp.chksum && udpchksum(packet))
  20688. - error("checksum error");
  20689. - TX packet->udp.chksum=0;
  20690. - if (0==(packet->udp.chksum=udpchksum(packet)))
  20691. - packet->upd.chksum=0xffff;
  20692. -**************************************************************************/
  20693. -static inline void
  20694. -dosum (unsigned short *start, unsigned int len, unsigned short *sum)
  20695. -{
  20696. - __asm__ __volatile__
  20697. - ("clc\n"
  20698. - "1:\tlodsw\n\t"
  20699. - "xchg %%al,%%ah\n\t" /* convert to host byte order */
  20700. - "adcw %%ax,%0\n\t" /* add carry of previous iteration */
  20701. - "loop 1b\n\t"
  20702. - "adcw $0,%0" /* add carry of last iteration */
  20703. - : "=b" (*sum), "=S"(start), "=c"(len)
  20704. - : "0"(*sum), "1"(start), "2"(len)
  20705. - : "ax", "cc"
  20706. - );
  20707. -}
  20708. -
  20709. -/* UDP sum:
  20710. - * proto, src_ip, dst_ip, udp_dport, udp_sport, 2*udp_len, payload
  20711. - */
  20712. -static unsigned short
  20713. -udpchksum (struct iphdr *packet)
  20714. -{
  20715. - int len = ntohs (packet->len);
  20716. - unsigned short rval;
  20717. -
  20718. - /* add udplength + protocol number */
  20719. - rval = (len - sizeof (struct iphdr)) + IP_UDP;
  20720. -
  20721. - /* pad to an even number of bytes */
  20722. - if (len % 2) {
  20723. - ((char *) packet)[len++] = 0;
  20724. - }
  20725. -
  20726. - /* sum over src/dst ipaddr + udp packet */
  20727. - len -= (char *) &packet->src - (char *) packet;
  20728. - dosum ((unsigned short *) &packet->src, len >> 1, &rval);
  20729. -
  20730. - /* take one's complement */
  20731. - return ~rval;
  20732. -}
  20733. -
  20734. -/**************************************************************************
  20735. -AWAIT_REPLY - Wait until we get a response for our request
  20736. -**************************************************************************/
  20737. -int
  20738. -await_reply (int type, int ival, void *ptr, int timeout)
  20739. -{
  20740. - unsigned long time;
  20741. - struct iphdr *ip;
  20742. - struct udphdr *udp;
  20743. - struct arprequest *arpreply;
  20744. - struct bootp_t *bootpreply;
  20745. - unsigned short ptype;
  20746. - unsigned int protohdrlen = (ETH_HLEN + sizeof (struct iphdr)
  20747. - + sizeof (struct udphdr));
  20748. -
  20749. - /* Clear the abort flag. */
  20750. - ip_abort = 0;
  20751. -
  20752. - time = timeout + currticks ();
  20753. - /* The timeout check is done below. The timeout is only checked if
  20754. - * there is no packet in the Rx queue. This assumes that eth_poll()
  20755. - * needs a negligible amount of time. */
  20756. - for (;;)
  20757. - {
  20758. - if (eth_poll ())
  20759. - {
  20760. - /* We have something! */
  20761. -
  20762. - /* Check for ARP - No IP hdr. */
  20763. - if (nic.packetlen >= ETH_HLEN)
  20764. - {
  20765. - ptype = (((unsigned short) nic.packet[12]) << 8
  20766. - | ((unsigned short) nic.packet[13]));
  20767. - }
  20768. - else
  20769. - /* What else could we do with it? */
  20770. - continue;
  20771. -
  20772. - if (nic.packetlen >= ETH_HLEN + sizeof (struct arprequest)
  20773. - && ptype == ARP)
  20774. - {
  20775. - unsigned long tmp;
  20776. -
  20777. - arpreply = (struct arprequest *) &nic.packet[ETH_HLEN];
  20778. -
  20779. - if (arpreply->opcode == htons (ARP_REPLY)
  20780. - && ! grub_memcmp (arpreply->sipaddr, ptr, sizeof (in_addr))
  20781. - && type == AWAIT_ARP)
  20782. - {
  20783. - grub_memmove ((char *) arptable[ival].node,
  20784. - arpreply->shwaddr,
  20785. - ETH_ALEN);
  20786. - return 1;
  20787. - }
  20788. -
  20789. - grub_memmove ((char *) &tmp, arpreply->tipaddr,
  20790. - sizeof (in_addr));
  20791. -
  20792. - if (arpreply->opcode == htons (ARP_REQUEST)
  20793. - && tmp == arptable[ARP_CLIENT].ipaddr.s_addr)
  20794. - {
  20795. - arpreply->opcode = htons (ARP_REPLY);
  20796. - grub_memmove (arpreply->tipaddr, arpreply->sipaddr,
  20797. - sizeof (in_addr));
  20798. - grub_memmove (arpreply->thwaddr, (char *) arpreply->shwaddr,
  20799. - ETH_ALEN);
  20800. - grub_memmove (arpreply->sipaddr,
  20801. - (char *) &arptable[ARP_CLIENT].ipaddr,
  20802. - sizeof (in_addr));
  20803. - grub_memmove (arpreply->shwaddr,
  20804. - arptable[ARP_CLIENT].node,
  20805. - ETH_ALEN);
  20806. - eth_transmit (arpreply->thwaddr, ARP,
  20807. - sizeof (struct arprequest),
  20808. - arpreply);
  20809. -#ifdef MDEBUG
  20810. - grub_memmove (&tmp, arpreply->tipaddr, sizeof (in_addr));
  20811. - etherboot_printf ("Sent ARP reply to: %@\n", tmp);
  20812. -#endif /* MDEBUG */
  20813. - }
  20814. -
  20815. - continue;
  20816. - }
  20817. -
  20818. - if (type == AWAIT_QDRAIN)
  20819. - continue;
  20820. -
  20821. - /* Check for RARP - No IP hdr. */
  20822. - if (type == AWAIT_RARP
  20823. - && nic.packetlen >= ETH_HLEN + sizeof (struct arprequest)
  20824. - && ptype == RARP)
  20825. - {
  20826. - arpreply = (struct arprequest *) &nic.packet[ETH_HLEN];
  20827. -
  20828. - if (arpreply->opcode == htons (RARP_REPLY)
  20829. - && ! grub_memcmp (arpreply->thwaddr, ptr, ETH_ALEN))
  20830. - {
  20831. - grub_memmove ((char *) arptable[ARP_SERVER].node,
  20832. - arpreply->shwaddr, ETH_ALEN);
  20833. - grub_memmove ((char *) &arptable[ARP_SERVER].ipaddr,
  20834. - arpreply->sipaddr, sizeof (in_addr));
  20835. - grub_memmove ((char *) &arptable[ARP_CLIENT].ipaddr,
  20836. - arpreply->tipaddr, sizeof (in_addr));
  20837. - return 1;
  20838. - }
  20839. -
  20840. - continue;
  20841. - }
  20842. -
  20843. - /* Anything else has IP header. */
  20844. - if (nic.packetlen < protohdrlen || ptype != IP)
  20845. - continue;
  20846. -
  20847. - ip = (struct iphdr *) &nic.packet[ETH_HLEN];
  20848. - if (ip->verhdrlen != 0x45
  20849. - || ipchksum ((unsigned short *) ip, sizeof (struct iphdr))
  20850. - || ip->protocol != IP_UDP)
  20851. - continue;
  20852. -
  20853. - /*
  20854. - - Till Straumann <Till.Straumann@TU-Berlin.de>
  20855. - added udp checksum (safer on a wireless link)
  20856. - added fragmentation check: I had a corrupted image
  20857. - in memory due to fragmented TFTP packets - took me
  20858. - 3 days to find the cause for this :-(
  20859. - */
  20860. -
  20861. - /* If More Fragments bit and Fragment Offset field
  20862. - are non-zero then packet is fragmented */
  20863. - if (ip->frags & htons(0x3FFF))
  20864. - {
  20865. - grub_printf ("ALERT: got a fragmented packet - reconfigure your server\n");
  20866. - continue;
  20867. - }
  20868. -
  20869. - udp = (struct udphdr *) &nic.packet[(ETH_HLEN
  20870. - + sizeof (struct iphdr))];
  20871. - if (udp->chksum && udpchksum (ip))
  20872. - {
  20873. - grub_printf ("UDP checksum error\n");
  20874. - continue;
  20875. - }
  20876. -
  20877. - /* BOOTP ? */
  20878. - bootpreply = (struct bootp_t *)
  20879. - &nic.packet[(ETH_HLEN + sizeof (struct iphdr)
  20880. - + sizeof (struct udphdr))];
  20881. - if (type == AWAIT_BOOTP
  20882. -#ifdef NO_DHCP_SUPPORT
  20883. - && (nic.packetlen
  20884. - >= (ETH_HLEN + sizeof (struct bootp_t) - BOOTP_VENDOR_LEN))
  20885. -#else
  20886. - && (nic.packetlen
  20887. - >= (ETH_HLEN + sizeof (struct bootp_t) - DHCP_OPT_LEN))
  20888. -#endif /* ! NO_DHCP_SUPPORT */
  20889. - && udp->dest == htons (BOOTP_CLIENT)
  20890. - && bootpreply->bp_op == BOOTP_REPLY
  20891. - && bootpreply->bp_xid == xid
  20892. - && (! grub_memcmp (broadcast, bootpreply->bp_hwaddr, ETH_ALEN)
  20893. - || ! grub_memcmp (arptable[ARP_CLIENT].node,
  20894. - bootpreply->bp_hwaddr, ETH_ALEN)))
  20895. - {
  20896. -#ifdef DEBUG
  20897. - grub_printf ("BOOTP packet was received.\n");
  20898. -#endif
  20899. - arptable[ARP_CLIENT].ipaddr.s_addr
  20900. - = bootpreply->bp_yiaddr.s_addr;
  20901. -#ifndef NO_DHCP_SUPPORT
  20902. - dhcp_addr.s_addr = bootpreply->bp_yiaddr.s_addr;
  20903. -#ifdef DEBUG
  20904. - etherboot_printf ("dhcp_addr = %@\n", dhcp_addr.s_addr);
  20905. -#endif
  20906. -#endif /* ! NO_DHCP_SUPPORT */
  20907. - netmask = default_netmask ();
  20908. - arptable[ARP_SERVER].ipaddr.s_addr
  20909. - = bootpreply->bp_siaddr.s_addr;
  20910. - /* Kill arp. */
  20911. - grub_memset (arptable[ARP_SERVER].node, 0, ETH_ALEN);
  20912. - arptable[ARP_GATEWAY].ipaddr.s_addr
  20913. - = bootpreply->bp_giaddr.s_addr;
  20914. - /* Kill arp. */
  20915. - grub_memset (arptable[ARP_GATEWAY].node, 0, ETH_ALEN);
  20916. -
  20917. - grub_memmove ((char *) BOOTP_DATA_ADDR, (char *) bootpreply,
  20918. - sizeof (struct bootpd_t));
  20919. -#ifdef NO_DHCP_SUPPORT
  20920. - decode_rfc1533 (BOOTP_DATA_ADDR->bootp_reply.bp_vend,
  20921. - 0, BOOTP_VENDOR_LEN + MAX_BOOTP_EXTLEN, 1);
  20922. -#else
  20923. - decode_rfc1533 (BOOTP_DATA_ADDR->bootp_reply.bp_vend,
  20924. - 0, DHCP_OPT_LEN + MAX_BOOTP_EXTLEN, 1);
  20925. -#endif /* ! NO_DHCP_SUPPORT */
  20926. -
  20927. - return 1;
  20928. - }
  20929. -
  20930. - /* TFTP ? */
  20931. - if (type == AWAIT_TFTP && ntohs (udp->dest) == ival)
  20932. - return 1;
  20933. - }
  20934. - else
  20935. - {
  20936. - /* Check for abort key only if the Rx queue is empty -
  20937. - * as long as we have something to process, don't
  20938. - * assume that something failed. It is unlikely that
  20939. - * we have no processing time left between packets. */
  20940. - if (checkkey () != -1 && ASCII_CHAR (getkey ()) == CTRL_C)
  20941. - {
  20942. - ip_abort = 1;
  20943. - return 0;
  20944. - }
  20945. -
  20946. - /* Do the timeout after at least a full queue walk. */
  20947. - if ((timeout == 0) || (currticks() > time))
  20948. - {
  20949. - break;
  20950. - }
  20951. - }
  20952. - }
  20953. -
  20954. - return 0;
  20955. -}
  20956. -
  20957. -/**************************************************************************
  20958. -DECODE_RFC1533 - Decodes RFC1533 header
  20959. -**************************************************************************/
  20960. -int
  20961. -decode_rfc1533 (unsigned char *p, int block, int len, int eof)
  20962. -{
  20963. - static unsigned char *extdata = NULL, *extend = NULL;
  20964. - unsigned char *extpath = NULL;
  20965. - unsigned char *endp;
  20966. -
  20967. - if (block == 0)
  20968. - {
  20969. - end_of_rfc1533 = NULL;
  20970. - vendorext_isvalid = 0;
  20971. -
  20972. - if (grub_memcmp (p, rfc1533_cookie, 4))
  20973. - /* no RFC 1533 header found */
  20974. - return 0;
  20975. -
  20976. - p += 4;
  20977. - endp = p + len;
  20978. - }
  20979. - else
  20980. - {
  20981. - if (block == 1)
  20982. - {
  20983. - if (grub_memcmp (p, rfc1533_cookie, 4))
  20984. - /* no RFC 1533 header found */
  20985. - return 0;
  20986. -
  20987. - p += 4;
  20988. - len -= 4;
  20989. - }
  20990. -
  20991. - if (extend + len
  20992. - <= ((unsigned char *)
  20993. - &(BOOTP_DATA_ADDR->bootp_extension[MAX_BOOTP_EXTLEN])))
  20994. - {
  20995. - grub_memmove (extend, p, len);
  20996. - extend += len;
  20997. - }
  20998. - else
  20999. - {
  21000. - grub_printf ("Overflow in vendor data buffer! Aborting...\n");
  21001. - *extdata = RFC1533_END;
  21002. - return 0;
  21003. - }
  21004. -
  21005. - p = extdata;
  21006. - endp = extend;
  21007. - }
  21008. -
  21009. - if (! eof)
  21010. - return -1;
  21011. -
  21012. - while (p < endp)
  21013. - {
  21014. - unsigned char c = *p;
  21015. -
  21016. - if (c == RFC1533_PAD)
  21017. - {
  21018. - p++;
  21019. - continue;
  21020. - }
  21021. - else if (c == RFC1533_END)
  21022. - {
  21023. - end_of_rfc1533 = endp = p;
  21024. - continue;
  21025. - }
  21026. - else if (c == RFC1533_NETMASK)
  21027. - {
  21028. - grub_memmove ((char *) &netmask, p + 2, sizeof (in_addr));
  21029. - }
  21030. - else if (c == RFC1533_GATEWAY)
  21031. - {
  21032. - /* This is a little simplistic, but it will
  21033. - usually be sufficient.
  21034. - Take only the first entry. */
  21035. - if (TAG_LEN (p) >= sizeof (in_addr))
  21036. - grub_memmove ((char *) &arptable[ARP_GATEWAY].ipaddr, p + 2,
  21037. - sizeof (in_addr));
  21038. - }
  21039. - else if (c == RFC1533_EXTENSIONPATH)
  21040. - extpath = p;
  21041. -#ifndef NO_DHCP_SUPPORT
  21042. - else if (c == RFC2132_MSG_TYPE)
  21043. - {
  21044. - dhcp_reply = *(p + 2);
  21045. - }
  21046. - else if (c == RFC2132_SRV_ID)
  21047. - {
  21048. - grub_memmove ((char *) &dhcp_server, p + 2, sizeof (in_addr));
  21049. -#ifdef DEBUG
  21050. - etherboot_printf ("dhcp_server = %@\n", dhcp_server.s_addr);
  21051. -#endif
  21052. - }
  21053. -#endif /* ! NO_DHCP_SUPPORT */
  21054. - else if (c == RFC1533_VENDOR_MAGIC
  21055. - && TAG_LEN(p) >= 6
  21056. - && ! grub_memcmp (p + 2, vendorext_magic, 4)
  21057. - && p[6] == RFC1533_VENDOR_MAJOR)
  21058. - vendorext_isvalid++;
  21059. - /* GRUB now handles its own tag. Get the name of a configuration
  21060. - file from the network. Cool... */
  21061. - else if (c == RFC1533_VENDOR_CONFIGFILE)
  21062. - {
  21063. - int l = TAG_LEN (p);
  21064. -
  21065. - /* Eliminate the trailing NULs according to RFC 2132. */
  21066. - while (*(p + 2 + l - 1) == '\000' && l > 0)
  21067. - l--;
  21068. -
  21069. - /* XXX: Should check if LEN is less than the maximum length
  21070. - of CONFIG_FILE. This kind of robustness will be a goal
  21071. - in GRUB 1.0. */
  21072. - grub_memmove (config_file, p + 2, l);
  21073. - config_file[l] = 0;
  21074. - }
  21075. -
  21076. - p += TAG_LEN (p) + 2;
  21077. - }
  21078. -
  21079. - extdata = extend = endp;
  21080. -
  21081. - /* Perhaps we can eliminate this because we doesn't require so
  21082. - much information, but I leave this alone. */
  21083. - if (block == 0 && extpath != NULL)
  21084. - {
  21085. - char fname[64];
  21086. - int fnamelen = TAG_LEN (extpath);
  21087. -
  21088. - while (*(extpath + 2 + fnamelen - 1) == '\000' && fnamelen > 0)
  21089. - fnamelen--;
  21090. -
  21091. - if (fnamelen + 1 > sizeof (fname))
  21092. - {
  21093. - grub_printf ("Too long file name for Extensions Path\n");
  21094. - return 0;
  21095. - }
  21096. - else if (! fnamelen)
  21097. - {
  21098. - grub_printf ("Empty file name for Extensions Path\n");
  21099. - return 0;
  21100. - }
  21101. -
  21102. - grub_memmove (fname, extpath + 2, fnamelen);
  21103. - fname[fnamelen] = '\000';
  21104. - grub_printf ("Loading BOOTP-extension file: %s\n", fname);
  21105. - tftp (fname, decode_rfc1533);
  21106. - }
  21107. -
  21108. - /* Proceed with next block. */
  21109. - return -1;
  21110. -}
  21111. -
  21112. -/**************************************************************************
  21113. -IPCHKSUM - Checksum IP Header
  21114. -**************************************************************************/
  21115. -static unsigned short
  21116. -ipchksum (unsigned short *ip, int len)
  21117. -{
  21118. - unsigned long sum = 0;
  21119. - len >>= 1;
  21120. - while (len--)
  21121. - {
  21122. - sum += *(ip++);
  21123. - if (sum > 0xFFFF)
  21124. - sum -= 0xFFFF;
  21125. - }
  21126. - return (~sum) & 0x0000FFFF;
  21127. -}
  21128. -
  21129. -#define TWO_SECOND_DIVISOR (2147483647l/TICKS_PER_SEC)
  21130. -
  21131. -/**************************************************************************
  21132. -RFC2131_SLEEP_INTERVAL - sleep for expotentially longer times
  21133. -**************************************************************************/
  21134. -long
  21135. -rfc2131_sleep_interval (int base, int exp)
  21136. -{
  21137. - static long seed = 0;
  21138. - long q;
  21139. - unsigned long tmo;
  21140. -
  21141. -#ifdef BACKOFF_LIMIT
  21142. - if (exp > BACKOFF_LIMIT)
  21143. - exp = BACKOFF_LIMIT;
  21144. -#endif
  21145. - if (!seed)
  21146. - /* Initialize linear congruential generator */
  21147. - seed = (currticks () + *((long *) &arptable[ARP_CLIENT].node)
  21148. - + ((short *) arptable[ARP_CLIENT].node)[2]);
  21149. - /* simplified version of the LCG given in Bruce Schneier's
  21150. - "Applied Cryptography" */
  21151. - q = seed / 53668;
  21152. - if ((seed = 40014 * (seed - 53668 * q) - 12211 *q ) < 0)
  21153. - seed += 2147483563L;
  21154. - tmo = (base << exp) + (TICKS_PER_SEC - (seed / TWO_SECOND_DIVISOR));
  21155. - return tmo;
  21156. -}
  21157. -
  21158. -/**************************************************************************
  21159. -CLEANUP - shut down networking
  21160. -**************************************************************************/
  21161. -void
  21162. -cleanup_net (void)
  21163. -{
  21164. - if (network_ready)
  21165. - {
  21166. - /* Stop receiving packets. */
  21167. - eth_disable ();
  21168. - network_ready = 0;
  21169. - }
  21170. -}
  21171. diff -Naur grub-0.97.orig/netboot/mii.h grub-0.97/netboot/mii.h
  21172. --- grub-0.97.orig/netboot/mii.h 1970-01-01 00:00:00.000000000 +0000
  21173. +++ grub-0.97/netboot/mii.h 2005-08-31 19:03:35.000000000 +0000
  21174. @@ -0,0 +1,105 @@
  21175. +/*
  21176. + * linux/mii.h: definitions for MII-compatible transceivers
  21177. + * Originally drivers/net/sunhme.h.
  21178. + *
  21179. + * Copyright (C) 1996, 1999, 2001 David S. Miller (davem@redhat.com)
  21180. + *
  21181. + * Copied Form Linux 2.4.25 an unneeded items removed by:
  21182. + * Timothy Legge (timlegge at etherboot dot org)
  21183. + *
  21184. + * 03/26/2004
  21185. + */
  21186. +
  21187. +/* Generic MII registers. */
  21188. +
  21189. +#define MII_BMCR 0x00 /* Basic mode control register */
  21190. +#define MII_BMSR 0x01 /* Basic mode status register */
  21191. +#define MII_PHYSID1 0x02 /* PHYS ID 1 */
  21192. +#define MII_PHYSID2 0x03 /* PHYS ID 2 */
  21193. +#define MII_ADVERTISE 0x04 /* Advertisement control reg */
  21194. +#define MII_LPA 0x05 /* Link partner ability reg */
  21195. +#define MII_EXPANSION 0x06 /* Expansion register */
  21196. +#define MII_DCOUNTER 0x12 /* Disconnect counter */
  21197. +#define MII_FCSCOUNTER 0x13 /* False carrier counter */
  21198. +#define MII_NWAYTEST 0x14 /* N-way auto-neg test reg */
  21199. +#define MII_RERRCOUNTER 0x15 /* Receive error counter */
  21200. +#define MII_SREVISION 0x16 /* Silicon revision */
  21201. +#define MII_RESV1 0x17 /* Reserved... */
  21202. +#define MII_LBRERROR 0x18 /* Lpback, rx, bypass error */
  21203. +#define MII_PHYADDR 0x19 /* PHY address */
  21204. +#define MII_RESV2 0x1a /* Reserved... */
  21205. +#define MII_TPISTATUS 0x1b /* TPI status for 10mbps */
  21206. +#define MII_NCONFIG 0x1c /* Network interface config */
  21207. +
  21208. +/* Basic mode control register. */
  21209. +#define BMCR_RESV 0x007f /* Unused... */
  21210. +#define BMCR_CTST 0x0080 /* Collision test */
  21211. +#define BMCR_FULLDPLX 0x0100 /* Full duplex */
  21212. +#define BMCR_ANRESTART 0x0200 /* Auto negotiation restart */
  21213. +#define BMCR_ISOLATE 0x0400 /* Disconnect DP83840 from MII */
  21214. +#define BMCR_PDOWN 0x0800 /* Powerdown the DP83840 */
  21215. +#define BMCR_ANENABLE 0x1000 /* Enable auto negotiation */
  21216. +#define BMCR_SPEED100 0x2000 /* Select 100Mbps */
  21217. +#define BMCR_LOOPBACK 0x4000 /* TXD loopback bits */
  21218. +#define BMCR_RESET 0x8000 /* Reset the DP83840 */
  21219. +
  21220. +/* Basic mode status register. */
  21221. +#define BMSR_ERCAP 0x0001 /* Ext-reg capability */
  21222. +#define BMSR_JCD 0x0002 /* Jabber detected */
  21223. +#define BMSR_LSTATUS 0x0004 /* Link status */
  21224. +#define BMSR_ANEGCAPABLE 0x0008 /* Able to do auto-negotiation */
  21225. +#define BMSR_RFAULT 0x0010 /* Remote fault detected */
  21226. +#define BMSR_ANEGCOMPLETE 0x0020 /* Auto-negotiation complete */
  21227. +#define BMSR_RESV 0x07c0 /* Unused... */
  21228. +#define BMSR_10HALF 0x0800 /* Can do 10mbps, half-duplex */
  21229. +#define BMSR_10FULL 0x1000 /* Can do 10mbps, full-duplex */
  21230. +#define BMSR_100HALF 0x2000 /* Can do 100mbps, half-duplex */
  21231. +#define BMSR_100FULL 0x4000 /* Can do 100mbps, full-duplex */
  21232. +#define BMSR_100BASE4 0x8000 /* Can do 100mbps, 4k packets */
  21233. +
  21234. +/* Advertisement control register. */
  21235. +#define ADVERTISE_SLCT 0x001f /* Selector bits */
  21236. +#define ADVERTISE_CSMA 0x0001 /* Only selector supported */
  21237. +#define ADVERTISE_10HALF 0x0020 /* Try for 10mbps half-duplex */
  21238. +#define ADVERTISE_10FULL 0x0040 /* Try for 10mbps full-duplex */
  21239. +#define ADVERTISE_100HALF 0x0080 /* Try for 100mbps half-duplex */
  21240. +#define ADVERTISE_100FULL 0x0100 /* Try for 100mbps full-duplex */
  21241. +#define ADVERTISE_100BASE4 0x0200 /* Try for 100mbps 4k packets */
  21242. +#define ADVERTISE_RESV 0x1c00 /* Unused... */
  21243. +#define ADVERTISE_RFAULT 0x2000 /* Say we can detect faults */
  21244. +#define ADVERTISE_LPACK 0x4000 /* Ack link partners response */
  21245. +#define ADVERTISE_NPAGE 0x8000 /* Next page bit */
  21246. +
  21247. +#define ADVERTISE_FULL (ADVERTISE_100FULL | ADVERTISE_10FULL | \
  21248. + ADVERTISE_CSMA)
  21249. +#define ADVERTISE_ALL (ADVERTISE_10HALF | ADVERTISE_10FULL | \
  21250. + ADVERTISE_100HALF | ADVERTISE_100FULL)
  21251. +
  21252. +/* Link partner ability register. */
  21253. +#define LPA_SLCT 0x001f /* Same as advertise selector */
  21254. +#define LPA_10HALF 0x0020 /* Can do 10mbps half-duplex */
  21255. +#define LPA_10FULL 0x0040 /* Can do 10mbps full-duplex */
  21256. +#define LPA_100HALF 0x0080 /* Can do 100mbps half-duplex */
  21257. +#define LPA_100FULL 0x0100 /* Can do 100mbps full-duplex */
  21258. +#define LPA_100BASE4 0x0200 /* Can do 100mbps 4k packets */
  21259. +#define LPA_RESV 0x1c00 /* Unused... */
  21260. +#define LPA_RFAULT 0x2000 /* Link partner faulted */
  21261. +#define LPA_LPACK 0x4000 /* Link partner acked us */
  21262. +#define LPA_NPAGE 0x8000 /* Next page bit */
  21263. +
  21264. +#define LPA_DUPLEX (LPA_10FULL | LPA_100FULL)
  21265. +#define LPA_100 (LPA_100FULL | LPA_100HALF | LPA_100BASE4)
  21266. +
  21267. +/* Expansion register for auto-negotiation. */
  21268. +#define EXPANSION_NWAY 0x0001 /* Can do N-way auto-nego */
  21269. +#define EXPANSION_LCWP 0x0002 /* Got new RX page code word */
  21270. +#define EXPANSION_ENABLENPAGE 0x0004 /* This enables npage words */
  21271. +#define EXPANSION_NPCAPABLE 0x0008 /* Link partner supports npage */
  21272. +#define EXPANSION_MFAULTS 0x0010 /* Multiple faults detected */
  21273. +#define EXPANSION_RESV 0xffe0 /* Unused... */
  21274. +
  21275. +/* N-way test register. */
  21276. +#define NWAYTEST_RESV1 0x00ff /* Unused... */
  21277. +#define NWAYTEST_LOOPBACK 0x0100 /* Enable loopback for N-way */
  21278. +#define NWAYTEST_RESV2 0xfe00 /* Unused... */
  21279. +
  21280. diff -Naur grub-0.97.orig/netboot/misc.c grub-0.97/netboot/misc.c
  21281. --- grub-0.97.orig/netboot/misc.c 2003-07-09 11:45:37.000000000 +0000
  21282. +++ grub-0.97/netboot/misc.c 2005-08-31 19:03:35.000000000 +0000
  21283. @@ -19,37 +19,90 @@
  21284. /* Based on "src/misc.c" in etherboot-5.0.5. */
  21285. -#define GRUB 1
  21286. -#include <etherboot.h>
  21287. +#include "grub.h"
  21288. +#include "timer.h"
  21289. -void
  21290. -sleep (int secs)
  21291. +#include "nic.h"
  21292. +
  21293. +/**************************************************************************
  21294. +RANDOM - compute a random number between 0 and 2147483647L or 2147483562?
  21295. +**************************************************************************/
  21296. +int32_t random(void)
  21297. {
  21298. - unsigned long tmo = currticks () + secs;
  21299. + static int32_t seed = 0;
  21300. + int32_t q;
  21301. + if (!seed) /* Initialize linear congruential generator */
  21302. + seed = currticks() + *(int32_t *)&arptable[ARP_CLIENT].node
  21303. + + ((int16_t *)arptable[ARP_CLIENT].node)[2];
  21304. + /* simplified version of the LCG given in Bruce Schneier's
  21305. + "Applied Cryptography" */
  21306. + q = seed/53668;
  21307. + if ((seed = 40014*(seed-53668*q) - 12211*q) < 0) seed += 2147483563L;
  21308. + return seed;
  21309. +}
  21310. - while (currticks () < tmo)
  21311. - ;
  21312. +/**************************************************************************
  21313. +POLL INTERRUPTIONS
  21314. +**************************************************************************/
  21315. +void poll_interruptions(void)
  21316. +{
  21317. + if (checkkey() != -1 && ASCII_CHAR(getkey()) == K_INTR) {
  21318. + user_abort++;
  21319. + }
  21320. }
  21321. -void
  21322. -twiddle (void)
  21323. +/**************************************************************************
  21324. +SLEEP
  21325. +**************************************************************************/
  21326. +void sleep(int secs)
  21327. {
  21328. - static unsigned long lastticks = 0;
  21329. - static int count = 0;
  21330. - static const char tiddles[]="-\\|/";
  21331. - unsigned long ticks;
  21332. + unsigned long tmo;
  21333. - if (debug)
  21334. - {
  21335. - if ((ticks = currticks ()) == lastticks)
  21336. - return;
  21337. -
  21338. - lastticks = ticks;
  21339. - grub_putchar (tiddles[(count++) & 3]);
  21340. - grub_putchar ('\b');
  21341. - }
  21342. + for (tmo = currticks()+secs*TICKS_PER_SEC; currticks() < tmo; ) {
  21343. + poll_interruptions();
  21344. + }
  21345. +}
  21346. +
  21347. +/**************************************************************************
  21348. +INTERRUPTIBLE SLEEP
  21349. +**************************************************************************/
  21350. +void interruptible_sleep(int secs)
  21351. +{
  21352. + printf("<sleep>\n");
  21353. + return sleep(secs);
  21354. +}
  21355. +
  21356. +/**************************************************************************
  21357. +TWIDDLE
  21358. +**************************************************************************/
  21359. +void twiddle(void)
  21360. +{
  21361. +#ifdef BAR_PROGRESS
  21362. + static int count=0;
  21363. + static const char tiddles[]="-\\|/";
  21364. + static unsigned long lastticks = 0;
  21365. + unsigned long ticks;
  21366. +#endif
  21367. +#ifdef FREEBSD_PXEEMU
  21368. + extern char pxeemu_nbp_active;
  21369. + if(pxeemu_nbp_active != 0)
  21370. + return;
  21371. +#endif
  21372. +#ifdef BAR_PROGRESS
  21373. + /* Limit the maximum rate at which characters are printed */
  21374. + ticks = currticks();
  21375. + if ((lastticks + (TICKS_PER_SEC/18)) > ticks)
  21376. + return;
  21377. + lastticks = ticks;
  21378. +
  21379. + putchar(tiddles[(count++)&3]);
  21380. + putchar('\b');
  21381. +#else
  21382. + //putchar('.');
  21383. +#endif /* BAR_PROGRESS */
  21384. }
  21385. +
  21386. /* Because Etherboot uses its own formats for the printf family,
  21387. define separate definitions from GRUB. */
  21388. /**************************************************************************
  21389. @@ -264,3 +317,5 @@
  21390. return ret;
  21391. }
  21392. +
  21393. +
  21394. diff -Naur grub-0.97.orig/netboot/natsemi.c grub-0.97/netboot/natsemi.c
  21395. --- grub-0.97.orig/netboot/natsemi.c 2003-07-09 11:45:38.000000000 +0000
  21396. +++ grub-0.97/netboot/natsemi.c 2005-08-31 19:53:07.000000000 +0000
  21397. @@ -47,15 +47,15 @@
  21398. /* Revision History */
  21399. /*
  21400. + 13 Dec 2003 timlegge 1.1 Enabled Multicast Support
  21401. 29 May 2001 mdc 1.0
  21402. Initial Release. Tested with Netgear FA311 and FA312 boards
  21403. -*/
  21404. +*/
  21405. /* Includes */
  21406. #include "etherboot.h"
  21407. #include "nic.h"
  21408. #include "pci.h"
  21409. -#include "cards.h"
  21410. /* defines */
  21411. @@ -71,21 +71,18 @@
  21412. #define NUM_RX_DESC 4 /* Number of Rx descriptor registers. */
  21413. -typedef unsigned char u8;
  21414. -typedef signed char s8;
  21415. -typedef unsigned short u16;
  21416. -typedef signed short s16;
  21417. -typedef unsigned int u32;
  21418. -typedef signed int s32;
  21419. +typedef uint8_t u8;
  21420. +typedef int8_t s8;
  21421. +typedef uint16_t u16;
  21422. +typedef int16_t s16;
  21423. +typedef uint32_t u32;
  21424. +typedef int32_t s32;
  21425. /* helpful macroes if on a big_endian machine for changing byte order.
  21426. not strictly needed on Intel */
  21427. -#define le16_to_cpu(val) (val)
  21428. -#define cpu_to_le32(val) (val)
  21429. #define get_unaligned(ptr) (*(ptr))
  21430. #define put_unaligned(val, ptr) ((void)( *(ptr) = (val) ))
  21431. #define get_u16(ptr) (*(u16 *)(ptr))
  21432. -#define virt_to_bus(x) ((unsigned long)x)
  21433. #define virt_to_le32desc(addr) virt_to_bus(addr)
  21434. enum pcistuff {
  21435. @@ -161,7 +158,8 @@
  21436. AcceptMulticast = 0x00200000,
  21437. AcceptAllMulticast = 0x20000000,
  21438. AcceptAllPhys = 0x10000000,
  21439. - AcceptMyPhys = 0x08000000
  21440. + AcceptMyPhys = 0x08000000,
  21441. + RxFilterEnable = 0x80000000
  21442. };
  21443. typedef struct _BufferDesc {
  21444. @@ -207,17 +205,12 @@
  21445. static BufferDesc txd __attribute__ ((aligned(4)));
  21446. static BufferDesc rxd[NUM_RX_DESC] __attribute__ ((aligned(4)));
  21447. -#ifdef USE_LOWMEM_BUFFER
  21448. -#define txb ((char *)0x10000 - TX_BUF_SIZE)
  21449. -#define rxb ((char *)0x10000 - NUM_RX_DESC*RX_BUF_SIZE - TX_BUF_SIZE)
  21450. -#else
  21451. static unsigned char txb[TX_BUF_SIZE] __attribute__ ((aligned(4)));
  21452. static unsigned char rxb[NUM_RX_DESC * RX_BUF_SIZE] __attribute__ ((aligned(4)));
  21453. -#endif
  21454. /* Function Prototypes */
  21455. -struct nic *natsemi_probe(struct nic *nic, unsigned short *io_addrs, struct pci_device *pci);
  21456. +static int natsemi_probe(struct dev *dev, struct pci_device *pci);
  21457. static int eeprom_read(long addr, int location);
  21458. static int mdio_read(int phy_id, int location);
  21459. static void natsemi_init(struct nic *nic);
  21460. @@ -228,8 +221,9 @@
  21461. static void natsemi_set_rx_mode(struct nic *nic);
  21462. static void natsemi_check_duplex(struct nic *nic);
  21463. static void natsemi_transmit(struct nic *nic, const char *d, unsigned int t, unsigned int s, const char *p);
  21464. -static int natsemi_poll(struct nic *nic);
  21465. -static void natsemi_disable(struct nic *nic);
  21466. +static int natsemi_poll(struct nic *nic, int retrieve);
  21467. +static void natsemi_disable(struct dev *dev);
  21468. +static void natsemi_irq(struct nic *nic, irq_action_t action);
  21469. /*
  21470. * Function: natsemi_probe
  21471. @@ -245,24 +239,28 @@
  21472. * Returns: struct nic *: pointer to NIC data structure
  21473. */
  21474. -struct nic *
  21475. -natsemi_probe(struct nic *nic, unsigned short *io_addrs, struct pci_device *pci)
  21476. +static int
  21477. +natsemi_probe(struct dev *dev, struct pci_device *pci)
  21478. {
  21479. + struct nic *nic = (struct nic *)dev;
  21480. int i;
  21481. int prev_eedata;
  21482. u32 tmp;
  21483. - if (io_addrs == 0 || *io_addrs == 0)
  21484. - return NULL;
  21485. + if (pci->ioaddr == 0)
  21486. + return 0;
  21487. +
  21488. + adjust_pci_device(pci);
  21489. /* initialize some commonly used globals */
  21490. - ioaddr = *io_addrs & ~3;
  21491. + nic->irqno = 0;
  21492. + nic->ioaddr = pci->ioaddr & ~3;
  21493. +
  21494. + ioaddr = pci->ioaddr & ~3;
  21495. vendor = pci->vendor;
  21496. dev_id = pci->dev_id;
  21497. nic_name = pci->name;
  21498. -
  21499. - adjust_pci_device(pci);
  21500. /* natsemi has a non-standard PM control register
  21501. * in PCI config space. Some boards apparently need
  21502. @@ -317,12 +315,12 @@
  21503. /* initialize device */
  21504. natsemi_init(nic);
  21505. - nic->reset = natsemi_init;
  21506. + dev->disable = natsemi_disable;
  21507. nic->poll = natsemi_poll;
  21508. nic->transmit = natsemi_transmit;
  21509. - nic->disable = natsemi_disable;
  21510. + nic->irq = natsemi_irq;
  21511. - return nic;
  21512. + return 1;
  21513. }
  21514. /* Read the EEPROM and MII Management Data I/O (MDIO) interfaces.
  21515. @@ -452,7 +450,7 @@
  21516. * Returns: void.
  21517. */
  21518. static void
  21519. -natsemi_reset(struct nic *nic)
  21520. +natsemi_reset(struct nic *nic __unused)
  21521. {
  21522. outl(ChipReset, ioaddr + ChipCmd);
  21523. @@ -504,14 +502,14 @@
  21524. */
  21525. static void
  21526. -natsemi_init_txd(struct nic *nic)
  21527. +natsemi_init_txd(struct nic *nic __unused)
  21528. {
  21529. txd.link = (u32) 0;
  21530. txd.cmdsts = (u32) 0;
  21531. - txd.bufptr = (u32) &txb[0];
  21532. + txd.bufptr = virt_to_bus(&txb[0]);
  21533. /* load Transmit Descriptor Register */
  21534. - outl((u32) &txd, ioaddr + TxRingPtr);
  21535. + outl(virt_to_bus(&txd), ioaddr + TxRingPtr);
  21536. if (natsemi_debug > 1)
  21537. printf("natsemi_init_txd: TX descriptor register loaded with: %X\n",
  21538. inl(ioaddr + TxRingPtr));
  21539. @@ -527,7 +525,7 @@
  21540. */
  21541. static void
  21542. -natsemi_init_rxd(struct nic *nic)
  21543. +natsemi_init_rxd(struct nic *nic __unused)
  21544. {
  21545. int i;
  21546. @@ -535,16 +533,16 @@
  21547. /* init RX descriptor */
  21548. for (i = 0; i < NUM_RX_DESC; i++) {
  21549. - rxd[i].link = (i+1 < NUM_RX_DESC) ? (u32) &rxd[i+1] : (u32) &rxd[0];
  21550. + rxd[i].link = virt_to_bus((i+1 < NUM_RX_DESC) ? &rxd[i+1] : &rxd[0]);
  21551. rxd[i].cmdsts = (u32) RX_BUF_SIZE;
  21552. - rxd[i].bufptr = (u32) &rxb[i*RX_BUF_SIZE];
  21553. + rxd[i].bufptr = virt_to_bus(&rxb[i*RX_BUF_SIZE]);
  21554. if (natsemi_debug > 1)
  21555. printf("natsemi_init_rxd: rxd[%d]=%X link=%X cmdsts=%X bufptr=%X\n",
  21556. i, &rxd[i], rxd[i].link, rxd[i].cmdsts, rxd[i].bufptr);
  21557. }
  21558. /* load Receive Descriptor Register */
  21559. - outl((u32) &rxd[0], ioaddr + RxRingPtr);
  21560. + outl(virt_to_bus(&rxd[0]), ioaddr + RxRingPtr);
  21561. if (natsemi_debug > 1)
  21562. printf("natsemi_init_rxd: RX descriptor register loaded with: %X\n",
  21563. @@ -562,14 +560,15 @@
  21564. * Returns: void.
  21565. */
  21566. -static void natsemi_set_rx_mode(struct nic *nic)
  21567. +static void natsemi_set_rx_mode(struct nic *nic __unused)
  21568. {
  21569. - u32 rx_mode = AcceptBroadcast | AcceptMyPhys;
  21570. + u32 rx_mode = RxFilterEnable | AcceptBroadcast |
  21571. + AcceptAllMulticast | AcceptMyPhys;
  21572. outl(rx_mode, ioaddr + RxFilterAddr);
  21573. }
  21574. -static void natsemi_check_duplex(struct nic *nic)
  21575. +static void natsemi_check_duplex(struct nic *nic __unused)
  21576. {
  21577. int duplex = inl(ioaddr + ChipConfig) & 0x20000000 ? 1 : 0;
  21578. @@ -607,14 +606,14 @@
  21579. unsigned int s, /* size */
  21580. const char *p) /* Packet */
  21581. {
  21582. - u32 status, to, nstype;
  21583. + u32 to, nstype;
  21584. u32 tx_status;
  21585. /* Stop the transmitter */
  21586. outl(TxOff, ioaddr + ChipCmd);
  21587. /* load Transmit Descriptor Register */
  21588. - outl((u32) &txd, ioaddr + TxRingPtr);
  21589. + outl(virt_to_bus(&txd), ioaddr + TxRingPtr);
  21590. if (natsemi_debug > 1)
  21591. printf("natsemi_transmit: TX descriptor register loaded with: %X\n",
  21592. inl(ioaddr + TxRingPtr));
  21593. @@ -636,7 +635,7 @@
  21594. txb[s++] = '\0';
  21595. /* set the transmit buffer descriptor and enable Transmit State Machine */
  21596. - txd.bufptr = (u32) &txb[0];
  21597. + txd.bufptr = virt_to_bus(&txb[0]);
  21598. txd.cmdsts = (u32) OWN | s;
  21599. /* restart the transmitter */
  21600. @@ -647,7 +646,7 @@
  21601. to = currticks() + TX_TIMEOUT;
  21602. - while ((((volatile u32) tx_status=txd.cmdsts) & OWN) && (currticks() < to))
  21603. + while ((volatile u32) ( tx_status=txd.cmdsts & OWN) && (currticks() < to))
  21604. /* wait */ ;
  21605. if (currticks() >= to) {
  21606. @@ -674,7 +673,7 @@
  21607. */
  21608. static int
  21609. -natsemi_poll(struct nic *nic)
  21610. +natsemi_poll(struct nic *nic, int retrieve)
  21611. {
  21612. u32 rx_status = rxd[cur_rx].cmdsts;
  21613. int retstat = 0;
  21614. @@ -685,6 +684,8 @@
  21615. if (!(rx_status & OWN))
  21616. return retstat;
  21617. + if ( ! retrieve ) return 1;
  21618. +
  21619. if (natsemi_debug > 1)
  21620. printf("natsemi_poll: got a packet: cur_rx:%d, status:%X\n",
  21621. cur_rx, rx_status);
  21622. @@ -704,7 +705,7 @@
  21623. /* return the descriptor and buffer to receive ring */
  21624. rxd[cur_rx].cmdsts = RX_BUF_SIZE;
  21625. - rxd[cur_rx].bufptr = (u32) &rxb[cur_rx*RX_BUF_SIZE];
  21626. + rxd[cur_rx].bufptr = virt_to_bus(&rxb[cur_rx*RX_BUF_SIZE]);
  21627. if (++cur_rx == NUM_RX_DESC)
  21628. cur_rx = 0;
  21629. @@ -725,8 +726,12 @@
  21630. */
  21631. static void
  21632. -natsemi_disable(struct nic *nic)
  21633. +natsemi_disable(struct dev *dev)
  21634. {
  21635. + struct nic *nic = (struct nic *)dev;
  21636. + /* merge reset and disable */
  21637. + natsemi_init(nic);
  21638. +
  21639. /* Disable interrupts using the mask. */
  21640. outl(0, ioaddr + IntrMask);
  21641. outl(0, ioaddr + IntrEnable);
  21642. @@ -737,3 +742,39 @@
  21643. /* Restore PME enable bit */
  21644. outl(SavedClkRun, ioaddr + ClkRun);
  21645. }
  21646. +
  21647. +/* Function: natsemi_irq
  21648. + *
  21649. + * Description: Enable, Disable, or Force interrupts
  21650. + *
  21651. + * Arguments: struct nic *nic: NIC data structure
  21652. + * irq_action_t action: requested action to perform
  21653. + *
  21654. + * Returns: void.
  21655. + */
  21656. +
  21657. +static void
  21658. +natsemi_irq(struct nic *nic __unused, irq_action_t action __unused)
  21659. +{
  21660. + switch ( action ) {
  21661. + case DISABLE :
  21662. + break;
  21663. + case ENABLE :
  21664. + break;
  21665. + case FORCE :
  21666. + break;
  21667. + }
  21668. +}
  21669. +
  21670. +static struct pci_id natsemi_nics[] = {
  21671. +PCI_ROM(0x100b, 0x0020, "dp83815", "DP83815"),
  21672. +};
  21673. +
  21674. +struct pci_driver natsemi_driver = {
  21675. + .type = NIC_DRIVER,
  21676. + .name = "NATSEMI",
  21677. + .probe = natsemi_probe,
  21678. + .ids = natsemi_nics,
  21679. + .id_count = sizeof(natsemi_nics)/sizeof(natsemi_nics[0]),
  21680. + .class = 0,
  21681. +};
  21682. diff -Naur grub-0.97.orig/netboot/nfs.h grub-0.97/netboot/nfs.h
  21683. --- grub-0.97.orig/netboot/nfs.h 1970-01-01 00:00:00.000000000 +0000
  21684. +++ grub-0.97/netboot/nfs.h 2005-08-31 19:03:35.000000000 +0000
  21685. @@ -0,0 +1,63 @@
  21686. +#ifndef _NFS_H
  21687. +#define _NFS_H
  21688. +
  21689. +#define SUNRPC_PORT 111
  21690. +
  21691. +#define PROG_PORTMAP 100000
  21692. +#define PROG_NFS 100003
  21693. +#define PROG_MOUNT 100005
  21694. +
  21695. +#define MSG_CALL 0
  21696. +#define MSG_REPLY 1
  21697. +
  21698. +#define PORTMAP_GETPORT 3
  21699. +
  21700. +#define MOUNT_ADDENTRY 1
  21701. +#define MOUNT_UMOUNTALL 4
  21702. +
  21703. +#define NFS_LOOKUP 4
  21704. +#define NFS_READLINK 5
  21705. +#define NFS_READ 6
  21706. +
  21707. +#define NFS_FHSIZE 32
  21708. +
  21709. +#define NFSERR_PERM 1
  21710. +#define NFSERR_NOENT 2
  21711. +#define NFSERR_ACCES 13
  21712. +#define NFSERR_ISDIR 21
  21713. +#define NFSERR_INVAL 22
  21714. +
  21715. +/* Block size used for NFS read accesses. A RPC reply packet (including all
  21716. + * headers) must fit within a single Ethernet frame to avoid fragmentation.
  21717. + * Chosen to be a power of two, as most NFS servers are optimized for this. */
  21718. +#define NFS_READ_SIZE 1024
  21719. +
  21720. +#define NFS_MAXLINKDEPTH 16
  21721. +
  21722. +struct rpc_t {
  21723. + struct iphdr ip;
  21724. + struct udphdr udp;
  21725. + union {
  21726. + uint8_t data[300]; /* longest RPC call must fit!!!! */
  21727. + struct {
  21728. + uint32_t id;
  21729. + uint32_t type;
  21730. + uint32_t rpcvers;
  21731. + uint32_t prog;
  21732. + uint32_t vers;
  21733. + uint32_t proc;
  21734. + uint32_t data[1];
  21735. + } call;
  21736. + struct {
  21737. + uint32_t id;
  21738. + uint32_t type;
  21739. + uint32_t rstatus;
  21740. + uint32_t verifier;
  21741. + uint32_t v2;
  21742. + uint32_t astatus;
  21743. + uint32_t data[1];
  21744. + } reply;
  21745. + } u;
  21746. +};
  21747. +
  21748. +#endif /* _NFS_H */
  21749. diff -Naur grub-0.97.orig/netboot/ni5010.c grub-0.97/netboot/ni5010.c
  21750. --- grub-0.97.orig/netboot/ni5010.c 2003-07-09 11:45:38.000000000 +0000
  21751. +++ grub-0.97/netboot/ni5010.c 1970-01-01 00:00:00.000000000 +0000
  21752. @@ -1,371 +0,0 @@
  21753. -/**************************************************************************
  21754. -Etherboot - BOOTP/TFTP Bootstrap Program
  21755. -Driver for NI5010.
  21756. -Code freely taken from Jan-Pascal van Best and Andreas Mohr's
  21757. -Linux NI5010 driver.
  21758. -***************************************************************************/
  21759. -
  21760. -/*
  21761. - * This program is free software; you can redistribute it and/or
  21762. - * modify it under the terms of the GNU General Public License as
  21763. - * published by the Free Software Foundation; either version 2, or (at
  21764. - * your option) any later version.
  21765. - */
  21766. -
  21767. -/* to get some global routines like printf */
  21768. -#include "etherboot.h"
  21769. -/* to get the interface to the body of the program */
  21770. -#include "nic.h"
  21771. -/* to get our own prototype */
  21772. -#include "cards.h"
  21773. -
  21774. -/* ni5010.h file included verbatim */
  21775. -/*
  21776. - * Racal-Interlan ni5010 Ethernet definitions
  21777. - *
  21778. - * This is an extension to the Linux operating system, and is covered by the
  21779. - * same Gnu Public License that covers that work.
  21780. - *
  21781. - * copyrights (c) 1996 by Jan-Pascal van Best (jvbest@wi.leidenuniv.nl)
  21782. - *
  21783. - * I have done a look in the following sources:
  21784. - * crynwr-packet-driver by Russ Nelson
  21785. - */
  21786. -
  21787. -#define NI5010_BUFSIZE 2048 /* number of bytes in a buffer */
  21788. -
  21789. -#define NI5010_MAGICVAL0 0x00 /* magic-values for ni5010 card */
  21790. -#define NI5010_MAGICVAL1 0x55
  21791. -#define NI5010_MAGICVAL2 0xAA
  21792. -
  21793. -#define SA_ADDR0 0x02
  21794. -#define SA_ADDR1 0x07
  21795. -#define SA_ADDR2 0x01
  21796. -
  21797. -/* The number of low I/O ports used by the ni5010 ethercard. */
  21798. -#define NI5010_IO_EXTENT 32
  21799. -
  21800. -#define PRINTK(x) if (NI5010_DEBUG) printk x
  21801. -#define PRINTK2(x) if (NI5010_DEBUG>=2) printk x
  21802. -#define PRINTK3(x) if (NI5010_DEBUG>=3) printk x
  21803. -
  21804. -/* The various IE command registers */
  21805. -#define EDLC_XSTAT (ioaddr + 0x00) /* EDLC transmit csr */
  21806. -#define EDLC_XCLR (ioaddr + 0x00) /* EDLC transmit "Clear IRQ" */
  21807. -#define EDLC_XMASK (ioaddr + 0x01) /* EDLC transmit "IRQ Masks" */
  21808. -#define EDLC_RSTAT (ioaddr + 0x02) /* EDLC receive csr */
  21809. -#define EDLC_RCLR (ioaddr + 0x02) /* EDLC receive "Clear IRQ" */
  21810. -#define EDLC_RMASK (ioaddr + 0x03) /* EDLC receive "IRQ Masks" */
  21811. -#define EDLC_XMODE (ioaddr + 0x04) /* EDLC transmit Mode */
  21812. -#define EDLC_RMODE (ioaddr + 0x05) /* EDLC receive Mode */
  21813. -#define EDLC_RESET (ioaddr + 0x06) /* EDLC RESET register */
  21814. -#define EDLC_TDR1 (ioaddr + 0x07) /* "Time Domain Reflectometry" reg1 */
  21815. -#define EDLC_ADDR (ioaddr + 0x08) /* EDLC station address, 6 bytes */
  21816. - /* 0x0E doesn't exist for r/w */
  21817. -#define EDLC_TDR2 (ioaddr + 0x0f) /* "Time Domain Reflectometry" reg2 */
  21818. -#define IE_GP (ioaddr + 0x10) /* GP pointer (word register) */
  21819. - /* 0x11 is 2nd byte of GP Pointer */
  21820. -#define IE_RCNT (ioaddr + 0x10) /* Count of bytes in rcv'd packet */
  21821. - /* 0x11 is 2nd byte of "Byte Count" */
  21822. -#define IE_MMODE (ioaddr + 0x12) /* Memory Mode register */
  21823. -#define IE_DMA_RST (ioaddr + 0x13) /* IE DMA Reset. write only */
  21824. -#define IE_ISTAT (ioaddr + 0x13) /* IE Interrupt Status. read only */
  21825. -#define IE_RBUF (ioaddr + 0x14) /* IE Receive Buffer port */
  21826. -#define IE_XBUF (ioaddr + 0x15) /* IE Transmit Buffer port */
  21827. -#define IE_SAPROM (ioaddr + 0x16) /* window on station addr prom */
  21828. -#define IE_RESET (ioaddr + 0x17) /* any write causes Board Reset */
  21829. -
  21830. -/* bits in EDLC_XSTAT, interrupt clear on write, status when read */
  21831. -#define XS_TPOK 0x80 /* transmit packet successful */
  21832. -#define XS_CS 0x40 /* carrier sense */
  21833. -#define XS_RCVD 0x20 /* transmitted packet received */
  21834. -#define XS_SHORT 0x10 /* transmission media is shorted */
  21835. -#define XS_UFLW 0x08 /* underflow. iff failed board */
  21836. -#define XS_COLL 0x04 /* collision occurred */
  21837. -#define XS_16COLL 0x02 /* 16th collision occurred */
  21838. -#define XS_PERR 0x01 /* parity error */
  21839. -
  21840. -#define XS_CLR_UFLW 0x08 /* clear underflow */
  21841. -#define XS_CLR_COLL 0x04 /* clear collision */
  21842. -#define XS_CLR_16COLL 0x02 /* clear 16th collision */
  21843. -#define XS_CLR_PERR 0x01 /* clear parity error */
  21844. -
  21845. -/* bits in EDLC_XMASK, mask/enable transmit interrupts. register is r/w */
  21846. -#define XM_TPOK 0x80 /* =1 to enable Xmt Pkt OK interrupts */
  21847. -#define XM_RCVD 0x20 /* =1 to enable Xmt Pkt Rcvd ints */
  21848. -#define XM_UFLW 0x08 /* =1 to enable Xmt Underflow ints */
  21849. -#define XM_COLL 0x04 /* =1 to enable Xmt Collision ints */
  21850. -#define XM_COLL16 0x02 /* =1 to enable Xmt 16th Coll ints */
  21851. -#define XM_PERR 0x01 /* =1 to enable Xmt Parity Error ints */
  21852. - /* note: always clear this bit */
  21853. -#define XM_ALL (XM_TPOK | XM_RCVD | XM_UFLW | XM_COLL | XM_COLL16)
  21854. -
  21855. -/* bits in EDLC_RSTAT, interrupt clear on write, status when read */
  21856. -#define RS_PKT_OK 0x80 /* received good packet */
  21857. -#define RS_RST_PKT 0x10 /* RESET packet received */
  21858. -#define RS_RUNT 0x08 /* Runt Pkt rcvd. Len < 64 Bytes */
  21859. -#define RS_ALIGN 0x04 /* Alignment error. not 8 bit aligned */
  21860. -#define RS_CRC_ERR 0x02 /* Bad CRC on rcvd pkt */
  21861. -#define RS_OFLW 0x01 /* overflow for rcv FIFO */
  21862. -#define RS_VALID_BITS ( RS_PKT_OK | RS_RST_PKT | RS_RUNT | RS_ALIGN | RS_CRC_ERR | RS_OFLW )
  21863. - /* all valid RSTAT bits */
  21864. -
  21865. -#define RS_CLR_PKT_OK 0x80 /* clear rcvd packet interrupt */
  21866. -#define RS_CLR_RST_PKT 0x10 /* clear RESET packet received */
  21867. -#define RS_CLR_RUNT 0x08 /* clear Runt Pckt received */
  21868. -#define RS_CLR_ALIGN 0x04 /* clear Alignment error */
  21869. -#define RS_CLR_CRC_ERR 0x02 /* clear CRC error */
  21870. -#define RS_CLR_OFLW 0x01 /* clear rcv FIFO Overflow */
  21871. -
  21872. -/* bits in EDLC_RMASK, mask/enable receive interrupts. register is r/w */
  21873. -#define RM_PKT_OK 0x80 /* =1 to enable rcvd good packet ints */
  21874. -#define RM_RST_PKT 0x10 /* =1 to enable RESET packet ints */
  21875. -#define RM_RUNT 0x08 /* =1 to enable Runt Pkt rcvd ints */
  21876. -#define RM_ALIGN 0x04 /* =1 to enable Alignment error ints */
  21877. -#define RM_CRC_ERR 0x02 /* =1 to enable Bad CRC error ints */
  21878. -#define RM_OFLW 0x01 /* =1 to enable overflow error ints */
  21879. -
  21880. -/* bits in EDLC_RMODE, set Receive Packet mode. register is r/w */
  21881. -#define RMD_TEST 0x80 /* =1 for Chip testing. normally 0 */
  21882. -#define RMD_ADD_SIZ 0x10 /* =1 5-byte addr match. normally 0 */
  21883. -#define RMD_EN_RUNT 0x08 /* =1 enable runt rcv. normally 0 */
  21884. -#define RMD_EN_RST 0x04 /* =1 to rcv RESET pkt. normally 0 */
  21885. -
  21886. -#define RMD_PROMISC 0x03 /* receive *all* packets. unusual */
  21887. -#define RMD_MULTICAST 0x02 /* receive multicasts too. unusual */
  21888. -#define RMD_BROADCAST 0x01 /* receive broadcasts & normal. usual */
  21889. -#define RMD_NO_PACKETS 0x00 /* don't receive any packets. unusual */
  21890. -
  21891. -/* bits in EDLC_XMODE, set Transmit Packet mode. register is r/w */
  21892. -#define XMD_COLL_CNT 0xf0 /* coll's since success. read-only */
  21893. -#define XMD_IG_PAR 0x08 /* =1 to ignore parity. ALWAYS set */
  21894. -#define XMD_T_MODE 0x04 /* =1 to power xcvr. ALWAYS set this */
  21895. -#define XMD_LBC 0x02 /* =1 for loopback. normally set */
  21896. -#define XMD_DIS_C 0x01 /* =1 disables contention. normally 0 */
  21897. -
  21898. -/* bits in EDLC_RESET, write only */
  21899. -#define RS_RESET 0x80 /* =1 to hold EDLC in reset state */
  21900. -
  21901. -/* bits in IE_MMODE, write only */
  21902. -#define MM_EN_DMA 0x80 /* =1 begin DMA xfer, Cplt clrs it */
  21903. -#define MM_EN_RCV 0x40 /* =1 allows Pkt rcv. clr'd by rcv */
  21904. -#define MM_EN_XMT 0x20 /* =1 begin Xmt pkt. Cplt clrs it */
  21905. -#define MM_BUS_PAGE 0x18 /* =00 ALWAYS. Used when MUX=1 */
  21906. -#define MM_NET_PAGE 0x06 /* =00 ALWAYS. Used when MUX=0 */
  21907. -#define MM_MUX 0x01 /* =1 means Rcv Buff on system bus */
  21908. - /* =0 means Xmt Buff on system bus */
  21909. -
  21910. -/* bits in IE_ISTAT, read only */
  21911. -#define IS_TDIAG 0x80 /* =1 if Diagnostic problem */
  21912. -#define IS_EN_RCV 0x20 /* =1 until frame is rcv'd cplt */
  21913. -#define IS_EN_XMT 0x10 /* =1 until frame is xmt'd cplt */
  21914. -#define IS_EN_DMA 0x08 /* =1 until DMA is cplt or aborted */
  21915. -#define IS_DMA_INT 0x04 /* =0 iff DMA done interrupt. */
  21916. -#define IS_R_INT 0x02 /* =0 iff unmasked Rcv interrupt */
  21917. -#define IS_X_INT 0x01 /* =0 iff unmasked Xmt interrupt */
  21918. -
  21919. -/* NIC specific static variables go here */
  21920. -
  21921. -static unsigned short ioaddr = 0;
  21922. -static unsigned int bufsize_rcv = 0;
  21923. -
  21924. -#if 0
  21925. -static void show_registers(void)
  21926. -{
  21927. - printf("XSTAT %hhX ", inb(EDLC_XSTAT));
  21928. - printf("XMASK %hhX ", inb(EDLC_XMASK));
  21929. - printf("RSTAT %hhX ", inb(EDLC_RSTAT));
  21930. - printf("RMASK %hhX ", inb(EDLC_RMASK));
  21931. - printf("RMODE %hhX ", inb(EDLC_RMODE));
  21932. - printf("XMODE %hhX ", inb(EDLC_XMODE));
  21933. - printf("ISTAT %hhX\n", inb(IE_ISTAT));
  21934. -}
  21935. -#endif
  21936. -
  21937. -static void reset_receiver(void)
  21938. -{
  21939. - outw(0, IE_GP); /* Receive packet at start of buffer */
  21940. - outb(RS_VALID_BITS, EDLC_RCLR); /* Clear all pending Rcv interrupts */
  21941. - outb(MM_EN_RCV, IE_MMODE); /* Enable rcv */
  21942. -}
  21943. -
  21944. -/**************************************************************************
  21945. -RESET - Reset adapter
  21946. -***************************************************************************/
  21947. -static void ni5010_reset(struct nic *nic)
  21948. -{
  21949. - int i;
  21950. -
  21951. - /* Reset the hardware here. Don't forget to set the station address. */
  21952. - outb(RS_RESET, EDLC_RESET); /* Hold up EDLC_RESET while configing board */
  21953. - outb(0, IE_RESET); /* Hardware reset of ni5010 board */
  21954. - outb(0, EDLC_XMASK); /* Disable all Xmt interrupts */
  21955. - outb(0, EDLC_RMASK); /* Disable all Rcv interrupt */
  21956. - outb(0xFF, EDLC_XCLR); /* Clear all pending Xmt interrupts */
  21957. - outb(0xFF, EDLC_RCLR); /* Clear all pending Rcv interrupts */
  21958. - outb(XMD_LBC, EDLC_XMODE); /* Only loopback xmits */
  21959. - /* Set the station address */
  21960. - for(i = 0; i < ETH_ALEN; i++)
  21961. - outb(nic->node_addr[i], EDLC_ADDR + i);
  21962. - outb(XMD_IG_PAR | XMD_T_MODE | XMD_LBC, EDLC_XMODE);
  21963. - /* Normal packet xmit mode */
  21964. - outb(RMD_BROADCAST, EDLC_RMODE);
  21965. - /* Receive broadcast and normal packets */
  21966. - reset_receiver();
  21967. - outb(0x00, EDLC_RESET); /* Un-reset the ni5010 */
  21968. -}
  21969. -
  21970. -/**************************************************************************
  21971. -POLL - Wait for a frame
  21972. -***************************************************************************/
  21973. -static int ni5010_poll(struct nic *nic)
  21974. -{
  21975. - int rcv_stat;
  21976. -
  21977. - if (((rcv_stat = inb(EDLC_RSTAT)) & RS_VALID_BITS) != RS_PKT_OK) {
  21978. - outb(rcv_stat, EDLC_RSTAT); /* Clear the status */
  21979. - return (0);
  21980. - }
  21981. - outb(rcv_stat, EDLC_RCLR); /* Clear the status */
  21982. - nic->packetlen = inw(IE_RCNT);
  21983. - /* Read packet into buffer */
  21984. - outb(MM_MUX, IE_MMODE); /* Rcv buffer to system bus */
  21985. - outw(0, IE_GP); /* Seek to beginning of packet */
  21986. - insb(IE_RBUF, nic->packet, nic->packetlen);
  21987. - return (1);
  21988. -}
  21989. -
  21990. -/**************************************************************************
  21991. -TRANSMIT - Transmit a frame
  21992. -***************************************************************************/
  21993. -static void ni5010_transmit(struct nic *nic,
  21994. - const char *d, /* Destination */
  21995. - unsigned int t, /* Type */
  21996. - unsigned int s, /* size */
  21997. - const char *p) /* Packet */
  21998. -{
  21999. - unsigned int len;
  22000. - int buf_offs, xmt_stat;
  22001. - unsigned long time;
  22002. -
  22003. - len = s + ETH_HLEN;
  22004. - if (len < ETH_ZLEN)
  22005. - len = ETH_ZLEN;
  22006. - buf_offs = NI5010_BUFSIZE - len;
  22007. - outb(0, EDLC_RMASK); /* Mask all receive interrupts */
  22008. - outb(0, IE_MMODE); /* Put Xmit buffer on system bus */
  22009. - outb(0xFF, EDLC_RCLR); /* Clear out pending rcv interrupts */
  22010. - outw(buf_offs, IE_GP); /* Point GP at start of packet */
  22011. - outsb(IE_XBUF, d, ETH_ALEN); /* Put dst in buffer */
  22012. - outsb(IE_XBUF, nic->node_addr, ETH_ALEN);/* Put src in buffer */
  22013. - outb(t >> 8, IE_XBUF);
  22014. - outb(t, IE_XBUF);
  22015. - outsb(IE_XBUF, p, s); /* Put data in buffer */
  22016. - while (s++ < ETH_ZLEN - ETH_HLEN) /* Pad to min size */
  22017. - outb(0, IE_XBUF);
  22018. - outw(buf_offs, IE_GP); /* Rewrite where packet starts */
  22019. - /* should work without that outb() (Crynwr used it) */
  22020. - /*outb(MM_MUX, IE_MMODE);*/
  22021. - /* Xmt buffer to EDLC bus */
  22022. - outb(MM_EN_XMT | MM_MUX, IE_MMODE); /* Begin transmission */
  22023. - /* wait for transmit complete */
  22024. - while (((xmt_stat = inb(IE_ISTAT)) & IS_EN_XMT) != 0)
  22025. - ;
  22026. - reset_receiver(); /* Immediately switch to receive */
  22027. -}
  22028. -
  22029. -/**************************************************************************
  22030. -DISABLE - Turn off ethernet interface
  22031. -***************************************************************************/
  22032. -static void ni5010_disable(struct nic *nic)
  22033. -{
  22034. - outb(0, IE_MMODE);
  22035. - outb(RS_RESET, EDLC_RESET);
  22036. -}
  22037. -
  22038. -static inline int rd_port(void)
  22039. -{
  22040. - inb(IE_RBUF);
  22041. - return inb(IE_SAPROM);
  22042. -}
  22043. -
  22044. -static int ni5010_probe1(struct nic *nic)
  22045. -{
  22046. - int i, boguscount = 40, data;
  22047. -
  22048. - /* The tests are from the Linux NI5010 driver
  22049. - I don't understand it all, but if it works for them... */
  22050. - if (inb(ioaddr) == 0xFF)
  22051. - return (0);
  22052. - while ((rd_port() & rd_port() & rd_port()
  22053. - & rd_port() & rd_port() & rd_port()) != 0xFF)
  22054. - {
  22055. - if (boguscount-- <= 0)
  22056. - return (0);
  22057. - }
  22058. - for (i = 0; i < 32; i++)
  22059. - if ((data = rd_port()) != 0xFF)
  22060. - break;
  22061. - if (data == 0xFF)
  22062. - return (0);
  22063. - if (data == SA_ADDR0 && rd_port() == SA_ADDR1 && rd_port() == SA_ADDR2) {
  22064. - for (i = 0; i < 4; i++)
  22065. - rd_port();
  22066. - if (rd_port() != NI5010_MAGICVAL1 || rd_port() != NI5010_MAGICVAL2)
  22067. - return (0);
  22068. - } else
  22069. - return (0);
  22070. - for (i = 0; i < ETH_ALEN; i++) {
  22071. - outw(i, IE_GP);
  22072. - nic->node_addr[i] = inb(IE_SAPROM);
  22073. - }
  22074. - printf("\nNI5010 ioaddr %#hX, addr %!\n", ioaddr, nic->node_addr);
  22075. -/* get the size of the onboard receive buffer
  22076. - * higher addresses than bufsize are wrapped into real buffer
  22077. - * i.e. data for offs. 0x801 is written to 0x1 with a 2K onboard buffer
  22078. - */
  22079. - if (bufsize_rcv == 0) {
  22080. - outb(1, IE_MMODE); /* Put Rcv buffer on system bus */
  22081. - outw(0, IE_GP); /* Point GP at start of packet */
  22082. - outb(0, IE_RBUF); /* set buffer byte 0 to 0 */
  22083. - for (i = 1; i < 0xFF; i++) {
  22084. - outw(i << 8, IE_GP); /* Point GP at packet size to be tested */
  22085. - outb(i, IE_RBUF);
  22086. - outw(0x0, IE_GP); /* Point GP at start of packet */
  22087. - data = inb(IE_RBUF);
  22088. - if (data == i) break;
  22089. - }
  22090. - bufsize_rcv = i << 8;
  22091. - outw(0, IE_GP); /* Point GP at start of packet */
  22092. - outb(0, IE_RBUF); /* set buffer byte 0 to 0 again */
  22093. - }
  22094. - printf("Bufsize rcv/xmt=%d/%d\n", bufsize_rcv, NI5010_BUFSIZE);
  22095. - return (1);
  22096. -}
  22097. -
  22098. -/**************************************************************************
  22099. -PROBE - Look for an adapter, this routine's visible to the outside
  22100. -***************************************************************************/
  22101. -struct nic *ni5010_probe(struct nic *nic, unsigned short *probe_addrs)
  22102. -{
  22103. - static unsigned short io_addrs[] = {
  22104. - 0x300, 0x320, 0x340, 0x360, 0x380, 0x3a0, 0 };
  22105. - unsigned short *p;
  22106. -
  22107. - /* if probe_addrs is 0, then use list above */
  22108. - if (probe_addrs == 0 || *probe_addrs == 0)
  22109. - probe_addrs = io_addrs;
  22110. - for (p = probe_addrs; (ioaddr = *p) != 0; p++) {
  22111. - if (ni5010_probe1(nic))
  22112. - break;
  22113. - }
  22114. - if (ioaddr == 0)
  22115. - return (0);
  22116. - ni5010_reset(nic);
  22117. - /* point to NIC specific routines */
  22118. - nic->reset = ni5010_reset;
  22119. - nic->poll = ni5010_poll;
  22120. - nic->transmit = ni5010_transmit;
  22121. - nic->disable = ni5010_disable;
  22122. - return (nic);
  22123. -}
  22124. diff -Naur grub-0.97.orig/netboot/nic.c grub-0.97/netboot/nic.c
  22125. --- grub-0.97.orig/netboot/nic.c 1970-01-01 00:00:00.000000000 +0000
  22126. +++ grub-0.97/netboot/nic.c 2005-08-31 19:03:35.000000000 +0000
  22127. @@ -0,0 +1,1198 @@
  22128. +/**************************************************************************
  22129. +Etherboot - Network Bootstrap Program
  22130. +
  22131. +Literature dealing with the network protocols:
  22132. + ARP - RFC826
  22133. + RARP - RFC903
  22134. + IP - RFC791
  22135. + UDP - RFC768
  22136. + BOOTP - RFC951, RFC2132 (vendor extensions)
  22137. + DHCP - RFC2131, RFC2132 (options)
  22138. + TFTP - RFC1350, RFC2347 (options), RFC2348 (blocksize), RFC2349 (tsize)
  22139. + RPC - RFC1831, RFC1832 (XDR), RFC1833 (rpcbind/portmapper)
  22140. + NFS - RFC1094, RFC1813 (v3, useful for clarifications, not implemented)
  22141. + IGMP - RFC1112, RFC2113, RFC2365, RFC2236, RFC3171
  22142. +
  22143. +**************************************************************************/
  22144. +#include "etherboot.h"
  22145. +#include "grub.h"
  22146. +#include "nic.h"
  22147. +#include "elf.h" /* FOR EM_CURRENT */
  22148. +#include "bootp.h"
  22149. +#include "if_arp.h"
  22150. +#include "tftp.h"
  22151. +#include "timer.h"
  22152. +#include "ip.h"
  22153. +#include "udp.h"
  22154. +
  22155. +/* Currently no other module uses rom, but it is available */
  22156. +struct rom_info rom;
  22157. +struct arptable_t arptable[MAX_ARP];
  22158. +#if MULTICAST_LEVEL2
  22159. +unsigned long last_igmpv1 = 0;
  22160. +struct igmptable_t igmptable[MAX_IGMP];
  22161. +#endif
  22162. +static unsigned long netmask;
  22163. +/* Used by nfs.c */
  22164. +char *hostname = "";
  22165. +int hostnamelen = 0;
  22166. +static uint32_t xid;
  22167. +static unsigned char *end_of_rfc1533 = NULL;
  22168. +static const unsigned char broadcast[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
  22169. +static const in_addr zeroIP = { 0L };
  22170. +static char rfc1533_venddata[MAX_RFC1533_VENDLEN];
  22171. +static unsigned char rfc1533_cookie[4] = { RFC1533_COOKIE };
  22172. +static unsigned char rfc1533_cookie_bootp[5] = { RFC1533_COOKIE, RFC1533_END };
  22173. +static unsigned char rfc1533_cookie_dhcp[] = { RFC1533_COOKIE };
  22174. +static int dhcp_reply;
  22175. +static in_addr dhcp_server = { 0L };
  22176. +static in_addr dhcp_addr = { 0L };
  22177. +
  22178. +static const unsigned char dhcpdiscover[] = {
  22179. + RFC2132_MSG_TYPE, 1, DHCPDISCOVER,
  22180. + RFC2132_MAX_SIZE, 2, /* request as much as we can */
  22181. + ETH_MAX_MTU / 256, ETH_MAX_MTU % 256,
  22182. + /* Vendor class identifier */
  22183. + RFC2132_VENDOR_CLASS_ID, 10, 'G', 'R', 'U', 'B', 'C', 'l', 'i', 'e', 'n', 't',
  22184. + RFC2132_PARAM_LIST, 4, RFC1533_NETMASK, RFC1533_GATEWAY,
  22185. + RFC1533_HOSTNAME, RFC1533_EXTENSIONPATH, RFC1533_END
  22186. +};
  22187. +static const unsigned char dhcprequest [] = {
  22188. + RFC2132_MSG_TYPE,1,DHCPREQUEST,
  22189. + RFC2132_SRV_ID,4,0,0,0,0,
  22190. + RFC2132_REQ_ADDR,4,0,0,0,0,
  22191. + RFC2132_MAX_SIZE,2, /* request as much as we can */
  22192. + ETH_MAX_MTU / 256, ETH_MAX_MTU % 256,
  22193. + /* Vendor class identifier */
  22194. + RFC2132_VENDOR_CLASS_ID, 10, 'G', 'R', 'U', 'B', 'C', 'l', 'i', 'e', 'n', 't',
  22195. + RFC2132_PARAM_LIST,
  22196. + /* 4 standard + 2 vendortags */
  22197. + 4 + 2,
  22198. + /* Standard parameters */
  22199. + RFC1533_NETMASK, RFC1533_GATEWAY,
  22200. + RFC1533_HOSTNAME, RFC1533_EXTENSIONPATH,
  22201. + /* Etherboot vendortags */
  22202. + RFC1533_VENDOR_MAGIC,
  22203. + RFC1533_VENDOR_CONFIGFILE,
  22204. + RFC1533_END
  22205. +};
  22206. +
  22207. +/* See nic.h */
  22208. +int user_abort = 0;
  22209. +int network_ready = 0;
  22210. +
  22211. +#ifdef REQUIRE_VCI_ETHERBOOT
  22212. +int vci_etherboot;
  22213. +#endif
  22214. +
  22215. +static int dummy(void *unused __unused)
  22216. +{
  22217. + return (0);
  22218. +}
  22219. +
  22220. +/* Careful. We need an aligned buffer to avoid problems on machines
  22221. + * that care about alignment. To trivally align the ethernet data
  22222. + * (the ip hdr and arp requests) we offset the packet by 2 bytes.
  22223. + * leaving the ethernet data 16 byte aligned. Beyond this
  22224. + * we use memmove but this makes the common cast simple and fast.
  22225. + */
  22226. +static char packet[ETH_FRAME_LEN + ETH_DATA_ALIGN] __aligned;
  22227. +
  22228. +struct nic nic =
  22229. +{
  22230. + {
  22231. + 0, /* dev.disable */
  22232. + {
  22233. + 0,
  22234. + 0,
  22235. + PCI_BUS_TYPE,
  22236. + }, /* dev.devid */
  22237. + 0, /* index */
  22238. + 0, /* type */
  22239. + PROBE_FIRST, /* how_pobe */
  22240. + PROBE_NONE, /* to_probe */
  22241. + 0, /* failsafe */
  22242. + 0, /* type_index */
  22243. + {}, /* state */
  22244. + },
  22245. + (int (*)(struct nic *, int))dummy, /* poll */
  22246. + (void (*)(struct nic *, const char *,
  22247. + unsigned int, unsigned int,
  22248. + const char *))dummy, /* transmit */
  22249. + (void (*)(struct nic *, irq_action_t))dummy, /* irq */
  22250. + 0, /* flags */
  22251. + &rom, /* rom_info */
  22252. + arptable[ARP_CLIENT].node, /* node_addr */
  22253. + packet + ETH_DATA_ALIGN, /* packet */
  22254. + 0, /* packetlen */
  22255. + 0, /* ioaddr */
  22256. + 0, /* irqno */
  22257. + NULL, /* priv_data */
  22258. +};
  22259. +
  22260. +
  22261. +
  22262. +int grub_eth_probe(void)
  22263. +{
  22264. + static int probed = 0;
  22265. + struct dev *dev;
  22266. +
  22267. + EnterFunction("grub_eth_probe");
  22268. +
  22269. + if (probed)
  22270. + return 1;
  22271. +
  22272. + network_ready = 0;
  22273. + grub_memset((char *)arptable, 0, MAX_ARP * sizeof(struct arptable_t));
  22274. + dev = &nic.dev;
  22275. + dev->how_probe = -1;
  22276. + dev->type = NIC_DRIVER;
  22277. + dev->failsafe = 1;
  22278. + rom = *((struct rom_info *)ROM_INFO_LOCATION);
  22279. +
  22280. + probed = (eth_probe(dev) == PROBE_WORKED);
  22281. +
  22282. + LeaveFunction("grub_eth_probe");
  22283. + return probed;
  22284. +}
  22285. +
  22286. +int eth_probe(struct dev *dev)
  22287. +{
  22288. + return probe(dev);
  22289. +}
  22290. +
  22291. +int eth_poll(int retrieve)
  22292. +{
  22293. + return ((*nic.poll)(&nic, retrieve));
  22294. +}
  22295. +
  22296. +void eth_transmit(const char *d, unsigned int t, unsigned int s, const void *p)
  22297. +{
  22298. + (*nic.transmit)(&nic, d, t, s, p);
  22299. + if (t == IP) twiddle();
  22300. +}
  22301. +
  22302. +void eth_disable(void)
  22303. +{
  22304. +#ifdef MULTICAST_LEVEL2
  22305. + int i;
  22306. + for(i = 0; i < MAX_IGMP; i++) {
  22307. + leave_group(i);
  22308. + }
  22309. +#endif
  22310. + disable(&nic.dev);
  22311. +}
  22312. +
  22313. +void eth_irq (irq_action_t action)
  22314. +{
  22315. + (*nic.irq)(&nic,action);
  22316. +}
  22317. +
  22318. +/**************************************************************************
  22319. +IPCHKSUM - Checksum IP Header
  22320. +**************************************************************************/
  22321. +uint16_t ipchksum(const void *data, unsigned long length)
  22322. +{
  22323. + unsigned long sum;
  22324. + unsigned long i;
  22325. + const uint8_t *ptr;
  22326. +
  22327. + /* In the most straight forward way possible,
  22328. + * compute an ip style checksum.
  22329. + */
  22330. + sum = 0;
  22331. + ptr = data;
  22332. + for(i = 0; i < length; i++) {
  22333. + unsigned long value;
  22334. + value = ptr[i];
  22335. + if (i & 1) {
  22336. + value <<= 8;
  22337. + }
  22338. + /* Add the new value */
  22339. + sum += value;
  22340. + /* Wrap around the carry */
  22341. + if (sum > 0xFFFF) {
  22342. + sum = (sum + (sum >> 16)) & 0xFFFF;
  22343. + }
  22344. + }
  22345. + return (~cpu_to_le16(sum)) & 0xFFFF;
  22346. +}
  22347. +
  22348. +uint16_t add_ipchksums(unsigned long offset, uint16_t sum, uint16_t new)
  22349. +{
  22350. + unsigned long checksum;
  22351. + sum = ~sum & 0xFFFF;
  22352. + new = ~new & 0xFFFF;
  22353. + if (offset & 1) {
  22354. + /* byte swap the sum if it came from an odd offset
  22355. + * since the computation is endian independant this
  22356. + * works.
  22357. + */
  22358. + new = bswap_16(new);
  22359. + }
  22360. + checksum = sum + new;
  22361. + if (checksum > 0xFFFF) {
  22362. + checksum -= 0xFFFF;
  22363. + }
  22364. + return (~checksum) & 0xFFFF;
  22365. +}
  22366. +
  22367. +/**************************************************************************
  22368. +DEFAULT_NETMASK - Return default netmask for IP address
  22369. +**************************************************************************/
  22370. +static inline unsigned long default_netmask(void)
  22371. +{
  22372. + int net = ntohl(arptable[ARP_CLIENT].ipaddr.s_addr) >> 24;
  22373. + if (net <= 127)
  22374. + return(htonl(0xff000000));
  22375. + else if (net < 192)
  22376. + return(htonl(0xffff0000));
  22377. + else
  22378. + return(htonl(0xffffff00));
  22379. +}
  22380. +
  22381. +/**************************************************************************
  22382. +IP_TRANSMIT - Send an IP datagram
  22383. +**************************************************************************/
  22384. +static int await_arp(int ival, void *ptr,
  22385. + unsigned short ptype, struct iphdr *ip __unused, struct udphdr *udp __unused)
  22386. +{
  22387. + struct arprequest *arpreply;
  22388. + if (ptype != ARP)
  22389. + return 0;
  22390. + if (nic.packetlen < ETH_HLEN + sizeof(struct arprequest))
  22391. + return 0;
  22392. + arpreply = (struct arprequest *)&nic.packet[ETH_HLEN];
  22393. +
  22394. + if (arpreply->opcode != htons(ARP_REPLY))
  22395. + return 0;
  22396. + if (memcmp(arpreply->sipaddr, ptr, sizeof(in_addr)) != 0)
  22397. + return 0;
  22398. + memcpy(arptable[ival].node, arpreply->shwaddr, ETH_ALEN);
  22399. + return 1;
  22400. +}
  22401. +
  22402. +int ip_transmit(int len, const void *buf)
  22403. +{
  22404. + unsigned long destip;
  22405. + struct iphdr *ip;
  22406. + struct arprequest arpreq;
  22407. + int arpentry, i;
  22408. + int retry;
  22409. +
  22410. + ip = (struct iphdr *)buf;
  22411. + destip = ip->dest.s_addr;
  22412. + if (destip == IP_BROADCAST) {
  22413. + eth_transmit(broadcast, IP, len, buf);
  22414. +#ifdef MULTICAST_LEVEL1
  22415. + } else if ((destip & htonl(MULTICAST_MASK)) == htonl(MULTICAST_NETWORK)) {
  22416. + unsigned char multicast[6];
  22417. + unsigned long hdestip;
  22418. + hdestip = ntohl(destip);
  22419. + multicast[0] = 0x01;
  22420. + multicast[1] = 0x00;
  22421. + multicast[2] = 0x5e;
  22422. + multicast[3] = (hdestip >> 16) & 0x7;
  22423. + multicast[4] = (hdestip >> 8) & 0xff;
  22424. + multicast[5] = hdestip & 0xff;
  22425. + eth_transmit(multicast, IP, len, buf);
  22426. +#endif
  22427. + } else {
  22428. + if (((destip & netmask) !=
  22429. + (arptable[ARP_CLIENT].ipaddr.s_addr & netmask)) &&
  22430. + arptable[ARP_GATEWAY].ipaddr.s_addr)
  22431. + destip = arptable[ARP_GATEWAY].ipaddr.s_addr;
  22432. + for(arpentry = 0; arpentry<MAX_ARP; arpentry++)
  22433. + if (arptable[arpentry].ipaddr.s_addr == destip) break;
  22434. + if (arpentry == MAX_ARP) {
  22435. + printf("%@ is not in my arp table!\n", destip);
  22436. + return(0);
  22437. + }
  22438. + for (i = 0; i < ETH_ALEN; i++)
  22439. + if (arptable[arpentry].node[i])
  22440. + break;
  22441. + if (i == ETH_ALEN) { /* Need to do arp request */
  22442. + arpreq.hwtype = htons(1);
  22443. + arpreq.protocol = htons(IP);
  22444. + arpreq.hwlen = ETH_ALEN;
  22445. + arpreq.protolen = 4;
  22446. + arpreq.opcode = htons(ARP_REQUEST);
  22447. + memcpy(arpreq.shwaddr, arptable[ARP_CLIENT].node, ETH_ALEN);
  22448. + memcpy(arpreq.sipaddr, &arptable[ARP_CLIENT].ipaddr, sizeof(in_addr));
  22449. + memset(arpreq.thwaddr, 0, ETH_ALEN);
  22450. + memcpy(arpreq.tipaddr, &destip, sizeof(in_addr));
  22451. + for (retry = 1; retry <= MAX_ARP_RETRIES; retry++) {
  22452. + long timeout;
  22453. + eth_transmit(broadcast, ARP, sizeof(arpreq),
  22454. + &arpreq);
  22455. + timeout = rfc2131_sleep_interval(TIMEOUT, retry);
  22456. + if (await_reply(await_arp, arpentry,
  22457. + arpreq.tipaddr, timeout)) goto xmit;
  22458. + }
  22459. + return(0);
  22460. + }
  22461. +xmit:
  22462. + eth_transmit(arptable[arpentry].node, IP, len, buf);
  22463. + }
  22464. + return 1;
  22465. +}
  22466. +
  22467. +void build_ip_hdr(unsigned long destip, int ttl, int protocol, int option_len,
  22468. + int len, const void *buf)
  22469. +{
  22470. + struct iphdr *ip;
  22471. + ip = (struct iphdr *)buf;
  22472. + ip->verhdrlen = 0x45;
  22473. + ip->verhdrlen += (option_len/4);
  22474. + ip->service = 0;
  22475. + ip->len = htons(len);
  22476. + ip->ident = 0;
  22477. + ip->frags = 0; /* Should we set don't fragment? */
  22478. + ip->ttl = ttl;
  22479. + ip->protocol = protocol;
  22480. + ip->chksum = 0;
  22481. + ip->src.s_addr = arptable[ARP_CLIENT].ipaddr.s_addr;
  22482. + ip->dest.s_addr = destip;
  22483. + ip->chksum = ipchksum(buf, sizeof(struct iphdr) + option_len);
  22484. +}
  22485. +
  22486. +static uint16_t udpchksum(struct iphdr *ip, struct udphdr *udp)
  22487. +{
  22488. + struct udp_pseudo_hdr pseudo;
  22489. + uint16_t checksum;
  22490. +
  22491. + /* Compute the pseudo header */
  22492. + pseudo.src.s_addr = ip->src.s_addr;
  22493. + pseudo.dest.s_addr = ip->dest.s_addr;
  22494. + pseudo.unused = 0;
  22495. + pseudo.protocol = IP_UDP;
  22496. + pseudo.len = udp->len;
  22497. +
  22498. + /* Sum the pseudo header */
  22499. + checksum = ipchksum(&pseudo, 12);
  22500. +
  22501. + /* Sum the rest of the udp packet */
  22502. + checksum = add_ipchksums(12, checksum, ipchksum(udp, ntohs(udp->len)));
  22503. + return checksum;
  22504. +}
  22505. +
  22506. +
  22507. +void build_udp_hdr(unsigned long destip,
  22508. + unsigned int srcsock, unsigned int destsock, int ttl,
  22509. + int len, const void *buf)
  22510. +{
  22511. + struct iphdr *ip;
  22512. + struct udphdr *udp;
  22513. + ip = (struct iphdr *)buf;
  22514. + build_ip_hdr(destip, ttl, IP_UDP, 0, len, buf);
  22515. + udp = (struct udphdr *)((char *)buf + sizeof(struct iphdr));
  22516. + udp->src = htons(srcsock);
  22517. + udp->dest = htons(destsock);
  22518. + udp->len = htons(len - sizeof(struct iphdr));
  22519. + udp->chksum = 0;
  22520. + if ((udp->chksum = udpchksum(ip, udp)) == 0)
  22521. + udp->chksum = 0xffff;
  22522. +}
  22523. +
  22524. +
  22525. +/**************************************************************************
  22526. +UDP_TRANSMIT - Send an UDP datagram
  22527. +**************************************************************************/
  22528. +int udp_transmit(unsigned long destip, unsigned int srcsock,
  22529. + unsigned int destsock, int len, const void *buf)
  22530. +{
  22531. + build_udp_hdr(destip, srcsock, destsock, 60, len, buf);
  22532. + return ip_transmit(len, buf);
  22533. +}
  22534. +
  22535. +/**************************************************************************
  22536. +QDRAIN - clear the nic's receive queue
  22537. +**************************************************************************/
  22538. +static int await_qdrain(int ival __unused, void *ptr __unused,
  22539. + unsigned short ptype __unused,
  22540. + struct iphdr *ip __unused, struct udphdr *udp __unused)
  22541. +{
  22542. + return 0;
  22543. +}
  22544. +
  22545. +void rx_qdrain(void)
  22546. +{
  22547. + /* Clear out the Rx queue first. It contains nothing of interest,
  22548. + * except possibly ARP requests from the DHCP/TFTP server. We use
  22549. + * polling throughout Etherboot, so some time may have passed since we
  22550. + * last polled the receive queue, which may now be filled with
  22551. + * broadcast packets. This will cause the reply to the packets we are
  22552. + * about to send to be lost immediately. Not very clever. */
  22553. + await_reply(await_qdrain, 0, NULL, 0);
  22554. +}
  22555. +
  22556. +/**
  22557. + * rarp
  22558. + *
  22559. + * Get IP address by rarp. Just copy from etherboot
  22560. + **/
  22561. +static int await_rarp(int ival, void *ptr, unsigned short ptype,
  22562. + struct iphdr *ip, struct udphdr *udp)
  22563. +{
  22564. + struct arprequest *arpreply;
  22565. + if (ptype != RARP)
  22566. + return 0;
  22567. + if (nic.packetlen < ETH_HLEN + sizeof(struct arprequest))
  22568. + return 0;
  22569. + arpreply = (struct arprequest *)&nic.packet[ETH_HLEN];
  22570. + if (arpreply->opcode != htons(RARP_REPLY))
  22571. + return 0;
  22572. + if (memcmp(arpreply->thwaddr, ptr, ETH_ALEN) == 0){
  22573. + memcpy(arptable[ARP_SERVER].node, arpreply->shwaddr, ETH_ALEN);
  22574. + memcpy(&arptable[ARP_SERVER].ipaddr, arpreply->sipaddr, sizeof(in_addr));
  22575. + memcpy(&arptable[ARP_CLIENT].ipaddr, arpreply->tipaddr, sizeof(in_addr));
  22576. + return 1;
  22577. + }
  22578. + return 0;
  22579. +}
  22580. +
  22581. +int rarp(void)
  22582. +{
  22583. + int retry;
  22584. +
  22585. + /* arp and rarp requests share the same packet structure. */
  22586. + struct arprequest rarpreq;
  22587. +
  22588. + if(!grub_eth_probe())
  22589. + return 0;
  22590. + network_ready = 0;
  22591. +
  22592. + memset(&rarpreq, 0, sizeof(rarpreq));
  22593. +
  22594. + rarpreq.hwtype = htons(1);
  22595. + rarpreq.protocol = htons(IP);
  22596. + rarpreq.hwlen = ETH_ALEN;
  22597. + rarpreq.protolen = 4;
  22598. + rarpreq.opcode = htons(RARP_REQUEST);
  22599. + memcpy(&rarpreq.shwaddr, arptable[ARP_CLIENT].node, ETH_ALEN);
  22600. + /* sipaddr is already zeroed out */
  22601. + memcpy(&rarpreq.thwaddr, arptable[ARP_CLIENT].node, ETH_ALEN);
  22602. + /* tipaddr is already zeroed out */
  22603. +
  22604. + for (retry = 0; retry < MAX_ARP_RETRIES; ++retry) {
  22605. + long timeout;
  22606. + eth_transmit(broadcast, RARP, sizeof(rarpreq), &rarpreq);
  22607. +
  22608. + timeout = rfc2131_sleep_interval(TIMEOUT, retry);
  22609. + if (await_reply(await_rarp, 0, rarpreq.shwaddr, timeout))
  22610. + break;
  22611. + if (user_abort)
  22612. + return 0;
  22613. + }
  22614. +
  22615. + if (retry < MAX_ARP_RETRIES) {
  22616. + network_ready = 1;
  22617. + return (1);
  22618. + }
  22619. + return (0);
  22620. +}
  22621. +
  22622. +/**
  22623. + * bootp
  22624. + *
  22625. + * Get IP address by bootp, segregate from bootp in etherboot.
  22626. + **/
  22627. +static int await_bootp(int ival __unused, void *ptr __unused,
  22628. + unsigned short ptype __unused, struct iphdr *ip __unused,
  22629. + struct udphdr *udp)
  22630. +{
  22631. + struct bootp_t *bootpreply;
  22632. + int len; /* Length of vendor */
  22633. +
  22634. + if (!udp) {
  22635. + return 0;
  22636. + }
  22637. + bootpreply = (struct bootp_t *)
  22638. + &nic.packet[ETH_HLEN + sizeof(struct iphdr) + sizeof(struct udphdr)];
  22639. + len = nic.packetlen - (ETH_HLEN + sizeof(struct iphdr) +
  22640. + sizeof(struct udphdr) + sizeof(struct bootp_t) - BOOTP_VENDOR_LEN);
  22641. + if (len < 0) {
  22642. + return 0;
  22643. + }
  22644. + if (udp->dest != htons(BOOTP_CLIENT))
  22645. + return 0;
  22646. + if (bootpreply->bp_op != BOOTP_REPLY)
  22647. + return 0;
  22648. + if (bootpreply->bp_xid != xid)
  22649. + return 0;
  22650. + if (memcmp((char *)&bootpreply->bp_siaddr, (char *)&zeroIP, sizeof(in_addr)) == 0)
  22651. + return 0;
  22652. + if ((memcmp(broadcast, bootpreply->bp_hwaddr, ETH_ALEN) != 0) &&
  22653. + (memcmp(arptable[ARP_CLIENT].node, bootpreply->bp_hwaddr, ETH_ALEN) != 0)) {
  22654. + return 0;
  22655. + }
  22656. + arptable[ARP_CLIENT].ipaddr.s_addr = bootpreply->bp_yiaddr.s_addr;
  22657. + netmask = default_netmask();
  22658. + arptable[ARP_SERVER].ipaddr.s_addr = bootpreply->bp_siaddr.s_addr;
  22659. + memset(arptable[ARP_SERVER].node, 0, ETH_ALEN); /* Kill arp */
  22660. + arptable[ARP_GATEWAY].ipaddr.s_addr = bootpreply->bp_giaddr.s_addr;
  22661. + memset(arptable[ARP_GATEWAY].node, 0, ETH_ALEN); /* Kill arp */
  22662. + /* We don't care bootpreply->bp_file, it must be 'pxegrub':-) */
  22663. + memcpy((char *)rfc1533_venddata, (char *)(bootpreply->bp_vend), len);
  22664. + decode_rfc1533(rfc1533_venddata, 0, len, 1);
  22665. + return(1);
  22666. +}
  22667. +
  22668. +int bootp(void)
  22669. +{
  22670. + int retry;
  22671. + struct bootpip_t ip;
  22672. + unsigned long starttime;
  22673. +
  22674. + EnterFunction("bootp");
  22675. +
  22676. + if(!grub_eth_probe())
  22677. + return 0;
  22678. + network_ready = 0;
  22679. +
  22680. + memset(&ip, 0, sizeof(struct bootpip_t));
  22681. + ip.bp.bp_op = BOOTP_REQUEST;
  22682. + ip.bp.bp_htype = 1;
  22683. + ip.bp.bp_hlen = ETH_ALEN;
  22684. + starttime = currticks();
  22685. + /* Use lower 32 bits of node address, more likely to be
  22686. + distinct than the time since booting */
  22687. + memcpy(&xid, &arptable[ARP_CLIENT].node[2], sizeof(xid));
  22688. + ip.bp.bp_xid = xid += htonl(starttime);
  22689. + /* bp_secs defaults to zero */
  22690. + memcpy(ip.bp.bp_hwaddr, arptable[ARP_CLIENT].node, ETH_ALEN);
  22691. + memcpy(ip.bp.bp_vend, rfc1533_cookie_bootp, sizeof(rfc1533_cookie_bootp)); /* request RFC-style options */
  22692. +
  22693. + for (retry = 0; retry < MAX_BOOTP_RETRIES; ) {
  22694. + long timeout;
  22695. +
  22696. + rx_qdrain();
  22697. +
  22698. + udp_transmit(IP_BROADCAST, BOOTP_CLIENT, BOOTP_SERVER,
  22699. + sizeof(struct bootpip_t), &ip);
  22700. + timeout = rfc2131_sleep_interval(TIMEOUT, retry++);
  22701. + if (await_reply(await_bootp, 0, NULL, timeout)){
  22702. + network_ready = 1;
  22703. + return(1);
  22704. + }
  22705. + if (user_abort)
  22706. + return 0;
  22707. + ip.bp.bp_secs = htons((currticks()-starttime)/TICKS_PER_SEC);
  22708. + }
  22709. + return(0);
  22710. +}
  22711. +
  22712. +/**
  22713. + * dhcp
  22714. + *
  22715. + * Get IP address by dhcp, segregate from bootp in etherboot.
  22716. + **/
  22717. +static int await_dhcp(int ival __unused, void *ptr __unused,
  22718. + unsigned short ptype __unused, struct iphdr *ip __unused,
  22719. + struct udphdr *udp)
  22720. +{
  22721. + struct dhcp_t *dhcpreply;
  22722. + int len;
  22723. +
  22724. + if (!udp) {
  22725. + return 0;
  22726. + }
  22727. + dhcpreply = (struct dhcp_t *)
  22728. + &nic.packet[ETH_HLEN + sizeof(struct iphdr) + sizeof(struct udphdr)];
  22729. + len = nic.packetlen - (ETH_HLEN + sizeof(struct iphdr) +
  22730. + sizeof(struct udphdr) + sizeof(struct dhcp_t) - DHCP_OPT_LEN);
  22731. + if (len < 0){
  22732. + return 0;
  22733. + }
  22734. + if (udp->dest != htons(BOOTP_CLIENT))
  22735. + return 0;
  22736. + if (dhcpreply->bp_op != BOOTP_REPLY)
  22737. + return 0;
  22738. + if (dhcpreply->bp_xid != xid)
  22739. + return 0;
  22740. + if (memcmp((char *)&dhcpreply->bp_siaddr, (char *)&zeroIP, sizeof(in_addr)) == 0)
  22741. + return 0;
  22742. + if ((memcmp(broadcast, dhcpreply->bp_hwaddr, ETH_ALEN) != 0) &&
  22743. + (memcmp(arptable[ARP_CLIENT].node, dhcpreply->bp_hwaddr, ETH_ALEN) != 0)) {
  22744. + return 0;
  22745. + }
  22746. + arptable[ARP_CLIENT].ipaddr.s_addr = dhcpreply->bp_yiaddr.s_addr;
  22747. + dhcp_addr.s_addr = dhcpreply->bp_yiaddr.s_addr;
  22748. + netmask = default_netmask();
  22749. + arptable[ARP_SERVER].ipaddr.s_addr = dhcpreply->bp_siaddr.s_addr;
  22750. + memset(arptable[ARP_SERVER].node, 0, ETH_ALEN); /* Kill arp */
  22751. + arptable[ARP_GATEWAY].ipaddr.s_addr = dhcpreply->bp_giaddr.s_addr;
  22752. + memset(arptable[ARP_GATEWAY].node, 0, ETH_ALEN); /* Kill arp */
  22753. + /* We don't care bootpreply->bp_file. It must be 'pxegrub' */
  22754. + memcpy((char *)rfc1533_venddata, (char *)(dhcpreply->bp_vend), len);
  22755. + decode_rfc1533(rfc1533_venddata, 0, len, 1);
  22756. + return(1);
  22757. +}
  22758. +
  22759. +int dhcp(void)
  22760. +{
  22761. + int retry;
  22762. + int reqretry;
  22763. + struct dhcpip_t ip;
  22764. + unsigned long starttime;
  22765. +
  22766. + if(!grub_eth_probe())
  22767. + return 0;
  22768. +
  22769. + network_ready = 0;
  22770. +
  22771. + memset(&ip, 0, sizeof(struct dhcpip_t));
  22772. + ip.bp.bp_op = BOOTP_REQUEST;
  22773. + ip.bp.bp_htype = 1;
  22774. + ip.bp.bp_hlen = ETH_ALEN;
  22775. + starttime = currticks();
  22776. + /* Use lower 32 bits of node address, more likely to be
  22777. + distinct than the time since booting */
  22778. + memcpy(&xid, &arptable[ARP_CLIENT].node[2], sizeof(xid));
  22779. + ip.bp.bp_xid = xid += htonl(starttime);
  22780. + memcpy(ip.bp.bp_hwaddr, arptable[ARP_CLIENT].node, ETH_ALEN);
  22781. + memcpy(ip.bp.bp_vend, rfc1533_cookie_dhcp, sizeof rfc1533_cookie_dhcp); /* request RFC-style options */
  22782. + memcpy(ip.bp.bp_vend + sizeof rfc1533_cookie_dhcp, dhcpdiscover, sizeof dhcpdiscover);
  22783. +
  22784. + for (retry = 0; retry < MAX_BOOTP_RETRIES; ) {
  22785. + long timeout;
  22786. +
  22787. + rx_qdrain();
  22788. +
  22789. + udp_transmit(IP_BROADCAST, BOOTP_CLIENT, BOOTP_SERVER,
  22790. + sizeof(struct bootpip_t), &ip);
  22791. + timeout = rfc2131_sleep_interval(TIMEOUT, retry++);
  22792. + if (await_reply(await_dhcp, 0, NULL, timeout)) {
  22793. + /* If not a DHCPOFFER then must be just a
  22794. + BOOTP reply, be backward compatible with
  22795. + BOOTP then. Jscott report a bug here, but I
  22796. + don't know how it happened */
  22797. + if (dhcp_reply != DHCPOFFER){
  22798. + network_ready = 1;
  22799. + return(1);
  22800. + }
  22801. + dhcp_reply = 0;
  22802. + memcpy(ip.bp.bp_vend, rfc1533_cookie_dhcp, sizeof rfc1533_cookie_dhcp);
  22803. + memcpy(ip.bp.bp_vend + sizeof rfc1533_cookie_dhcp, dhcprequest, sizeof dhcprequest);
  22804. + /* Beware: the magic numbers 9 and 15 depend on
  22805. + the layout of dhcprequest */
  22806. + memcpy(&ip.bp.bp_vend[9], &dhcp_server, sizeof(in_addr));
  22807. + memcpy(&ip.bp.bp_vend[15], &dhcp_addr, sizeof(in_addr));
  22808. + for (reqretry = 0; reqretry < MAX_BOOTP_RETRIES; ) {
  22809. + udp_transmit(IP_BROADCAST, BOOTP_CLIENT, BOOTP_SERVER,
  22810. + sizeof(struct bootpip_t), &ip);
  22811. + dhcp_reply=0;
  22812. + timeout = rfc2131_sleep_interval(TIMEOUT, reqretry++);
  22813. + if (await_reply(await_dhcp, 0, NULL, timeout))
  22814. + if (dhcp_reply == DHCPACK){
  22815. + network_ready = 1;
  22816. + return(1);
  22817. + }
  22818. + if (user_abort)
  22819. + return 0;
  22820. + }
  22821. + }
  22822. + if (user_abort)
  22823. + return 0;
  22824. + ip.bp.bp_secs = htons((currticks()-starttime)/TICKS_PER_SEC);
  22825. + }
  22826. + return(0);
  22827. +}
  22828. +
  22829. +#ifdef MULTICAST_LEVEL2
  22830. +static void send_igmp_reports(unsigned long now)
  22831. +{
  22832. + int i;
  22833. + for(i = 0; i < MAX_IGMP; i++) {
  22834. + if (igmptable[i].time && (now >= igmptable[i].time)) {
  22835. + struct igmp_ip_t igmp;
  22836. + igmp.router_alert[0] = 0x94;
  22837. + igmp.router_alert[1] = 0x04;
  22838. + igmp.router_alert[2] = 0;
  22839. + igmp.router_alert[3] = 0;
  22840. + build_ip_hdr(igmptable[i].group.s_addr,
  22841. + 1, IP_IGMP, sizeof(igmp.router_alert), sizeof(igmp), &igmp);
  22842. + igmp.igmp.type = IGMPv2_REPORT;
  22843. + if (last_igmpv1 &&
  22844. + (now < last_igmpv1 + IGMPv1_ROUTER_PRESENT_TIMEOUT)) {
  22845. + igmp.igmp.type = IGMPv1_REPORT;
  22846. + }
  22847. + igmp.igmp.response_time = 0;
  22848. + igmp.igmp.chksum = 0;
  22849. + igmp.igmp.group.s_addr = igmptable[i].group.s_addr;
  22850. + igmp.igmp.chksum = ipchksum(&igmp.igmp, sizeof(igmp.igmp));
  22851. + ip_transmit(sizeof(igmp), &igmp);
  22852. +#ifdef MDEBUG
  22853. + printf("Sent IGMP report to: %@\n", igmp.igmp.group.s_addr);
  22854. +#endif
  22855. + /* Don't send another igmp report until asked */
  22856. + igmptable[i].time = 0;
  22857. + }
  22858. + }
  22859. +}
  22860. +
  22861. +static void process_igmp(struct iphdr *ip, unsigned long now)
  22862. +{
  22863. + struct igmp *igmp;
  22864. + int i;
  22865. + unsigned iplen = 0;
  22866. + if (!ip || (ip->protocol == IP_IGMP) ||
  22867. + (nic.packetlen < sizeof(struct iphdr) + sizeof(struct igmp))) {
  22868. + return;
  22869. + }
  22870. + iplen = (ip->verhdrlen & 0xf)*4;
  22871. + igmp = (struct igmp *)&nic.packet[sizeof(struct iphdr)];
  22872. + if (ipchksum(igmp, ntohs(ip->len) - iplen) != 0)
  22873. + return;
  22874. + if ((igmp->type == IGMP_QUERY) &&
  22875. + (ip->dest.s_addr == htonl(GROUP_ALL_HOSTS))) {
  22876. + unsigned long interval = IGMP_INTERVAL;
  22877. + if (igmp->response_time == 0) {
  22878. + last_igmpv1 = now;
  22879. + } else {
  22880. + interval = (igmp->response_time * TICKS_PER_SEC)/10;
  22881. + }
  22882. +
  22883. +#ifdef MDEBUG
  22884. + printf("Received IGMP query for: %@\n", igmp->group.s_addr);
  22885. +#endif
  22886. + for(i = 0; i < MAX_IGMP; i++) {
  22887. + uint32_t group = igmptable[i].group.s_addr;
  22888. + if ((group == 0) || (group == igmp->group.s_addr)) {
  22889. + unsigned long time;
  22890. + time = currticks() + rfc1112_sleep_interval(interval, 0);
  22891. + if (time < igmptable[i].time) {
  22892. + igmptable[i].time = time;
  22893. + }
  22894. + }
  22895. + }
  22896. + }
  22897. + if (((igmp->type == IGMPv1_REPORT) || (igmp->type == IGMPv2_REPORT)) &&
  22898. + (ip->dest.s_addr == igmp->group.s_addr)) {
  22899. +#ifdef MDEBUG
  22900. + printf("Received IGMP report for: %@\n", igmp->group.s_addr);
  22901. +#endif
  22902. + for(i = 0; i < MAX_IGMP; i++) {
  22903. + if ((igmptable[i].group.s_addr == igmp->group.s_addr) &&
  22904. + igmptable[i].time != 0) {
  22905. + igmptable[i].time = 0;
  22906. + }
  22907. + }
  22908. + }
  22909. +}
  22910. +
  22911. +void leave_group(int slot)
  22912. +{
  22913. + /* Be very stupid and always send a leave group message if
  22914. + * I have subscribed. Imperfect but it is standards
  22915. + * compliant, easy and reliable to implement.
  22916. + *
  22917. + * The optimal group leave method is to only send leave when,
  22918. + * we were the last host to respond to a query on this group,
  22919. + * and igmpv1 compatibility is not enabled.
  22920. + */
  22921. + if (igmptable[slot].group.s_addr) {
  22922. + struct igmp_ip_t igmp;
  22923. + igmp.router_alert[0] = 0x94;
  22924. + igmp.router_alert[1] = 0x04;
  22925. + igmp.router_alert[2] = 0;
  22926. + igmp.router_alert[3] = 0;
  22927. + build_ip_hdr(htonl(GROUP_ALL_HOSTS),
  22928. + 1, IP_IGMP, sizeof(igmp.router_alert), sizeof(igmp), &igmp);
  22929. + igmp.igmp.type = IGMP_LEAVE;
  22930. + igmp.igmp.response_time = 0;
  22931. + igmp.igmp.chksum = 0;
  22932. + igmp.igmp.group.s_addr = igmptable[slot].group.s_addr;
  22933. + igmp.igmp.chksum = ipchksum(&igmp.igmp, sizeof(igmp));
  22934. + ip_transmit(sizeof(igmp), &igmp);
  22935. +#ifdef MDEBUG
  22936. + printf("Sent IGMP leave for: %@\n", igmp.igmp.group.s_addr);
  22937. +#endif
  22938. + }
  22939. + memset(&igmptable[slot], 0, sizeof(igmptable[0]));
  22940. +}
  22941. +
  22942. +void join_group(int slot, unsigned long group)
  22943. +{
  22944. + /* I have already joined */
  22945. + if (igmptable[slot].group.s_addr == group)
  22946. + return;
  22947. + if (igmptable[slot].group.s_addr) {
  22948. + leave_group(slot);
  22949. + }
  22950. + /* Only join a group if we are given a multicast ip, this way
  22951. + * code can be given a non-multicast (broadcast or unicast ip)
  22952. + * and still work...
  22953. + */
  22954. + if ((group & htonl(MULTICAST_MASK)) == htonl(MULTICAST_NETWORK)) {
  22955. + igmptable[slot].group.s_addr = group;
  22956. + igmptable[slot].time = currticks();
  22957. + }
  22958. +}
  22959. +#else
  22960. +#define send_igmp_reports(now);
  22961. +#define process_igmp(ip, now)
  22962. +#endif
  22963. +
  22964. +/**************************************************************************
  22965. +AWAIT_REPLY - Wait until we get a response for our request
  22966. +************f**************************************************************/
  22967. +int await_reply(reply_t reply, int ival, void *ptr, long timeout)
  22968. +{
  22969. + unsigned long time, now;
  22970. + struct iphdr *ip;
  22971. + unsigned iplen = 0;
  22972. + struct udphdr *udp;
  22973. + unsigned short ptype;
  22974. + int result;
  22975. +
  22976. + user_abort = 0;
  22977. +
  22978. + time = timeout + currticks();
  22979. + /* The timeout check is done below. The timeout is only checked if
  22980. + * there is no packet in the Rx queue. This assumes that eth_poll()
  22981. + * needs a negligible amount of time.
  22982. + */
  22983. + for (;;) {
  22984. + now = currticks();
  22985. + send_igmp_reports(now);
  22986. + result = eth_poll(1);
  22987. + if (result == 0) {
  22988. + /* We don't have anything */
  22989. +
  22990. + /* Check for abort key only if the Rx queue is empty -
  22991. + * as long as we have something to process, don't
  22992. + * assume that something failed. It is unlikely that
  22993. + * we have no processing time left between packets. */
  22994. + poll_interruptions();
  22995. + /* Do the timeout after at least a full queue walk. */
  22996. + if ((timeout == 0) || (currticks() > time) || user_abort == 1) {
  22997. + break;
  22998. + }
  22999. + continue;
  23000. + }
  23001. +
  23002. + /* We have something! */
  23003. +
  23004. + /* Find the Ethernet packet type */
  23005. + if (nic.packetlen >= ETH_HLEN) {
  23006. + ptype = ((unsigned short) nic.packet[12]) << 8
  23007. + | ((unsigned short) nic.packet[13]);
  23008. + } else continue; /* what else could we do with it? */
  23009. + /* Verify an IP header */
  23010. + ip = 0;
  23011. + if ((ptype == IP) && (nic.packetlen >= ETH_HLEN + sizeof(struct iphdr))) {
  23012. + unsigned ipoptlen;
  23013. + ip = (struct iphdr *)&nic.packet[ETH_HLEN];
  23014. + if ((ip->verhdrlen < 0x45) || (ip->verhdrlen > 0x4F))
  23015. + continue;
  23016. + iplen = (ip->verhdrlen & 0xf) * 4;
  23017. + if (ipchksum(ip, iplen) != 0)
  23018. + continue;
  23019. + if (ip->frags & htons(0x3FFF)) {
  23020. + static int warned_fragmentation = 0;
  23021. + if (!warned_fragmentation) {
  23022. + printf("ALERT: got a fragmented packet - reconfigure your server\n");
  23023. + warned_fragmentation = 1;
  23024. + }
  23025. + continue;
  23026. + }
  23027. + if (ntohs(ip->len) > ETH_MAX_MTU)
  23028. + continue;
  23029. +
  23030. + ipoptlen = iplen - sizeof(struct iphdr);
  23031. + if (ipoptlen) {
  23032. + /* Delete the ip options, to guarantee
  23033. + * good alignment, and make etherboot simpler.
  23034. + */
  23035. + memmove(&nic.packet[ETH_HLEN + sizeof(struct iphdr)],
  23036. + &nic.packet[ETH_HLEN + iplen],
  23037. + nic.packetlen - ipoptlen);
  23038. + nic.packetlen -= ipoptlen;
  23039. + }
  23040. + }
  23041. + udp = 0;
  23042. + if (ip && (ip->protocol == IP_UDP) &&
  23043. + (nic.packetlen >= ETH_HLEN + sizeof(struct iphdr) + sizeof(struct udphdr))) {
  23044. + udp = (struct udphdr *)&nic.packet[ETH_HLEN + sizeof(struct iphdr)];
  23045. +
  23046. + /* Make certain we have a reasonable packet length */
  23047. + if (ntohs(udp->len) > (ntohs(ip->len) - iplen))
  23048. + continue;
  23049. +
  23050. + if (udp->chksum && udpchksum(ip, udp)) {
  23051. + printf("UDP checksum error\n");
  23052. + continue;
  23053. + }
  23054. + }
  23055. + result = reply(ival, ptr, ptype, ip, udp);
  23056. + if (result > 0) {
  23057. + return result;
  23058. + }
  23059. +
  23060. + /* If it isn't a packet the upper layer wants see if there is a default
  23061. + * action. This allows us reply to arp and igmp queryies.
  23062. + */
  23063. + if ((ptype == ARP) &&
  23064. + (nic.packetlen >= ETH_HLEN + sizeof(struct arprequest))) {
  23065. + struct arprequest *arpreply;
  23066. + unsigned long tmp;
  23067. +
  23068. + arpreply = (struct arprequest *)&nic.packet[ETH_HLEN];
  23069. + memcpy(&tmp, arpreply->tipaddr, sizeof(in_addr));
  23070. + if ((arpreply->opcode == htons(ARP_REQUEST)) &&
  23071. + (tmp == arptable[ARP_CLIENT].ipaddr.s_addr)) {
  23072. + arpreply->opcode = htons(ARP_REPLY);
  23073. + memcpy(arpreply->tipaddr, arpreply->sipaddr, sizeof(in_addr));
  23074. + memcpy(arpreply->thwaddr, arpreply->shwaddr, ETH_ALEN);
  23075. + memcpy(arpreply->sipaddr, &arptable[ARP_CLIENT].ipaddr, sizeof(in_addr));
  23076. + memcpy(arpreply->shwaddr, arptable[ARP_CLIENT].node, ETH_ALEN);
  23077. + eth_transmit(arpreply->thwaddr, ARP,
  23078. + sizeof(struct arprequest),
  23079. + arpreply);
  23080. +#ifdef MDEBUG
  23081. + memcpy(&tmp, arpreply->tipaddr, sizeof(in_addr));
  23082. + printf("Sent ARP reply to: %@\n",tmp);
  23083. +#endif /* MDEBUG */
  23084. + }
  23085. + }
  23086. + process_igmp(ip, now);
  23087. + }
  23088. + return(0);
  23089. +}
  23090. +
  23091. +#ifdef REQUIRE_VCI_ETHERBOOT
  23092. +/**************************************************************************
  23093. +FIND_VCI_ETHERBOOT - Looks for "Etherboot" in Vendor Encapsulated Identifiers
  23094. +On entry p points to byte count of VCI options
  23095. +**************************************************************************/
  23096. +static int find_vci_etherboot(unsigned char *p)
  23097. +{
  23098. + unsigned char *end = p + 1 + *p;
  23099. +
  23100. + for (p++; p < end; ) {
  23101. + if (*p == RFC2132_VENDOR_CLASS_ID) {
  23102. + if (strncmp("Etherboot", p + 2, sizeof("Etherboot") - 1) == 0)
  23103. + return (1);
  23104. + } else if (*p == RFC1533_END)
  23105. + return (0);
  23106. + p += TAG_LEN(p) + 2;
  23107. + }
  23108. + return (0);
  23109. +}
  23110. +#endif /* REQUIRE_VCI_ETHERBOOT */
  23111. +
  23112. +/**
  23113. + * decode_rfc1533
  23114. + *
  23115. + * Decodes RFC1533 header
  23116. + **/
  23117. +int decode_rfc1533(unsigned char *p, unsigned int block, unsigned int len, int eof)
  23118. +{
  23119. + static unsigned char *extdata = NULL, *extend = NULL;
  23120. + unsigned char *extpath = NULL;
  23121. + unsigned char *endp;
  23122. +
  23123. + if (block == 0) {
  23124. + end_of_rfc1533 = NULL;
  23125. + if (memcmp(p, rfc1533_cookie, sizeof(rfc1533_cookie)))
  23126. + return(0); /* no RFC 1533 header found */
  23127. + p += 4;
  23128. + endp = p + len;
  23129. + } else {
  23130. + if (block == 1) {
  23131. + if (memcmp(p, rfc1533_cookie, sizeof(rfc1533_cookie)))
  23132. + return(0); /* no RFC 1533 header found */
  23133. + p += 4;
  23134. + len -= 4; }
  23135. + if (extend + len <= (unsigned char *)
  23136. + rfc1533_venddata + sizeof(rfc1533_venddata)) {
  23137. + memcpy(extend, p, len);
  23138. + extend += len;
  23139. + } else {
  23140. + printf("Overflow in vendor data buffer! Aborting...\n");
  23141. + *extdata = RFC1533_END;
  23142. + return(0);
  23143. + }
  23144. + p = extdata; endp = extend;
  23145. + }
  23146. + if (!eof)
  23147. + return 1;
  23148. + while (p < endp) {
  23149. + unsigned char c = *p;
  23150. + if (c == RFC1533_PAD) {
  23151. + p++;
  23152. + continue;
  23153. + }
  23154. + else if (c == RFC1533_END) {
  23155. + end_of_rfc1533 = endp = p;
  23156. + continue;
  23157. + }
  23158. + else if (c == RFC1533_NETMASK)
  23159. + memcpy(&netmask, p+2, sizeof(in_addr));
  23160. + else if (c == RFC1533_GATEWAY) {
  23161. + /* This is a little simplistic, but it will
  23162. + usually be sufficient.
  23163. + Take only the first entry */
  23164. + if (TAG_LEN(p) >= sizeof(in_addr))
  23165. + memcpy(&arptable[ARP_GATEWAY].ipaddr, p+2, sizeof(in_addr));
  23166. + }
  23167. + else if (c == RFC1533_EXTENSIONPATH)
  23168. + extpath = p;
  23169. + else if (c == RFC2132_MSG_TYPE)
  23170. + dhcp_reply=*(p+2);
  23171. + else if (c == RFC2132_SRV_ID)
  23172. + memcpy(&dhcp_server, p+2, sizeof(in_addr));
  23173. + else if (c == RFC1533_HOSTNAME) {
  23174. + hostname = p + 2;
  23175. + hostnamelen = *(p + 1);
  23176. + }
  23177. + else if (c == RFC1533_VENDOR_CONFIGFILE){
  23178. + int l = TAG_LEN (p);
  23179. +
  23180. + /* Eliminate the trailing NULs according to RFC 2132. */
  23181. + while (*(p + 2 + l - 1) == '\000' && l > 0)
  23182. + l--;
  23183. +
  23184. + /* XXX: Should check if LEN is less than the maximum length
  23185. + of CONFIG_FILE. This kind of robustness will be a goal
  23186. + in GRUB 1.0. */
  23187. + memcpy (config_file, p + 2, l);
  23188. + config_file[l] = 0;
  23189. + }
  23190. + else {
  23191. + ;
  23192. + }
  23193. + p += TAG_LEN(p) + 2;
  23194. + }
  23195. + extdata = extend = endp;
  23196. + if (block <= 0 && extpath != NULL) {
  23197. + char fname[64];
  23198. + if (TAG_LEN(extpath) >= sizeof(fname)){
  23199. + printf("Overflow in vendor data buffer! Aborting...\n");
  23200. + *extdata = RFC1533_END;
  23201. + return(0);
  23202. + }
  23203. + memcpy(fname, extpath+2, TAG_LEN(extpath));
  23204. + fname[(int)TAG_LEN(extpath)] = '\0';
  23205. + printf("Loading BOOTP-extension file: %s\n",fname);
  23206. + tftp_file_read(fname, decode_rfc1533);
  23207. + }
  23208. + return 1; /* proceed with next block */
  23209. +}
  23210. +
  23211. +
  23212. +/* FIXME double check TWO_SECOND_DIVISOR */
  23213. +#define TWO_SECOND_DIVISOR (RAND_MAX/TICKS_PER_SEC)
  23214. +/**************************************************************************
  23215. +RFC2131_SLEEP_INTERVAL - sleep for expotentially longer times (base << exp) +- 1 sec)
  23216. +**************************************************************************/
  23217. +long rfc2131_sleep_interval(long base, int exp)
  23218. +{
  23219. + unsigned long tmo;
  23220. +#ifdef BACKOFF_LIMIT
  23221. + if (exp > BACKOFF_LIMIT)
  23222. + exp = BACKOFF_LIMIT;
  23223. +#endif
  23224. + tmo = (base << exp) + (TICKS_PER_SEC - (random()/TWO_SECOND_DIVISOR));
  23225. + return tmo;
  23226. +}
  23227. +
  23228. +#ifdef MULTICAST_LEVEL2
  23229. +/**************************************************************************
  23230. +RFC1112_SLEEP_INTERVAL - sleep for expotentially longer times, up to (base << exp)
  23231. +**************************************************************************/
  23232. +long rfc1112_sleep_interval(long base, int exp)
  23233. +{
  23234. + unsigned long divisor, tmo;
  23235. +#ifdef BACKOFF_LIMIT
  23236. + if (exp > BACKOFF_LIMIT)
  23237. + exp = BACKOFF_LIMIT;
  23238. +#endif
  23239. + divisor = RAND_MAX/(base << exp);
  23240. + tmo = random()/divisor;
  23241. + return tmo;
  23242. +}
  23243. +#endif /* MULTICAST_LEVEL_2 */
  23244. +/* ifconfig - configure network interface. */
  23245. +int
  23246. +ifconfig (char *ip, char *sm, char *gw, char *svr)
  23247. +{
  23248. + in_addr tmp;
  23249. +
  23250. + if (sm)
  23251. + {
  23252. + if (! inet_aton (sm, &tmp))
  23253. + return 0;
  23254. +
  23255. + netmask = tmp.s_addr;
  23256. + }
  23257. +
  23258. + if (ip)
  23259. + {
  23260. + if (! inet_aton (ip, &arptable[ARP_CLIENT].ipaddr))
  23261. + return 0;
  23262. +
  23263. + if (! netmask && ! sm)
  23264. + netmask = default_netmask ();
  23265. + }
  23266. +
  23267. + if (gw && ! inet_aton (gw, &arptable[ARP_GATEWAY].ipaddr))
  23268. + return 0;
  23269. +
  23270. + /* Clear out the ARP entry. */
  23271. + grub_memset (arptable[ARP_GATEWAY].node, 0, ETH_ALEN);
  23272. +
  23273. + if (svr && ! inet_aton (svr, &arptable[ARP_SERVER].ipaddr))
  23274. + return 0;
  23275. +
  23276. + /* Likewise. */
  23277. + grub_memset (arptable[ARP_SERVER].node, 0, ETH_ALEN);
  23278. +
  23279. + if (ip || sm)
  23280. + {
  23281. + if (IP_BROADCAST == (netmask | arptable[ARP_CLIENT].ipaddr.s_addr)
  23282. + || netmask == (netmask | arptable[ARP_CLIENT].ipaddr.s_addr)
  23283. + || ! netmask)
  23284. + network_ready = 0;
  23285. + else
  23286. + network_ready = 1;
  23287. + }
  23288. +
  23289. + return 1;
  23290. +}
  23291. +
  23292. +/*
  23293. + * print_network_configuration
  23294. + *
  23295. + * Output the network configuration. It may broke the graphic console now.:-(
  23296. + */
  23297. +void print_network_configuration (void)
  23298. +{
  23299. + EnterFunction("print_network_configuration");
  23300. + if (! grub_eth_probe ())
  23301. + grub_printf ("No ethernet card found.\n");
  23302. + else if (! network_ready)
  23303. + grub_printf ("Not initialized yet.\n");
  23304. + else {
  23305. + etherboot_printf ("Address: %@\n", arptable[ARP_CLIENT].ipaddr.s_addr);
  23306. + etherboot_printf ("Netmask: %@\n", netmask);
  23307. + etherboot_printf ("Server: %@\n", arptable[ARP_SERVER].ipaddr.s_addr);
  23308. + etherboot_printf ("Gateway: %@\n", arptable[ARP_GATEWAY].ipaddr.s_addr);
  23309. + }
  23310. + LeaveFunction("print_network_configuration");
  23311. +}
  23312. +
  23313. +/**
  23314. + * cleanup_net
  23315. + *
  23316. + * Mark network unusable, and disable NICs
  23317. + */
  23318. +void cleanup_net (void)
  23319. +{
  23320. + if (network_ready){
  23321. + /* Stop receiving packets. */
  23322. + eth_disable ();
  23323. + network_ready = 0;
  23324. + }
  23325. +}
  23326. diff -Naur grub-0.97.orig/netboot/nic.h grub-0.97/netboot/nic.h
  23327. --- grub-0.97.orig/netboot/nic.h 2003-07-09 11:45:38.000000000 +0000
  23328. +++ grub-0.97/netboot/nic.h 2005-08-31 19:03:35.000000000 +0000
  23329. @@ -8,24 +8,38 @@
  23330. #ifndef NIC_H
  23331. #define NIC_H
  23332. +#include "dev.h"
  23333. +
  23334. +typedef enum {
  23335. + DISABLE = 0,
  23336. + ENABLE,
  23337. + FORCE
  23338. +} irq_action_t;
  23339. +
  23340. /*
  23341. * Structure returned from eth_probe and passed to other driver
  23342. * functions.
  23343. */
  23344. -
  23345. struct nic
  23346. {
  23347. - void (*reset)P((struct nic *));
  23348. - int (*poll)P((struct nic *));
  23349. + struct dev dev; /* This must come first */
  23350. + int (*poll)P((struct nic *, int retrieve));
  23351. void (*transmit)P((struct nic *, const char *d,
  23352. unsigned int t, unsigned int s, const char *p));
  23353. - void (*disable)P((struct nic *));
  23354. + void (*irq)P((struct nic *, irq_action_t));
  23355. int flags; /* driver specific flags */
  23356. struct rom_info *rom_info; /* -> rom_info from main */
  23357. unsigned char *node_addr;
  23358. - char *packet;
  23359. + unsigned char *packet;
  23360. unsigned int packetlen;
  23361. + unsigned int ioaddr;
  23362. + unsigned char irqno;
  23363. void *priv_data; /* driver can hang private data here */
  23364. };
  23365. +extern int eth_probe(struct dev *dev);
  23366. +extern int eth_poll(int retrieve);
  23367. +extern void eth_transmit(const char *d, unsigned int t, unsigned int s, const void *p);
  23368. +extern void eth_disable(void);
  23369. +extern void eth_irq(irq_action_t action);
  23370. #endif /* NIC_H */
  23371. diff -Naur grub-0.97.orig/netboot/ns83820.c grub-0.97/netboot/ns83820.c
  23372. --- grub-0.97.orig/netboot/ns83820.c 1970-01-01 00:00:00.000000000 +0000
  23373. +++ grub-0.97/netboot/ns83820.c 2005-08-31 19:03:35.000000000 +0000
  23374. @@ -0,0 +1,1020 @@
  23375. +/**************************************************************************
  23376. +* ns83820.c: Etherboot device driver for the National Semiconductor 83820
  23377. +* Written 2004 by Timothy Legge <tlegge@rogers.com>
  23378. +*
  23379. +* This program is free software; you can redistribute it and/or modify
  23380. +* it under the terms of the GNU General Public License as published by
  23381. +* the Free Software Foundation; either version 2 of the License, or
  23382. +* (at your option) any later version.
  23383. +*
  23384. +* This program is distributed in the hope that it will be useful,
  23385. +* but WITHOUT ANY WARRANTY; without even the implied warranty of
  23386. +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23387. +* GNU General Public License for more details.
  23388. +*
  23389. +* You should have received a copy of the GNU General Public License
  23390. +* along with this program; if not, write to the Free Software
  23391. +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23392. +*
  23393. +* Portions of this code based on:
  23394. +* ns83820.c by Benjamin LaHaise with contributions
  23395. +* for Linux kernel 2.4.x.
  23396. +*
  23397. +* Linux Driver Version 0.20, 20020610
  23398. +*
  23399. +* This development of this Etherboot driver was funded by:
  23400. +*
  23401. +* NXTV: http://www.nxtv.com/
  23402. +*
  23403. +* REVISION HISTORY:
  23404. +* ================
  23405. +*
  23406. +* v1.0 02-16-2004 timlegge Initial port of Linux driver
  23407. +* v1.1 02-19-2004 timlegge More rohbust transmit and poll
  23408. +*
  23409. +* Indent Options: indent -kr -i8
  23410. +***************************************************************************/
  23411. +
  23412. +/* to get some global routines like printf */
  23413. +#include "etherboot.h"
  23414. +/* to get the interface to the body of the program */
  23415. +#include "nic.h"
  23416. +/* to get the PCI support functions, if this is a PCI NIC */
  23417. +#include "pci.h"
  23418. +
  23419. +#if ARCH == ia64 /* Support 64-bit addressing */
  23420. +#define USE_64BIT_ADDR
  23421. +#endif
  23422. +
  23423. +//#define DDEBUG
  23424. +#ifdef DDEBUG
  23425. +#define dprintf(x) printf x
  23426. +#else
  23427. +#define dprintf(x)
  23428. +#endif
  23429. +
  23430. +typedef unsigned char u8;
  23431. +typedef signed char s8;
  23432. +typedef unsigned short u16;
  23433. +typedef signed short s16;
  23434. +typedef unsigned int u32;
  23435. +typedef signed int s32;
  23436. +
  23437. +#define HZ 100
  23438. +
  23439. +/* Condensed operations for readability. */
  23440. +#define virt_to_le32desc(addr) cpu_to_le32(virt_to_bus(addr))
  23441. +#define le32desc_to_virt(addr) bus_to_virt(le32_to_cpu(addr))
  23442. +
  23443. +/* NIC specific static variables go here */
  23444. +
  23445. +/* Global parameters. See MODULE_PARM near the bottom. */
  23446. +// static int ihr = 2;
  23447. +static int reset_phy = 0;
  23448. +static int lnksts = 0; /* CFG_LNKSTS bit polarity */
  23449. +
  23450. +#if defined(CONFIG_HIGHMEM64G) || defined(__ia64__)
  23451. +#define USE_64BIT_ADDR "+"
  23452. +#endif
  23453. +
  23454. +#if defined(USE_64BIT_ADDR)
  23455. +#define TRY_DAC 1
  23456. +#else
  23457. +#define TRY_DAC 0
  23458. +#endif
  23459. +
  23460. +/* tunables */
  23461. +#define RX_BUF_SIZE 1500 /* 8192 */
  23462. +
  23463. +/* Must not exceed ~65000. */
  23464. +#define NR_RX_DESC 64
  23465. +#define NR_TX_DESC 1
  23466. +
  23467. + /* not tunable *//* Extra 6 bytes for 64 bit alignment (divisable by 8) */
  23468. +#define REAL_RX_BUF_SIZE (RX_BUF_SIZE + 14 + 6) /* rx/tx mac addr + type */
  23469. +
  23470. +#define MIN_TX_DESC_FREE 8
  23471. +
  23472. +/* register defines */
  23473. +#define CFGCS 0x04
  23474. +
  23475. +#define CR_TXE 0x00000001
  23476. +#define CR_TXD 0x00000002
  23477. +/* Ramit : Here's a tip, don't do a RXD immediately followed by an RXE
  23478. + * The Receive engine skips one descriptor and moves
  23479. + * onto the next one!! */
  23480. +#define CR_RXE 0x00000004
  23481. +#define CR_RXD 0x00000008
  23482. +#define CR_TXR 0x00000010
  23483. +#define CR_RXR 0x00000020
  23484. +#define CR_SWI 0x00000080
  23485. +#define CR_RST 0x00000100
  23486. +
  23487. +#define PTSCR_EEBIST_FAIL 0x00000001
  23488. +#define PTSCR_EEBIST_EN 0x00000002
  23489. +#define PTSCR_EELOAD_EN 0x00000004
  23490. +#define PTSCR_RBIST_FAIL 0x000001b8
  23491. +#define PTSCR_RBIST_DONE 0x00000200
  23492. +#define PTSCR_RBIST_EN 0x00000400
  23493. +#define PTSCR_RBIST_RST 0x00002000
  23494. +
  23495. +#define MEAR_EEDI 0x00000001
  23496. +#define MEAR_EEDO 0x00000002
  23497. +#define MEAR_EECLK 0x00000004
  23498. +#define MEAR_EESEL 0x00000008
  23499. +#define MEAR_MDIO 0x00000010
  23500. +#define MEAR_MDDIR 0x00000020
  23501. +#define MEAR_MDC 0x00000040
  23502. +
  23503. +#define ISR_TXDESC3 0x40000000
  23504. +#define ISR_TXDESC2 0x20000000
  23505. +#define ISR_TXDESC1 0x10000000
  23506. +#define ISR_TXDESC0 0x08000000
  23507. +#define ISR_RXDESC3 0x04000000
  23508. +#define ISR_RXDESC2 0x02000000
  23509. +#define ISR_RXDESC1 0x01000000
  23510. +#define ISR_RXDESC0 0x00800000
  23511. +#define ISR_TXRCMP 0x00400000
  23512. +#define ISR_RXRCMP 0x00200000
  23513. +#define ISR_DPERR 0x00100000
  23514. +#define ISR_SSERR 0x00080000
  23515. +#define ISR_RMABT 0x00040000
  23516. +#define ISR_RTABT 0x00020000
  23517. +#define ISR_RXSOVR 0x00010000
  23518. +#define ISR_HIBINT 0x00008000
  23519. +#define ISR_PHY 0x00004000
  23520. +#define ISR_PME 0x00002000
  23521. +#define ISR_SWI 0x00001000
  23522. +#define ISR_MIB 0x00000800
  23523. +#define ISR_TXURN 0x00000400
  23524. +#define ISR_TXIDLE 0x00000200
  23525. +#define ISR_TXERR 0x00000100
  23526. +#define ISR_TXDESC 0x00000080
  23527. +#define ISR_TXOK 0x00000040
  23528. +#define ISR_RXORN 0x00000020
  23529. +#define ISR_RXIDLE 0x00000010
  23530. +#define ISR_RXEARLY 0x00000008
  23531. +#define ISR_RXERR 0x00000004
  23532. +#define ISR_RXDESC 0x00000002
  23533. +#define ISR_RXOK 0x00000001
  23534. +
  23535. +#define TXCFG_CSI 0x80000000
  23536. +#define TXCFG_HBI 0x40000000
  23537. +#define TXCFG_MLB 0x20000000
  23538. +#define TXCFG_ATP 0x10000000
  23539. +#define TXCFG_ECRETRY 0x00800000
  23540. +#define TXCFG_BRST_DIS 0x00080000
  23541. +#define TXCFG_MXDMA1024 0x00000000
  23542. +#define TXCFG_MXDMA512 0x00700000
  23543. +#define TXCFG_MXDMA256 0x00600000
  23544. +#define TXCFG_MXDMA128 0x00500000
  23545. +#define TXCFG_MXDMA64 0x00400000
  23546. +#define TXCFG_MXDMA32 0x00300000
  23547. +#define TXCFG_MXDMA16 0x00200000
  23548. +#define TXCFG_MXDMA8 0x00100000
  23549. +
  23550. +#define CFG_LNKSTS 0x80000000
  23551. +#define CFG_SPDSTS 0x60000000
  23552. +#define CFG_SPDSTS1 0x40000000
  23553. +#define CFG_SPDSTS0 0x20000000
  23554. +#define CFG_DUPSTS 0x10000000
  23555. +#define CFG_TBI_EN 0x01000000
  23556. +#define CFG_MODE_1000 0x00400000
  23557. +/* Ramit : Dont' ever use AUTO_1000, it never works and is buggy.
  23558. + * Read the Phy response and then configure the MAC accordingly */
  23559. +#define CFG_AUTO_1000 0x00200000
  23560. +#define CFG_PINT_CTL 0x001c0000
  23561. +#define CFG_PINT_DUPSTS 0x00100000
  23562. +#define CFG_PINT_LNKSTS 0x00080000
  23563. +#define CFG_PINT_SPDSTS 0x00040000
  23564. +#define CFG_TMRTEST 0x00020000
  23565. +#define CFG_MRM_DIS 0x00010000
  23566. +#define CFG_MWI_DIS 0x00008000
  23567. +#define CFG_T64ADDR 0x00004000
  23568. +#define CFG_PCI64_DET 0x00002000
  23569. +#define CFG_DATA64_EN 0x00001000
  23570. +#define CFG_M64ADDR 0x00000800
  23571. +#define CFG_PHY_RST 0x00000400
  23572. +#define CFG_PHY_DIS 0x00000200
  23573. +#define CFG_EXTSTS_EN 0x00000100
  23574. +#define CFG_REQALG 0x00000080
  23575. +#define CFG_SB 0x00000040
  23576. +#define CFG_POW 0x00000020
  23577. +#define CFG_EXD 0x00000010
  23578. +#define CFG_PESEL 0x00000008
  23579. +#define CFG_BROM_DIS 0x00000004
  23580. +#define CFG_EXT_125 0x00000002
  23581. +#define CFG_BEM 0x00000001
  23582. +
  23583. +#define EXTSTS_UDPPKT 0x00200000
  23584. +#define EXTSTS_TCPPKT 0x00080000
  23585. +#define EXTSTS_IPPKT 0x00020000
  23586. +
  23587. +#define SPDSTS_POLARITY (CFG_SPDSTS1 | CFG_SPDSTS0 | CFG_DUPSTS | (lnksts ? CFG_LNKSTS : 0))
  23588. +
  23589. +#define MIBC_MIBS 0x00000008
  23590. +#define MIBC_ACLR 0x00000004
  23591. +#define MIBC_FRZ 0x00000002
  23592. +#define MIBC_WRN 0x00000001
  23593. +
  23594. +#define PCR_PSEN (1 << 31)
  23595. +#define PCR_PS_MCAST (1 << 30)
  23596. +#define PCR_PS_DA (1 << 29)
  23597. +#define PCR_STHI_8 (3 << 23)
  23598. +#define PCR_STLO_4 (1 << 23)
  23599. +#define PCR_FFHI_8K (3 << 21)
  23600. +#define PCR_FFLO_4K (1 << 21)
  23601. +#define PCR_PAUSE_CNT 0xFFFE
  23602. +
  23603. +#define RXCFG_AEP 0x80000000
  23604. +#define RXCFG_ARP 0x40000000
  23605. +#define RXCFG_STRIPCRC 0x20000000
  23606. +#define RXCFG_RX_FD 0x10000000
  23607. +#define RXCFG_ALP 0x08000000
  23608. +#define RXCFG_AIRL 0x04000000
  23609. +#define RXCFG_MXDMA512 0x00700000
  23610. +#define RXCFG_DRTH 0x0000003e
  23611. +#define RXCFG_DRTH0 0x00000002
  23612. +
  23613. +#define RFCR_RFEN 0x80000000
  23614. +#define RFCR_AAB 0x40000000
  23615. +#define RFCR_AAM 0x20000000
  23616. +#define RFCR_AAU 0x10000000
  23617. +#define RFCR_APM 0x08000000
  23618. +#define RFCR_APAT 0x07800000
  23619. +#define RFCR_APAT3 0x04000000
  23620. +#define RFCR_APAT2 0x02000000
  23621. +#define RFCR_APAT1 0x01000000
  23622. +#define RFCR_APAT0 0x00800000
  23623. +#define RFCR_AARP 0x00400000
  23624. +#define RFCR_MHEN 0x00200000
  23625. +#define RFCR_UHEN 0x00100000
  23626. +#define RFCR_ULM 0x00080000
  23627. +
  23628. +#define VRCR_RUDPE 0x00000080
  23629. +#define VRCR_RTCPE 0x00000040
  23630. +#define VRCR_RIPE 0x00000020
  23631. +#define VRCR_IPEN 0x00000010
  23632. +#define VRCR_DUTF 0x00000008
  23633. +#define VRCR_DVTF 0x00000004
  23634. +#define VRCR_VTREN 0x00000002
  23635. +#define VRCR_VTDEN 0x00000001
  23636. +
  23637. +#define VTCR_PPCHK 0x00000008
  23638. +#define VTCR_GCHK 0x00000004
  23639. +#define VTCR_VPPTI 0x00000002
  23640. +#define VTCR_VGTI 0x00000001
  23641. +
  23642. +#define CR 0x00
  23643. +#define CFG 0x04
  23644. +#define MEAR 0x08
  23645. +#define PTSCR 0x0c
  23646. +#define ISR 0x10
  23647. +#define IMR 0x14
  23648. +#define IER 0x18
  23649. +#define IHR 0x1c
  23650. +#define TXDP 0x20
  23651. +#define TXDP_HI 0x24
  23652. +#define TXCFG 0x28
  23653. +#define GPIOR 0x2c
  23654. +#define RXDP 0x30
  23655. +#define RXDP_HI 0x34
  23656. +#define RXCFG 0x38
  23657. +#define PQCR 0x3c
  23658. +#define WCSR 0x40
  23659. +#define PCR 0x44
  23660. +#define RFCR 0x48
  23661. +#define RFDR 0x4c
  23662. +
  23663. +#define SRR 0x58
  23664. +
  23665. +#define VRCR 0xbc
  23666. +#define VTCR 0xc0
  23667. +#define VDR 0xc4
  23668. +#define CCSR 0xcc
  23669. +
  23670. +#define TBICR 0xe0
  23671. +#define TBISR 0xe4
  23672. +#define TANAR 0xe8
  23673. +#define TANLPAR 0xec
  23674. +#define TANER 0xf0
  23675. +#define TESR 0xf4
  23676. +
  23677. +#define TBICR_MR_AN_ENABLE 0x00001000
  23678. +#define TBICR_MR_RESTART_AN 0x00000200
  23679. +
  23680. +#define TBISR_MR_LINK_STATUS 0x00000020
  23681. +#define TBISR_MR_AN_COMPLETE 0x00000004
  23682. +
  23683. +#define TANAR_PS2 0x00000100
  23684. +#define TANAR_PS1 0x00000080
  23685. +#define TANAR_HALF_DUP 0x00000040
  23686. +#define TANAR_FULL_DUP 0x00000020
  23687. +
  23688. +#define GPIOR_GP5_OE 0x00000200
  23689. +#define GPIOR_GP4_OE 0x00000100
  23690. +#define GPIOR_GP3_OE 0x00000080
  23691. +#define GPIOR_GP2_OE 0x00000040
  23692. +#define GPIOR_GP1_OE 0x00000020
  23693. +#define GPIOR_GP3_OUT 0x00000004
  23694. +#define GPIOR_GP1_OUT 0x00000001
  23695. +
  23696. +#define LINK_AUTONEGOTIATE 0x01
  23697. +#define LINK_DOWN 0x02
  23698. +#define LINK_UP 0x04
  23699. +
  23700. +
  23701. +#define __kick_rx() writel(CR_RXE, ns->base + CR)
  23702. +
  23703. +#define kick_rx() do { \
  23704. + dprintf(("kick_rx: maybe kicking\n")); \
  23705. + writel(virt_to_le32desc(&rx_ring[ns->cur_rx]), ns->base + RXDP); \
  23706. + if (ns->next_rx == ns->next_empty) \
  23707. + printf("uh-oh: next_rx == next_empty???\n"); \
  23708. + __kick_rx(); \
  23709. +} while(0)
  23710. +
  23711. +
  23712. +#ifdef USE_64BIT_ADDR
  23713. +#define HW_ADDR_LEN 8
  23714. +#else
  23715. +#define HW_ADDR_LEN 4
  23716. +#endif
  23717. +
  23718. +#define CMDSTS_OWN 0x80000000
  23719. +#define CMDSTS_MORE 0x40000000
  23720. +#define CMDSTS_INTR 0x20000000
  23721. +#define CMDSTS_ERR 0x10000000
  23722. +#define CMDSTS_OK 0x08000000
  23723. +#define CMDSTS_LEN_MASK 0x0000ffff
  23724. +
  23725. +#define CMDSTS_DEST_MASK 0x01800000
  23726. +#define CMDSTS_DEST_SELF 0x00800000
  23727. +#define CMDSTS_DEST_MULTI 0x01000000
  23728. +
  23729. +#define DESC_SIZE 8 /* Should be cache line sized */
  23730. +
  23731. +#ifdef USE_64BIT_ADDR
  23732. +struct ring_desc {
  23733. + uint64_t link;
  23734. + uint64_t bufptr;
  23735. + u32 cmdsts;
  23736. + u32 extsts; /* Extended status field */
  23737. +};
  23738. +#else
  23739. +struct ring_desc {
  23740. + u32 link;
  23741. + u32 bufptr;
  23742. + u32 cmdsts;
  23743. + u32 extsts; /* Extended status field */
  23744. +};
  23745. +#endif
  23746. +
  23747. +/* Define the TX Descriptor */
  23748. +static struct ring_desc tx_ring[NR_TX_DESC]
  23749. + __attribute__ ((aligned(8)));
  23750. +
  23751. +/* Create a static buffer of size REAL_RX_BUF_SIZE for each
  23752. +TX Descriptor. All descriptors point to a
  23753. +part of this buffer */
  23754. +static unsigned char txb[NR_TX_DESC * REAL_RX_BUF_SIZE];
  23755. +
  23756. +/* Define the TX Descriptor */
  23757. +static struct ring_desc rx_ring[NR_RX_DESC]
  23758. + __attribute__ ((aligned(8)));
  23759. +
  23760. +/* Create a static buffer of size REAL_RX_BUF_SIZE for each
  23761. +RX Descriptor All descriptors point to a
  23762. +part of this buffer */
  23763. +static unsigned char rxb[NR_RX_DESC * REAL_RX_BUF_SIZE]
  23764. + __attribute__ ((aligned(8)));
  23765. +
  23766. +/* Private Storage for the NIC */
  23767. +struct ns83820_private {
  23768. + u8 *base;
  23769. + int up;
  23770. + long idle;
  23771. + u32 *next_rx_desc;
  23772. + u16 next_rx, next_empty;
  23773. + u32 cur_rx;
  23774. + u32 *descs;
  23775. + unsigned ihr;
  23776. + u32 CFG_cache;
  23777. + u32 MEAR_cache;
  23778. + u32 IMR_cache;
  23779. + int linkstate;
  23780. + u16 tx_done_idx;
  23781. + u16 tx_idx;
  23782. + u16 tx_intr_idx;
  23783. + u32 phy_descs;
  23784. + u32 *tx_descs;
  23785. +
  23786. +} nsx;
  23787. +static struct ns83820_private *ns;
  23788. +
  23789. +static void phy_intr(struct nic *nic __unused)
  23790. +{
  23791. + static char *speeds[] =
  23792. + { "10", "100", "1000", "1000(?)", "1000F" };
  23793. + u32 cfg, new_cfg;
  23794. + u32 tbisr, tanar, tanlpar;
  23795. + int speed, fullduplex, newlinkstate;
  23796. +
  23797. + cfg = readl(ns->base + CFG) ^ SPDSTS_POLARITY;
  23798. + if (ns->CFG_cache & CFG_TBI_EN) {
  23799. + /* we have an optical transceiver */
  23800. + tbisr = readl(ns->base + TBISR);
  23801. + tanar = readl(ns->base + TANAR);
  23802. + tanlpar = readl(ns->base + TANLPAR);
  23803. + dprintf(("phy_intr: tbisr=%hX, tanar=%hX, tanlpar=%hX\n",
  23804. + tbisr, tanar, tanlpar));
  23805. +
  23806. + if ((fullduplex = (tanlpar & TANAR_FULL_DUP)
  23807. + && (tanar & TANAR_FULL_DUP))) {
  23808. +
  23809. + /* both of us are full duplex */
  23810. + writel(readl(ns->base + TXCFG)
  23811. + | TXCFG_CSI | TXCFG_HBI | TXCFG_ATP,
  23812. + ns->base + TXCFG);
  23813. + writel(readl(ns->base + RXCFG) | RXCFG_RX_FD,
  23814. + ns->base + RXCFG);
  23815. + /* Light up full duplex LED */
  23816. + writel(readl(ns->base + GPIOR) | GPIOR_GP1_OUT,
  23817. + ns->base + GPIOR);
  23818. +
  23819. + } else if (((tanlpar & TANAR_HALF_DUP)
  23820. + && (tanar & TANAR_HALF_DUP))
  23821. + || ((tanlpar & TANAR_FULL_DUP)
  23822. + && (tanar & TANAR_HALF_DUP))
  23823. + || ((tanlpar & TANAR_HALF_DUP)
  23824. + && (tanar & TANAR_FULL_DUP))) {
  23825. +
  23826. + /* one or both of us are half duplex */
  23827. + writel((readl(ns->base + TXCFG)
  23828. + & ~(TXCFG_CSI | TXCFG_HBI)) | TXCFG_ATP,
  23829. + ns->base + TXCFG);
  23830. + writel(readl(ns->base + RXCFG) & ~RXCFG_RX_FD,
  23831. + ns->base + RXCFG);
  23832. + /* Turn off full duplex LED */
  23833. + writel(readl(ns->base + GPIOR) & ~GPIOR_GP1_OUT,
  23834. + ns->base + GPIOR);
  23835. + }
  23836. +
  23837. + speed = 4; /* 1000F */
  23838. +
  23839. + } else {
  23840. + /* we have a copper transceiver */
  23841. + new_cfg =
  23842. + ns->CFG_cache & ~(CFG_SB | CFG_MODE_1000 | CFG_SPDSTS);
  23843. +
  23844. + if (cfg & CFG_SPDSTS1)
  23845. + new_cfg |= CFG_MODE_1000;
  23846. + else
  23847. + new_cfg &= ~CFG_MODE_1000;
  23848. +
  23849. + speed = ((cfg / CFG_SPDSTS0) & 3);
  23850. + fullduplex = (cfg & CFG_DUPSTS);
  23851. +
  23852. + if (fullduplex)
  23853. + new_cfg |= CFG_SB;
  23854. +
  23855. + if ((cfg & CFG_LNKSTS) &&
  23856. + ((new_cfg ^ ns->CFG_cache) & CFG_MODE_1000)) {
  23857. + writel(new_cfg, ns->base + CFG);
  23858. + ns->CFG_cache = new_cfg;
  23859. + }
  23860. +
  23861. + ns->CFG_cache &= ~CFG_SPDSTS;
  23862. + ns->CFG_cache |= cfg & CFG_SPDSTS;
  23863. + }
  23864. +
  23865. + newlinkstate = (cfg & CFG_LNKSTS) ? LINK_UP : LINK_DOWN;
  23866. +
  23867. + if (newlinkstate & LINK_UP && ns->linkstate != newlinkstate) {
  23868. + printf("link now %s mbps, %s duplex and up.\n",
  23869. + speeds[speed], fullduplex ? "full" : "half");
  23870. + } else if (newlinkstate & LINK_DOWN
  23871. + && ns->linkstate != newlinkstate) {
  23872. + printf("link now down.\n");
  23873. + }
  23874. + ns->linkstate = newlinkstate;
  23875. +}
  23876. +static void ns83820_set_multicast(struct nic *nic __unused);
  23877. +static void ns83820_setup_rx(struct nic *nic)
  23878. +{
  23879. + unsigned i;
  23880. + ns->idle = 1;
  23881. + ns->next_rx = 0;
  23882. + ns->next_rx_desc = ns->descs;
  23883. + ns->next_empty = 0;
  23884. + ns->cur_rx = 0;
  23885. +
  23886. +
  23887. + for (i = 0; i < NR_RX_DESC; i++) {
  23888. + rx_ring[i].link = virt_to_le32desc(&rx_ring[i + 1]);
  23889. + rx_ring[i].bufptr =
  23890. + virt_to_le32desc(&rxb[i * REAL_RX_BUF_SIZE]);
  23891. + rx_ring[i].cmdsts = cpu_to_le32(REAL_RX_BUF_SIZE);
  23892. + rx_ring[i].extsts = cpu_to_le32(0);
  23893. + }
  23894. +// No need to wrap the ring
  23895. +// rx_ring[i].link = virt_to_le32desc(&rx_ring[0]);
  23896. + writel(0, ns->base + RXDP_HI);
  23897. + writel(virt_to_le32desc(&rx_ring[0]), ns->base + RXDP);
  23898. +
  23899. + dprintf(("starting receiver\n"));
  23900. +
  23901. + writel(0x0001, ns->base + CCSR);
  23902. + writel(0, ns->base + RFCR);
  23903. + writel(0x7fc00000, ns->base + RFCR);
  23904. + writel(0xffc00000, ns->base + RFCR);
  23905. +
  23906. + ns->up = 1;
  23907. +
  23908. + phy_intr(nic);
  23909. +
  23910. + /* Okay, let it rip */
  23911. + ns->IMR_cache |= ISR_PHY;
  23912. + ns->IMR_cache |= ISR_RXRCMP;
  23913. + //dev->IMR_cache |= ISR_RXERR;
  23914. + //dev->IMR_cache |= ISR_RXOK;
  23915. + ns->IMR_cache |= ISR_RXORN;
  23916. + ns->IMR_cache |= ISR_RXSOVR;
  23917. + ns->IMR_cache |= ISR_RXDESC;
  23918. + ns->IMR_cache |= ISR_RXIDLE;
  23919. + ns->IMR_cache |= ISR_TXDESC;
  23920. + ns->IMR_cache |= ISR_TXIDLE;
  23921. +
  23922. + // No reason to enable interupts...
  23923. + // writel(ns->IMR_cache, ns->base + IMR);
  23924. + // writel(1, ns->base + IER);
  23925. + ns83820_set_multicast(nic);
  23926. + kick_rx();
  23927. +}
  23928. +
  23929. +
  23930. +static void ns83820_do_reset(struct nic *nic __unused, u32 which)
  23931. +{
  23932. + dprintf(("resetting chip...\n"));
  23933. + writel(which, ns->base + CR);
  23934. + do {
  23935. +
  23936. + } while (readl(ns->base + CR) & which);
  23937. + dprintf(("okay!\n"));
  23938. +}
  23939. +
  23940. +static void ns83820_reset(struct nic *nic)
  23941. +{
  23942. + unsigned i;
  23943. + dprintf(("ns83820_reset\n"));
  23944. +
  23945. + writel(0, ns->base + PQCR);
  23946. +
  23947. + ns83820_setup_rx(nic);
  23948. +
  23949. + for (i = 0; i < NR_TX_DESC; i++) {
  23950. + tx_ring[i].link = 0;
  23951. + tx_ring[i].bufptr = 0;
  23952. + tx_ring[i].cmdsts = cpu_to_le32(0);
  23953. + tx_ring[i].extsts = cpu_to_le32(0);
  23954. + }
  23955. +
  23956. + ns->tx_idx = 0;
  23957. + ns->tx_done_idx = 0;
  23958. + writel(0, ns->base + TXDP_HI);
  23959. + return;
  23960. +}
  23961. +static void ns83820_getmac(struct nic *nic __unused, u8 * mac)
  23962. +{
  23963. + unsigned i;
  23964. + for (i = 0; i < 3; i++) {
  23965. + u32 data;
  23966. + /* Read from the perfect match memory: this is loaded by
  23967. + * the chip from the EEPROM via the EELOAD self test.
  23968. + */
  23969. + writel(i * 2, ns->base + RFCR);
  23970. + data = readl(ns->base + RFDR);
  23971. + *mac++ = data;
  23972. + *mac++ = data >> 8;
  23973. + }
  23974. +}
  23975. +
  23976. +static void ns83820_set_multicast(struct nic *nic __unused)
  23977. +{
  23978. + u8 *rfcr = ns->base + RFCR;
  23979. + u32 and_mask = 0xffffffff;
  23980. + u32 or_mask = 0;
  23981. + u32 val;
  23982. +
  23983. + /* Support Multicast */
  23984. + and_mask &= ~(RFCR_AAU | RFCR_AAM);
  23985. + or_mask |= RFCR_AAM;
  23986. + val = (readl(rfcr) & and_mask) | or_mask;
  23987. + /* Ramit : RFCR Write Fix doc says RFEN must be 0 modify other bits */
  23988. + writel(val & ~RFCR_RFEN, rfcr);
  23989. + writel(val, rfcr);
  23990. +
  23991. +}
  23992. +static void ns83820_run_bist(struct nic *nic __unused, const char *name,
  23993. + u32 enable, u32 done, u32 fail)
  23994. +{
  23995. + int timed_out = 0;
  23996. + long start;
  23997. + u32 status;
  23998. + int loops = 0;
  23999. +
  24000. + dprintf(("start %s\n", name))
  24001. +
  24002. + start = currticks();
  24003. +
  24004. + writel(enable, ns->base + PTSCR);
  24005. + for (;;) {
  24006. + loops++;
  24007. + status = readl(ns->base + PTSCR);
  24008. + if (!(status & enable))
  24009. + break;
  24010. + if (status & done)
  24011. + break;
  24012. + if (status & fail)
  24013. + break;
  24014. + if ((currticks() - start) >= HZ) {
  24015. + timed_out = 1;
  24016. + break;
  24017. + }
  24018. + }
  24019. +
  24020. + if (status & fail)
  24021. + printf("%s failed! (0x%hX & 0x%hX)\n", name, status, fail);
  24022. + else if (timed_out)
  24023. + printf("run_bist %s timed out! (%hX)\n", name, status);
  24024. + dprintf(("done %s in %d loops\n", name, loops));
  24025. +}
  24026. +
  24027. +/*************************************
  24028. +Check Link
  24029. +*************************************/
  24030. +static void ns83820_check_intr(struct nic *nic) {
  24031. + int i;
  24032. + u32 isr = readl(ns->base + ISR);
  24033. + if(ISR_PHY & isr)
  24034. + phy_intr(nic);
  24035. + if(( ISR_RXIDLE | ISR_RXDESC | ISR_RXERR) & isr)
  24036. + kick_rx();
  24037. + for (i = 0; i < NR_RX_DESC; i++) {
  24038. + if (rx_ring[i].cmdsts == CMDSTS_OWN) {
  24039. +// rx_ring[i].link = virt_to_le32desc(&rx_ring[i + 1]);
  24040. + rx_ring[i].cmdsts = cpu_to_le32(REAL_RX_BUF_SIZE);
  24041. + }
  24042. + }
  24043. +}
  24044. +/**************************************************************************
  24045. +POLL - Wait for a frame
  24046. +***************************************************************************/
  24047. +static int ns83820_poll(struct nic *nic, int retrieve)
  24048. +{
  24049. + /* return true if there's an ethernet packet ready to read */
  24050. + /* nic->packet should contain data on return */
  24051. + /* nic->packetlen should contain length of data */
  24052. + u32 cmdsts;
  24053. + int entry = ns->cur_rx;
  24054. +
  24055. + ns83820_check_intr(nic);
  24056. +
  24057. + cmdsts = le32_to_cpu(rx_ring[entry].cmdsts);
  24058. +
  24059. + if ( ! ( (CMDSTS_OWN & (cmdsts)) && (cmdsts != (CMDSTS_OWN)) ) )
  24060. + return 0;
  24061. +
  24062. + if ( ! retrieve ) return 1;
  24063. +
  24064. + if (! (CMDSTS_OK & cmdsts) )
  24065. + return 0;
  24066. +
  24067. + nic->packetlen = cmdsts & 0xffff;
  24068. + memcpy(nic->packet,
  24069. + rxb + (entry * REAL_RX_BUF_SIZE),
  24070. + nic->packetlen);
  24071. + // rx_ring[entry].link = 0;
  24072. + rx_ring[entry].cmdsts = cpu_to_le32(CMDSTS_OWN);
  24073. +
  24074. + ns->cur_rx = ++ns->cur_rx % NR_RX_DESC;
  24075. +
  24076. + if (ns->cur_rx == 0) /* We have wrapped the ring */
  24077. + kick_rx();
  24078. +
  24079. + return 1;
  24080. +}
  24081. +
  24082. +static inline void kick_tx(struct nic *nic __unused)
  24083. +{
  24084. + dprintf(("kick_tx\n"));
  24085. + writel(CR_TXE, ns->base + CR);
  24086. +}
  24087. +
  24088. +/**************************************************************************
  24089. +TRANSMIT - Transmit a frame
  24090. +***************************************************************************/
  24091. +static void ns83820_transmit(struct nic *nic, const char *d, /* Destination */
  24092. + unsigned int t, /* Type */
  24093. + unsigned int s, /* size */
  24094. + const char *p)
  24095. +{ /* Packet */
  24096. + /* send the packet to destination */
  24097. +
  24098. + u16 nstype;
  24099. + u32 cmdsts, extsts;
  24100. + int cur_tx = 0;
  24101. + u32 isr = readl(ns->base + ISR);
  24102. + if (ISR_TXIDLE & isr)
  24103. + kick_tx(nic);
  24104. + /* point to the current txb incase multiple tx_rings are used */
  24105. + memcpy(txb, d, ETH_ALEN);
  24106. + memcpy(txb + ETH_ALEN, nic->node_addr, ETH_ALEN);
  24107. + nstype = htons((u16) t);
  24108. + memcpy(txb + 2 * ETH_ALEN, (u8 *) & nstype, 2);
  24109. + memcpy(txb + ETH_HLEN, p, s);
  24110. + s += ETH_HLEN;
  24111. + s &= 0x0FFF;
  24112. + while (s < ETH_ZLEN)
  24113. + txb[s++] = '\0';
  24114. +
  24115. + /* Setup the transmit descriptor */
  24116. + extsts = 0;
  24117. + extsts |= EXTSTS_UDPPKT;
  24118. +
  24119. + tx_ring[cur_tx].bufptr = virt_to_le32desc(&txb);
  24120. + tx_ring[cur_tx].extsts = cpu_to_le32(extsts);
  24121. +
  24122. + cmdsts = cpu_to_le32(0);
  24123. + cmdsts |= cpu_to_le32(CMDSTS_OWN | s);
  24124. + tx_ring[cur_tx].cmdsts = cpu_to_le32(cmdsts);
  24125. +
  24126. + writel(virt_to_le32desc(&tx_ring[0]), ns->base + TXDP);
  24127. + kick_tx(nic);
  24128. +}
  24129. +
  24130. +/**************************************************************************
  24131. +DISABLE - Turn off ethernet interface
  24132. +***************************************************************************/
  24133. +static void ns83820_disable(struct dev *dev)
  24134. +{
  24135. + /* put the card in its initial state */
  24136. + /* This function serves 3 purposes.
  24137. + * This disables DMA and interrupts so we don't receive
  24138. + * unexpected packets or interrupts from the card after
  24139. + * etherboot has finished.
  24140. + * This frees resources so etherboot may use
  24141. + * this driver on another interface
  24142. + * This allows etherboot to reinitialize the interface
  24143. + * if something is something goes wrong.
  24144. + */
  24145. + /* disable interrupts */
  24146. + writel(0, ns->base + IMR);
  24147. + writel(0, ns->base + IER);
  24148. + readl(ns->base + IER);
  24149. +
  24150. + ns->up = 0;
  24151. +
  24152. + ns83820_do_reset((struct nic *) dev, CR_RST);
  24153. +
  24154. + ns->IMR_cache &=
  24155. + ~(ISR_RXOK | ISR_RXDESC | ISR_RXERR | ISR_RXEARLY |
  24156. + ISR_RXIDLE);
  24157. + writel(ns->IMR_cache, ns->base + IMR);
  24158. +
  24159. + /* touch the pci bus... */
  24160. + readl(ns->base + IMR);
  24161. +
  24162. + /* assumes the transmitter is already disabled and reset */
  24163. + writel(0, ns->base + RXDP_HI);
  24164. + writel(0, ns->base + RXDP);
  24165. +}
  24166. +
  24167. +/**************************************************************************
  24168. +IRQ - Enable, Disable, or Force interrupts
  24169. +***************************************************************************/
  24170. +static void ns83820_irq(struct nic *nic __unused, irq_action_t action __unused)
  24171. +{
  24172. + switch ( action ) {
  24173. + case DISABLE :
  24174. + break;
  24175. + case ENABLE :
  24176. + break;
  24177. + case FORCE :
  24178. + break;
  24179. + }
  24180. +}
  24181. +
  24182. +/**************************************************************************
  24183. +PROBE - Look for an adapter, this routine's visible to the outside
  24184. +***************************************************************************/
  24185. +
  24186. +#define board_found 1
  24187. +#define valid_link 0
  24188. +static int ns83820_probe(struct dev *dev, struct pci_device *pci)
  24189. +{
  24190. + struct nic *nic = (struct nic *) dev;
  24191. + int sz;
  24192. + long addr;
  24193. + int using_dac = 0;
  24194. +
  24195. + if (pci->ioaddr == 0)
  24196. + return 0;
  24197. +
  24198. + printf("ns83820.c: Found %s, vendor=0x%hX, device=0x%hX\n",
  24199. + pci->name, pci->vendor, pci->dev_id);
  24200. +
  24201. + /* point to private storage */
  24202. + ns = &nsx;
  24203. +
  24204. + adjust_pci_device(pci);
  24205. +
  24206. + addr = pci_bar_start(pci, PCI_BASE_ADDRESS_1);
  24207. + sz = pci_bar_size(pci, PCI_BASE_ADDRESS_1);
  24208. +
  24209. + ns->base = ioremap(addr, (1UL << 12));
  24210. +// ns->base = ioremap(addr, sz);
  24211. +
  24212. + if (!ns->base)
  24213. + return 0;
  24214. +
  24215. + nic->irqno = 0;
  24216. + nic->ioaddr = pci->ioaddr & ~3;
  24217. +
  24218. + /* disable interrupts */
  24219. + writel(0, ns->base + IMR);
  24220. + writel(0, ns->base + IER);
  24221. + readl(ns->base + IER);
  24222. +
  24223. + ns->IMR_cache = 0;
  24224. +
  24225. + ns83820_do_reset(nic, CR_RST);
  24226. +
  24227. + /* Must reset the ram bist before running it */
  24228. + writel(PTSCR_RBIST_RST, ns->base + PTSCR);
  24229. + ns83820_run_bist(nic, "sram bist", PTSCR_RBIST_EN,
  24230. + PTSCR_RBIST_DONE, PTSCR_RBIST_FAIL);
  24231. + ns83820_run_bist(nic, "eeprom bist", PTSCR_EEBIST_EN, 0,
  24232. + PTSCR_EEBIST_FAIL);
  24233. + ns83820_run_bist(nic, "eeprom load", PTSCR_EELOAD_EN, 0, 0);
  24234. +
  24235. + /* I love config registers */
  24236. + ns->CFG_cache = readl(ns->base + CFG);
  24237. +
  24238. + if ((ns->CFG_cache & CFG_PCI64_DET)) {
  24239. + printf("%s: detected 64 bit PCI data bus.\n", pci->name);
  24240. + /*dev->CFG_cache |= CFG_DATA64_EN; */
  24241. + if (!(ns->CFG_cache & CFG_DATA64_EN))
  24242. + printf
  24243. + ("%s: EEPROM did not enable 64 bit bus. Disabled.\n",
  24244. + pci->name);
  24245. + } else
  24246. + ns->CFG_cache &= ~(CFG_DATA64_EN);
  24247. +
  24248. + ns->CFG_cache &= (CFG_TBI_EN | CFG_MRM_DIS | CFG_MWI_DIS |
  24249. + CFG_T64ADDR | CFG_DATA64_EN | CFG_EXT_125 |
  24250. + CFG_M64ADDR);
  24251. + ns->CFG_cache |=
  24252. + CFG_PINT_DUPSTS | CFG_PINT_LNKSTS | CFG_PINT_SPDSTS |
  24253. + CFG_EXTSTS_EN | CFG_EXD | CFG_PESEL;
  24254. + ns->CFG_cache |= CFG_REQALG;
  24255. + ns->CFG_cache |= CFG_POW;
  24256. + ns->CFG_cache |= CFG_TMRTEST;
  24257. +
  24258. + /* When compiled with 64 bit addressing, we must always enable
  24259. + * the 64 bit descriptor format.
  24260. + */
  24261. +#ifdef USE_64BIT_ADDR
  24262. + ns->CFG_cache |= CFG_M64ADDR;
  24263. +#endif
  24264. +
  24265. +//FIXME: Enable section on dac or remove this
  24266. + if (using_dac)
  24267. + ns->CFG_cache |= CFG_T64ADDR;
  24268. +
  24269. + /* Big endian mode does not seem to do what the docs suggest */
  24270. + ns->CFG_cache &= ~CFG_BEM;
  24271. +
  24272. + /* setup optical transceiver if we have one */
  24273. + if (ns->CFG_cache & CFG_TBI_EN) {
  24274. + dprintf(("%s: enabling optical transceiver\n", pci->name));
  24275. + writel(readl(ns->base + GPIOR) | 0x3e8, ns->base + GPIOR);
  24276. +
  24277. + /* setup auto negotiation feature advertisement */
  24278. + writel(readl(ns->base + TANAR)
  24279. + | TANAR_HALF_DUP | TANAR_FULL_DUP,
  24280. + ns->base + TANAR);
  24281. +
  24282. + /* start auto negotiation */
  24283. + writel(TBICR_MR_AN_ENABLE | TBICR_MR_RESTART_AN,
  24284. + ns->base + TBICR);
  24285. + writel(TBICR_MR_AN_ENABLE, ns->base + TBICR);
  24286. + ns->linkstate = LINK_AUTONEGOTIATE;
  24287. +
  24288. + ns->CFG_cache |= CFG_MODE_1000;
  24289. + }
  24290. + writel(ns->CFG_cache, ns->base + CFG);
  24291. + dprintf(("CFG: %hX\n", ns->CFG_cache));
  24292. +
  24293. + /* FIXME: reset_phy is defaulted to 0, should we reset anyway? */
  24294. + if (reset_phy) {
  24295. + dprintf(("%s: resetting phy\n", pci->name));
  24296. + writel(ns->CFG_cache | CFG_PHY_RST, ns->base + CFG);
  24297. + writel(ns->CFG_cache, ns->base + CFG);
  24298. + }
  24299. +#if 0 /* Huh? This sets the PCI latency register. Should be done via
  24300. + * the PCI layer. FIXME.
  24301. + */
  24302. + if (readl(dev->base + SRR))
  24303. + writel(readl(dev->base + 0x20c) | 0xfe00,
  24304. + dev->base + 0x20c);
  24305. +#endif
  24306. +
  24307. + /* Note! The DMA burst size interacts with packet
  24308. + * transmission, such that the largest packet that
  24309. + * can be transmitted is 8192 - FLTH - burst size.
  24310. + * If only the transmit fifo was larger...
  24311. + */
  24312. + /* Ramit : 1024 DMA is not a good idea, it ends up banging
  24313. + * some DELL and COMPAQ SMP systems */
  24314. + writel(TXCFG_CSI | TXCFG_HBI | TXCFG_ATP | TXCFG_MXDMA512
  24315. + | ((1600 / 32) * 0x100), ns->base + TXCFG);
  24316. +
  24317. + /* Set Rx to full duplex, don't accept runt, errored, long or length
  24318. + * range errored packets. Use 512 byte DMA.
  24319. + */
  24320. + /* Ramit : 1024 DMA is not a good idea, it ends up banging
  24321. + * some DELL and COMPAQ SMP systems
  24322. + * Turn on ALP, only we are accpeting Jumbo Packets */
  24323. + writel(RXCFG_AEP | RXCFG_ARP | RXCFG_AIRL | RXCFG_RX_FD
  24324. + | RXCFG_STRIPCRC
  24325. + //| RXCFG_ALP
  24326. + | (RXCFG_MXDMA512) | 0, ns->base + RXCFG);
  24327. +
  24328. + /* Disable priority queueing */
  24329. + writel(0, ns->base + PQCR);
  24330. +
  24331. + /* Enable IP checksum validation and detetion of VLAN headers.
  24332. + * Note: do not set the reject options as at least the 0x102
  24333. + * revision of the chip does not properly accept IP fragments
  24334. + * at least for UDP.
  24335. + */
  24336. + /* Ramit : Be sure to turn on RXCFG_ARP if VLAN's are enabled, since
  24337. + * the MAC it calculates the packetsize AFTER stripping the VLAN
  24338. + * header, and if a VLAN Tagged packet of 64 bytes is received (like
  24339. + * a ping with a VLAN header) then the card, strips the 4 byte VLAN
  24340. + * tag and then checks the packet size, so if RXCFG_ARP is not enabled,
  24341. + * it discrards it!. These guys......
  24342. + */
  24343. + writel(VRCR_IPEN | VRCR_VTDEN, ns->base + VRCR);
  24344. +
  24345. + /* Enable per-packet TCP/UDP/IP checksumming */
  24346. + writel(VTCR_PPCHK, ns->base + VTCR);
  24347. +
  24348. + /* Ramit : Enable async and sync pause frames */
  24349. +// writel(0, ns->base + PCR);
  24350. + writel((PCR_PS_MCAST | PCR_PS_DA | PCR_PSEN | PCR_FFLO_4K |
  24351. + PCR_FFHI_8K | PCR_STLO_4 | PCR_STHI_8 | PCR_PAUSE_CNT),
  24352. + ns->base + PCR);
  24353. +
  24354. + /* Disable Wake On Lan */
  24355. + writel(0, ns->base + WCSR);
  24356. +
  24357. + ns83820_getmac(nic, nic->node_addr);
  24358. + printf("%! at ioaddr 0x%hX, ", nic->node_addr, ns->base);
  24359. +
  24360. + if (using_dac) {
  24361. + dprintf(("%s: using 64 bit addressing.\n", pci->name));
  24362. + }
  24363. +
  24364. + dprintf(("%s: DP83820 %d.%d: %! io=0x%hX\n",
  24365. + pci->name,
  24366. + (unsigned) readl(ns->base + SRR) >> 8,
  24367. + (unsigned) readl(ns->base + SRR) & 0xff,
  24368. + nic->node_addr, pci->ioaddr));
  24369. +
  24370. +#ifdef PHY_CODE_IS_FINISHED
  24371. + ns83820_probe_phy(dev);
  24372. +#endif
  24373. +
  24374. + ns83820_reset(nic);
  24375. + /* point to NIC specific routines */
  24376. + dev->disable = ns83820_disable;
  24377. + nic->poll = ns83820_poll;
  24378. + nic->transmit = ns83820_transmit;
  24379. + nic->irq = ns83820_irq;
  24380. + return 1;
  24381. +}
  24382. +
  24383. +static struct pci_id ns83820_nics[] = {
  24384. + PCI_ROM(0x100b, 0x0022, "ns83820", "National Semiconductor 83820"),
  24385. +};
  24386. +
  24387. +struct pci_driver ns83820_driver = {
  24388. + .type = NIC_DRIVER,
  24389. + .name = "NS83820/PCI",
  24390. + .probe = ns83820_probe,
  24391. + .ids = ns83820_nics,
  24392. + .id_count = sizeof(ns83820_nics) / sizeof(ns83820_nics[0]),
  24393. + .class = 0,
  24394. +};
  24395. diff -Naur grub-0.97.orig/netboot/ns8390.c grub-0.97/netboot/ns8390.c
  24396. --- grub-0.97.orig/netboot/ns8390.c 2003-07-09 11:45:38.000000000 +0000
  24397. +++ grub-0.97/netboot/ns8390.c 2005-08-31 21:13:41.000000000 +0000
  24398. @@ -13,11 +13,15 @@
  24399. the proper functioning of this software, nor do the authors assume any
  24400. responsibility for damages incurred with its use.
  24401. +Multicast support added by Timothy Legge (timlegge@users.sourceforge.net) 09/28/2003
  24402. +Relocation support added by Ken Yap (ken_yap@users.sourceforge.net) 28/12/02
  24403. 3c503 support added by Bill Paul (wpaul@ctr.columbia.edu) on 11/15/94
  24404. SMC8416 support added by Bill Paul (wpaul@ctr.columbia.edu) on 12/25/94
  24405. 3c503 PIO support added by Jim Hague (jim.hague@acm.org) on 2/17/98
  24406. RX overrun by Klaus Espenlaub (espenlaub@informatik.uni-ulm.de) on 3/10/99
  24407. parts taken from the Linux 8390 driver (by Donald Becker and Paul Gortmaker)
  24408. +SMC8416 PIO support added by Andrew Bettison (andrewb@zip.com.au) on 4/3/02
  24409. + based on the Linux 8390 driver (by Donald Becker and Paul Gortmaker)
  24410. **************************************************************************/
  24411. @@ -26,10 +30,16 @@
  24412. #include "ns8390.h"
  24413. #ifdef INCLUDE_NS8390
  24414. #include "pci.h"
  24415. +#else
  24416. +#include "isa.h"
  24417. #endif
  24418. -#include "cards.h"
  24419. -static unsigned char eth_vendor, eth_flags, eth_laar;
  24420. +typedef int Address;
  24421. +
  24422. +static unsigned char eth_vendor, eth_flags;
  24423. +#ifdef INCLUDE_WD
  24424. +static unsigned char eth_laar;
  24425. +#endif
  24426. static unsigned short eth_nic_base, eth_asic_base;
  24427. static unsigned char eth_memsize, eth_rx_start, eth_tx_start;
  24428. static Address eth_bmem, eth_rmem;
  24429. @@ -66,6 +76,7 @@
  24430. #endif
  24431. #if defined(INCLUDE_WD)
  24432. +#define ASIC_PIO WD_IAR
  24433. #define eth_probe wd_probe
  24434. #if defined(INCLUDE_3C503) || defined(INCLUDE_NE) || defined(INCLUDE_NS8390)
  24435. Error you must only define one of INCLUDE_WD, INCLUDE_3C503, INCLUDE_NE, INCLUDE_NS8390
  24436. @@ -101,13 +112,16 @@
  24437. #endif
  24438. #endif
  24439. -#if defined(INCLUDE_NE) || defined(INCLUDE_NS8390) || (defined(INCLUDE_3C503) && !defined(T503_SHMEM))
  24440. +#if defined(INCLUDE_NE) || defined(INCLUDE_NS8390) || (defined(INCLUDE_3C503) && !defined(T503_SHMEM)) || (defined(INCLUDE_WD) && defined(WD_790_PIO))
  24441. /**************************************************************************
  24442. ETH_PIO_READ - Read a frame via Programmed I/O
  24443. **************************************************************************/
  24444. static void eth_pio_read(unsigned int src, unsigned char *dst, unsigned int cnt)
  24445. {
  24446. - if (eth_flags & FLAG_16BIT) { ++cnt; cnt &= ~1; }
  24447. +#ifdef INCLUDE_WD
  24448. + outb(src & 0xff, eth_asic_base + WD_GP2);
  24449. + outb(src >> 8, eth_asic_base + WD_GP2);
  24450. +#else
  24451. outb(D8390_COMMAND_RD2 |
  24452. D8390_COMMAND_STA, eth_nic_base + D8390_P0_COMMAND);
  24453. outb(cnt, eth_nic_base + D8390_P0_RBCR0);
  24454. @@ -122,9 +136,10 @@
  24455. outb(src >> 8, eth_asic_base + _3COM_DAMSB);
  24456. outb(t503_output | _3COM_CR_START, eth_asic_base + _3COM_CR);
  24457. #endif
  24458. +#endif
  24459. if (eth_flags & FLAG_16BIT)
  24460. - cnt >>= 1;
  24461. + cnt = (cnt + 1) >> 1;
  24462. while(cnt--) {
  24463. #ifdef INCLUDE_3C503
  24464. @@ -153,7 +168,10 @@
  24465. #ifdef COMPEX_RL2000_FIX
  24466. unsigned int x;
  24467. #endif /* COMPEX_RL2000_FIX */
  24468. - if (eth_flags & FLAG_16BIT) { ++cnt; cnt &= ~1; }
  24469. +#ifdef INCLUDE_WD
  24470. + outb(dst & 0xff, eth_asic_base + WD_GP2);
  24471. + outb(dst >> 8, eth_asic_base + WD_GP2);
  24472. +#else
  24473. outb(D8390_COMMAND_RD2 |
  24474. D8390_COMMAND_STA, eth_nic_base + D8390_P0_COMMAND);
  24475. outb(D8390_ISR_RDC, eth_nic_base + D8390_P0_ISR);
  24476. @@ -170,9 +188,10 @@
  24477. outb(t503_output | _3COM_CR_DDIR | _3COM_CR_START, eth_asic_base + _3COM_CR);
  24478. #endif
  24479. +#endif
  24480. if (eth_flags & FLAG_16BIT)
  24481. - cnt >>= 1;
  24482. + cnt = (cnt + 1) >> 1;
  24483. while(cnt--)
  24484. {
  24485. @@ -201,17 +220,40 @@
  24486. if (x >= COMPEX_RL2000_TRIES)
  24487. printf("Warning: Compex RL2000 aborted wait!\n");
  24488. #endif /* COMPEX_RL2000_FIX */
  24489. +#ifndef INCLUDE_WD
  24490. while((inb(eth_nic_base + D8390_P0_ISR) & D8390_ISR_RDC)
  24491. != D8390_ISR_RDC);
  24492. #endif
  24493. +#endif
  24494. }
  24495. #else
  24496. /**************************************************************************
  24497. ETH_PIO_READ - Dummy routine when NE2000 not compiled in
  24498. **************************************************************************/
  24499. -static void eth_pio_read(unsigned int src, unsigned char *dst, unsigned int cnt) {}
  24500. +static void eth_pio_read(unsigned int src __unused, unsigned char *dst __unused, unsigned int cnt __unused) {}
  24501. #endif
  24502. +
  24503. +/**************************************************************************
  24504. +enable_multycast - Enable Multicast
  24505. +**************************************************************************/
  24506. +static void enable_multicast(unsigned short eth_nic_base)
  24507. +{
  24508. + unsigned char mcfilter[8];
  24509. + int i;
  24510. + memset(mcfilter, 0xFF, 8);
  24511. + outb(4, eth_nic_base+D8390_P0_RCR);
  24512. + outb(D8390_COMMAND_RD2 + D8390_COMMAND_PS1, eth_nic_base + D8390_P0_COMMAND);
  24513. + for(i=0;i<8;i++)
  24514. + {
  24515. + outb(mcfilter[i], eth_nic_base + 8 + i);
  24516. + if(inb(eth_nic_base + 8 + i)!=mcfilter[i])
  24517. + printf("Error SMC 83C690 Multicast filter read/write mishap %d\n",i);
  24518. + }
  24519. + outb(D8390_COMMAND_RD2 + D8390_COMMAND_PS0, eth_nic_base + D8390_P0_COMMAND);
  24520. + outb(4 | 0x08, eth_nic_base+D8390_P0_RCR);
  24521. +}
  24522. +
  24523. /**************************************************************************
  24524. NS8390_RESET - Reset adapter
  24525. **************************************************************************/
  24526. @@ -238,7 +280,14 @@
  24527. outb(eth_tx_start, eth_nic_base+D8390_P0_TPSR);
  24528. outb(eth_rx_start, eth_nic_base+D8390_P0_PSTART);
  24529. #ifdef INCLUDE_WD
  24530. - if (eth_flags & FLAG_790) outb(0, eth_nic_base + 0x09);
  24531. + if (eth_flags & FLAG_790) {
  24532. +#ifdef WD_790_PIO
  24533. + outb(0x10, eth_asic_base + 0x06); /* disable interrupts, enable PIO */
  24534. + outb(0x01, eth_nic_base + 0x09); /* enable ring read auto-wrap */
  24535. +#else
  24536. + outb(0, eth_nic_base + 0x09);
  24537. +#endif
  24538. + }
  24539. #endif
  24540. outb(eth_memsize, eth_nic_base+D8390_P0_PSTOP);
  24541. outb(eth_memsize - 1, eth_nic_base+D8390_P0_BOUND);
  24542. @@ -266,8 +315,10 @@
  24543. outb(D8390_COMMAND_PS0 |
  24544. D8390_COMMAND_RD2 | D8390_COMMAND_STA, eth_nic_base+D8390_P0_COMMAND);
  24545. outb(0xFF, eth_nic_base+D8390_P0_ISR);
  24546. - outb(0, eth_nic_base+D8390_P0_TCR);
  24547. - outb(4, eth_nic_base+D8390_P0_RCR); /* allow broadcast frames */
  24548. + outb(0, eth_nic_base+D8390_P0_TCR); /* transmitter on */
  24549. + outb(4, eth_nic_base+D8390_P0_RCR); /* allow rx broadcast frames */
  24550. +
  24551. + enable_multicast(eth_nic_base);
  24552. #ifdef INCLUDE_3C503
  24553. /*
  24554. @@ -281,7 +332,7 @@
  24555. #endif
  24556. }
  24557. -static int ns8390_poll(struct nic *nic);
  24558. +static int ns8390_poll(struct nic *nic, int retrieve);
  24559. #ifndef INCLUDE_3C503
  24560. /**************************************************************************
  24561. @@ -324,7 +375,7 @@
  24562. /* clear the RX ring, acknowledge overrun interrupt */
  24563. eth_drain_receiver = 1;
  24564. - while (ns8390_poll(nic))
  24565. + while (ns8390_poll(nic, 1))
  24566. /* Nothing */;
  24567. eth_drain_receiver = 0;
  24568. outb(D8390_ISR_OVW, eth_nic_base+D8390_P0_ISR);
  24569. @@ -344,50 +395,54 @@
  24570. unsigned int s, /* size */
  24571. const char *p) /* Packet */
  24572. {
  24573. +#if defined(INCLUDE_3C503) || (defined(INCLUDE_WD) && ! defined(WD_790_PIO))
  24574. + Address eth_vmem = bus_to_virt(eth_bmem);
  24575. +#endif
  24576. #ifdef INCLUDE_3C503
  24577. if (!(eth_flags & FLAG_PIO)) {
  24578. - memcpy((char *)eth_bmem, d, ETH_ALEN); /* dst */
  24579. - memcpy((char *)eth_bmem+ETH_ALEN, nic->node_addr, ETH_ALEN); /* src */
  24580. - *((char *)eth_bmem+12) = t>>8; /* type */
  24581. - *((char *)eth_bmem+13) = t;
  24582. - memcpy((char *)eth_bmem+ETH_HLEN, p, s);
  24583. + memcpy((char *)eth_vmem, d, ETH_ALEN); /* dst */
  24584. + memcpy((char *)eth_vmem+ETH_ALEN, nic->node_addr, ETH_ALEN); /* src */
  24585. + *((char *)eth_vmem+12) = t>>8; /* type */
  24586. + *((char *)eth_vmem+13) = t;
  24587. + memcpy((char *)eth_vmem+ETH_HLEN, p, s);
  24588. s += ETH_HLEN;
  24589. - while (s < ETH_ZLEN) *((char *)eth_bmem+(s++)) = 0;
  24590. + while (s < ETH_ZLEN) *((char *)eth_vmem+(s++)) = 0;
  24591. }
  24592. #endif
  24593. #ifdef INCLUDE_WD
  24594. - /* Memory interface */
  24595. if (eth_flags & FLAG_16BIT) {
  24596. outb(eth_laar | WD_LAAR_M16EN, eth_asic_base + WD_LAAR);
  24597. inb(0x84);
  24598. }
  24599. +#ifndef WD_790_PIO
  24600. + /* Memory interface */
  24601. if (eth_flags & FLAG_790) {
  24602. outb(WD_MSR_MENB, eth_asic_base + WD_MSR);
  24603. inb(0x84);
  24604. }
  24605. inb(0x84);
  24606. - memcpy((char *)eth_bmem, d, ETH_ALEN); /* dst */
  24607. - memcpy((char *)eth_bmem+ETH_ALEN, nic->node_addr, ETH_ALEN); /* src */
  24608. - *((char *)eth_bmem+12) = t>>8; /* type */
  24609. - *((char *)eth_bmem+13) = t;
  24610. - memcpy((char *)eth_bmem+ETH_HLEN, p, s);
  24611. + memcpy((char *)eth_vmem, d, ETH_ALEN); /* dst */
  24612. + memcpy((char *)eth_vmem+ETH_ALEN, nic->node_addr, ETH_ALEN); /* src */
  24613. + *((char *)eth_vmem+12) = t>>8; /* type */
  24614. + *((char *)eth_vmem+13) = t;
  24615. + memcpy((char *)eth_vmem+ETH_HLEN, p, s);
  24616. s += ETH_HLEN;
  24617. - while (s < ETH_ZLEN) *((char *)eth_bmem+(s++)) = 0;
  24618. + while (s < ETH_ZLEN) *((char *)eth_vmem+(s++)) = 0;
  24619. if (eth_flags & FLAG_790) {
  24620. outb(0, eth_asic_base + WD_MSR);
  24621. inb(0x84);
  24622. }
  24623. - if (eth_flags & FLAG_16BIT) {
  24624. - outb(eth_laar & ~WD_LAAR_M16EN, eth_asic_base + WD_LAAR);
  24625. - inb(0x84);
  24626. - }
  24627. +#else
  24628. + inb(0x84);
  24629. +#endif
  24630. #endif
  24631. #if defined(INCLUDE_3C503)
  24632. - if (eth_flags & FLAG_PIO) {
  24633. + if (eth_flags & FLAG_PIO)
  24634. #endif
  24635. -#if defined(INCLUDE_NE) || defined(INCLUDE_NS8390) || (defined(INCLUDE_3C503) && !defined(T503_SHMEM))
  24636. +#if defined(INCLUDE_NE) || defined(INCLUDE_NS8390) || (defined(INCLUDE_3C503) && !defined(T503_SHMEM)) || (defined(INCLUDE_WD) && defined(WD_790_PIO))
  24637. + {
  24638. /* Programmed I/O */
  24639. unsigned short type;
  24640. type = (t >> 8) | (t << 8);
  24641. @@ -398,12 +453,16 @@
  24642. eth_pio_write(p, (eth_tx_start<<8)+ETH_HLEN, s);
  24643. s += ETH_HLEN;
  24644. if (s < ETH_ZLEN) s = ETH_ZLEN;
  24645. + }
  24646. #endif
  24647. #if defined(INCLUDE_3C503)
  24648. - }
  24649. #endif
  24650. #ifdef INCLUDE_WD
  24651. + if (eth_flags & FLAG_16BIT) {
  24652. + outb(eth_laar & ~WD_LAAR_M16EN, eth_asic_base + WD_LAAR);
  24653. + inb(0x84);
  24654. + }
  24655. if (eth_flags & FLAG_790)
  24656. outb(D8390_COMMAND_PS0 |
  24657. D8390_COMMAND_STA, eth_nic_base+D8390_P0_COMMAND);
  24658. @@ -428,7 +487,7 @@
  24659. /**************************************************************************
  24660. NS8390_POLL - Wait for a frame
  24661. **************************************************************************/
  24662. -static int ns8390_poll(struct nic *nic)
  24663. +static int ns8390_poll(struct nic *nic, int retrieve)
  24664. {
  24665. int ret = 0;
  24666. unsigned char rstat, curr, next;
  24667. @@ -453,22 +512,27 @@
  24668. outb(D8390_COMMAND_PS0, eth_nic_base+D8390_P0_COMMAND);
  24669. if (curr >= eth_memsize) curr=eth_rx_start;
  24670. if (curr == next) return(0);
  24671. +
  24672. + if ( ! retrieve ) return 1;
  24673. +
  24674. #ifdef INCLUDE_WD
  24675. if (eth_flags & FLAG_16BIT) {
  24676. outb(eth_laar | WD_LAAR_M16EN, eth_asic_base + WD_LAAR);
  24677. inb(0x84);
  24678. }
  24679. +#ifndef WD_790_PIO
  24680. if (eth_flags & FLAG_790) {
  24681. outb(WD_MSR_MENB, eth_asic_base + WD_MSR);
  24682. inb(0x84);
  24683. }
  24684. +#endif
  24685. inb(0x84);
  24686. #endif
  24687. pktoff = next << 8;
  24688. if (eth_flags & FLAG_PIO)
  24689. eth_pio_read(pktoff, (char *)&pkthdr, 4);
  24690. else
  24691. - memcpy(&pkthdr, (char *)eth_rmem + pktoff, 4);
  24692. + memcpy(&pkthdr, bus_to_virt(eth_rmem + pktoff), 4);
  24693. pktoff += sizeof(pkthdr);
  24694. /* incoming length includes FCS so must sub 4 */
  24695. len = pkthdr.len - 4;
  24696. @@ -486,7 +550,7 @@
  24697. if (eth_flags & FLAG_PIO)
  24698. eth_pio_read(pktoff, p, frag);
  24699. else
  24700. - memcpy(p, (char *)eth_rmem + pktoff, frag);
  24701. + memcpy(p, bus_to_virt(eth_rmem + pktoff), frag);
  24702. pktoff = eth_rx_start << 8;
  24703. p += frag;
  24704. len -= frag;
  24705. @@ -495,14 +559,16 @@
  24706. if (eth_flags & FLAG_PIO)
  24707. eth_pio_read(pktoff, p, len);
  24708. else
  24709. - memcpy(p, (char *)eth_rmem + pktoff, len);
  24710. + memcpy(p, bus_to_virt(eth_rmem + pktoff), len);
  24711. ret = 1;
  24712. }
  24713. #ifdef INCLUDE_WD
  24714. +#ifndef WD_790_PIO
  24715. if (eth_flags & FLAG_790) {
  24716. outb(0, eth_asic_base + WD_MSR);
  24717. inb(0x84);
  24718. }
  24719. +#endif
  24720. if (eth_flags & FLAG_16BIT) {
  24721. outb(eth_laar & ~WD_LAAR_M16EN, eth_asic_base + WD_LAAR);
  24722. inb(0x84);
  24723. @@ -519,31 +585,56 @@
  24724. /**************************************************************************
  24725. NS8390_DISABLE - Turn off adapter
  24726. **************************************************************************/
  24727. -static void ns8390_disable(struct nic *nic)
  24728. +static void ns8390_disable(struct dev *dev)
  24729. {
  24730. + struct nic *nic = (struct nic *)dev;
  24731. + /* reset and disable merge */
  24732. + ns8390_reset(nic);
  24733. +}
  24734. +
  24735. +/**************************************************************************
  24736. +NS8390_IRQ - Enable, Disable, or Force interrupts
  24737. +**************************************************************************/
  24738. +static void ns8390_irq(struct nic *nic __unused, irq_action_t action __unused)
  24739. +{
  24740. + switch ( action ) {
  24741. + case DISABLE :
  24742. + break;
  24743. + case ENABLE :
  24744. + break;
  24745. + case FORCE :
  24746. + break;
  24747. + }
  24748. }
  24749. /**************************************************************************
  24750. ETH_PROBE - Look for an adapter
  24751. **************************************************************************/
  24752. #ifdef INCLUDE_NS8390
  24753. -struct nic *eth_probe(struct nic *nic, unsigned short *probe_addrs,
  24754. - struct pci_device *pci)
  24755. +static int eth_probe (struct dev *dev, struct pci_device *pci)
  24756. #else
  24757. -struct nic *eth_probe(struct nic *nic, unsigned short *probe_addrs)
  24758. +static int eth_probe (struct dev *dev, unsigned short *probe_addrs __unused)
  24759. #endif
  24760. {
  24761. + struct nic *nic = (struct nic *)dev;
  24762. int i;
  24763. - struct wd_board *brd;
  24764. - unsigned short chksum;
  24765. - unsigned char c;
  24766. +#ifdef INCLUDE_NS8390
  24767. + unsigned short pci_probe_addrs[] = { pci->ioaddr, 0 };
  24768. + unsigned short *probe_addrs = pci_probe_addrs;
  24769. +#endif
  24770. eth_vendor = VENDOR_NONE;
  24771. eth_drain_receiver = 0;
  24772. + nic->irqno = 0;
  24773. +
  24774. #ifdef INCLUDE_WD
  24775. +{
  24776. /******************************************************************
  24777. Search for WD/SMC cards
  24778. ******************************************************************/
  24779. + struct wd_board *brd;
  24780. + unsigned short chksum;
  24781. + unsigned char c;
  24782. for (eth_asic_base = WD_LOW_BASE; eth_asic_base <= WD_HIGH_BASE;
  24783. eth_asic_base += 0x20) {
  24784. chksum = 0;
  24785. @@ -560,6 +651,9 @@
  24786. /* We've found a board */
  24787. eth_vendor = VENDOR_WD;
  24788. eth_nic_base = eth_asic_base + WD_NIC_ADDR;
  24789. +
  24790. + nic->ioaddr = eth_nic_base;
  24791. +
  24792. c = inb(eth_asic_base+WD_BID); /* Get board id */
  24793. for (brd = wd_boards; brd->name; brd++)
  24794. if (brd->id == c) break;
  24795. @@ -582,8 +676,9 @@
  24796. } else
  24797. eth_bmem = WD_DEFAULT_MEM;
  24798. if (brd->id == TYPE_SMC8216T || brd->id == TYPE_SMC8216C) {
  24799. - *((unsigned int *)(eth_bmem + 8192)) = (unsigned int)0;
  24800. - if (*((unsigned int *)(eth_bmem + 8192))) {
  24801. + /* from Linux driver, 8416BT detects as 8216 sometimes */
  24802. + unsigned int addr = inb(eth_asic_base + 0xb);
  24803. + if (((addr >> 4) & 3) == 0) {
  24804. brd += 2;
  24805. eth_memsize = brd->memsize;
  24806. }
  24807. @@ -592,19 +687,27 @@
  24808. for (i=0; i<ETH_ALEN; i++) {
  24809. nic->node_addr[i] = inb(i+eth_asic_base+WD_LAR);
  24810. }
  24811. - printf("\n%s base %#hx, memory %#hx, addr %!\n",
  24812. - brd->name, eth_asic_base, eth_bmem, nic->node_addr);
  24813. + printf("\n%s base %#hx", brd->name, eth_asic_base);
  24814. if (eth_flags & FLAG_790) {
  24815. +#ifdef WD_790_PIO
  24816. + printf(", PIO mode, addr %!\n", nic->node_addr);
  24817. + eth_bmem = 0;
  24818. + eth_flags |= FLAG_PIO; /* force PIO mode */
  24819. + outb(0, eth_asic_base+WD_MSR);
  24820. +#else
  24821. + printf(", memory %#x, addr %!\n", eth_bmem, nic->node_addr);
  24822. outb(WD_MSR_MENB, eth_asic_base+WD_MSR);
  24823. outb((inb(eth_asic_base+0x04) |
  24824. 0x80), eth_asic_base+0x04);
  24825. - outb((((unsigned)eth_bmem >> 13) & 0x0F) |
  24826. - (((unsigned)eth_bmem >> 11) & 0x40) |
  24827. + outb(((unsigned)(eth_bmem >> 13) & 0x0F) |
  24828. + ((unsigned)(eth_bmem >> 11) & 0x40) |
  24829. (inb(eth_asic_base+0x0B) & 0xB0), eth_asic_base+0x0B);
  24830. outb((inb(eth_asic_base+0x04) &
  24831. ~0x80), eth_asic_base+0x04);
  24832. +#endif
  24833. } else {
  24834. - outb((((unsigned)eth_bmem >> 13) & 0x3F) | 0x40, eth_asic_base+WD_MSR);
  24835. + printf(", memory %#x, addr %!\n", eth_bmem, nic->node_addr);
  24836. + outb(((unsigned)(eth_bmem >> 13) & 0x3F) | 0x40, eth_asic_base+WD_MSR);
  24837. }
  24838. if (eth_flags & FLAG_16BIT) {
  24839. if (eth_flags & FLAG_790) {
  24840. @@ -624,8 +727,14 @@
  24841. }
  24842. inb(0x84);
  24843. }
  24844. +}
  24845. #endif
  24846. #ifdef INCLUDE_3C503
  24847. +#ifdef T503_AUI
  24848. + nic->flags = 1; /* aui */
  24849. +#else
  24850. + nic->flags = 0; /* no aui */
  24851. +#endif
  24852. /******************************************************************
  24853. Search for 3Com 3c503 if no WD/SMC cards
  24854. ******************************************************************/
  24855. @@ -708,11 +817,12 @@
  24856. /* Get our ethernet address */
  24857. outb(_3COM_CR_EALO | _3COM_CR_XSEL, eth_asic_base + _3COM_CR);
  24858. + nic->ioaddr = eth_nic_base;
  24859. printf("\n3Com 3c503 base %#hx, ", eth_nic_base);
  24860. if (eth_flags & FLAG_PIO)
  24861. printf("PIO mode");
  24862. else
  24863. - printf("memory %#hx", eth_bmem);
  24864. + printf("memory %#x", eth_bmem);
  24865. for (i=0; i<ETH_ALEN; i++) {
  24866. nic->node_addr[i] = inb(eth_nic_base+i);
  24867. }
  24868. @@ -734,9 +844,9 @@
  24869. */
  24870. if (!(eth_flags & FLAG_PIO)) {
  24871. - memset((char *)eth_bmem, 0, 0x2000);
  24872. + memset(bus_to_virt(eth_bmem), 0, 0x2000);
  24873. for(i = 0; i < 0x2000; ++i)
  24874. - if (*(((char *)eth_bmem)+i)) {
  24875. + if (*((char *)(bus_to_virt(eth_bmem+i)))) {
  24876. printf ("Failed to clear 3c503 shared mem.\n");
  24877. return (0);
  24878. }
  24879. @@ -749,9 +859,11 @@
  24880. }
  24881. #endif
  24882. #if defined(INCLUDE_NE) || defined(INCLUDE_NS8390)
  24883. +{
  24884. /******************************************************************
  24885. Search for NE1000/2000 if no WD/SMC or 3com cards
  24886. ******************************************************************/
  24887. + unsigned char c;
  24888. if (eth_vendor == VENDOR_NONE) {
  24889. char romdata[16], testbuf[32];
  24890. int idx;
  24891. @@ -810,23 +922,94 @@
  24892. for (i=0; i<ETH_ALEN; i++) {
  24893. nic->node_addr[i] = romdata[i + ((eth_flags & FLAG_16BIT) ? i : 0)];
  24894. }
  24895. + nic->ioaddr = eth_nic_base;
  24896. printf("\nNE%c000 base %#hx, addr %!\n",
  24897. (eth_flags & FLAG_16BIT) ? '2' : '1', eth_nic_base,
  24898. nic->node_addr);
  24899. }
  24900. +}
  24901. #endif
  24902. if (eth_vendor == VENDOR_NONE)
  24903. return(0);
  24904. if (eth_vendor != VENDOR_3COM)
  24905. eth_rmem = eth_bmem;
  24906. ns8390_reset(nic);
  24907. - nic->reset = ns8390_reset;
  24908. - nic->poll = ns8390_poll;
  24909. +
  24910. + dev->disable = ns8390_disable;
  24911. + nic->poll = ns8390_poll;
  24912. nic->transmit = ns8390_transmit;
  24913. - nic->disable = ns8390_disable;
  24914. - return(nic);
  24915. + nic->irq = ns8390_irq;
  24916. +
  24917. + /* Based on PnP ISA map */
  24918. +#ifdef INCLUDE_WD
  24919. + dev->devid.vendor_id = htons(GENERIC_ISAPNP_VENDOR);
  24920. + dev->devid.device_id = htons(0x812a);
  24921. +#endif
  24922. +#ifdef INCLUDE_3C503
  24923. + dev->devid.vendor_id = htons(GENERIC_ISAPNP_VENDOR);
  24924. + dev->devid.device_id = htons(0x80f3);
  24925. +#endif
  24926. +#ifdef INCLUDE_NE
  24927. + dev->devid.vendor_id = htons(GENERIC_ISAPNP_VENDOR);
  24928. + dev->devid.device_id = htons(0x80d6);
  24929. +#endif
  24930. + return 1;
  24931. }
  24932. +#ifdef INCLUDE_WD
  24933. +static struct isa_driver wd_driver __isa_driver = {
  24934. + .type = NIC_DRIVER,
  24935. + .name = "WD",
  24936. + .probe = wd_probe,
  24937. + .ioaddrs = 0,
  24938. +};
  24939. +#endif
  24940. +
  24941. +#ifdef INCLUDE_3C503
  24942. +static struct isa_driver t503_driver __isa_driver = {
  24943. + .type = NIC_DRIVER,
  24944. + .name = "3C503",
  24945. + .probe = t503_probe,
  24946. + .ioaddrs = 0,
  24947. +};
  24948. +#endif
  24949. +
  24950. +#ifdef INCLUDE_NE
  24951. +static struct isa_driver ne_driver __isa_driver = {
  24952. + .type = NIC_DRIVER,
  24953. + .name = "NE*000",
  24954. + .probe = ne_probe,
  24955. + .ioaddrs = 0,
  24956. +};
  24957. +#endif
  24958. +
  24959. +#ifdef INCLUDE_NS8390
  24960. +static struct pci_id nepci_nics[] = {
  24961. +/* A few NE2000 PCI clones, list not exhaustive */
  24962. +PCI_ROM(0x10ec, 0x8029, "rtl8029", "Realtek 8029"),
  24963. +PCI_ROM(0x1186, 0x0300, "dlink-528", "D-Link DE-528"),
  24964. +PCI_ROM(0x1050, 0x0940, "winbond940", "Winbond NE2000-PCI"), /* Winbond 86C940 / 89C940 */
  24965. +PCI_ROM(0x1050, 0x5a5a, "winbond940f", "Winbond W89c940F"), /* Winbond 89C940F */
  24966. +PCI_ROM(0x11f6, 0x1401, "compexrl2000", "Compex ReadyLink 2000"),
  24967. +PCI_ROM(0x8e2e, 0x3000, "ktiet32p2", "KTI ET32P2"),
  24968. +PCI_ROM(0x4a14, 0x5000, "nv5000sc", "NetVin NV5000SC"),
  24969. +PCI_ROM(0x12c3, 0x0058, "holtek80232", "Holtek HT80232"),
  24970. +PCI_ROM(0x12c3, 0x5598, "holtek80229", "Holtek HT80229"),
  24971. +PCI_ROM(0x10bd, 0x0e34, "surecom-ne34", "Surecom NE34"),
  24972. +PCI_ROM(0x1106, 0x0926, "via86c926", "Via 86c926"),
  24973. +};
  24974. +
  24975. +struct pci_driver nepci_driver = {
  24976. + .type = NIC_DRIVER,
  24977. + .name = "NE2000/PCI",
  24978. + .probe = nepci_probe,
  24979. + .ids = nepci_nics,
  24980. + .id_count = sizeof(nepci_nics)/sizeof(nepci_nics[0]),
  24981. + .class = 0,
  24982. +};
  24983. +
  24984. +#endif /* INCLUDE_NS8390 */
  24985. +
  24986. /*
  24987. * Local variables:
  24988. * c-basic-offset: 8
  24989. diff -Naur grub-0.97.orig/netboot/osdep.h grub-0.97/netboot/osdep.h
  24990. --- grub-0.97.orig/netboot/osdep.h 2003-07-09 11:45:38.000000000 +0000
  24991. +++ grub-0.97/netboot/osdep.h 2005-08-31 19:03:35.000000000 +0000
  24992. @@ -1,94 +1,18 @@
  24993. -#ifndef __OSDEP_H__
  24994. -#define __OSDEP_H__
  24995. +#ifndef _OSDEP_H
  24996. +#define _OSDEP_H
  24997. -/*
  24998. - * This program is free software; you can redistribute it and/or
  24999. - * modify it under the terms of the GNU General Public License as
  25000. - * published by the Free Software Foundation; either version 2, or (at
  25001. - * your option) any later version.
  25002. - */
  25003. +#define __unused __attribute__((unused))
  25004. +#define __aligned __attribute__((aligned(16)))
  25005. -#define __LITTLE_ENDIAN /* x86 */
  25006. -
  25007. -/* Taken from /usr/include/linux/hfs_sysdep.h */
  25008. -#if defined(__BIG_ENDIAN)
  25009. -# if !defined(__constant_htonl)
  25010. -# define __constant_htonl(x) (x)
  25011. -# endif
  25012. -# if !defined(__constant_htons)
  25013. -# define __constant_htons(x) (x)
  25014. -# endif
  25015. -#elif defined(__LITTLE_ENDIAN)
  25016. -# if !defined(__constant_htonl)
  25017. -# define __constant_htonl(x) \
  25018. - ((unsigned long int)((((unsigned long int)(x) & 0x000000ffU) << 24) | \
  25019. - (((unsigned long int)(x) & 0x0000ff00U) << 8) | \
  25020. - (((unsigned long int)(x) & 0x00ff0000U) >> 8) | \
  25021. - (((unsigned long int)(x) & 0xff000000U) >> 24)))
  25022. -# endif
  25023. -# if !defined(__constant_htons)
  25024. -# define __constant_htons(x) \
  25025. - ((unsigned short int)((((unsigned short int)(x) & 0x00ff) << 8) | \
  25026. - (((unsigned short int)(x) & 0xff00) >> 8)))
  25027. -# endif
  25028. -#else
  25029. -# error "Don't know if bytes are big- or little-endian!"
  25030. -#endif
  25031. -
  25032. -#define ntohl(x) \
  25033. -(__builtin_constant_p(x) ? \
  25034. - __constant_htonl((x)) : \
  25035. - __swap32(x))
  25036. -#define htonl(x) \
  25037. -(__builtin_constant_p(x) ? \
  25038. - __constant_htonl((x)) : \
  25039. - __swap32(x))
  25040. -#define ntohs(x) \
  25041. -(__builtin_constant_p(x) ? \
  25042. - __constant_htons((x)) : \
  25043. - __swap16(x))
  25044. -#define htons(x) \
  25045. -(__builtin_constant_p(x) ? \
  25046. - __constant_htons((x)) : \
  25047. - __swap16(x))
  25048. -
  25049. -static inline unsigned long int __swap32(unsigned long int x)
  25050. -{
  25051. - __asm__("xchgb %b0,%h0\n\t"
  25052. - "rorl $16,%0\n\t"
  25053. - "xchgb %b0,%h0"
  25054. - : "=q" (x)
  25055. - : "0" (x));
  25056. - return x;
  25057. -}
  25058. -
  25059. -static inline unsigned short int __swap16(unsigned short int x)
  25060. -{
  25061. - __asm__("xchgb %b0,%h0"
  25062. - : "=q" (x)
  25063. - : "0" (x));
  25064. - return x;
  25065. -}
  25066. -
  25067. -/* Make routines available to all */
  25068. -#define swap32(x) __swap32(x)
  25069. -#define swap16(x) __swap16(x)
  25070. -
  25071. -#include "linux-asm-io.h"
  25072. -
  25073. -typedef unsigned long Address;
  25074. +#include "io.h"
  25075. +#include "byteswap.h"
  25076. +#include "latch.h"
  25077. /* ANSI prototyping macro */
  25078. #ifdef __STDC__
  25079. -#define P(x) x
  25080. +# define P(x) x
  25081. #else
  25082. -#define P(x) ()
  25083. +# define P(x) ()
  25084. #endif
  25085. #endif
  25086. -
  25087. -/*
  25088. - * Local variables:
  25089. - * c-basic-offset: 8
  25090. - * End:
  25091. - */
  25092. diff -Naur grub-0.97.orig/netboot/otulip.c grub-0.97/netboot/otulip.c
  25093. --- grub-0.97.orig/netboot/otulip.c 2003-07-09 11:45:38.000000000 +0000
  25094. +++ grub-0.97/netboot/otulip.c 1970-01-01 00:00:00.000000000 +0000
  25095. @@ -1,374 +0,0 @@
  25096. -/*
  25097. - Etherboot DEC Tulip driver
  25098. - adapted by Ken Yap from
  25099. -
  25100. - FreeBSD netboot DEC 21143 driver
  25101. -
  25102. - Author: David Sharp
  25103. - date: Nov/98
  25104. -
  25105. - Known to work on DEC DE500 using 21143-PC chipset.
  25106. - Even on cards with the same chipset there can be
  25107. - incompatablity problems with the way media selection
  25108. - and status LED settings are done. See comments below.
  25109. -
  25110. - Some code fragments were taken from verious places,
  25111. - Ken Yap's etherboot, FreeBSD's if_de.c, and various
  25112. - Linux related files. DEC's manuals for the 21143 and
  25113. - SROM format were very helpful. The Linux de driver
  25114. - development page has a number of links to useful
  25115. - related information. Have a look at:
  25116. - ftp://cesdis.gsfc.nasa.gov/pub/linux/drivers/tulip-devel.html
  25117. -
  25118. -*/
  25119. -
  25120. -#include "etherboot.h"
  25121. -#include "nic.h"
  25122. -#include "pci.h"
  25123. -#include "cards.h"
  25124. -#include "otulip.h"
  25125. -
  25126. -static unsigned short vendor, dev_id;
  25127. -static unsigned short ioaddr;
  25128. -static unsigned int *membase;
  25129. -static unsigned char srom[1024];
  25130. -
  25131. -#define BUFLEN 1536 /* must be longword divisable */
  25132. - /* buffers must be longword aligned */
  25133. -
  25134. -/* transmit descriptor and buffer */
  25135. -static struct txdesc txd;
  25136. -
  25137. -/* receive descriptor(s) and buffer(s) */
  25138. -#define NRXD 4
  25139. -static struct rxdesc rxd[NRXD];
  25140. -static int rxd_tail = 0;
  25141. -#ifdef USE_LOWMEM_BUFFER
  25142. -#define rxb ((char *)0x10000 - NRXD * BUFLEN)
  25143. -#define txb ((char *)0x10000 - NRXD * BUFLEN - BUFLEN)
  25144. -#else
  25145. -static unsigned char rxb[NRXD * BUFLEN];
  25146. -static unsigned char txb[BUFLEN];
  25147. -#endif
  25148. -
  25149. -static unsigned char ehdr[ETH_HLEN]; /* buffer for ethernet header */
  25150. -
  25151. -enum tulip_offsets {
  25152. - CSR0=0, CSR1=0x08, CSR2=0x10, CSR3=0x18, CSR4=0x20, CSR5=0x28,
  25153. - CSR6=0x30, CSR7=0x38, CSR8=0x40, CSR9=0x48, CSR10=0x50, CSR11=0x58,
  25154. - CSR12=0x60, CSR13=0x68, CSR14=0x70, CSR15=0x78 };
  25155. -
  25156. -
  25157. -/***************************************************************************/
  25158. -/* 21143 specific stuff */
  25159. -/***************************************************************************/
  25160. -
  25161. -/* XXX assume 33MHz PCI bus, this is not very accurate and should be
  25162. - used only with gross over estimations of required delay times unless
  25163. - you tune UADJUST to your specific processor and I/O subsystem */
  25164. -
  25165. -#define UADJUST 870
  25166. -static void udelay(unsigned long usec) {
  25167. - unsigned long i;
  25168. - for (i=((usec*UADJUST)/33)+1; i>0; i--) (void) TULIP_CSR_READ(csr_0);
  25169. -}
  25170. -
  25171. -/* The following srom related code was taken from FreeBSD's if_de.c */
  25172. -/* with minor alterations to make it work here. the Linux code is */
  25173. -/* better but this was easier to use */
  25174. -
  25175. -static void delay_300ns(void)
  25176. -{
  25177. - int idx;
  25178. - for (idx = (300 / 33) + 1; idx > 0; idx--)
  25179. - (void) TULIP_CSR_READ(csr_busmode);
  25180. -}
  25181. -
  25182. -#define EMIT do { TULIP_CSR_WRITE(csr_srom_mii, csr); delay_300ns(); } while (0)
  25183. -
  25184. -static void srom_idle(void)
  25185. -{
  25186. - unsigned bit, csr;
  25187. -
  25188. - csr = SROMSEL ; EMIT;
  25189. - csr = SROMSEL | SROMRD; EMIT;
  25190. - csr ^= SROMCS; EMIT;
  25191. - csr ^= SROMCLKON; EMIT;
  25192. - /*
  25193. - * Write 25 cycles of 0 which will force the SROM to be idle.
  25194. - */
  25195. - for (bit = 3 + SROM_BITWIDTH + 16; bit > 0; bit--) {
  25196. - csr ^= SROMCLKOFF; EMIT; /* clock low; data not valid */
  25197. - csr ^= SROMCLKON; EMIT; /* clock high; data valid */
  25198. - }
  25199. - csr ^= SROMCLKOFF; EMIT;
  25200. - csr ^= SROMCS; EMIT;
  25201. - csr = 0; EMIT;
  25202. -}
  25203. -
  25204. -static void srom_read(void)
  25205. -{
  25206. - unsigned idx;
  25207. - const unsigned bitwidth = SROM_BITWIDTH;
  25208. - const unsigned cmdmask = (SROMCMD_RD << bitwidth);
  25209. - const unsigned msb = 1 << (bitwidth + 3 - 1);
  25210. - unsigned lastidx = (1 << bitwidth) - 1;
  25211. -
  25212. - srom_idle();
  25213. -
  25214. - for (idx = 0; idx <= lastidx; idx++) {
  25215. - unsigned lastbit, data, bits, bit, csr;
  25216. - csr = SROMSEL ; EMIT;
  25217. - csr = SROMSEL | SROMRD; EMIT;
  25218. - csr ^= SROMCSON; EMIT;
  25219. - csr ^= SROMCLKON; EMIT;
  25220. -
  25221. - lastbit = 0;
  25222. - for (bits = idx|cmdmask, bit = bitwidth + 3; bit > 0; bit--, bits <<= 1)
  25223. - {
  25224. - const unsigned thisbit = bits & msb;
  25225. - csr ^= SROMCLKOFF; EMIT; /* clock low; data not valid */
  25226. - if (thisbit != lastbit) {
  25227. - csr ^= SROMDOUT; EMIT; /* clock low; invert data */
  25228. - } else {
  25229. - EMIT;
  25230. - }
  25231. - csr ^= SROMCLKON; EMIT; /* clock high; data valid */
  25232. - lastbit = thisbit;
  25233. - }
  25234. - csr ^= SROMCLKOFF; EMIT;
  25235. -
  25236. - for (data = 0, bits = 0; bits < 16; bits++) {
  25237. - data <<= 1;
  25238. - csr ^= SROMCLKON; EMIT; /* clock high; data valid */
  25239. - data |= TULIP_CSR_READ(csr_srom_mii) & SROMDIN ? 1 : 0;
  25240. - csr ^= SROMCLKOFF; EMIT; /* clock low; data not valid */
  25241. - }
  25242. - srom[idx*2] = data & 0xFF;
  25243. - srom[idx*2+1] = data >> 8;
  25244. - csr = SROMSEL | SROMRD; EMIT;
  25245. - csr = 0; EMIT;
  25246. - }
  25247. - srom_idle();
  25248. -}
  25249. -
  25250. -/**************************************************************************
  25251. -ETH_RESET - Reset adapter
  25252. -***************************************************************************/
  25253. -static void tulip_reset(struct nic *nic)
  25254. -{
  25255. - int x,cnt=2;
  25256. -
  25257. - outl(0x00000001, ioaddr + CSR0);
  25258. - udelay(1000);
  25259. - /* turn off reset and set cache align=16lword, burst=unlimit */
  25260. - outl(0x01A08000, ioaddr + CSR0);
  25261. -
  25262. - /* for some reason the media selection does not take
  25263. - the first time se it is repeated. */
  25264. -
  25265. - while(cnt--) {
  25266. - /* stop TX,RX processes */
  25267. - if (cnt == 1)
  25268. - outl(0x32404000, ioaddr + CSR6);
  25269. - else
  25270. - outl(0x32000040, ioaddr + CSR6);
  25271. -
  25272. - /* XXX - media selection is vendor specific and hard coded right
  25273. - here. This should be fixed to use the hints in the SROM and
  25274. - allow media selection by the user at runtime. MII support
  25275. - should also be added. Support for chips other than the
  25276. - 21143 should be added here as well */
  25277. -
  25278. - /* start set to 10Mbps half-duplex */
  25279. -
  25280. - /* setup SIA */
  25281. - outl(0x0, ioaddr + CSR13); /* reset SIA */
  25282. - outl(0x7f3f, ioaddr + CSR14);
  25283. - outl(0x8000008, ioaddr + CSR15);
  25284. - outl(0x0, ioaddr + CSR13);
  25285. - outl(0x1, ioaddr + CSR13);
  25286. - outl(0x2404000, ioaddr + CSR6);
  25287. -
  25288. - /* initalize GP */
  25289. - outl(0x8af0008, ioaddr + CSR15);
  25290. - outl(0x50008, ioaddr + CSR15);
  25291. -
  25292. - /* end set to 10Mbps half-duplex */
  25293. -
  25294. - if (vendor == PCI_VENDOR_ID_MACRONIX && dev_id == PCI_DEVICE_ID_MX987x5) {
  25295. - /* do stuff for MX98715 */
  25296. - outl(0x01a80000, ioaddr + CSR6);
  25297. - outl(0xFFFFFFFF, ioaddr + CSR14);
  25298. - outl(0x00001000, ioaddr + CSR12);
  25299. - }
  25300. -
  25301. - outl(0x0, ioaddr + CSR7); /* disable interrupts */
  25302. -
  25303. - /* construct setup packet which is used by the 21143 to
  25304. - program its CAM to recognize interesting MAC addresses */
  25305. -
  25306. - memset(&txd, 0, sizeof(struct txdesc));
  25307. - txd.buf1addr = &txb[0];
  25308. - txd.buf2addr = &txb[0]; /* just in case */
  25309. - txd.buf1sz = 192; /* setup packet must be 192 bytes */
  25310. - txd.buf2sz = 0;
  25311. - txd.control = 0x020; /* setup packet */
  25312. - txd.status = 0x80000000; /* give ownership to 21143 */
  25313. -
  25314. - /* construct perfect filter frame */
  25315. - /* with mac address as first match */
  25316. - /* and broadcast address for all others */
  25317. -
  25318. - for(x=0;x<192;x++) txb[x] = 0xff;
  25319. - txb[0] = nic->node_addr[0];
  25320. - txb[1] = nic->node_addr[1];
  25321. - txb[4] = nic->node_addr[2];
  25322. - txb[5] = nic->node_addr[3];
  25323. - txb[8] = nic->node_addr[4];
  25324. - txb[9] = nic->node_addr[5];
  25325. - outl((unsigned long)&txd, ioaddr + CSR4); /* set xmit buf */
  25326. - outl(0x2406000, ioaddr + CSR6); /* start transmiter */
  25327. -
  25328. - udelay(50000); /* wait for the setup packet to be processed */
  25329. -
  25330. - }
  25331. -
  25332. - /* setup receive descriptor */
  25333. - {
  25334. - int x;
  25335. - for(x=0;x<NRXD;x++) {
  25336. - memset(&rxd[x], 0, sizeof(struct rxdesc));
  25337. - rxd[x].buf1addr = &rxb[x * BUFLEN];
  25338. - rxd[x].buf2addr = 0; /* not used */
  25339. - rxd[x].buf1sz = BUFLEN;
  25340. - rxd[x].buf2sz = 0; /* not used */
  25341. - rxd[x].control = 0x0;
  25342. - rxd[x].status = 0x80000000; /* give ownership it to 21143 */
  25343. - }
  25344. - rxd[NRXD - 1].control = 0x008; /* Set Receive end of ring on la
  25345. -st descriptor */
  25346. - rxd_tail = 0;
  25347. - }
  25348. -
  25349. - /* tell DC211XX where to find rx descriptor list */
  25350. - outl((unsigned long)&rxd[0], ioaddr + CSR3);
  25351. - /* start the receiver */
  25352. - outl(0x2406002, ioaddr + CSR6);
  25353. -
  25354. -}
  25355. -
  25356. -/**************************************************************************
  25357. -ETH_TRANSMIT - Transmit a frame
  25358. -***************************************************************************/
  25359. -static const char padmap[] = {
  25360. - 0, 3, 2, 1};
  25361. -
  25362. -static void tulip_transmit(struct nic *nic, const char *d, unsigned int t, unsigned int s, const char *p)
  25363. -{
  25364. - unsigned long time;
  25365. -
  25366. - /* setup ethernet header */
  25367. -
  25368. - memcpy(ehdr, d, ETH_ALEN);
  25369. - memcpy(&ehdr[ETH_ALEN], nic->node_addr, ETH_ALEN);
  25370. - ehdr[ETH_ALEN*2] = (t >> 8) & 0xff;
  25371. - ehdr[ETH_ALEN*2+1] = t & 0xff;
  25372. -
  25373. - /* setup the transmit descriptor */
  25374. -
  25375. - memset(&txd, 0, sizeof(struct txdesc));
  25376. -
  25377. - txd.buf1addr = &ehdr[0]; /* ethernet header */
  25378. - txd.buf1sz = ETH_HLEN;
  25379. -
  25380. - txd.buf2addr = p; /* packet to transmit */
  25381. - txd.buf2sz = s;
  25382. -
  25383. - txd.control = 0x188; /* LS+FS+TER */
  25384. -
  25385. - txd.status = 0x80000000; /* give it to 21143 */
  25386. -
  25387. - outl(inl(ioaddr + CSR6) & ~0x00004000, ioaddr + CSR6);
  25388. - outl((unsigned long)&txd, ioaddr + CSR4);
  25389. - outl(inl(ioaddr + CSR6) | 0x00004000, ioaddr + CSR6);
  25390. -
  25391. -/* Wait for transmit to complete before returning. not well tested.
  25392. -
  25393. - time = currticks();
  25394. - while(txd.status & 0x80000000) {
  25395. - if (currticks() - time > 20) {
  25396. - printf("transmit timeout.\n");
  25397. - break;
  25398. - }
  25399. - }
  25400. -*/
  25401. -
  25402. -}
  25403. -
  25404. -/**************************************************************************
  25405. -ETH_POLL - Wait for a frame
  25406. -***************************************************************************/
  25407. -static int tulip_poll(struct nic *nic)
  25408. -{
  25409. - if (rxd[rxd_tail].status & 0x80000000) return 0;
  25410. -
  25411. - nic->packetlen = (rxd[rxd_tail].status & 0x3FFF0000) >> 16;
  25412. -
  25413. - /* copy packet to working buffer */
  25414. - /* XXX - this copy could be avoided with a little more work
  25415. - but for now we are content with it because the optimised
  25416. - memcpy(, , ) is quite fast */
  25417. -
  25418. - memcpy(nic->packet, rxb + rxd_tail * BUFLEN, nic->packetlen);
  25419. -
  25420. - /* return the descriptor and buffer to recieve ring */
  25421. - rxd[rxd_tail].status = 0x80000000;
  25422. - rxd_tail++;
  25423. - if (rxd_tail == NRXD) rxd_tail = 0;
  25424. -
  25425. - return 1;
  25426. -}
  25427. -
  25428. -static void tulip_disable(struct nic *nic)
  25429. -{
  25430. - /* nothing for the moment */
  25431. -}
  25432. -
  25433. -/**************************************************************************
  25434. -ETH_PROBE - Look for an adapter
  25435. -***************************************************************************/
  25436. -struct nic *otulip_probe(struct nic *nic, unsigned short *io_addrs, struct pci_device *pci)
  25437. -{
  25438. - int i;
  25439. -
  25440. - if (io_addrs == 0 || *io_addrs == 0)
  25441. - return (0);
  25442. - vendor = pci->vendor;
  25443. - dev_id = pci->dev_id;
  25444. - ioaddr = *io_addrs;
  25445. - membase = (unsigned int *)pci->membase;
  25446. -
  25447. - /* wakeup chip */
  25448. - pcibios_write_config_dword(pci->bus,pci->devfn,0x40,0x00000000);
  25449. -
  25450. - /* Stop the chip's Tx and Rx processes. */
  25451. - /* outl(inl(ioaddr + CSR6) & ~0x2002, ioaddr + CSR6); */
  25452. - /* Clear the missed-packet counter. */
  25453. - /* (volatile int)inl(ioaddr + CSR8); */
  25454. -
  25455. - srom_read();
  25456. -
  25457. - for (i=0; i < ETH_ALEN; i++)
  25458. - nic->node_addr[i] = srom[20+i];
  25459. -
  25460. - printf("Tulip %! at ioaddr %#hX\n", nic->node_addr, ioaddr);
  25461. -
  25462. - tulip_reset(nic);
  25463. -
  25464. - nic->reset = tulip_reset;
  25465. - nic->poll = tulip_poll;
  25466. - nic->transmit = tulip_transmit;
  25467. - nic->disable = tulip_disable;
  25468. - return nic;
  25469. -}
  25470. diff -Naur grub-0.97.orig/netboot/otulip.h grub-0.97/netboot/otulip.h
  25471. --- grub-0.97.orig/netboot/otulip.h 2003-07-09 11:45:38.000000000 +0000
  25472. +++ grub-0.97/netboot/otulip.h 1970-01-01 00:00:00.000000000 +0000
  25473. @@ -1,76 +0,0 @@
  25474. -/* mostly stolen from FreeBSD if_de.c, if_devar.h */
  25475. -
  25476. -#define TULIP_CSR_READ(csr) (membase[csr*2])
  25477. -#define CSR_READ(csr) (membase[csr*2])
  25478. -#define TULIP_CSR_WRITE(csr, val) (membase[csr*2] = val)
  25479. -#define CSR_WRITE(csr, val) (membase[csr*2] = val)
  25480. -
  25481. -#define csr_0 0
  25482. -#define csr_1 1
  25483. -#define csr_2 2
  25484. -#define csr_3 3
  25485. -#define csr_4 4
  25486. -#define csr_5 5
  25487. -#define csr_6 6
  25488. -#define csr_7 7
  25489. -#define csr_8 8
  25490. -#define csr_9 9
  25491. -#define csr_10 10
  25492. -#define csr_11 11
  25493. -#define csr_12 12
  25494. -#define csr_13 13
  25495. -#define csr_14 14
  25496. -#define csr_15 15
  25497. -
  25498. -#define csr_busmode csr_0
  25499. -#define csr_txpoll csr_1
  25500. -#define csr_rxpoll csr_2
  25501. -#define csr_rxlist csr_3
  25502. -#define csr_txlist csr_4
  25503. -#define csr_status csr_5
  25504. -#define csr_command csr_6
  25505. -#define csr_intr csr_7
  25506. -#define csr_missed_frames csr_8
  25507. -#define csr_enetrom csr_9 /* 21040 */
  25508. -#define csr_reserved csr_10 /* 21040 */
  25509. -#define csr_full_duplex csr_11 /* 21040 */
  25510. -#define csr_bootrom csr_10 /* 21041/21140A/?? */
  25511. -#define csr_gp csr_12 /* 21140* */
  25512. -#define csr_watchdog csr_15 /* 21140* */
  25513. -#define csr_gp_timer csr_11 /* 21041/21140* */
  25514. -#define csr_srom_mii csr_9 /* 21041/21140* */
  25515. -#define csr_sia_status csr_12 /* 2104x */
  25516. -#define csr_sia_connectivity csr_13 /* 2104x */
  25517. -#define csr_sia_tx_rx csr_14 /* 2104x */
  25518. -#define csr_sia_general csr_15 /* 2104x */
  25519. -
  25520. -#define SROMSEL 0x0800
  25521. -#define SROMCS 0x0001
  25522. -#define SROMCLKON 0x0002
  25523. -#define SROMCLKOFF 0x0002
  25524. -#define SROMRD 0x4000
  25525. -#define SROMWR 0x2000
  25526. -#define SROM_BITWIDTH 6
  25527. -#define SROMCMD_RD 6
  25528. -#define SROMCSON 0x0001
  25529. -#define SROMDOUT 0x0004
  25530. -#define SROMDIN 0x0008
  25531. -
  25532. -
  25533. -struct txdesc {
  25534. - unsigned long status; /* owner, status */
  25535. - unsigned long buf1sz:11, /* size of buffer 1 */
  25536. - buf2sz:11, /* size of buffer 2 */
  25537. - control:10; /* control bits */
  25538. - const unsigned char *buf1addr; /* buffer 1 address */
  25539. - const unsigned char *buf2addr; /* buffer 2 address */
  25540. -};
  25541. -
  25542. -struct rxdesc {
  25543. - unsigned long status; /* owner, status */
  25544. - unsigned long buf1sz:11, /* size of buffer 1 */
  25545. - buf2sz:11, /* size of buffer 2 */
  25546. - control:10; /* control bits */
  25547. - unsigned char *buf1addr; /* buffer 1 address */
  25548. - unsigned char *buf2addr; /* buffer 2 address */
  25549. -};
  25550. diff -Naur grub-0.97.orig/netboot/pci.c grub-0.97/netboot/pci.c
  25551. --- grub-0.97.orig/netboot/pci.c 2003-07-09 11:45:38.000000000 +0000
  25552. +++ grub-0.97/netboot/pci.c 2005-08-31 19:03:35.000000000 +0000
  25553. @@ -1,15 +1,3 @@
  25554. -/*
  25555. -** Support for NE2000 PCI clones added David Monro June 1997
  25556. -** Generalised to other NICs by Ken Yap July 1997
  25557. -**
  25558. -** Most of this is taken from:
  25559. -**
  25560. -** /usr/src/linux/drivers/pci/pci.c
  25561. -** /usr/src/linux/include/linux/pci.h
  25562. -** /usr/src/linux/arch/i386/bios32.c
  25563. -** /usr/src/linux/include/linux/bios32.h
  25564. -** /usr/src/linux/drivers/net/ne.c
  25565. -*/
  25566. /*
  25567. * This program is free software; you can redistribute it and/or
  25568. @@ -18,402 +6,294 @@
  25569. * your option) any later version.
  25570. */
  25571. -#include "etherboot.h"
  25572. +#include "grub.h"
  25573. #include "pci.h"
  25574. -/*#define DEBUG 1*/
  25575. -#define DEBUG 0
  25576. -
  25577. -#ifdef CONFIG_PCI_DIRECT
  25578. -#define PCIBIOS_SUCCESSFUL 0x00
  25579. -
  25580. -/*
  25581. - * Functions for accessing PCI configuration space with type 1 accesses
  25582. - */
  25583. -
  25584. -#define CONFIG_CMD(bus, device_fn, where) (0x80000000 | (bus << 16) | (device_fn << 8) | (where & ~3))
  25585. -
  25586. -int pcibios_read_config_byte(unsigned int bus, unsigned int device_fn,
  25587. - unsigned int where, unsigned char *value)
  25588. +unsigned long virt_offset = 0;
  25589. +unsigned long virt_to_phys(volatile const void *virt_addr)
  25590. {
  25591. - outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  25592. - *value = inb(0xCFC + (where&3));
  25593. - return PCIBIOS_SUCCESSFUL;
  25594. + return ((unsigned long)virt_addr) + virt_offset;
  25595. }
  25596. -int pcibios_read_config_word (unsigned int bus,
  25597. - unsigned int device_fn, unsigned int where, unsigned short *value)
  25598. +void *phys_to_virt(unsigned long phys_addr)
  25599. {
  25600. - outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  25601. - *value = inw(0xCFC + (where&2));
  25602. - return PCIBIOS_SUCCESSFUL;
  25603. + return (void *)(phys_addr - virt_offset);
  25604. }
  25605. -int pcibios_read_config_dword (unsigned int bus, unsigned int device_fn,
  25606. - unsigned int where, unsigned int *value)
  25607. -{
  25608. - outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  25609. - *value = inl(0xCFC);
  25610. - return PCIBIOS_SUCCESSFUL;
  25611. -}
  25612. +#ifdef INCLUDE_3C595
  25613. +extern struct pci_driver t595_driver;
  25614. +#endif /* INCLUDE_3C595 */
  25615. -int pcibios_write_config_byte (unsigned int bus, unsigned int device_fn,
  25616. - unsigned int where, unsigned char value)
  25617. -{
  25618. - outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  25619. - outb(value, 0xCFC + (where&3));
  25620. - return PCIBIOS_SUCCESSFUL;
  25621. -}
  25622. +#ifdef INCLUDE_3C90X
  25623. +extern struct pci_driver a3c90x_driver;
  25624. +#endif /* INCLUDE_3C90X */
  25625. -int pcibios_write_config_word (unsigned int bus, unsigned int device_fn,
  25626. - unsigned int where, unsigned short value)
  25627. -{
  25628. - outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  25629. - outw(value, 0xCFC + (where&2));
  25630. - return PCIBIOS_SUCCESSFUL;
  25631. -}
  25632. +#ifdef INCLUDE_DAVICOM
  25633. +extern struct pci_driver davicom_driver;
  25634. +#endif /* INCLUDE_DAVICOM */
  25635. -int pcibios_write_config_dword (unsigned int bus, unsigned int device_fn, unsigned int where, unsigned int value)
  25636. -{
  25637. - outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  25638. - outl(value, 0xCFC);
  25639. - return PCIBIOS_SUCCESSFUL;
  25640. -}
  25641. +#ifdef INCLUDE_E1000
  25642. +extern struct pci_driver e1000_driver;
  25643. +#endif /* INCLUDE_E1000 */
  25644. -#undef CONFIG_CMD
  25645. +#ifdef INCLUDE_EEPRO100
  25646. +extern struct pci_driver eepro100_driver;
  25647. +#endif /* INCLUDE_EEPRO100 */
  25648. -#else /* CONFIG_PCI_DIRECT not defined */
  25649. +#ifdef INCLUDE_EPIC100
  25650. +extern struct pci_driver epic100_driver;
  25651. +#endif /* INCLUDE_EPIC100 */
  25652. -static struct {
  25653. - unsigned long address;
  25654. - unsigned short segment;
  25655. -} bios32_indirect = { 0, KERN_CODE_SEG };
  25656. -
  25657. -static long pcibios_entry;
  25658. -static struct {
  25659. - unsigned long address;
  25660. - unsigned short segment;
  25661. -} pci_indirect = { 0, KERN_CODE_SEG };
  25662. +#ifdef INCLUDE_FORCEDETH
  25663. +extern struct pci_driver forcedeth_driver;
  25664. +#endif /* INCLUDE_FORCEDETH */
  25665. -static unsigned long bios32_service(unsigned long service)
  25666. -{
  25667. - unsigned char return_code; /* %al */
  25668. - unsigned long address; /* %ebx */
  25669. - unsigned long length; /* %ecx */
  25670. - unsigned long entry; /* %edx */
  25671. - unsigned long flags;
  25672. -
  25673. - save_flags(flags);
  25674. - __asm__(
  25675. -#ifdef ABSOLUTE_WITHOUT_ASTERISK
  25676. - "lcall (%%edi)"
  25677. -#else
  25678. - "lcall *(%%edi)"
  25679. -#endif
  25680. - : "=a" (return_code),
  25681. - "=b" (address),
  25682. - "=c" (length),
  25683. - "=d" (entry)
  25684. - : "0" (service),
  25685. - "1" (0),
  25686. - "D" (&bios32_indirect));
  25687. - restore_flags(flags);
  25688. -
  25689. - switch (return_code) {
  25690. - case 0:
  25691. - return address + entry;
  25692. - case 0x80: /* Not present */
  25693. - printf("bios32_service(%d) : not present\n", service);
  25694. - return 0;
  25695. - default: /* Shouldn't happen */
  25696. - printf("bios32_service(%d) : returned %#X, mail drew@colorado.edu\n",
  25697. - service, return_code);
  25698. - return 0;
  25699. - }
  25700. -}
  25701. +#ifdef INCLUDE_NATSEMI
  25702. +extern struct pci_driver natsemi_driver;
  25703. +#endif /* INCLUDE_NATSEMI */
  25704. -int pcibios_read_config_byte(unsigned int bus,
  25705. - unsigned int device_fn, unsigned int where, unsigned char *value)
  25706. -{
  25707. - unsigned long ret;
  25708. - unsigned long bx = (bus << 8) | device_fn;
  25709. - unsigned long flags;
  25710. -
  25711. - save_flags(flags);
  25712. - __asm__(
  25713. -#ifdef ABSOLUTE_WITHOUT_ASTERISK
  25714. - "lcall (%%esi)\n\t"
  25715. -#else
  25716. - "lcall *(%%esi)\n\t"
  25717. -#endif
  25718. - "jc 1f\n\t"
  25719. - "xor %%ah, %%ah\n"
  25720. - "1:"
  25721. - : "=c" (*value),
  25722. - "=a" (ret)
  25723. - : "1" (PCIBIOS_READ_CONFIG_BYTE),
  25724. - "b" (bx),
  25725. - "D" ((long) where),
  25726. - "S" (&pci_indirect));
  25727. - restore_flags(flags);
  25728. - return (int) (ret & 0xff00) >> 8;
  25729. -}
  25730. +#ifdef INCLUDE_NS83820
  25731. +extern struct pci_driver ns83820_driver;
  25732. +#endif /* INCLUDE_NS83820 */
  25733. -int pcibios_read_config_word(unsigned int bus,
  25734. - unsigned int device_fn, unsigned int where, unsigned short *value)
  25735. -{
  25736. - unsigned long ret;
  25737. - unsigned long bx = (bus << 8) | device_fn;
  25738. - unsigned long flags;
  25739. -
  25740. - save_flags(flags);
  25741. - __asm__(
  25742. -#ifdef ABSOLUTE_WITHOUT_ASTERISK
  25743. - "lcall (%%esi)\n\t"
  25744. -#else
  25745. - "lcall *(%%esi)\n\t"
  25746. -#endif
  25747. - "jc 1f\n\t"
  25748. - "xor %%ah, %%ah\n"
  25749. - "1:"
  25750. - : "=c" (*value),
  25751. - "=a" (ret)
  25752. - : "1" (PCIBIOS_READ_CONFIG_WORD),
  25753. - "b" (bx),
  25754. - "D" ((long) where),
  25755. - "S" (&pci_indirect));
  25756. - restore_flags(flags);
  25757. - return (int) (ret & 0xff00) >> 8;
  25758. -}
  25759. +#ifdef INCLUDE_NS8390
  25760. +extern struct pci_driver nepci_driver;
  25761. +#endif /* INCLUDE_NS8390 */
  25762. -int pcibios_read_config_dword(unsigned int bus,
  25763. - unsigned int device_fn, unsigned int where, unsigned int *value)
  25764. -{
  25765. - unsigned long ret;
  25766. - unsigned long bx = (bus << 8) | device_fn;
  25767. - unsigned long flags;
  25768. -
  25769. - save_flags(flags);
  25770. - __asm__(
  25771. -#ifdef ABSOLUTE_WITHOUT_ASTERISK
  25772. - "lcall (%%esi)\n\t"
  25773. -#else
  25774. - "lcall *(%%esi)\n\t"
  25775. -#endif
  25776. - "jc 1f\n\t"
  25777. - "xor %%ah, %%ah\n"
  25778. - "1:"
  25779. - : "=c" (*value),
  25780. - "=a" (ret)
  25781. - : "1" (PCIBIOS_READ_CONFIG_DWORD),
  25782. - "b" (bx),
  25783. - "D" ((long) where),
  25784. - "S" (&pci_indirect));
  25785. - restore_flags(flags);
  25786. - return (int) (ret & 0xff00) >> 8;
  25787. -}
  25788. +#ifdef INCLUDE_PCNET32
  25789. +extern struct pci_driver pcnet32_driver;
  25790. +#endif /* INCLUDE_PCNET32 */
  25791. -int pcibios_write_config_byte (unsigned int bus,
  25792. - unsigned int device_fn, unsigned int where, unsigned char value)
  25793. -{
  25794. - unsigned long ret;
  25795. - unsigned long bx = (bus << 8) | device_fn;
  25796. - unsigned long flags;
  25797. -
  25798. - save_flags(flags); cli();
  25799. - __asm__(
  25800. -#ifdef ABSOLUTE_WITHOUT_ASTERISK
  25801. - "lcall (%%esi)\n\t"
  25802. -#else
  25803. - "lcall *(%%esi)\n\t"
  25804. -#endif
  25805. - "jc 1f\n\t"
  25806. - "xor %%ah, %%ah\n"
  25807. - "1:"
  25808. - : "=a" (ret)
  25809. - : "0" (PCIBIOS_WRITE_CONFIG_BYTE),
  25810. - "c" (value),
  25811. - "b" (bx),
  25812. - "D" ((long) where),
  25813. - "S" (&pci_indirect));
  25814. - restore_flags(flags);
  25815. - return (int) (ret & 0xff00) >> 8;
  25816. -}
  25817. +#ifdef INCLUDE_PNIC
  25818. +extern struct pci_driver pnic_driver;
  25819. +#endif /* INCLUDE_PNIC */
  25820. -int pcibios_write_config_word (unsigned int bus,
  25821. - unsigned int device_fn, unsigned int where, unsigned short value)
  25822. -{
  25823. - unsigned long ret;
  25824. - unsigned long bx = (bus << 8) | device_fn;
  25825. - unsigned long flags;
  25826. -
  25827. - save_flags(flags); cli();
  25828. - __asm__(
  25829. -#ifdef ABSOLUTE_WITHOUT_ASTERISK
  25830. - "lcall (%%esi)\n\t"
  25831. -#else
  25832. - "lcall *(%%esi)\n\t"
  25833. -#endif
  25834. - "jc 1f\n\t"
  25835. - "xor %%ah, %%ah\n"
  25836. - "1:"
  25837. - : "=a" (ret)
  25838. - : "0" (PCIBIOS_WRITE_CONFIG_WORD),
  25839. - "c" (value),
  25840. - "b" (bx),
  25841. - "D" ((long) where),
  25842. - "S" (&pci_indirect));
  25843. - restore_flags(flags);
  25844. - return (int) (ret & 0xff00) >> 8;
  25845. -}
  25846. +#ifdef INCLUDE_RTL8139
  25847. +extern struct pci_driver rtl8139_driver;
  25848. +#endif /* INCLUDE_RTL8139 */
  25849. -int pcibios_write_config_dword (unsigned int bus,
  25850. - unsigned int device_fn, unsigned int where, unsigned int value)
  25851. -{
  25852. - unsigned long ret;
  25853. - unsigned long bx = (bus << 8) | device_fn;
  25854. - unsigned long flags;
  25855. -
  25856. - save_flags(flags); cli();
  25857. - __asm__(
  25858. -#ifdef ABSOLUTE_WITHOUT_ASTERISK
  25859. - "lcall (%%esi)\n\t"
  25860. -#else
  25861. - "lcall *(%%esi)\n\t"
  25862. -#endif
  25863. - "jc 1f\n\t"
  25864. - "xor %%ah, %%ah\n"
  25865. - "1:"
  25866. - : "=a" (ret)
  25867. - : "0" (PCIBIOS_WRITE_CONFIG_DWORD),
  25868. - "c" (value),
  25869. - "b" (bx),
  25870. - "D" ((long) where),
  25871. - "S" (&pci_indirect));
  25872. - restore_flags(flags);
  25873. - return (int) (ret & 0xff00) >> 8;
  25874. -}
  25875. +#ifdef INCLUDE_SIS900
  25876. +extern struct pci_driver sis900_driver;
  25877. +extern struct pci_driver sis_bridge_driver;
  25878. +#endif /* INCLUDE_SIS900 */
  25879. -static void check_pcibios(void)
  25880. -{
  25881. - unsigned long signature;
  25882. - unsigned char present_status;
  25883. - unsigned char major_revision;
  25884. - unsigned char minor_revision;
  25885. - unsigned long flags;
  25886. - int pack;
  25887. -
  25888. - if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
  25889. - pci_indirect.address = pcibios_entry;
  25890. -
  25891. - save_flags(flags);
  25892. - __asm__(
  25893. -#ifdef ABSOLUTE_WITHOUT_ASTERISK
  25894. - "lcall (%%edi)\n\t"
  25895. -#else
  25896. - "lcall *(%%edi)\n\t"
  25897. -#endif
  25898. - "jc 1f\n\t"
  25899. - "xor %%ah, %%ah\n"
  25900. - "1:\tshl $8, %%eax\n\t"
  25901. - "movw %%bx, %%ax"
  25902. - : "=d" (signature),
  25903. - "=a" (pack)
  25904. - : "1" (PCIBIOS_PCI_BIOS_PRESENT),
  25905. - "D" (&pci_indirect)
  25906. - : "bx", "cx");
  25907. - restore_flags(flags);
  25908. -
  25909. - present_status = (pack >> 16) & 0xff;
  25910. - major_revision = (pack >> 8) & 0xff;
  25911. - minor_revision = pack & 0xff;
  25912. - if (present_status || (signature != PCI_SIGNATURE)) {
  25913. - printf("ERROR: BIOS32 says PCI BIOS, but no PCI "
  25914. - "BIOS????\n");
  25915. - pcibios_entry = 0;
  25916. - }
  25917. -#if DEBUG
  25918. - if (pcibios_entry) {
  25919. - printf ("pcibios_init : PCI BIOS revision %hhX.%hhX"
  25920. - " entry at %#X\n", major_revision,
  25921. - minor_revision, pcibios_entry);
  25922. - }
  25923. -#endif
  25924. - }
  25925. -}
  25926. +#ifdef INCLUDE_SUNDANCE
  25927. +extern struct pci_driver sundance_driver;
  25928. +#endif /* INCLUDE_SUNDANCE */
  25929. -static void pcibios_init(void)
  25930. -{
  25931. - union bios32 *check;
  25932. - unsigned char sum;
  25933. - int i, length;
  25934. - unsigned long bios32_entry = 0;
  25935. -
  25936. - /*
  25937. - * Follow the standard procedure for locating the BIOS32 Service
  25938. - * directory by scanning the permissible address range from
  25939. - * 0xe0000 through 0xfffff for a valid BIOS32 structure.
  25940. - *
  25941. - */
  25942. +#ifdef INCLUDE_TG3
  25943. +extern struct pci_driver tg3_driver;
  25944. +#endif /* INCLUDE_TG3 */
  25945. +
  25946. +#ifdef INCLUDE_TLAN
  25947. +extern struct pci_driver tlan_driver;
  25948. +#endif /* INCLUDE_TLAN */
  25949. +
  25950. +#ifdef INCLUDE_TULIP
  25951. +extern struct pci_driver tulip_driver;
  25952. +#endif /* INCLUDE_TULIP */
  25953. +
  25954. +#ifdef INCLUDE_UNDI
  25955. +extern struct pci_driver undi_driver;
  25956. +#endif /* INCLUDE_UNDI */
  25957. +
  25958. +#ifdef INCLUDE_VIA_RHINE
  25959. +extern struct pci_driver rhine_driver;
  25960. +#endif/* INCLUDE_VIA_RHINE */
  25961. +
  25962. +#ifdef INCLUDE_W89C840
  25963. +extern struct pci_driver w89c840_driver;
  25964. +#endif /* INCLUDE_W89C840 */
  25965. +
  25966. +#ifdef INCLUDE_R8169
  25967. +extern struct pci_driver r8169_driver;
  25968. +#endif /* INCLUDE_R8169 */
  25969. +
  25970. +static const struct pci_driver *pci_drivers[] = {
  25971. +
  25972. +#ifdef INCLUDE_3C595
  25973. + &t595_driver,
  25974. +#endif /* INCLUDE_3C595 */
  25975. +
  25976. +#ifdef INCLUDE_3C90X
  25977. + &a3c90x_driver,
  25978. +#endif /* INCLUDE_3C90X */
  25979. +
  25980. +#ifdef INCLUDE_DAVICOM
  25981. + &davicom_driver,
  25982. +#endif /* INCLUDE_DAVICOM */
  25983. +
  25984. +#ifdef INCLUDE_E1000
  25985. + &e1000_driver,
  25986. +#endif /* INCLUDE_E1000 */
  25987. +
  25988. +#ifdef INCLUDE_EEPRO100
  25989. + &eepro100_driver,
  25990. +#endif /* INCLUDE_EEPRO100 */
  25991. +
  25992. +#ifdef INCLUDE_EPIC100
  25993. + &epic100_driver,
  25994. +#endif /* INCLUDE_EPIC100 */
  25995. +
  25996. +#ifdef INCLUDE_FORCEDETH
  25997. + &forcedeth_driver,
  25998. +#endif /* INCLUDE_FORCEDETH */
  25999. +
  26000. +#ifdef INCLUDE_NATSEMI
  26001. + &natsemi_driver,
  26002. +#endif /* INCLUDE_NATSEMI */
  26003. +
  26004. +#ifdef INCLUDE_NS83820
  26005. + &ns83820_driver,
  26006. +#endif /* INCLUDE_NS83820 */
  26007. +
  26008. +#ifdef INCLUDE_NS8390
  26009. + &nepci_driver,
  26010. +#endif /* INCLUDE_NS8390 */
  26011. +
  26012. +#ifdef INCLUDE_PCNET32
  26013. + &pcnet32_driver,
  26014. +#endif /* INCLUDE_PCNET32 */
  26015. +
  26016. +#ifdef INCLUDE_PNIC
  26017. + &pnic_driver,
  26018. +#endif /* INCLUDE_PNIC */
  26019. - for (check = (union bios32 *) 0xe0000; check <= (union bios32 *) 0xffff0; ++check) {
  26020. - if (check->fields.signature != BIOS32_SIGNATURE)
  26021. +#ifdef INCLUDE_RTL8139
  26022. + &rtl8139_driver,
  26023. +#endif /* INCLUDE_RTL8139 */
  26024. +
  26025. +#ifdef INCLUDE_SIS900
  26026. + &sis900_driver,
  26027. + &sis_bridge_driver,
  26028. +#endif /* INCLUDE_SIS900 */
  26029. +
  26030. +#ifdef INCLUDE_SUNDANCE
  26031. + &sundance_driver,
  26032. +#endif /* INCLUDE_SUNDANCE */
  26033. +
  26034. +#ifdef INCLUDE_TG3
  26035. + & tg3_driver,
  26036. +#endif /* INCLUDE_TG3 */
  26037. +
  26038. +#ifdef INCLUDE_TLAN
  26039. + &tlan_driver,
  26040. +#endif /* INCLUDE_TLAN */
  26041. +
  26042. +#ifdef INCLUDE_TULIP
  26043. + & tulip_driver,
  26044. +#endif /* INCLUDE_TULIP */
  26045. +
  26046. +#ifdef INCLUDE_VIA_RHINE
  26047. + &rhine_driver,
  26048. +#endif/* INCLUDE_VIA_RHINE */
  26049. +
  26050. +#ifdef INCLUDE_W89C840
  26051. + &w89c840_driver,
  26052. +#endif /* INCLUDE_W89C840 */
  26053. +
  26054. +#ifdef INCLUDE_R8169
  26055. + &r8169_driver,
  26056. +#endif /* INCLUDE_R8169 */
  26057. +
  26058. +/* We must be the last one */
  26059. +#ifdef INCLUDE_UNDI
  26060. + &undi_driver,
  26061. +#endif /* INCLUDE_UNDI */
  26062. +
  26063. + 0
  26064. +};
  26065. +
  26066. +static void scan_drivers(
  26067. + int type,
  26068. + uint32_t class, uint16_t vendor, uint16_t device,
  26069. + const struct pci_driver *last_driver, struct pci_device *dev)
  26070. +{
  26071. + const struct pci_driver *skip_driver = last_driver;
  26072. + /* Assume there is only one match of the correct type */
  26073. + const struct pci_driver *driver;
  26074. + int i, j;
  26075. +
  26076. + for(j = 0; pci_drivers[j] != 0; j++){
  26077. + driver = pci_drivers[j];
  26078. + if (driver->type != type)
  26079. continue;
  26080. - length = check->fields.length * 16;
  26081. - if (!length)
  26082. + if (skip_driver) {
  26083. + if (skip_driver == driver)
  26084. + skip_driver = 0;
  26085. continue;
  26086. - sum = 0;
  26087. - for (i = 0; i < length ; ++i)
  26088. - sum += check->chars[i];
  26089. - if (sum != 0)
  26090. + }
  26091. + for(i = 0; i < driver->id_count; i++) {
  26092. + if ((vendor == driver->ids[i].vendor) &&
  26093. + (device == driver->ids[i].dev_id)) {
  26094. +
  26095. + dev->driver = driver;
  26096. + dev->name = driver->ids[i].name;
  26097. +
  26098. + goto out;
  26099. + }
  26100. + }
  26101. + }
  26102. + if (!class) {
  26103. + goto out;
  26104. + }
  26105. + for(j = 0; pci_drivers[j] != 0; j++){
  26106. + driver = pci_drivers[j];
  26107. + if (driver->type != type)
  26108. continue;
  26109. - if (check->fields.revision != 0) {
  26110. - printf("pcibios_init : unsupported revision %d at %#X, mail drew@colorado.edu\n",
  26111. - check->fields.revision, check);
  26112. + if (skip_driver) {
  26113. + if (skip_driver == driver)
  26114. + skip_driver = 0;
  26115. continue;
  26116. }
  26117. -#if DEBUG
  26118. - printf("pcibios_init : BIOS32 Service Directory "
  26119. - "structure at %#X\n", check);
  26120. -#endif
  26121. - if (!bios32_entry) {
  26122. - if (check->fields.entry >= 0x100000) {
  26123. - printf("pcibios_init: entry in high "
  26124. - "memory, giving up\n");
  26125. - return;
  26126. - } else {
  26127. - bios32_entry = check->fields.entry;
  26128. -#if DEBUG
  26129. - printf("pcibios_init : BIOS32 Service Directory"
  26130. - " entry at %#X\n", bios32_entry);
  26131. -#endif
  26132. - bios32_indirect.address = bios32_entry;
  26133. - }
  26134. + if (last_driver == driver)
  26135. + continue;
  26136. + if ((class >> 8) == driver->class) {
  26137. + dev->driver = driver;
  26138. + dev->name = driver->name;
  26139. + goto out;
  26140. }
  26141. }
  26142. - if (bios32_entry)
  26143. - check_pcibios();
  26144. + out:
  26145. + return;
  26146. }
  26147. -#endif /* CONFIG_PCI_DIRECT not defined*/
  26148. -static void scan_bus(struct pci_device *pcidev)
  26149. +void scan_pci_bus(int type, struct pci_device *dev)
  26150. {
  26151. - unsigned int devfn, l, bus, buses;
  26152. + unsigned int first_bus, first_devfn;
  26153. + const struct pci_driver *first_driver;
  26154. + unsigned int devfn, bus, buses;
  26155. unsigned char hdr_type = 0;
  26156. - unsigned short vendor, device;
  26157. - unsigned int membase, ioaddr, romaddr;
  26158. - int i, reg;
  26159. - unsigned int pci_ioaddr = 0;
  26160. -
  26161. + uint32_t class;
  26162. + uint16_t vendor, device;
  26163. + uint32_t l, membase, ioaddr, romaddr;
  26164. + int reg;
  26165. +
  26166. + EnterFunction("scan_pci_bus");
  26167. + first_bus = 0;
  26168. + first_devfn = 0;
  26169. + first_driver = 0;
  26170. + if (dev->driver) {
  26171. + first_driver = dev->driver;
  26172. + first_bus = dev->bus;
  26173. + first_devfn = dev->devfn;
  26174. + /* Re read the header type on a restart */
  26175. + pcibios_read_config_byte(first_bus, first_devfn & ~0x7,
  26176. + PCI_HEADER_TYPE, &hdr_type);
  26177. + dev->driver = 0;
  26178. + dev->bus = 0;
  26179. + dev->devfn = 0;
  26180. + }
  26181. +
  26182. /* Scan all PCI buses, until we find our card.
  26183. - * We could be smart only scan the required busses but that
  26184. + * We could be smart only scan the required buses but that
  26185. * is error prone, and tricky.
  26186. - * By scanning all possible pci busses in order we should find
  26187. + * By scanning all possible pci buses in order we should find
  26188. * our card eventually.
  26189. */
  26190. buses=256;
  26191. - for (bus = 0; bus < buses; ++bus) {
  26192. - for (devfn = 0; devfn < 0xff; ++devfn) {
  26193. + for (bus = first_bus; bus < buses; ++bus) {
  26194. + for (devfn = first_devfn; devfn < 0xff; ++devfn, first_driver = 0) {
  26195. if (PCI_FUNC (devfn) == 0)
  26196. pcibios_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type);
  26197. else if (!(hdr_type & 0x80)) /* not a multi-function device */
  26198. @@ -421,61 +301,90 @@
  26199. pcibios_read_config_dword(bus, devfn, PCI_VENDOR_ID, &l);
  26200. /* some broken boards return 0 if a slot is empty: */
  26201. if (l == 0xffffffff || l == 0x00000000) {
  26202. - hdr_type = 0;
  26203. continue;
  26204. }
  26205. vendor = l & 0xffff;
  26206. device = (l >> 16) & 0xffff;
  26207. + pcibios_read_config_dword(bus, devfn, PCI_REVISION, &l);
  26208. + class = (l >> 8) & 0xffffff;
  26209. #if DEBUG
  26210. - printf("bus %hhX, function %hhX, vendor %hX, device %hX\n",
  26211. - bus, devfn, vendor, device);
  26212. + {
  26213. + int i;
  26214. + printf("%hhx:%hhx.%hhx [%hX/%hX] ---- ",
  26215. + bus, PCI_SLOT(devfn), PCI_FUNC(devfn),
  26216. + vendor, device);
  26217. +#if DEBUG > 1
  26218. + for(i = 0; i < 256; i++) {
  26219. + unsigned char byte;
  26220. + if ((i & 0xf) == 0) {
  26221. + printf("%hhx: ", i);
  26222. + }
  26223. + pcibios_read_config_byte(bus, devfn, i, &byte);
  26224. + printf("%hhx ", byte);
  26225. + if ((i & 0xf) == 0xf) {
  26226. + printf("\n");
  26227. + }
  26228. + }
  26229. +#endif
  26230. +
  26231. + }
  26232. +#endif
  26233. + scan_drivers(type, class, vendor, device, first_driver, dev);
  26234. + if (!dev->driver){
  26235. +#if DEBUG
  26236. + printf("No driver fit.\n");
  26237. #endif
  26238. - for (i = 0; pcidev[i].vendor != 0; i++) {
  26239. - if (vendor != pcidev[i].vendor
  26240. - || device != pcidev[i].dev_id)
  26241. + continue;
  26242. + }
  26243. +#if DEBUG
  26244. + printf("Get Driver:\n");
  26245. +#endif
  26246. + dev->devfn = devfn;
  26247. + dev->bus = bus;
  26248. + dev->class = class;
  26249. + dev->vendor = vendor;
  26250. + dev->dev_id = device;
  26251. +
  26252. +
  26253. + /* Get the ROM base address */
  26254. + pcibios_read_config_dword(bus, devfn,
  26255. + PCI_ROM_ADDRESS, &romaddr);
  26256. + romaddr >>= 10;
  26257. + dev->romaddr = romaddr;
  26258. +
  26259. + /* Get the ``membase'' */
  26260. + pcibios_read_config_dword(bus, devfn,
  26261. + PCI_BASE_ADDRESS_1, &membase);
  26262. + dev->membase = membase;
  26263. +
  26264. + /* Get the ``ioaddr'' */
  26265. + for (reg = PCI_BASE_ADDRESS_0; reg <= PCI_BASE_ADDRESS_5; reg += 4) {
  26266. + pcibios_read_config_dword(bus, devfn, reg, &ioaddr);
  26267. + if ((ioaddr & PCI_BASE_ADDRESS_IO_MASK) == 0 || (ioaddr & PCI_BASE_ADDRESS_SPACE_IO) == 0)
  26268. continue;
  26269. - pcidev[i].devfn = devfn;
  26270. - pcidev[i].bus = bus;
  26271. - for (reg = PCI_BASE_ADDRESS_0; reg <= PCI_BASE_ADDRESS_5; reg += 4) {
  26272. - pcibios_read_config_dword(bus, devfn, reg, &ioaddr);
  26273. -
  26274. - if ((ioaddr & PCI_BASE_ADDRESS_IO_MASK) == 0 || (ioaddr & PCI_BASE_ADDRESS_SPACE_IO) == 0)
  26275. - continue;
  26276. - /* Strip the I/O address out of the returned value */
  26277. - ioaddr &= PCI_BASE_ADDRESS_IO_MASK;
  26278. - /* Get the memory base address */
  26279. - pcibios_read_config_dword(bus, devfn,
  26280. - PCI_BASE_ADDRESS_1, &membase);
  26281. - /* Get the ROM base address */
  26282. - pcibios_read_config_dword(bus, devfn, PCI_ROM_ADDRESS, &romaddr);
  26283. - romaddr >>= 10;
  26284. - printf("Found %s at %#hx, ROM address %#hx\n",
  26285. - pcidev[i].name, ioaddr, romaddr);
  26286. - /* Take the first one or the one that matches in boot ROM address */
  26287. - if (pci_ioaddr == 0 || romaddr == ((unsigned long) rom.rom_segment << 4)) {
  26288. - pcidev[i].membase = membase;
  26289. - pcidev[i].ioaddr = ioaddr;
  26290. - return;
  26291. - }
  26292. - }
  26293. +
  26294. +
  26295. + /* Strip the I/O address out of the returned value */
  26296. + ioaddr &= PCI_BASE_ADDRESS_IO_MASK;
  26297. +
  26298. + /* Take the first one or the one that matches in boot ROM address */
  26299. + dev->ioaddr = ioaddr;
  26300. }
  26301. +#if DEBUG > 2
  26302. + printf("Found %s ROM address %#hx\n",
  26303. + dev->name, romaddr);
  26304. +#endif
  26305. + LeaveFunction("scan_pci_bus");
  26306. + return;
  26307. }
  26308. + first_devfn = 0;
  26309. }
  26310. + first_bus = 0;
  26311. + LeaveFunction("scan_pci_bus");
  26312. }
  26313. -void eth_pci_init(struct pci_device *pcidev)
  26314. -{
  26315. -#ifndef CONFIG_PCI_DIRECT
  26316. - pcibios_init();
  26317. - if (!pcibios_entry) {
  26318. - printf("pci_init: no BIOS32 detected\n");
  26319. - return;
  26320. - }
  26321. -#endif
  26322. - scan_bus(pcidev);
  26323. - /* return values are in pcidev structures */
  26324. -}
  26325. +
  26326. /*
  26327. * Set device to be a busmaster in case BIOS neglected to do so.
  26328. @@ -489,13 +398,134 @@
  26329. pcibios_read_config_word(p->bus, p->devfn, PCI_COMMAND, &pci_command);
  26330. new_command = pci_command | PCI_COMMAND_MASTER|PCI_COMMAND_IO;
  26331. if (pci_command != new_command) {
  26332. - printf("The PCI BIOS has not enabled this device!\nUpdating PCI command %hX->%hX. pci_bus %hhX pci_device_fn %hhX\n",
  26333. +#if DEBUG > 0
  26334. + printf(
  26335. + "The PCI BIOS has not enabled this device!\n"
  26336. + "Updating PCI command %hX->%hX. pci_bus %hhX pci_device_fn %hhX\n",
  26337. pci_command, new_command, p->bus, p->devfn);
  26338. +#endif
  26339. pcibios_write_config_word(p->bus, p->devfn, PCI_COMMAND, new_command);
  26340. }
  26341. pcibios_read_config_byte(p->bus, p->devfn, PCI_LATENCY_TIMER, &pci_latency);
  26342. if (pci_latency < 32) {
  26343. - printf("PCI latency timer (CFLT) is unreasonably low at %d. Setting to 32 clocks.\n", pci_latency);
  26344. +#if DEBUG > 0
  26345. + printf("PCI latency timer (CFLT) is unreasonably low at %d. Setting to 32 clocks.\n",
  26346. + pci_latency);
  26347. +#endif
  26348. pcibios_write_config_byte(p->bus, p->devfn, PCI_LATENCY_TIMER, 32);
  26349. }
  26350. }
  26351. +
  26352. +/*
  26353. + * Find the start of a pci resource.
  26354. + */
  26355. +unsigned long pci_bar_start(struct pci_device *dev, unsigned int index)
  26356. +{
  26357. + uint32_t lo, hi;
  26358. + unsigned long bar;
  26359. + pci_read_config_dword(dev, index, &lo);
  26360. + if (lo & PCI_BASE_ADDRESS_SPACE_IO) {
  26361. + bar = lo & PCI_BASE_ADDRESS_IO_MASK;
  26362. + } else {
  26363. + bar = 0;
  26364. + if ((lo & PCI_BASE_ADDRESS_MEM_TYPE_MASK) == PCI_BASE_ADDRESS_MEM_TYPE_64) {
  26365. + pci_read_config_dword(dev, index + 4, &hi);
  26366. + if (hi) {
  26367. + if (sizeof(unsigned long) > sizeof(uint32_t)) {
  26368. + bar = hi;
  26369. + /* It's REALLY interesting:-) */
  26370. + bar <<=32;
  26371. + }
  26372. + else {
  26373. + printf("Unhandled 64bit BAR\n");
  26374. + return -1UL;
  26375. + }
  26376. + }
  26377. + }
  26378. + bar |= lo & PCI_BASE_ADDRESS_MEM_MASK;
  26379. + }
  26380. + return bar + pcibios_bus_base(dev->bus);
  26381. +}
  26382. +
  26383. +/*
  26384. + * Find the size of a pci resource.
  26385. + */
  26386. +unsigned long pci_bar_size(struct pci_device *dev, unsigned int bar)
  26387. +{
  26388. + uint32_t start, size;
  26389. + /* Save the original bar */
  26390. + pci_read_config_dword(dev, bar, &start);
  26391. + /* Compute which bits can be set */
  26392. + pci_write_config_dword(dev, bar, ~0);
  26393. + pci_read_config_dword(dev, bar, &size);
  26394. + /* Restore the original size */
  26395. + pci_write_config_dword(dev, bar, start);
  26396. + /* Find the significant bits */
  26397. + if (start & PCI_BASE_ADDRESS_SPACE_IO) {
  26398. + size &= PCI_BASE_ADDRESS_IO_MASK;
  26399. + } else {
  26400. + size &= PCI_BASE_ADDRESS_MEM_MASK;
  26401. + }
  26402. + /* Find the lowest bit set */
  26403. + size = size & ~(size - 1);
  26404. + return size;
  26405. +}
  26406. +
  26407. +/**
  26408. + * pci_find_capability - query for devices' capabilities
  26409. + * @dev: PCI device to query
  26410. + * @cap: capability code
  26411. + *
  26412. + * Tell if a device supports a given PCI capability.
  26413. + * Returns the address of the requested capability structure within the
  26414. + * device's PCI configuration space or 0 in case the device does not
  26415. + * support it. Possible values for @cap:
  26416. + *
  26417. + * %PCI_CAP_ID_PM Power Management
  26418. + *
  26419. + * %PCI_CAP_ID_AGP Accelerated Graphics Port
  26420. + *
  26421. + * %PCI_CAP_ID_VPD Vital Product Data
  26422. + *
  26423. + * %PCI_CAP_ID_SLOTID Slot Identification
  26424. + *
  26425. + * %PCI_CAP_ID_MSI Message Signalled Interrupts
  26426. + *
  26427. + * %PCI_CAP_ID_CHSWP CompactPCI HotSwap
  26428. + */
  26429. +int pci_find_capability(struct pci_device *dev, int cap)
  26430. +{
  26431. + uint16_t status;
  26432. + uint8_t pos, id;
  26433. + uint8_t hdr_type;
  26434. + int ttl = 48;
  26435. +
  26436. + pci_read_config_word(dev, PCI_STATUS, &status);
  26437. + if (!(status & PCI_STATUS_CAP_LIST))
  26438. + return 0;
  26439. + pci_read_config_byte(dev, PCI_HEADER_TYPE, &hdr_type);
  26440. + switch (hdr_type & 0x7F) {
  26441. + case PCI_HEADER_TYPE_NORMAL:
  26442. + case PCI_HEADER_TYPE_BRIDGE:
  26443. + default:
  26444. + pci_read_config_byte(dev, PCI_CAPABILITY_LIST, &pos);
  26445. + break;
  26446. + case PCI_HEADER_TYPE_CARDBUS:
  26447. + pci_read_config_byte(dev, PCI_CB_CAPABILITY_LIST, &pos);
  26448. + break;
  26449. + }
  26450. + while (ttl-- && pos >= 0x40) {
  26451. + pos &= ~3;
  26452. + pci_read_config_byte(dev, pos + PCI_CAP_LIST_ID, &id);
  26453. +#if DEBUG > 0
  26454. + printf("Capability: %d\n", id);
  26455. +#endif
  26456. + if (id == 0xff)
  26457. + break;
  26458. + if (id == cap)
  26459. + return pos;
  26460. + pci_read_config_byte(dev, pos + PCI_CAP_LIST_NEXT, &pos);
  26461. + }
  26462. + return 0;
  26463. +}
  26464. +
  26465. diff -Naur grub-0.97.orig/netboot/pci.h grub-0.97/netboot/pci.h
  26466. --- grub-0.97.orig/netboot/pci.h 2003-07-09 11:45:38.000000000 +0000
  26467. +++ grub-0.97/netboot/pci.h 2005-08-31 21:31:46.000000000 +0000
  26468. @@ -1,4 +1,4 @@
  26469. -#ifndef PCI_H
  26470. +#if !defined(PCI_H) && defined(CONFIG_PCI)
  26471. #define PCI_H
  26472. /*
  26473. @@ -21,10 +21,19 @@
  26474. * your option) any later version.
  26475. */
  26476. +#include "pci_ids.h"
  26477. +
  26478. #define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */
  26479. #define PCI_COMMAND_MEM 0x2 /* Enable response in mem space */
  26480. #define PCI_COMMAND_MASTER 0x4 /* Enable bus mastering */
  26481. #define PCI_LATENCY_TIMER 0x0d /* 8 bits */
  26482. +#define PCI_COMMAND_SPECIAL 0x8 /* Enable response to special cycles */
  26483. +#define PCI_COMMAND_INVALIDATE 0x10 /* Use memory write and invalidate */
  26484. +#define PCI_COMMAND_VGA_PALETTE 0x20 /* Enable palette snooping */
  26485. +#define PCI_COMMAND_PARITY 0x40 /* Enable parity checking */
  26486. +#define PCI_COMMAND_WAIT 0x80 /* Enable address/data stepping */
  26487. +#define PCI_COMMAND_SERR 0x100 /* Enable SERR */
  26488. +#define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */
  26489. #define PCIBIOS_PCI_FUNCTION_ID 0xb1XX
  26490. #define PCIBIOS_PCI_BIOS_PRESENT 0xb101
  26491. @@ -42,10 +51,37 @@
  26492. #define PCI_DEVICE_ID 0x02 /* 16 bits */
  26493. #define PCI_COMMAND 0x04 /* 16 bits */
  26494. +#define PCI_STATUS 0x06 /* 16 bits */
  26495. +#define PCI_STATUS_CAP_LIST 0x10 /* Support Capability List */
  26496. +#define PCI_STATUS_66MHZ 0x20 /* Support 66 Mhz PCI 2.1 bus */
  26497. +#define PCI_STATUS_UDF 0x40 /* Support User Definable Features [obsolete] */
  26498. +#define PCI_STATUS_FAST_BACK 0x80 /* Accept fast-back to back */
  26499. +#define PCI_STATUS_PARITY 0x100 /* Detected parity error */
  26500. +#define PCI_STATUS_DEVSEL_MASK 0x600 /* DEVSEL timing */
  26501. +#define PCI_STATUS_DEVSEL_FAST 0x000
  26502. +#define PCI_STATUS_DEVSEL_MEDIUM 0x200
  26503. +#define PCI_STATUS_DEVSEL_SLOW 0x400
  26504. +#define PCI_STATUS_SIG_TARGET_ABORT 0x800 /* Set on target abort */
  26505. +#define PCI_STATUS_REC_TARGET_ABORT 0x1000 /* Master ack of " */
  26506. +#define PCI_STATUS_REC_MASTER_ABORT 0x2000 /* Set on master abort */
  26507. +#define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000 /* Set when we drive SERR */
  26508. +#define PCI_STATUS_DETECTED_PARITY 0x8000 /* Set on parity error */
  26509. +
  26510. #define PCI_REVISION 0x08 /* 8 bits */
  26511. +#define PCI_REVISION_ID 0x08 /* 8 bits */
  26512. +#define PCI_CLASS_REVISION 0x08 /* 32 bits */
  26513. #define PCI_CLASS_CODE 0x0b /* 8 bits */
  26514. #define PCI_SUBCLASS_CODE 0x0a /* 8 bits */
  26515. #define PCI_HEADER_TYPE 0x0e /* 8 bits */
  26516. +#define PCI_HEADER_TYPE_NORMAL 0
  26517. +#define PCI_HEADER_TYPE_BRIDGE 1
  26518. +#define PCI_HEADER_TYPE_CARDBUS 2
  26519. +
  26520. +
  26521. +/* Header type 0 (normal devices) */
  26522. +#define PCI_CARDBUS_CIS 0x28
  26523. +#define PCI_SUBSYSTEM_VENDOR_ID 0x2c
  26524. +#define PCI_SUBSYSTEM_ID 0x2e
  26525. #define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */
  26526. #define PCI_BASE_ADDRESS_1 0x14 /* 32 bits */
  26527. @@ -54,15 +90,155 @@
  26528. #define PCI_BASE_ADDRESS_4 0x20 /* 32 bits */
  26529. #define PCI_BASE_ADDRESS_5 0x24 /* 32 bits */
  26530. +#define PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06
  26531. +#define PCI_BASE_ADDRESS_MEM_TYPE_32 0x00 /* 32 bit address */
  26532. +#define PCI_BASE_ADDRESS_MEM_TYPE_1M 0x02 /* Below 1M [obsolete] */
  26533. +#define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04 /* 64 bit address */
  26534. +
  26535. #ifndef PCI_BASE_ADDRESS_IO_MASK
  26536. #define PCI_BASE_ADDRESS_IO_MASK (~0x03)
  26537. #endif
  26538. +#ifndef PCI_BASE_ADDRESS_MEM_MASK
  26539. +#define PCI_BASE_ADDRESS_MEM_MASK (~0x0f)
  26540. +#endif
  26541. #define PCI_BASE_ADDRESS_SPACE_IO 0x01
  26542. #define PCI_ROM_ADDRESS 0x30 /* 32 bits */
  26543. #define PCI_ROM_ADDRESS_ENABLE 0x01 /* Write 1 to enable ROM,
  26544. bits 31..11 are address,
  26545. 10..2 are reserved */
  26546. +#define PCI_CAPABILITY_LIST 0x34 /* Offset of first capability list entry */
  26547. +
  26548. +#define PCI_INTERRUPT_LINE 0x3c /* IRQ number (0-15) */
  26549. +#define PCI_INTERRUPT_PIN 0x3d /* IRQ pin on PCI bus (A-D) */
  26550. +
  26551. +/* Header type 1 (PCI-to-PCI bridges) */
  26552. +#define PCI_PRIMARY_BUS 0x18 /* Primary bus number */
  26553. +#define PCI_SECONDARY_BUS 0x19 /* Secondary bus number */
  26554. +#define PCI_SUBORDINATE_BUS 0x1a /* Highest bus number behind the bridge */
  26555. +#define PCI_SEC_LATENCY_TIMER 0x1b /* Latency timer for secondary interface */
  26556. +#define PCI_IO_BASE 0x1c /* I/O range behind the bridge */
  26557. +#define PCI_IO_LIMIT 0x1d
  26558. +#define PCI_IO_RANGE_TYPE_MASK 0x0f /* I/O bridging type */
  26559. +#define PCI_IO_RANGE_TYPE_16 0x00
  26560. +#define PCI_IO_RANGE_TYPE_32 0x01
  26561. +#define PCI_IO_RANGE_MASK ~0x0f
  26562. +#define PCI_SEC_STATUS 0x1e /* Secondary status register, only bit 14 used */
  26563. +#define PCI_MEMORY_BASE 0x20 /* Memory range behind */
  26564. +#define PCI_MEMORY_LIMIT 0x22
  26565. +#define PCI_MEMORY_RANGE_TYPE_MASK 0x0f
  26566. +#define PCI_MEMORY_RANGE_MASK ~0x0f
  26567. +#define PCI_PREF_MEMORY_BASE 0x24 /* Prefetchable memory range behind */
  26568. +#define PCI_PREF_MEMORY_LIMIT 0x26
  26569. +#define PCI_PREF_RANGE_TYPE_MASK 0x0f
  26570. +#define PCI_PREF_RANGE_TYPE_32 0x00
  26571. +#define PCI_PREF_RANGE_TYPE_64 0x01
  26572. +#define PCI_PREF_RANGE_MASK ~0x0f
  26573. +#define PCI_PREF_BASE_UPPER32 0x28 /* Upper half of prefetchable memory range */
  26574. +#define PCI_PREF_LIMIT_UPPER32 0x2c
  26575. +#define PCI_IO_BASE_UPPER16 0x30 /* Upper half of I/O addresses */
  26576. +#define PCI_IO_LIMIT_UPPER16 0x32
  26577. +/* 0x34 same as for htype 0 */
  26578. +/* 0x35-0x3b is reserved */
  26579. +#define PCI_ROM_ADDRESS1 0x38 /* Same as PCI_ROM_ADDRESS, but for htype 1 */
  26580. +/* 0x3c-0x3d are same as for htype 0 */
  26581. +#define PCI_BRIDGE_CONTROL 0x3e
  26582. +#define PCI_BRIDGE_CTL_PARITY 0x01 /* Enable parity detection on secondary interface */
  26583. +#define PCI_BRIDGE_CTL_SERR 0x02 /* The same for SERR forwarding */
  26584. +#define PCI_BRIDGE_CTL_NO_ISA 0x04 /* Disable bridging of ISA ports */
  26585. +#define PCI_BRIDGE_CTL_VGA 0x08 /* Forward VGA addresses */
  26586. +#define PCI_BRIDGE_CTL_MASTER_ABORT 0x20 /* Report master aborts */
  26587. +#define PCI_BRIDGE_CTL_BUS_RESET 0x40 /* Secondary bus reset */
  26588. +#define PCI_BRIDGE_CTL_FAST_BACK 0x80 /* Fast Back2Back enabled on secondary interface */
  26589. +
  26590. +#define PCI_CB_CAPABILITY_LIST 0x14
  26591. +
  26592. +/* Capability lists */
  26593. +
  26594. +#define PCI_CAP_LIST_ID 0 /* Capability ID */
  26595. +#define PCI_CAP_ID_PM 0x01 /* Power Management */
  26596. +#define PCI_CAP_ID_AGP 0x02 /* Accelerated Graphics Port */
  26597. +#define PCI_CAP_ID_VPD 0x03 /* Vital Product Data */
  26598. +#define PCI_CAP_ID_SLOTID 0x04 /* Slot Identification */
  26599. +#define PCI_CAP_ID_MSI 0x05 /* Message Signalled Interrupts */
  26600. +#define PCI_CAP_ID_CHSWP 0x06 /* CompactPCI HotSwap */
  26601. +#define PCI_CAP_LIST_NEXT 1 /* Next capability in the list */
  26602. +#define PCI_CAP_FLAGS 2 /* Capability defined flags (16 bits) */
  26603. +#define PCI_CAP_SIZEOF 4
  26604. +
  26605. +/* Power Management Registers */
  26606. +
  26607. +#define PCI_PM_PMC 2 /* PM Capabilities Register */
  26608. +#define PCI_PM_CAP_VER_MASK 0x0007 /* Version */
  26609. +#define PCI_PM_CAP_PME_CLOCK 0x0008 /* PME clock required */
  26610. +#define PCI_PM_CAP_RESERVED 0x0010 /* Reserved field */
  26611. +#define PCI_PM_CAP_DSI 0x0020 /* Device specific initialization */
  26612. +#define PCI_PM_CAP_AUX_POWER 0x01C0 /* Auxilliary power support mask */
  26613. +#define PCI_PM_CAP_D1 0x0200 /* D1 power state support */
  26614. +#define PCI_PM_CAP_D2 0x0400 /* D2 power state support */
  26615. +#define PCI_PM_CAP_PME 0x0800 /* PME pin supported */
  26616. +#define PCI_PM_CAP_PME_MASK 0xF800 /* PME Mask of all supported states */
  26617. +#define PCI_PM_CAP_PME_D0 0x0800 /* PME# from D0 */
  26618. +#define PCI_PM_CAP_PME_D1 0x1000 /* PME# from D1 */
  26619. +#define PCI_PM_CAP_PME_D2 0x2000 /* PME# from D2 */
  26620. +#define PCI_PM_CAP_PME_D3 0x4000 /* PME# from D3 (hot) */
  26621. +#define PCI_PM_CAP_PME_D3cold 0x8000 /* PME# from D3 (cold) */
  26622. +#define PCI_PM_CTRL 4 /* PM control and status register */
  26623. +#define PCI_PM_CTRL_STATE_MASK 0x0003 /* Current power state (D0 to D3) */
  26624. +#define PCI_PM_CTRL_PME_ENABLE 0x0100 /* PME pin enable */
  26625. +#define PCI_PM_CTRL_DATA_SEL_MASK 0x1e00 /* Data select (??) */
  26626. +#define PCI_PM_CTRL_DATA_SCALE_MASK 0x6000 /* Data scale (??) */
  26627. +#define PCI_PM_CTRL_PME_STATUS 0x8000 /* PME pin status */
  26628. +#define PCI_PM_PPB_EXTENSIONS 6 /* PPB support extensions (??) */
  26629. +#define PCI_PM_PPB_B2_B3 0x40 /* Stop clock when in D3hot (??) */
  26630. +#define PCI_PM_BPCC_ENABLE 0x80 /* Bus power/clock control enable (??) */
  26631. +#define PCI_PM_DATA_REGISTER 7 /* (??) */
  26632. +#define PCI_PM_SIZEOF 8
  26633. +
  26634. +/* AGP registers */
  26635. +
  26636. +#define PCI_AGP_VERSION 2 /* BCD version number */
  26637. +#define PCI_AGP_RFU 3 /* Rest of capability flags */
  26638. +#define PCI_AGP_STATUS 4 /* Status register */
  26639. +#define PCI_AGP_STATUS_RQ_MASK 0xff000000 /* Maximum number of requests - 1 */
  26640. +#define PCI_AGP_STATUS_SBA 0x0200 /* Sideband addressing supported */
  26641. +#define PCI_AGP_STATUS_64BIT 0x0020 /* 64-bit addressing supported */
  26642. +#define PCI_AGP_STATUS_FW 0x0010 /* FW transfers supported */
  26643. +#define PCI_AGP_STATUS_RATE4 0x0004 /* 4x transfer rate supported */
  26644. +#define PCI_AGP_STATUS_RATE2 0x0002 /* 2x transfer rate supported */
  26645. +#define PCI_AGP_STATUS_RATE1 0x0001 /* 1x transfer rate supported */
  26646. +#define PCI_AGP_COMMAND 8 /* Control register */
  26647. +#define PCI_AGP_COMMAND_RQ_MASK 0xff000000 /* Master: Maximum number of requests */
  26648. +#define PCI_AGP_COMMAND_SBA 0x0200 /* Sideband addressing enabled */
  26649. +#define PCI_AGP_COMMAND_AGP 0x0100 /* Allow processing of AGP transactions */
  26650. +#define PCI_AGP_COMMAND_64BIT 0x0020 /* Allow processing of 64-bit addresses */
  26651. +#define PCI_AGP_COMMAND_FW 0x0010 /* Force FW transfers */
  26652. +#define PCI_AGP_COMMAND_RATE4 0x0004 /* Use 4x rate */
  26653. +#define PCI_AGP_COMMAND_RATE2 0x0002 /* Use 2x rate */
  26654. +#define PCI_AGP_COMMAND_RATE1 0x0001 /* Use 1x rate */
  26655. +#define PCI_AGP_SIZEOF 12
  26656. +
  26657. +/* Slot Identification */
  26658. +
  26659. +#define PCI_SID_ESR 2 /* Expansion Slot Register */
  26660. +#define PCI_SID_ESR_NSLOTS 0x1f /* Number of expansion slots available */
  26661. +#define PCI_SID_ESR_FIC 0x20 /* First In Chassis Flag */
  26662. +#define PCI_SID_CHASSIS_NR 3 /* Chassis Number */
  26663. +
  26664. +/* Message Signalled Interrupts registers */
  26665. +
  26666. +#define PCI_MSI_FLAGS 2 /* Various flags */
  26667. +#define PCI_MSI_FLAGS_64BIT 0x80 /* 64-bit addresses allowed */
  26668. +#define PCI_MSI_FLAGS_QSIZE 0x70 /* Message queue size configured */
  26669. +#define PCI_MSI_FLAGS_QMASK 0x0e /* Maximum queue size available */
  26670. +#define PCI_MSI_FLAGS_ENABLE 0x01 /* MSI feature enabled */
  26671. +#define PCI_MSI_RFU 3 /* Rest of capability flags */
  26672. +#define PCI_MSI_ADDRESS_LO 4 /* Lower 32 bits */
  26673. +#define PCI_MSI_ADDRESS_HI 8 /* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */
  26674. +#define PCI_MSI_DATA_32 8 /* 16 bits of data for 32-bit devices */
  26675. +#define PCI_MSI_DATA_64 12 /* 16 bits of data for 64-bit devices */
  26676. +
  26677. +#define PCI_SLOT(devfn) ((devfn) >> 3)
  26678. #define PCI_FUNC(devfn) ((devfn) & 0x07)
  26679. #define BIOS32_SIGNATURE (('_' << 0) + ('3' << 8) + ('2' << 16) + ('_' << 24))
  26680. @@ -85,108 +261,97 @@
  26681. char chars[16];
  26682. };
  26683. -#define KERN_CODE_SEG 0x8 /* This _MUST_ match start.S */
  26684. -
  26685. -/* Stuff for asm */
  26686. -#define save_flags(x) \
  26687. -__asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */ :"memory")
  26688. -
  26689. -#define cli() __asm__ __volatile__ ("cli": : :"memory")
  26690. -
  26691. -#define restore_flags(x) \
  26692. -__asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory")
  26693. -
  26694. -#define PCI_VENDOR_ID_ADMTEK 0x1317
  26695. -#define PCI_DEVICE_ID_ADMTEK_0985 0x0985
  26696. -#define PCI_VENDOR_ID_REALTEK 0x10ec
  26697. -#define PCI_DEVICE_ID_REALTEK_8029 0x8029
  26698. -#define PCI_DEVICE_ID_REALTEK_8139 0x8139
  26699. -#define PCI_VENDOR_ID_WINBOND2 0x1050
  26700. -#define PCI_DEVICE_ID_WINBOND2_89C940 0x0940
  26701. -#define PCI_DEVICE_ID_WINBOND2_89C840 0x0840
  26702. -#define PCI_VENDOR_ID_COMPEX 0x11f6
  26703. -#define PCI_DEVICE_ID_COMPEX_RL2000 0x1401
  26704. -#define PCI_DEVICE_ID_COMPEX_RL100ATX 0x2011
  26705. -#define PCI_VENDOR_ID_KTI 0x8e2e
  26706. -#define PCI_DEVICE_ID_KTI_ET32P2 0x3000
  26707. -#define PCI_VENDOR_ID_NETVIN 0x4a14
  26708. -#define PCI_DEVICE_ID_NETVIN_NV5000SC 0x5000
  26709. -#define PCI_VENDOR_ID_HOLTEK 0x12c3
  26710. -#define PCI_DEVICE_ID_HOLTEK_HT80232 0x0058
  26711. -#define PCI_VENDOR_ID_3COM 0x10b7
  26712. -#define PCI_DEVICE_ID_3COM_3C590 0x5900
  26713. -#define PCI_DEVICE_ID_3COM_3C595 0x5950
  26714. -#define PCI_DEVICE_ID_3COM_3C595_1 0x5951
  26715. -#define PCI_DEVICE_ID_3COM_3C595_2 0x5952
  26716. -#define PCI_DEVICE_ID_3COM_3C900TPO 0x9000
  26717. -#define PCI_DEVICE_ID_3COM_3C900COMBO 0x9001
  26718. -#define PCI_DEVICE_ID_3COM_3C905TX 0x9050
  26719. -#define PCI_DEVICE_ID_3COM_3C905T4 0x9051
  26720. -#define PCI_DEVICE_ID_3COM_3C905B_TX 0x9055
  26721. -#define PCI_DEVICE_ID_3COM_3C905C_TXM 0x9200
  26722. -#define PCI_VENDOR_ID_INTEL 0x8086
  26723. -#define PCI_DEVICE_ID_INTEL_82557 0x1229
  26724. -#define PCI_DEVICE_ID_INTEL_82559ER 0x1209
  26725. -#define PCI_DEVICE_ID_INTEL_ID1029 0x1029
  26726. -#define PCI_DEVICE_ID_INTEL_ID1030 0x1030
  26727. -#define PCI_DEVICE_ID_INTEL_82562 0x2449
  26728. -#define PCI_VENDOR_ID_AMD 0x1022
  26729. -#define PCI_DEVICE_ID_AMD_LANCE 0x2000
  26730. -#define PCI_VENDOR_ID_AMD_HOMEPNA 0x1022
  26731. -#define PCI_DEVICE_ID_AMD_HOMEPNA 0x2001
  26732. -#define PCI_VENDOR_ID_SMC_1211 0x1113
  26733. -#define PCI_DEVICE_ID_SMC_1211 0x1211
  26734. -#define PCI_VENDOR_ID_DEC 0x1011
  26735. -#define PCI_DEVICE_ID_DEC_TULIP 0x0002
  26736. -#define PCI_DEVICE_ID_DEC_TULIP_FAST 0x0009
  26737. -#define PCI_DEVICE_ID_DEC_TULIP_PLUS 0x0014
  26738. -#define PCI_DEVICE_ID_DEC_21142 0x0019
  26739. -#define PCI_VENDOR_ID_SMC 0x10B8
  26740. -#ifndef PCI_DEVICE_ID_SMC_EPIC100
  26741. -# define PCI_DEVICE_ID_SMC_EPIC100 0x0005
  26742. -#endif
  26743. -#define PCI_VENDOR_ID_MACRONIX 0x10d9
  26744. -#define PCI_DEVICE_ID_MX987x5 0x0531
  26745. -#define PCI_VENDOR_ID_LINKSYS 0x11AD
  26746. -#define PCI_DEVICE_ID_LC82C115 0xC115
  26747. -#define PCI_VENDOR_ID_VIATEC 0x1106
  26748. -#define PCI_DEVICE_ID_VIA_RHINE_I 0x3043
  26749. -#define PCI_DEVICE_ID_VIA_VT6102 0x3065
  26750. -#define PCI_DEVICE_ID_VIA_86C100A 0x6100
  26751. -#define PCI_VENDOR_ID_DAVICOM 0x1282
  26752. -#define PCI_DEVICE_ID_DM9009 0x9009
  26753. -#define PCI_DEVICE_ID_DM9102 0x9102
  26754. -#define PCI_VENDOR_ID_SIS 0x1039
  26755. -#define PCI_DEVICE_ID_SIS900 0x0900
  26756. -#define PCI_DEVICE_ID_SIS7016 0x7016
  26757. -#define PCI_VENDOR_ID_DLINK 0x1186
  26758. -#define PCI_DEVICE_ID_DFE530TXP 0x1300
  26759. -#define PCI_VENDOR_ID_NS 0x100B
  26760. -#define PCI_DEVICE_ID_DP83815 0x0020
  26761. -#define PCI_VENDOR_ID_OLICOM 0x108d
  26762. -#define PCI_DEVICE_ID_OLICOM_OC3136 0x0001
  26763. -#define PCI_DEVICE_ID_OLICOM_OC2315 0x0011
  26764. -#define PCI_DEVICE_ID_OLICOM_OC2325 0x0012
  26765. -#define PCI_DEVICE_ID_OLICOM_OC2183 0x0013
  26766. -#define PCI_DEVICE_ID_OLICOM_OC2326 0x0014
  26767. -#define PCI_DEVICE_ID_OLICOM_OC6151 0x0021
  26768. +struct pci_device;
  26769. +struct dev;
  26770. +typedef int (*pci_probe_t)(struct dev *, struct pci_device *);
  26771. struct pci_device {
  26772. - unsigned short vendor, dev_id;
  26773. - const char *name;
  26774. - unsigned int membase;
  26775. - unsigned short ioaddr;
  26776. - unsigned char devfn;
  26777. - unsigned char bus;
  26778. + uint32_t class;
  26779. + uint16_t vendor, dev_id;
  26780. + const char *name;
  26781. + /* membase and ioaddr are silly and depricated */
  26782. + unsigned int membase;
  26783. + unsigned int ioaddr;
  26784. + unsigned int romaddr;
  26785. + unsigned char irq;
  26786. + unsigned char devfn;
  26787. + unsigned char bus;
  26788. + unsigned char use_specified;
  26789. + const struct pci_driver *driver;
  26790. +};
  26791. +
  26792. +extern void scan_pci_bus(int type, struct pci_device *dev);
  26793. +extern void find_pci(int type, struct pci_device *dev);
  26794. +
  26795. +extern int pcibios_read_config_byte(unsigned int bus, unsigned int device_fn, unsigned int where, uint8_t *value);
  26796. +extern int pcibios_write_config_byte (unsigned int bus, unsigned int device_fn, unsigned int where, uint8_t value);
  26797. +extern int pcibios_read_config_word(unsigned int bus, unsigned int device_fn, unsigned int where, uint16_t *value);
  26798. +extern int pcibios_write_config_word (unsigned int bus, unsigned int device_fn, unsigned int where, uint16_t value);
  26799. +extern int pcibios_read_config_dword(unsigned int bus, unsigned int device_fn, unsigned int where, uint32_t *value);
  26800. +extern int pcibios_write_config_dword(unsigned int bus, unsigned int device_fn, unsigned int where, uint32_t value);
  26801. +extern unsigned long pcibios_bus_base(unsigned int bus);
  26802. +extern void adjust_pci_device(struct pci_device *p);
  26803. +
  26804. +
  26805. +static inline int
  26806. +pci_read_config_byte(struct pci_device *dev, unsigned int where, uint8_t *value)
  26807. +{
  26808. + return pcibios_read_config_byte(dev->bus, dev->devfn, where, value);
  26809. +}
  26810. +static inline int
  26811. +pci_write_config_byte(struct pci_device *dev, unsigned int where, uint8_t value)
  26812. +{
  26813. + return pcibios_write_config_byte(dev->bus, dev->devfn, where, value);
  26814. +}
  26815. +static inline int
  26816. +pci_read_config_word(struct pci_device *dev, unsigned int where, uint16_t *value)
  26817. +{
  26818. + return pcibios_read_config_word(dev->bus, dev->devfn, where, value);
  26819. +}
  26820. +static inline int
  26821. +pci_write_config_word(struct pci_device *dev, unsigned int where, uint16_t value)
  26822. +{
  26823. + return pcibios_write_config_word(dev->bus, dev->devfn, where, value);
  26824. +}
  26825. +static inline int
  26826. +pci_read_config_dword(struct pci_device *dev, unsigned int where, uint32_t *value)
  26827. +{
  26828. + return pcibios_read_config_dword(dev->bus, dev->devfn, where, value);
  26829. +}
  26830. +static inline int
  26831. +pci_write_config_dword(struct pci_device *dev, unsigned int where, uint32_t value)
  26832. +{
  26833. + return pcibios_write_config_dword(dev->bus, dev->devfn, where, value);
  26834. +}
  26835. +
  26836. +/* Helper functions to find the size of a pci bar */
  26837. +extern unsigned long pci_bar_start(struct pci_device *dev, unsigned int bar);
  26838. +extern unsigned long pci_bar_size(struct pci_device *dev, unsigned int bar);
  26839. +/* Helper function to find pci capabilities */
  26840. +extern int pci_find_capability(struct pci_device *dev, int cap);
  26841. +struct pci_id {
  26842. + unsigned short vendor, dev_id;
  26843. + const char *name;
  26844. +};
  26845. +
  26846. +struct dev;
  26847. +/* Most pci drivers will use this */
  26848. +struct pci_driver {
  26849. + int type;
  26850. + const char *name;
  26851. + pci_probe_t probe;
  26852. + struct pci_id *ids;
  26853. + int id_count;
  26854. +
  26855. +/* On a few occasions the hardware is standardized enough that
  26856. + * we only need to know the class of the device and not the exact
  26857. + * type to drive the device correctly. If this is the case
  26858. + * set a class value other than 0.
  26859. + */
  26860. + unsigned short class;
  26861. };
  26862. -extern void eth_pci_init(struct pci_device *);
  26863. +#define PCI_ROM(VENDOR_ID, DEVICE_ID, IMAGE, DESCRIPTION) \
  26864. + { VENDOR_ID, DEVICE_ID, IMAGE, }
  26865. -extern int pcibios_read_config_byte(unsigned int bus, unsigned int device_fn, unsigned int where, unsigned char *value);
  26866. -extern int pcibios_write_config_byte (unsigned int bus, unsigned int device_fn, unsigned int where, unsigned char value);
  26867. -extern int pcibios_read_config_word(unsigned int bus, unsigned int device_fn, unsigned int where, unsigned short *value);
  26868. -extern int pcibios_write_config_word (unsigned int bus, unsigned int device_fn, unsigned int where, unsigned short value);
  26869. -extern int pcibios_read_config_dword(unsigned int bus, unsigned int device_fn, unsigned int where, unsigned int *value);
  26870. -extern int pcibios_write_config_dword(unsigned int bus, unsigned int device_fn, unsigned int where, unsigned int value);
  26871. -void adjust_pci_device(struct pci_device *p);
  26872. #endif /* PCI_H */
  26873. diff -Naur grub-0.97.orig/netboot/pci_ids.h grub-0.97/netboot/pci_ids.h
  26874. --- grub-0.97.orig/netboot/pci_ids.h 1970-01-01 00:00:00.000000000 +0000
  26875. +++ grub-0.97/netboot/pci_ids.h 2005-08-31 19:03:35.000000000 +0000
  26876. @@ -0,0 +1,1809 @@
  26877. +/*
  26878. + * PCI Class, Vendor and Device IDs
  26879. + *
  26880. + * Please keep sorted.
  26881. + */
  26882. +
  26883. +/* Device classes and subclasses */
  26884. +
  26885. +#define PCI_CLASS_NOT_DEFINED 0x0000
  26886. +#define PCI_CLASS_NOT_DEFINED_VGA 0x0001
  26887. +
  26888. +#define PCI_BASE_CLASS_STORAGE 0x01
  26889. +#define PCI_CLASS_STORAGE_SCSI 0x0100
  26890. +#define PCI_CLASS_STORAGE_IDE 0x0101
  26891. +#define PCI_CLASS_STORAGE_FLOPPY 0x0102
  26892. +#define PCI_CLASS_STORAGE_IPI 0x0103
  26893. +#define PCI_CLASS_STORAGE_RAID 0x0104
  26894. +#define PCI_CLASS_STORAGE_OTHER 0x0180
  26895. +
  26896. +#define PCI_BASE_CLASS_NETWORK 0x02
  26897. +#define PCI_CLASS_NETWORK_ETHERNET 0x0200
  26898. +#define PCI_CLASS_NETWORK_TOKEN_RING 0x0201
  26899. +#define PCI_CLASS_NETWORK_FDDI 0x0202
  26900. +#define PCI_CLASS_NETWORK_ATM 0x0203
  26901. +#define PCI_CLASS_NETWORK_OTHER 0x0280
  26902. +
  26903. +#define PCI_BASE_CLASS_DISPLAY 0x03
  26904. +#define PCI_CLASS_DISPLAY_VGA 0x0300
  26905. +#define PCI_CLASS_DISPLAY_XGA 0x0301
  26906. +#define PCI_CLASS_DISPLAY_3D 0x0302
  26907. +#define PCI_CLASS_DISPLAY_OTHER 0x0380
  26908. +
  26909. +#define PCI_BASE_CLASS_MULTIMEDIA 0x04
  26910. +#define PCI_CLASS_MULTIMEDIA_VIDEO 0x0400
  26911. +#define PCI_CLASS_MULTIMEDIA_AUDIO 0x0401
  26912. +#define PCI_CLASS_MULTIMEDIA_PHONE 0x0402
  26913. +#define PCI_CLASS_MULTIMEDIA_OTHER 0x0480
  26914. +
  26915. +#define PCI_BASE_CLASS_MEMORY 0x05
  26916. +#define PCI_CLASS_MEMORY_RAM 0x0500
  26917. +#define PCI_CLASS_MEMORY_FLASH 0x0501
  26918. +#define PCI_CLASS_MEMORY_OTHER 0x0580
  26919. +
  26920. +#define PCI_BASE_CLASS_BRIDGE 0x06
  26921. +#define PCI_CLASS_BRIDGE_HOST 0x0600
  26922. +#define PCI_CLASS_BRIDGE_ISA 0x0601
  26923. +#define PCI_CLASS_BRIDGE_EISA 0x0602
  26924. +#define PCI_CLASS_BRIDGE_MC 0x0603
  26925. +#define PCI_CLASS_BRIDGE_PCI 0x0604
  26926. +#define PCI_CLASS_BRIDGE_PCMCIA 0x0605
  26927. +#define PCI_CLASS_BRIDGE_NUBUS 0x0606
  26928. +#define PCI_CLASS_BRIDGE_CARDBUS 0x0607
  26929. +#define PCI_CLASS_BRIDGE_RACEWAY 0x0608
  26930. +#define PCI_CLASS_BRIDGE_OTHER 0x0680
  26931. +
  26932. +#define PCI_BASE_CLASS_COMMUNICATION 0x07
  26933. +#define PCI_CLASS_COMMUNICATION_SERIAL 0x0700
  26934. +#define PCI_CLASS_COMMUNICATION_PARALLEL 0x0701
  26935. +#define PCI_CLASS_COMMUNICATION_MULTISERIAL 0x0702
  26936. +#define PCI_CLASS_COMMUNICATION_MODEM 0x0703
  26937. +#define PCI_CLASS_COMMUNICATION_OTHER 0x0780
  26938. +
  26939. +#define PCI_BASE_CLASS_SYSTEM 0x08
  26940. +#define PCI_CLASS_SYSTEM_PIC 0x0800
  26941. +#define PCI_CLASS_SYSTEM_DMA 0x0801
  26942. +#define PCI_CLASS_SYSTEM_TIMER 0x0802
  26943. +#define PCI_CLASS_SYSTEM_RTC 0x0803
  26944. +#define PCI_CLASS_SYSTEM_PCI_HOTPLUG 0x0804
  26945. +#define PCI_CLASS_SYSTEM_OTHER 0x0880
  26946. +
  26947. +#define PCI_BASE_CLASS_INPUT 0x09
  26948. +#define PCI_CLASS_INPUT_KEYBOARD 0x0900
  26949. +#define PCI_CLASS_INPUT_PEN 0x0901
  26950. +#define PCI_CLASS_INPUT_MOUSE 0x0902
  26951. +#define PCI_CLASS_INPUT_SCANNER 0x0903
  26952. +#define PCI_CLASS_INPUT_GAMEPORT 0x0904
  26953. +#define PCI_CLASS_INPUT_OTHER 0x0980
  26954. +
  26955. +#define PCI_BASE_CLASS_DOCKING 0x0a
  26956. +#define PCI_CLASS_DOCKING_GENERIC 0x0a00
  26957. +#define PCI_CLASS_DOCKING_OTHER 0x0a80
  26958. +
  26959. +#define PCI_BASE_CLASS_PROCESSOR 0x0b
  26960. +#define PCI_CLASS_PROCESSOR_386 0x0b00
  26961. +#define PCI_CLASS_PROCESSOR_486 0x0b01
  26962. +#define PCI_CLASS_PROCESSOR_PENTIUM 0x0b02
  26963. +#define PCI_CLASS_PROCESSOR_ALPHA 0x0b10
  26964. +#define PCI_CLASS_PROCESSOR_POWERPC 0x0b20
  26965. +#define PCI_CLASS_PROCESSOR_MIPS 0x0b30
  26966. +#define PCI_CLASS_PROCESSOR_CO 0x0b40
  26967. +
  26968. +#define PCI_BASE_CLASS_SERIAL 0x0c
  26969. +#define PCI_CLASS_SERIAL_FIREWIRE 0x0c00
  26970. +#define PCI_CLASS_SERIAL_ACCESS 0x0c01
  26971. +#define PCI_CLASS_SERIAL_SSA 0x0c02
  26972. +#define PCI_CLASS_SERIAL_USB 0x0c03
  26973. +#define PCI_CLASS_SERIAL_FIBER 0x0c04
  26974. +#define PCI_CLASS_SERIAL_SMBUS 0x0c05
  26975. +
  26976. +#define PCI_BASE_CLASS_INTELLIGENT 0x0e
  26977. +#define PCI_CLASS_INTELLIGENT_I2O 0x0e00
  26978. +
  26979. +#define PCI_BASE_CLASS_SATELLITE 0x0f
  26980. +#define PCI_CLASS_SATELLITE_TV 0x0f00
  26981. +#define PCI_CLASS_SATELLITE_AUDIO 0x0f01
  26982. +#define PCI_CLASS_SATELLITE_VOICE 0x0f03
  26983. +#define PCI_CLASS_SATELLITE_DATA 0x0f04
  26984. +
  26985. +#define PCI_BASE_CLASS_CRYPT 0x10
  26986. +#define PCI_CLASS_CRYPT_NETWORK 0x1000
  26987. +#define PCI_CLASS_CRYPT_ENTERTAINMENT 0x1001
  26988. +#define PCI_CLASS_CRYPT_OTHER 0x1080
  26989. +
  26990. +#define PCI_BASE_CLASS_SIGNAL_PROCESSING 0x11
  26991. +#define PCI_CLASS_SP_DPIO 0x1100
  26992. +#define PCI_CLASS_SP_OTHER 0x1180
  26993. +
  26994. +#define PCI_CLASS_OTHERS 0xff
  26995. +
  26996. +/* Vendors and devices. Sort key: vendor first, device next. */
  26997. +
  26998. +#define PCI_VENDOR_ID_DYNALINK 0x0675
  26999. +#define PCI_DEVICE_ID_DYNALINK_IS64PH 0x1702
  27000. +
  27001. +#define PCI_VENDOR_ID_BERKOM 0x0871
  27002. +#define PCI_DEVICE_ID_BERKOM_A1T 0xffa1
  27003. +#define PCI_DEVICE_ID_BERKOM_T_CONCEPT 0xffa2
  27004. +#define PCI_DEVICE_ID_BERKOM_A4T 0xffa4
  27005. +#define PCI_DEVICE_ID_BERKOM_SCITEL_QUADRO 0xffa8
  27006. +
  27007. +#define PCI_VENDOR_ID_COMPAQ 0x0e11
  27008. +#define PCI_DEVICE_ID_COMPAQ_TOKENRING 0x0508
  27009. +#define PCI_DEVICE_ID_COMPAQ_1280 0x3033
  27010. +#define PCI_DEVICE_ID_COMPAQ_TRIFLEX 0x4000
  27011. +#define PCI_DEVICE_ID_COMPAQ_6010 0x6010
  27012. +#define PCI_DEVICE_ID_COMPAQ_SMART2P 0xae10
  27013. +#define PCI_DEVICE_ID_COMPAQ_NETEL100 0xae32
  27014. +#define PCI_DEVICE_ID_COMPAQ_NETEL10 0xae34
  27015. +#define PCI_DEVICE_ID_COMPAQ_NETFLEX3I 0xae35
  27016. +#define PCI_DEVICE_ID_COMPAQ_NETEL100D 0xae40
  27017. +#define PCI_DEVICE_ID_COMPAQ_NETEL100PI 0xae43
  27018. +#define PCI_DEVICE_ID_COMPAQ_NETEL100I 0xb011
  27019. +#define PCI_DEVICE_ID_COMPAQ_CISS 0xb060
  27020. +#define PCI_DEVICE_ID_COMPAQ_CISSB 0xb178
  27021. +#define PCI_DEVICE_ID_COMPAQ_THUNDER 0xf130
  27022. +#define PCI_DEVICE_ID_COMPAQ_NETFLEX3B 0xf150
  27023. +
  27024. +#define PCI_VENDOR_ID_NCR 0x1000
  27025. +#define PCI_VENDOR_ID_LSI_LOGIC 0x1000
  27026. +#define PCI_DEVICE_ID_NCR_53C810 0x0001
  27027. +#define PCI_DEVICE_ID_NCR_53C820 0x0002
  27028. +#define PCI_DEVICE_ID_NCR_53C825 0x0003
  27029. +#define PCI_DEVICE_ID_NCR_53C815 0x0004
  27030. +#define PCI_DEVICE_ID_LSI_53C810AP 0x0005
  27031. +#define PCI_DEVICE_ID_NCR_53C860 0x0006
  27032. +#define PCI_DEVICE_ID_LSI_53C1510 0x000a
  27033. +#define PCI_DEVICE_ID_NCR_53C896 0x000b
  27034. +#define PCI_DEVICE_ID_NCR_53C895 0x000c
  27035. +#define PCI_DEVICE_ID_NCR_53C885 0x000d
  27036. +#define PCI_DEVICE_ID_NCR_53C875 0x000f
  27037. +#define PCI_DEVICE_ID_NCR_53C1510 0x0010
  27038. +#define PCI_DEVICE_ID_LSI_53C895A 0x0012
  27039. +#define PCI_DEVICE_ID_LSI_53C875A 0x0013
  27040. +#define PCI_DEVICE_ID_LSI_53C1010_33 0x0020
  27041. +#define PCI_DEVICE_ID_LSI_53C1010_66 0x0021
  27042. +#define PCI_DEVICE_ID_LSI_53C1030 0x0030
  27043. +#define PCI_DEVICE_ID_LSI_53C1035 0x0040
  27044. +#define PCI_DEVICE_ID_NCR_53C875J 0x008f
  27045. +#define PCI_DEVICE_ID_LSI_FC909 0x0621
  27046. +#define PCI_DEVICE_ID_LSI_FC929 0x0622
  27047. +#define PCI_DEVICE_ID_LSI_FC929_LAN 0x0623
  27048. +#define PCI_DEVICE_ID_LSI_FC919 0x0624
  27049. +#define PCI_DEVICE_ID_LSI_FC919_LAN 0x0625
  27050. +#define PCI_DEVICE_ID_NCR_YELLOWFIN 0x0701
  27051. +#define PCI_DEVICE_ID_LSI_61C102 0x0901
  27052. +#define PCI_DEVICE_ID_LSI_63C815 0x1000
  27053. +
  27054. +#define PCI_VENDOR_ID_ATI 0x1002
  27055. +/* Mach64 */
  27056. +#define PCI_DEVICE_ID_ATI_68800 0x4158
  27057. +#define PCI_DEVICE_ID_ATI_215CT222 0x4354
  27058. +#define PCI_DEVICE_ID_ATI_210888CX 0x4358
  27059. +#define PCI_DEVICE_ID_ATI_215ET222 0x4554
  27060. +/* Mach64 / Rage */
  27061. +#define PCI_DEVICE_ID_ATI_215GB 0x4742
  27062. +#define PCI_DEVICE_ID_ATI_215GD 0x4744
  27063. +#define PCI_DEVICE_ID_ATI_215GI 0x4749
  27064. +#define PCI_DEVICE_ID_ATI_215GP 0x4750
  27065. +#define PCI_DEVICE_ID_ATI_215GQ 0x4751
  27066. +#define PCI_DEVICE_ID_ATI_215XL 0x4752
  27067. +#define PCI_DEVICE_ID_ATI_215GT 0x4754
  27068. +#define PCI_DEVICE_ID_ATI_215GTB 0x4755
  27069. +#define PCI_DEVICE_ID_ATI_215_IV 0x4756
  27070. +#define PCI_DEVICE_ID_ATI_215_IW 0x4757
  27071. +#define PCI_DEVICE_ID_ATI_215_IZ 0x475A
  27072. +#define PCI_DEVICE_ID_ATI_210888GX 0x4758
  27073. +#define PCI_DEVICE_ID_ATI_215_LB 0x4c42
  27074. +#define PCI_DEVICE_ID_ATI_215_LD 0x4c44
  27075. +#define PCI_DEVICE_ID_ATI_215_LG 0x4c47
  27076. +#define PCI_DEVICE_ID_ATI_215_LI 0x4c49
  27077. +#define PCI_DEVICE_ID_ATI_215_LM 0x4c4D
  27078. +#define PCI_DEVICE_ID_ATI_215_LN 0x4c4E
  27079. +#define PCI_DEVICE_ID_ATI_215_LR 0x4c52
  27080. +#define PCI_DEVICE_ID_ATI_215_LS 0x4c53
  27081. +#define PCI_DEVICE_ID_ATI_264_LT 0x4c54
  27082. +/* Mach64 VT */
  27083. +#define PCI_DEVICE_ID_ATI_264VT 0x5654
  27084. +#define PCI_DEVICE_ID_ATI_264VU 0x5655
  27085. +#define PCI_DEVICE_ID_ATI_264VV 0x5656
  27086. +/* Rage128 Pro GL */
  27087. +#define PCI_DEVICE_ID_ATI_Rage128_PA 0x5041
  27088. +#define PCI_DEVICE_ID_ATI_Rage128_PB 0x5042
  27089. +#define PCI_DEVICE_ID_ATI_Rage128_PC 0x5043
  27090. +#define PCI_DEVICE_ID_ATI_Rage128_PD 0x5044
  27091. +#define PCI_DEVICE_ID_ATI_Rage128_PE 0x5045
  27092. +#define PCI_DEVICE_ID_ATI_RAGE128_PF 0x5046
  27093. +/* Rage128 Pro VR */
  27094. +#define PCI_DEVICE_ID_ATI_RAGE128_PG 0x5047
  27095. +#define PCI_DEVICE_ID_ATI_RAGE128_PH 0x5048
  27096. +#define PCI_DEVICE_ID_ATI_RAGE128_PI 0x5049
  27097. +#define PCI_DEVICE_ID_ATI_RAGE128_PJ 0x504A
  27098. +#define PCI_DEVICE_ID_ATI_RAGE128_PK 0x504B
  27099. +#define PCI_DEVICE_ID_ATI_RAGE128_PL 0x504C
  27100. +#define PCI_DEVICE_ID_ATI_RAGE128_PM 0x504D
  27101. +#define PCI_DEVICE_ID_ATI_RAGE128_PN 0x504E
  27102. +#define PCI_DEVICE_ID_ATI_RAGE128_PO 0x504F
  27103. +#define PCI_DEVICE_ID_ATI_RAGE128_PP 0x5050
  27104. +#define PCI_DEVICE_ID_ATI_RAGE128_PQ 0x5051
  27105. +#define PCI_DEVICE_ID_ATI_RAGE128_PR 0x5052
  27106. +#define PCI_DEVICE_ID_ATI_RAGE128_TR 0x5452
  27107. +#define PCI_DEVICE_ID_ATI_RAGE128_PS 0x5053
  27108. +#define PCI_DEVICE_ID_ATI_RAGE128_PT 0x5054
  27109. +#define PCI_DEVICE_ID_ATI_RAGE128_PU 0x5055
  27110. +#define PCI_DEVICE_ID_ATI_RAGE128_PV 0x5056
  27111. +#define PCI_DEVICE_ID_ATI_RAGE128_PW 0x5057
  27112. +#define PCI_DEVICE_ID_ATI_RAGE128_PX 0x5058
  27113. +/* Rage128 GL */
  27114. +#define PCI_DEVICE_ID_ATI_RAGE128_RE 0x5245
  27115. +#define PCI_DEVICE_ID_ATI_RAGE128_RF 0x5246
  27116. +#define PCI_DEVICE_ID_ATI_RAGE128_RG 0x534b
  27117. +#define PCI_DEVICE_ID_ATI_RAGE128_RH 0x534c
  27118. +#define PCI_DEVICE_ID_ATI_RAGE128_RI 0x534d
  27119. +/* Rage128 VR */
  27120. +#define PCI_DEVICE_ID_ATI_RAGE128_RK 0x524b
  27121. +#define PCI_DEVICE_ID_ATI_RAGE128_RL 0x524c
  27122. +#define PCI_DEVICE_ID_ATI_RAGE128_RM 0x5345
  27123. +#define PCI_DEVICE_ID_ATI_RAGE128_RN 0x5346
  27124. +#define PCI_DEVICE_ID_ATI_RAGE128_RO 0x5347
  27125. +/* Rage128 M3 */
  27126. +#define PCI_DEVICE_ID_ATI_RAGE128_LE 0x4c45
  27127. +#define PCI_DEVICE_ID_ATI_RAGE128_LF 0x4c46
  27128. +/* Rage128 Pro Ultra */
  27129. +#define PCI_DEVICE_ID_ATI_RAGE128_U1 0x5446
  27130. +#define PCI_DEVICE_ID_ATI_RAGE128_U2 0x544C
  27131. +#define PCI_DEVICE_ID_ATI_RAGE128_U3 0x5452
  27132. +/* Radeon M4 */
  27133. +#define PCI_DEVICE_ID_ATI_RADEON_LE 0x4d45
  27134. +#define PCI_DEVICE_ID_ATI_RADEON_LF 0x4d46
  27135. +/* Radeon NV-100 */
  27136. +#define PCI_DEVICE_ID_ATI_RADEON_N1 0x5159
  27137. +#define PCI_DEVICE_ID_ATI_RADEON_N2 0x515a
  27138. +/* Radeon */
  27139. +#define PCI_DEVICE_ID_ATI_RADEON_RA 0x5144
  27140. +#define PCI_DEVICE_ID_ATI_RADEON_RB 0x5145
  27141. +#define PCI_DEVICE_ID_ATI_RADEON_RC 0x5146
  27142. +#define PCI_DEVICE_ID_ATI_RADEON_RD 0x5147
  27143. +
  27144. +#define PCI_VENDOR_ID_VLSI 0x1004
  27145. +#define PCI_DEVICE_ID_VLSI_82C592 0x0005
  27146. +#define PCI_DEVICE_ID_VLSI_82C593 0x0006
  27147. +#define PCI_DEVICE_ID_VLSI_82C594 0x0007
  27148. +#define PCI_DEVICE_ID_VLSI_82C597 0x0009
  27149. +#define PCI_DEVICE_ID_VLSI_82C541 0x000c
  27150. +#define PCI_DEVICE_ID_VLSI_82C543 0x000d
  27151. +#define PCI_DEVICE_ID_VLSI_82C532 0x0101
  27152. +#define PCI_DEVICE_ID_VLSI_82C534 0x0102
  27153. +#define PCI_DEVICE_ID_VLSI_82C535 0x0104
  27154. +#define PCI_DEVICE_ID_VLSI_82C147 0x0105
  27155. +#define PCI_DEVICE_ID_VLSI_VAS96011 0x0702
  27156. +
  27157. +#define PCI_VENDOR_ID_ADL 0x1005
  27158. +#define PCI_DEVICE_ID_ADL_2301 0x2301
  27159. +
  27160. +#define PCI_VENDOR_ID_NS 0x100b
  27161. +#define PCI_DEVICE_ID_NS_87415 0x0002
  27162. +#define PCI_DEVICE_ID_NS_87560_LIO 0x000e
  27163. +#define PCI_DEVICE_ID_NS_87560_USB 0x0012
  27164. +#define PCI_DEVICE_ID_NS_83815 0x0020
  27165. +#define PCI_DEVICE_ID_DP83815 0x0020
  27166. +#define PCI_DEVICE_ID_NS_83820 0x0022
  27167. +#define PCI_DEVICE_ID_NS_87410 0xd001
  27168. +
  27169. +#define PCI_VENDOR_ID_TSENG 0x100c
  27170. +#define PCI_DEVICE_ID_TSENG_W32P_2 0x3202
  27171. +#define PCI_DEVICE_ID_TSENG_W32P_b 0x3205
  27172. +#define PCI_DEVICE_ID_TSENG_W32P_c 0x3206
  27173. +#define PCI_DEVICE_ID_TSENG_W32P_d 0x3207
  27174. +#define PCI_DEVICE_ID_TSENG_ET6000 0x3208
  27175. +
  27176. +#define PCI_VENDOR_ID_WEITEK 0x100e
  27177. +#define PCI_DEVICE_ID_WEITEK_P9000 0x9001
  27178. +#define PCI_DEVICE_ID_WEITEK_P9100 0x9100
  27179. +
  27180. +#define PCI_VENDOR_ID_DEC 0x1011
  27181. +#define PCI_DEVICE_ID_DEC_BRD 0x0001
  27182. +#define PCI_DEVICE_ID_DEC_TULIP 0x0002
  27183. +#define PCI_DEVICE_ID_DEC_TGA 0x0004
  27184. +#define PCI_DEVICE_ID_DEC_TULIP_FAST 0x0009
  27185. +#define PCI_DEVICE_ID_DEC_TGA2 0x000D
  27186. +#define PCI_DEVICE_ID_DEC_FDDI 0x000F
  27187. +#define PCI_DEVICE_ID_DEC_TULIP_PLUS 0x0014
  27188. +#define PCI_DEVICE_ID_DEC_21142 0x0019
  27189. +#define PCI_DEVICE_ID_DEC_21052 0x0021
  27190. +#define PCI_DEVICE_ID_DEC_21150 0x0022
  27191. +#define PCI_DEVICE_ID_DEC_21152 0x0024
  27192. +#define PCI_DEVICE_ID_DEC_21153 0x0025
  27193. +#define PCI_DEVICE_ID_DEC_21154 0x0026
  27194. +#define PCI_DEVICE_ID_DEC_21285 0x1065
  27195. +#define PCI_DEVICE_ID_COMPAQ_42XX 0x0046
  27196. +
  27197. +#define PCI_VENDOR_ID_CIRRUS 0x1013
  27198. +#define PCI_DEVICE_ID_CIRRUS_7548 0x0038
  27199. +#define PCI_DEVICE_ID_CIRRUS_5430 0x00a0
  27200. +#define PCI_DEVICE_ID_CIRRUS_5434_4 0x00a4
  27201. +#define PCI_DEVICE_ID_CIRRUS_5434_8 0x00a8
  27202. +#define PCI_DEVICE_ID_CIRRUS_5436 0x00ac
  27203. +#define PCI_DEVICE_ID_CIRRUS_5446 0x00b8
  27204. +#define PCI_DEVICE_ID_CIRRUS_5480 0x00bc
  27205. +#define PCI_DEVICE_ID_CIRRUS_5462 0x00d0
  27206. +#define PCI_DEVICE_ID_CIRRUS_5464 0x00d4
  27207. +#define PCI_DEVICE_ID_CIRRUS_5465 0x00d6
  27208. +#define PCI_DEVICE_ID_CIRRUS_6729 0x1100
  27209. +#define PCI_DEVICE_ID_CIRRUS_6832 0x1110
  27210. +#define PCI_DEVICE_ID_CIRRUS_7542 0x1200
  27211. +#define PCI_DEVICE_ID_CIRRUS_7543 0x1202
  27212. +#define PCI_DEVICE_ID_CIRRUS_7541 0x1204
  27213. +
  27214. +#define PCI_VENDOR_ID_IBM 0x1014
  27215. +#define PCI_DEVICE_ID_IBM_FIRE_CORAL 0x000a
  27216. +#define PCI_DEVICE_ID_IBM_TR 0x0018
  27217. +#define PCI_DEVICE_ID_IBM_82G2675 0x001d
  27218. +#define PCI_DEVICE_ID_IBM_MCA 0x0020
  27219. +#define PCI_DEVICE_ID_IBM_82351 0x0022
  27220. +#define PCI_DEVICE_ID_IBM_PYTHON 0x002d
  27221. +#define PCI_DEVICE_ID_IBM_SERVERAID 0x002e
  27222. +#define PCI_DEVICE_ID_IBM_TR_WAKE 0x003e
  27223. +#define PCI_DEVICE_ID_IBM_MPIC 0x0046
  27224. +#define PCI_DEVICE_ID_IBM_3780IDSP 0x007d
  27225. +#define PCI_DEVICE_ID_IBM_CHUKAR 0x0096
  27226. +#define PCI_DEVICE_ID_IBM_405GP 0x0156
  27227. +#define PCI_DEVICE_ID_IBM_SERVERAIDI960 0x01bd
  27228. +#define PCI_DEVICE_ID_IBM_MPIC_2 0xffff
  27229. +
  27230. +#define PCI_VENDOR_ID_COMPEX2 0x101a // pci.ids says "AT&T GIS (NCR)"
  27231. +#define PCI_DEVICE_ID_COMPEX2_100VG 0x0005
  27232. +
  27233. +#define PCI_VENDOR_ID_WD 0x101c
  27234. +#define PCI_DEVICE_ID_WD_7197 0x3296
  27235. +
  27236. +#define PCI_VENDOR_ID_AMI 0x101e
  27237. +#define PCI_DEVICE_ID_AMI_MEGARAID3 0x1960
  27238. +#define PCI_DEVICE_ID_AMI_MEGARAID 0x9010
  27239. +#define PCI_DEVICE_ID_AMI_MEGARAID2 0x9060
  27240. +
  27241. +#define PCI_VENDOR_ID_AMD 0x1022
  27242. +
  27243. +#define PCI_DEVICE_ID_AMD_LANCE 0x2000
  27244. +#define PCI_DEVICE_ID_AMD_LANCE_HOME 0x2001
  27245. +#define PCI_DEVICE_ID_AMD_HOMEPNA 0x2001
  27246. +#define PCI_DEVICE_ID_AMD_SCSI 0x2020
  27247. +#define PCI_DEVICE_ID_AMD_FE_GATE_7006 0x7006
  27248. +#define PCI_DEVICE_ID_AMD_FE_GATE_7007 0x7007
  27249. +#define PCI_DEVICE_ID_AMD_FE_GATE_700C 0x700C
  27250. +#define PCI_DEVIDE_ID_AMD_FE_GATE_700D 0x700D
  27251. +#define PCI_DEVICE_ID_AMD_FE_GATE_700E 0x700E
  27252. +#define PCI_DEVICE_ID_AMD_FE_GATE_700F 0x700F
  27253. +#define PCI_DEVICE_ID_AMD_COBRA_7400 0x7400
  27254. +#define PCI_DEVICE_ID_AMD_COBRA_7401 0x7401
  27255. +#define PCI_DEVICE_ID_AMD_COBRA_7403 0x7403
  27256. +#define PCI_DEVICE_ID_AMD_COBRA_7404 0x7404
  27257. +#define PCI_DEVICE_ID_AMD_VIPER_7408 0x7408
  27258. +#define PCI_DEVICE_ID_AMD_VIPER_7409 0x7409
  27259. +#define PCI_DEVICE_ID_AMD_VIPER_740B 0x740B
  27260. +#define PCI_DEVICE_ID_AMD_VIPER_740C 0x740C
  27261. +#define PCI_DEVICE_ID_AMD_VIPER_7410 0x7410
  27262. +#define PCI_DEVICE_ID_AMD_VIPER_7411 0x7411
  27263. +#define PCI_DEVICE_ID_AMD_VIPER_7413 0x7413
  27264. +#define PCI_DEVICE_ID_AMD_VIPER_7414 0x7414
  27265. +#define PCI_DEVICE_ID_AMD_VIPER_7440 0x7440
  27266. +#define PCI_DEVICE_ID_AMD_VIPER_7441 0x7441
  27267. +#define PCI_DEVICE_ID_AMD_VIPER_7443 0x7443
  27268. +#define PCI_DEVICE_ID_AMD_VIPER_7448 0x7448
  27269. +#define PCI_DEVICE_ID_AMD_VIPER_7449 0x7449
  27270. +
  27271. +#define PCI_VENDOR_ID_TRIDENT 0x1023
  27272. +#define PCI_DEVICE_ID_TRIDENT_4DWAVE_DX 0x2000
  27273. +#define PCI_DEVICE_ID_TRIDENT_4DWAVE_NX 0x2001
  27274. +#define PCI_DEVICE_ID_TRIDENT_9320 0x9320
  27275. +#define PCI_DEVICE_ID_TRIDENT_9388 0x9388
  27276. +#define PCI_DEVICE_ID_TRIDENT_9397 0x9397
  27277. +#define PCI_DEVICE_ID_TRIDENT_939A 0x939A
  27278. +#define PCI_DEVICE_ID_TRIDENT_9520 0x9520
  27279. +#define PCI_DEVICE_ID_TRIDENT_9525 0x9525
  27280. +#define PCI_DEVICE_ID_TRIDENT_9420 0x9420
  27281. +#define PCI_DEVICE_ID_TRIDENT_9440 0x9440
  27282. +#define PCI_DEVICE_ID_TRIDENT_9660 0x9660
  27283. +#define PCI_DEVICE_ID_TRIDENT_9750 0x9750
  27284. +#define PCI_DEVICE_ID_TRIDENT_9850 0x9850
  27285. +#define PCI_DEVICE_ID_TRIDENT_9880 0x9880
  27286. +#define PCI_DEVICE_ID_TRIDENT_8400 0x8400
  27287. +#define PCI_DEVICE_ID_TRIDENT_8420 0x8420
  27288. +#define PCI_DEVICE_ID_TRIDENT_8500 0x8500
  27289. +
  27290. +#define PCI_VENDOR_ID_AI 0x1025
  27291. +#define PCI_DEVICE_ID_AI_M1435 0x1435
  27292. +
  27293. +#define PCI_VENDOR_ID_DELL 0x1028
  27294. +
  27295. +#define PCI_VENDOR_ID_MATROX 0x102B
  27296. +#define PCI_DEVICE_ID_MATROX_MGA_2 0x0518
  27297. +#define PCI_DEVICE_ID_MATROX_MIL 0x0519
  27298. +#define PCI_DEVICE_ID_MATROX_MYS 0x051A
  27299. +#define PCI_DEVICE_ID_MATROX_MIL_2 0x051b
  27300. +#define PCI_DEVICE_ID_MATROX_MIL_2_AGP 0x051f
  27301. +#define PCI_DEVICE_ID_MATROX_MGA_IMP 0x0d10
  27302. +#define PCI_DEVICE_ID_MATROX_G100_MM 0x1000
  27303. +#define PCI_DEVICE_ID_MATROX_G100_AGP 0x1001
  27304. +#define PCI_DEVICE_ID_MATROX_G200_PCI 0x0520
  27305. +#define PCI_DEVICE_ID_MATROX_G200_AGP 0x0521
  27306. +#define PCI_DEVICE_ID_MATROX_G400 0x0525
  27307. +#define PCI_DEVICE_ID_MATROX_G550 0x2527
  27308. +#define PCI_DEVICE_ID_MATROX_VIA 0x4536
  27309. +
  27310. +#define PCI_VENDOR_ID_CT 0x102c
  27311. +#define PCI_DEVICE_ID_CT_65545 0x00d8
  27312. +#define PCI_DEVICE_ID_CT_65548 0x00dc
  27313. +#define PCI_DEVICE_ID_CT_65550 0x00e0
  27314. +#define PCI_DEVICE_ID_CT_65554 0x00e4
  27315. +#define PCI_DEVICE_ID_CT_65555 0x00e5
  27316. +
  27317. +#define PCI_VENDOR_ID_MIRO 0x1031
  27318. +#define PCI_DEVICE_ID_MIRO_36050 0x5601
  27319. +
  27320. +#define PCI_VENDOR_ID_NEC 0x1033
  27321. +#define PCI_DEVICE_ID_NEC_PCX2 0x0046
  27322. +#define PCI_DEVICE_ID_NEC_NILE4 0x005a
  27323. +#define PCI_DEVICE_ID_NEC_VRC5476 0x009b
  27324. +
  27325. +#define PCI_VENDOR_ID_FD 0x1036
  27326. +#define PCI_DEVICE_ID_FD_36C70 0x0000
  27327. +
  27328. +#define PCI_VENDOR_ID_SIS 0x1039
  27329. +#define PCI_VENDOR_ID_SI 0x1039
  27330. +#define PCI_DEVICE_ID_SI_5591_AGP 0x0001
  27331. +#define PCI_DEVICE_ID_SI_6202 0x0002
  27332. +#define PCI_DEVICE_ID_SI_503 0x0008
  27333. +#define PCI_DEVICE_ID_SI_ACPI 0x0009
  27334. +#define PCI_DEVICE_ID_SI_5597_VGA 0x0200
  27335. +#define PCI_DEVICE_ID_SI_6205 0x0205
  27336. +#define PCI_DEVICE_ID_SI_501 0x0406
  27337. +#define PCI_DEVICE_ID_SI_496 0x0496
  27338. +#define PCI_DEVICE_ID_SI_300 0x0300
  27339. +#define PCI_DEVICE_ID_SI_315H 0x0310
  27340. +#define PCI_DEVICE_ID_SI_315 0x0315
  27341. +#define PCI_DEVICE_ID_SI_315PRO 0x0325
  27342. +#define PCI_DEVICE_ID_SI_530 0x0530
  27343. +#define PCI_DEVICE_ID_SI_540 0x0540
  27344. +#define PCI_DEVICE_ID_SI_550 0x0550
  27345. +#define PCI_DEVICE_ID_SI_601 0x0601
  27346. +#define PCI_DEVICE_ID_SI_620 0x0620
  27347. +#define PCI_DEVICE_ID_SI_630 0x0630
  27348. +#define PCI_DEVICE_ID_SI_635 0x0635
  27349. +#define PCI_DEVICE_ID_SI_640 0x0640
  27350. +#define PCI_DEVICE_ID_SI_645 0x0645
  27351. +#define PCI_DEVICE_ID_SI_650 0x0650
  27352. +#define PCI_DEVICE_ID_SI_730 0x0730
  27353. +#define PCI_DEVICE_ID_SI_735 0x0735
  27354. +#define PCI_DEVICE_ID_SI_740 0x0740
  27355. +#define PCI_DEVICE_ID_SI_745 0x0745
  27356. +#define PCI_DEVICE_ID_SI_750 0x0750
  27357. +#define PCI_DEVICE_ID_SI_900 0x0900
  27358. +#define PCI_DEVICE_ID_SIS900 0x0900
  27359. +#define PCI_DEVICE_ID_SI_5107 0x5107
  27360. +#define PCI_DEVICE_ID_SI_5300 0x5300
  27361. +#define PCI_DEVICE_ID_SI_540_VGA 0x5300
  27362. +#define PCI_DEVICE_ID_SI_550_VGA 0x5315
  27363. +#define PCI_DEVICE_ID_SI_5511 0x5511
  27364. +#define PCI_DEVICE_ID_SI_5513 0x5513
  27365. +#define PCI_DEVICE_ID_SI_5571 0x5571
  27366. +#define PCI_DEVICE_ID_SI_5591 0x5591
  27367. +#define PCI_DEVICE_ID_SI_5597 0x5597
  27368. +#define PCI_DEVICE_ID_SI_5598 0x5598
  27369. +#define PCI_DEVICE_ID_SI_5600 0x5600
  27370. +#define PCI_DEVICE_ID_SI_6300 0x6300
  27371. +#define PCI_DEVICE_ID_SI_630_VGA 0x6300
  27372. +#define PCI_DEVICE_ID_SI_6306 0x6306
  27373. +#define PCI_DEVICE_ID_SI_6326 0x6326
  27374. +#define PCI_DEVICE_ID_SI_7001 0x7001
  27375. +#define PCI_DEVICE_ID_SI_7016 0x7016
  27376. +#define PCI_DEVICE_ID_SIS7016 0x7016
  27377. +#define PCI_DEVICE_ID_SI_730_VGA 0x7300
  27378. +
  27379. +#define PCI_VENDOR_ID_HP 0x103c
  27380. +#define PCI_DEVICE_ID_HP_DONNER_GFX 0x1008
  27381. +#define PCI_DEVICE_ID_HP_TACHYON 0x1028
  27382. +#define PCI_DEVICE_ID_HP_TACHLITE 0x1029
  27383. +#define PCI_DEVICE_ID_HP_J2585A 0x1030
  27384. +#define PCI_DEVICE_ID_HP_J2585B 0x1031
  27385. +#define PCI_DEVICE_ID_HP_SAS 0x1048
  27386. +#define PCI_DEVICE_ID_HP_DIVA1 0x1049
  27387. +#define PCI_DEVICE_ID_HP_DIVA2 0x104A
  27388. +#define PCI_DEVICE_ID_HP_SP2_0 0x104B
  27389. +
  27390. +#define PCI_VENDOR_ID_PCTECH 0x1042
  27391. +#define PCI_DEVICE_ID_PCTECH_RZ1000 0x1000
  27392. +#define PCI_DEVICE_ID_PCTECH_RZ1001 0x1001
  27393. +#define PCI_DEVICE_ID_PCTECH_SAMURAI_0 0x3000
  27394. +#define PCI_DEVICE_ID_PCTECH_SAMURAI_1 0x3010
  27395. +#define PCI_DEVICE_ID_PCTECH_SAMURAI_IDE 0x3020
  27396. +
  27397. +#define PCI_VENDOR_ID_ASUSTEK 0x1043
  27398. +#define PCI_DEVICE_ID_ASUSTEK_0675 0x0675
  27399. +
  27400. +#define PCI_VENDOR_ID_DPT 0x1044
  27401. +#define PCI_DEVICE_ID_DPT 0xa400
  27402. +
  27403. +#define PCI_VENDOR_ID_OPTI 0x1045
  27404. +#define PCI_DEVICE_ID_OPTI_92C178 0xc178
  27405. +#define PCI_DEVICE_ID_OPTI_82C557 0xc557
  27406. +#define PCI_DEVICE_ID_OPTI_82C558 0xc558
  27407. +#define PCI_DEVICE_ID_OPTI_82C621 0xc621
  27408. +#define PCI_DEVICE_ID_OPTI_82C700 0xc700
  27409. +#define PCI_DEVICE_ID_OPTI_82C701 0xc701
  27410. +#define PCI_DEVICE_ID_OPTI_82C814 0xc814
  27411. +#define PCI_DEVICE_ID_OPTI_82C822 0xc822
  27412. +#define PCI_DEVICE_ID_OPTI_82C861 0xc861
  27413. +#define PCI_DEVICE_ID_OPTI_82C825 0xd568
  27414. +
  27415. +#define PCI_VENDOR_ID_ELSA 0x1048
  27416. +#define PCI_DEVICE_ID_ELSA_MICROLINK 0x1000
  27417. +#define PCI_DEVICE_ID_ELSA_QS3000 0x3000
  27418. +
  27419. +#define PCI_VENDOR_ID_ELSA 0x1048
  27420. +#define PCI_DEVICE_ID_ELSA_MICROLINK 0x1000
  27421. +#define PCI_DEVICE_ID_ELSA_QS3000 0x3000
  27422. +
  27423. +#define PCI_VENDOR_ID_SGS 0x104a
  27424. +#define PCI_DEVICE_ID_SGS_2000 0x0008
  27425. +#define PCI_DEVICE_ID_SGS_1764 0x0009
  27426. +
  27427. +#define PCI_VENDOR_ID_BUSLOGIC 0x104B
  27428. +#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC 0x0140
  27429. +#define PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER 0x1040
  27430. +#define PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT 0x8130
  27431. +
  27432. +#define PCI_VENDOR_ID_TI 0x104c
  27433. +#define PCI_DEVICE_ID_TI_TVP4010 0x3d04
  27434. +#define PCI_DEVICE_ID_TI_TVP4020 0x3d07
  27435. +#define PCI_DEVICE_ID_TI_1130 0xac12
  27436. +#define PCI_DEVICE_ID_TI_1031 0xac13
  27437. +#define PCI_DEVICE_ID_TI_1131 0xac15
  27438. +#define PCI_DEVICE_ID_TI_1250 0xac16
  27439. +#define PCI_DEVICE_ID_TI_1220 0xac17
  27440. +#define PCI_DEVICE_ID_TI_1221 0xac19
  27441. +#define PCI_DEVICE_ID_TI_1210 0xac1a
  27442. +#define PCI_DEVICE_ID_TI_1410 0xac50
  27443. +#define PCI_DEVICE_ID_TI_1450 0xac1b
  27444. +#define PCI_DEVICE_ID_TI_1225 0xac1c
  27445. +#define PCI_DEVICE_ID_TI_1251A 0xac1d
  27446. +#define PCI_DEVICE_ID_TI_1211 0xac1e
  27447. +#define PCI_DEVICE_ID_TI_1251B 0xac1f
  27448. +#define PCI_DEVICE_ID_TI_4410 0xac41
  27449. +#define PCI_DEVICE_ID_TI_4451 0xac42
  27450. +#define PCI_DEVICE_ID_TI_1420 0xac51
  27451. +
  27452. +#define PCI_VENDOR_ID_SONY 0x104d
  27453. +#define PCI_DEVICE_ID_SONY_CXD3222 0x8039
  27454. +
  27455. +#define PCI_VENDOR_ID_OAK 0x104e
  27456. +#define PCI_DEVICE_ID_OAK_OTI107 0x0107
  27457. +
  27458. +/* Winbond have two vendor IDs! See 0x10ad as well */
  27459. +#define PCI_VENDOR_ID_WINBOND2 0x1050
  27460. +#define PCI_DEVICE_ID_WINBOND2_89C840 0x0840
  27461. +#define PCI_DEVICE_ID_WINBOND2_89C940 0x0940
  27462. +#define PCI_DEVICE_ID_WINBOND2_89C940F 0x5a5a
  27463. +#define PCI_DEVICE_ID_WINBOND2_6692 0x6692
  27464. +
  27465. +#define PCI_VENDOR_ID_ANIGMA 0x1051
  27466. +#define PCI_DEVICE_ID_ANIGMA_MC145575 0x0100
  27467. +
  27468. +#define PCI_VENDOR_ID_EFAR 0x1055
  27469. +#define PCI_DEVICE_ID_EFAR_SLC90E66_1 0x9130
  27470. +#define PCI_DEVICE_ID_EFAR_SLC90E66_0 0x9460
  27471. +#define PCI_DEVICE_ID_EFAR_SLC90E66_2 0x9462
  27472. +#define PCI_DEVICE_ID_EFAR_SLC90E66_3 0x9463
  27473. +
  27474. +#define PCI_VENDOR_ID_MOTOROLA 0x1057
  27475. +#define PCI_VENDOR_ID_MOTOROLA_OOPS 0x1507
  27476. +#define PCI_DEVICE_ID_MOTOROLA_MPC105 0x0001
  27477. +#define PCI_DEVICE_ID_MOTOROLA_MPC106 0x0002
  27478. +#define PCI_DEVICE_ID_MOTOROLA_RAVEN 0x4801
  27479. +#define PCI_DEVICE_ID_MOTOROLA_FALCON 0x4802
  27480. +#define PCI_DEVICE_ID_MOTOROLA_CPX8216 0x4806
  27481. +
  27482. +#define PCI_VENDOR_ID_PROMISE 0x105a
  27483. +#define PCI_DEVICE_ID_PROMISE_20265 0x0d30
  27484. +#define PCI_DEVICE_ID_PROMISE_20267 0x4d30
  27485. +#define PCI_DEVICE_ID_PROMISE_20246 0x4d33
  27486. +#define PCI_DEVICE_ID_PROMISE_20262 0x4d38
  27487. +#define PCI_DEVICE_ID_PROMISE_20268 0x4d68
  27488. +#define PCI_DEVICE_ID_PROMISE_20268R 0x6268
  27489. +#define PCI_DEVICE_ID_PROMISE_20269 0x4d69
  27490. +#define PCI_DEVICE_ID_PROMISE_20275 0x1275
  27491. +#define PCI_DEVICE_ID_PROMISE_5300 0x5300
  27492. +
  27493. +#define PCI_VENDOR_ID_N9 0x105d
  27494. +#define PCI_DEVICE_ID_N9_I128 0x2309
  27495. +#define PCI_DEVICE_ID_N9_I128_2 0x2339
  27496. +#define PCI_DEVICE_ID_N9_I128_T2R 0x493d
  27497. +
  27498. +#define PCI_VENDOR_ID_UMC 0x1060
  27499. +#define PCI_DEVICE_ID_UMC_UM8673F 0x0101
  27500. +#define PCI_DEVICE_ID_UMC_UM8891A 0x0891
  27501. +#define PCI_DEVICE_ID_UMC_UM8886BF 0x673a
  27502. +#define PCI_DEVICE_ID_UMC_UM8886A 0x886a
  27503. +#define PCI_DEVICE_ID_UMC_UM8881F 0x8881
  27504. +#define PCI_DEVICE_ID_UMC_UM8886F 0x8886
  27505. +#define PCI_DEVICE_ID_UMC_UM9017F 0x9017
  27506. +#define PCI_DEVICE_ID_UMC_UM8886N 0xe886
  27507. +#define PCI_DEVICE_ID_UMC_UM8891N 0xe891
  27508. +
  27509. +#define PCI_VENDOR_ID_X 0x1061
  27510. +#define PCI_DEVICE_ID_X_AGX016 0x0001
  27511. +
  27512. +#define PCI_VENDOR_ID_MYLEX 0x1069
  27513. +#define PCI_DEVICE_ID_MYLEX_DAC960_P 0x0001
  27514. +#define PCI_DEVICE_ID_MYLEX_DAC960_PD 0x0002
  27515. +#define PCI_DEVICE_ID_MYLEX_DAC960_PG 0x0010
  27516. +#define PCI_DEVICE_ID_MYLEX_DAC960_LA 0x0020
  27517. +#define PCI_DEVICE_ID_MYLEX_DAC960_LP 0x0050
  27518. +#define PCI_DEVICE_ID_MYLEX_DAC960_BA 0xBA56
  27519. +
  27520. +#define PCI_VENDOR_ID_PICOP 0x1066
  27521. +#define PCI_DEVICE_ID_PICOP_PT86C52X 0x0001
  27522. +#define PCI_DEVICE_ID_PICOP_PT80C524 0x8002
  27523. +
  27524. +#define PCI_VENDOR_ID_APPLE 0x106b
  27525. +#define PCI_DEVICE_ID_APPLE_BANDIT 0x0001
  27526. +#define PCI_DEVICE_ID_APPLE_GC 0x0002
  27527. +#define PCI_DEVICE_ID_APPLE_HYDRA 0x000e
  27528. +#define PCI_DEVICE_ID_APPLE_UNI_N_FW 0x0018
  27529. +#define PCI_DEVICE_ID_APPLE_KL_USB 0x0019
  27530. +#define PCI_DEVICE_ID_APPLE_UNI_N_AGP 0x0020
  27531. +#define PCI_DEVICE_ID_APPLE_UNI_N_GMAC 0x0021
  27532. +#define PCI_DEVICE_ID_APPLE_UNI_N_FW2 0x0030
  27533. +
  27534. +#define PCI_VENDOR_ID_YAMAHA 0x1073
  27535. +#define PCI_DEVICE_ID_YAMAHA_724 0x0004
  27536. +#define PCI_DEVICE_ID_YAMAHA_724F 0x000d
  27537. +#define PCI_DEVICE_ID_YAMAHA_740 0x000a
  27538. +#define PCI_DEVICE_ID_YAMAHA_740C 0x000c
  27539. +#define PCI_DEVICE_ID_YAMAHA_744 0x0010
  27540. +#define PCI_DEVICE_ID_YAMAHA_754 0x0012
  27541. +
  27542. +#define PCI_VENDOR_ID_NEXGEN 0x1074
  27543. +#define PCI_DEVICE_ID_NEXGEN_82C501 0x4e78
  27544. +
  27545. +#define PCI_VENDOR_ID_QLOGIC 0x1077
  27546. +#define PCI_DEVICE_ID_QLOGIC_ISP1020 0x1020
  27547. +#define PCI_DEVICE_ID_QLOGIC_ISP1022 0x1022
  27548. +#define PCI_DEVICE_ID_QLOGIC_ISP2100 0x2100
  27549. +#define PCI_DEVICE_ID_QLOGIC_ISP2200 0x2200
  27550. +
  27551. +#define PCI_VENDOR_ID_CYRIX 0x1078
  27552. +#define PCI_DEVICE_ID_CYRIX_5510 0x0000
  27553. +#define PCI_DEVICE_ID_CYRIX_PCI_MASTER 0x0001
  27554. +#define PCI_DEVICE_ID_CYRIX_5520 0x0002
  27555. +#define PCI_DEVICE_ID_CYRIX_5530_LEGACY 0x0100
  27556. +#define PCI_DEVICE_ID_CYRIX_5530_SMI 0x0101
  27557. +#define PCI_DEVICE_ID_CYRIX_5530_IDE 0x0102
  27558. +#define PCI_DEVICE_ID_CYRIX_5530_AUDIO 0x0103
  27559. +#define PCI_DEVICE_ID_CYRIX_5530_VIDEO 0x0104
  27560. +
  27561. +#define PCI_VENDOR_ID_LEADTEK 0x107d
  27562. +#define PCI_DEVICE_ID_LEADTEK_805 0x0000
  27563. +
  27564. +#define PCI_VENDOR_ID_INTERPHASE 0x107e
  27565. +#define PCI_DEVICE_ID_INTERPHASE_5526 0x0004
  27566. +#define PCI_DEVICE_ID_INTERPHASE_55x6 0x0005
  27567. +#define PCI_DEVICE_ID_INTERPHASE_5575 0x0008
  27568. +
  27569. +#define PCI_VENDOR_ID_CONTAQ 0x1080
  27570. +#define PCI_DEVICE_ID_CONTAQ_82C599 0x0600
  27571. +#define PCI_DEVICE_ID_CONTAQ_82C693 0xc693
  27572. +
  27573. +#define PCI_VENDOR_ID_FOREX 0x1083
  27574. +
  27575. +#define PCI_VENDOR_ID_OLICOM 0x108d
  27576. +#define PCI_DEVICE_ID_OLICOM_OC3136 0x0001
  27577. +#define PCI_DEVICE_ID_OLICOM_OC2315 0x0011
  27578. +#define PCI_DEVICE_ID_OLICOM_OC2325 0x0012
  27579. +#define PCI_DEVICE_ID_OLICOM_OC2183 0x0013
  27580. +#define PCI_DEVICE_ID_OLICOM_OC2326 0x0014
  27581. +#define PCI_DEVICE_ID_OLICOM_OC6151 0x0021
  27582. +
  27583. +#define PCI_VENDOR_ID_SUN 0x108e
  27584. +#define PCI_DEVICE_ID_SUN_EBUS 0x1000
  27585. +#define PCI_DEVICE_ID_SUN_HAPPYMEAL 0x1001
  27586. +#define PCI_DEVICE_ID_SUN_RIO_EBUS 0x1100
  27587. +#define PCI_DEVICE_ID_SUN_RIO_GEM 0x1101
  27588. +#define PCI_DEVICE_ID_SUN_RIO_1394 0x1102
  27589. +#define PCI_DEVICE_ID_SUN_RIO_USB 0x1103
  27590. +#define PCI_DEVICE_ID_SUN_GEM 0x2bad
  27591. +#define PCI_DEVICE_ID_SUN_SIMBA 0x5000
  27592. +#define PCI_DEVICE_ID_SUN_PBM 0x8000
  27593. +#define PCI_DEVICE_ID_SUN_SCHIZO 0x8001
  27594. +#define PCI_DEVICE_ID_SUN_SABRE 0xa000
  27595. +#define PCI_DEVICE_ID_SUN_HUMMINGBIRD 0xa001
  27596. +
  27597. +#define PCI_VENDOR_ID_CMD 0x1095
  27598. +#define PCI_DEVICE_ID_CMD_640 0x0640
  27599. +#define PCI_DEVICE_ID_CMD_643 0x0643
  27600. +#define PCI_DEVICE_ID_CMD_646 0x0646
  27601. +#define PCI_DEVICE_ID_CMD_647 0x0647
  27602. +#define PCI_DEVICE_ID_CMD_648 0x0648
  27603. +#define PCI_DEVICE_ID_CMD_649 0x0649
  27604. +#define PCI_DEVICE_ID_CMD_670 0x0670
  27605. +#define PCI_DEVICE_ID_CMD_680 0x0680
  27606. +
  27607. +#define PCI_VENDOR_ID_VISION 0x1098
  27608. +#define PCI_DEVICE_ID_VISION_QD8500 0x0001
  27609. +#define PCI_DEVICE_ID_VISION_QD8580 0x0002
  27610. +
  27611. +#define PCI_VENDOR_ID_BROOKTREE 0x109e
  27612. +#define PCI_DEVICE_ID_BROOKTREE_848 0x0350
  27613. +#define PCI_DEVICE_ID_BROOKTREE_849A 0x0351
  27614. +#define PCI_DEVICE_ID_BROOKTREE_878_1 0x036e
  27615. +#define PCI_DEVICE_ID_BROOKTREE_878 0x0878
  27616. +#define PCI_DEVICE_ID_BROOKTREE_8474 0x8474
  27617. +
  27618. +#define PCI_VENDOR_ID_SIERRA 0x10a8
  27619. +#define PCI_DEVICE_ID_SIERRA_STB 0x0000
  27620. +
  27621. +#define PCI_VENDOR_ID_SGI 0x10a9
  27622. +#define PCI_DEVICE_ID_SGI_IOC3 0x0003
  27623. +
  27624. +#define PCI_VENDOR_ID_ACC 0x10aa
  27625. +#define PCI_DEVICE_ID_ACC_2056 0x0000
  27626. +
  27627. +#define PCI_VENDOR_ID_WINBOND 0x10ad
  27628. +#define PCI_DEVICE_ID_WINBOND_83769 0x0001
  27629. +#define PCI_DEVICE_ID_WINBOND_82C105 0x0105
  27630. +#define PCI_DEVICE_ID_WINBOND_83C553 0x0565
  27631. +
  27632. +#define PCI_VENDOR_ID_DATABOOK 0x10b3
  27633. +#define PCI_DEVICE_ID_DATABOOK_87144 0xb106
  27634. +
  27635. +#define PCI_VENDOR_ID_PLX 0x10b5
  27636. +#define PCI_DEVICE_ID_PLX_R685 0x1030
  27637. +#define PCI_DEVICE_ID_PLX_ROMULUS 0x106a
  27638. +#define PCI_DEVICE_ID_PLX_SPCOM800 0x1076
  27639. +#define PCI_DEVICE_ID_PLX_1077 0x1077
  27640. +#define PCI_DEVICE_ID_PLX_SPCOM200 0x1103
  27641. +#define PCI_DEVICE_ID_PLX_DJINN_ITOO 0x1151
  27642. +#define PCI_DEVICE_ID_PLX_R753 0x1152
  27643. +#define PCI_DEVICE_ID_PLX_9050 0x9050
  27644. +#define PCI_DEVICE_ID_PLX_9060 0x9060
  27645. +#define PCI_DEVICE_ID_PLX_9060ES 0x906E
  27646. +#define PCI_DEVICE_ID_PLX_9060SD 0x906D
  27647. +#define PCI_DEVICE_ID_PLX_9080 0x9080
  27648. +#define PCI_DEVICE_ID_PLX_GTEK_SERIAL2 0xa001
  27649. +
  27650. +#define PCI_VENDOR_ID_MADGE 0x10b6
  27651. +#define PCI_DEVICE_ID_MADGE_MK2 0x0002
  27652. +#define PCI_DEVICE_ID_MADGE_C155S 0x1001
  27653. +
  27654. +#define PCI_VENDOR_ID_3COM 0x10b7
  27655. +#define PCI_DEVICE_ID_3COM_3C985 0x0001
  27656. +#define PCI_DEVICE_ID_3COM_3C339 0x3390
  27657. +#define PCI_DEVICE_ID_3COM_3C590 0x5900
  27658. +#define PCI_DEVICE_ID_3COM_3C595 0x5950
  27659. +#define PCI_DEVICE_ID_3COM_3C595TX 0x5950
  27660. +#define PCI_DEVICE_ID_3COM_3C595_1 0x5951
  27661. +#define PCI_DEVICE_ID_3COM_3C595T4 0x5951
  27662. +#define PCI_DEVICE_ID_3COM_3C595_2 0x5952
  27663. +#define PCI_DEVICE_ID_3COM_3C595MII 0x5952
  27664. +#define PCI_DEVICE_ID_3COM_3C900TPO 0x9000
  27665. +#define PCI_DEVICE_ID_3COM_3C900COMBO 0x9001
  27666. +#define PCI_DEVICE_ID_3COM_3C905TX 0x9050
  27667. +#define PCI_DEVICE_ID_3COM_3C905T4 0x9051
  27668. +#define PCI_DEVICE_ID_3COM_3C905B_TX 0x9055
  27669. +#define PCI_DEVICE_ID_3COM_3C905C_TXM 0x9200
  27670. +
  27671. +#define PCI_VENDOR_ID_SMC 0x10b8
  27672. +#define PCI_DEVICE_ID_SMC_EPIC100 0x0005
  27673. +
  27674. +#define PCI_VENDOR_ID_SUNDANCE 0x13F0
  27675. +#define PCI_DEVICE_ID_SUNDANCE_ALTA 0x0201
  27676. +
  27677. +#define PCI_VENDOR_ID_AL 0x10b9
  27678. +#define PCI_DEVICE_ID_AL_M1445 0x1445
  27679. +#define PCI_DEVICE_ID_AL_M1449 0x1449
  27680. +#define PCI_DEVICE_ID_AL_M1451 0x1451
  27681. +#define PCI_DEVICE_ID_AL_M1461 0x1461
  27682. +#define PCI_DEVICE_ID_AL_M1489 0x1489
  27683. +#define PCI_DEVICE_ID_AL_M1511 0x1511
  27684. +#define PCI_DEVICE_ID_AL_M1513 0x1513
  27685. +#define PCI_DEVICE_ID_AL_M1521 0x1521
  27686. +#define PCI_DEVICE_ID_AL_M1523 0x1523
  27687. +#define PCI_DEVICE_ID_AL_M1531 0x1531
  27688. +#define PCI_DEVICE_ID_AL_M1533 0x1533
  27689. +#define PCI_DEVICE_ID_AL_M1541 0x1541
  27690. +#define PCI_DEVICE_ID_AL_M1621 0x1621
  27691. +#define PCI_DEVICE_ID_AL_M1631 0x1631
  27692. +#define PCI_DEVICE_ID_AL_M1641 0x1641
  27693. +#define PCI_DEVICE_ID_AL_M1647 0x1647
  27694. +#define PCI_DEVICE_ID_AL_M1651 0x1651
  27695. +#define PCI_DEVICE_ID_AL_M1543 0x1543
  27696. +#define PCI_DEVICE_ID_AL_M3307 0x3307
  27697. +#define PCI_DEVICE_ID_AL_M4803 0x5215
  27698. +#define PCI_DEVICE_ID_AL_M5219 0x5219
  27699. +#define PCI_DEVICE_ID_AL_M5229 0x5229
  27700. +#define PCI_DEVICE_ID_AL_M5237 0x5237
  27701. +#define PCI_DEVICE_ID_AL_M5243 0x5243
  27702. +#define PCI_DEVICE_ID_AL_M5451 0x5451
  27703. +#define PCI_DEVICE_ID_AL_M7101 0x7101
  27704. +
  27705. +#define PCI_VENDOR_ID_MITSUBISHI 0x10ba
  27706. +
  27707. +#define PCI_VENDOR_ID_SURECOM 0x10bd
  27708. +#define PCI_DEVICE_ID_SURECOM_NE34 0x0e34
  27709. +
  27710. +#define PCI_VENDOR_ID_NEOMAGIC 0x10c8
  27711. +#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_NM2070 0x0001
  27712. +#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_128V 0x0002
  27713. +#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_128ZV 0x0003
  27714. +#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_NM2160 0x0004
  27715. +#define PCI_DEVICE_ID_NEOMAGIC_MAGICMEDIA_256AV 0x0005
  27716. +#define PCI_DEVICE_ID_NEOMAGIC_MAGICGRAPH_128ZVPLUS 0x0083
  27717. +
  27718. +#define PCI_VENDOR_ID_ASP 0x10cd
  27719. +#define PCI_DEVICE_ID_ASP_ABP940 0x1200
  27720. +#define PCI_DEVICE_ID_ASP_ABP940U 0x1300
  27721. +#define PCI_DEVICE_ID_ASP_ABP940UW 0x2300
  27722. +
  27723. +#define PCI_VENDOR_ID_MACRONIX 0x10d9
  27724. +#define PCI_DEVICE_ID_MACRONIX_MX98713 0x0512
  27725. +#define PCI_DEVICE_ID_MX987x3 0x0512
  27726. +#define PCI_DEVICE_ID_MACRONIX_MX987x5 0x0531
  27727. +#define PCI_DEVICE_ID_MX987x5 0x0531
  27728. +
  27729. +#define PCI_VENDOR_ID_TCONRAD 0x10da
  27730. +#define PCI_DEVICE_ID_TCONRAD_TOKENRING 0x0508
  27731. +
  27732. +#define PCI_VENDOR_ID_CERN 0x10dc
  27733. +#define PCI_DEVICE_ID_CERN_SPSB_PMC 0x0001
  27734. +#define PCI_DEVICE_ID_CERN_SPSB_PCI 0x0002
  27735. +#define PCI_DEVICE_ID_CERN_HIPPI_DST 0x0021
  27736. +#define PCI_DEVICE_ID_CERN_HIPPI_SRC 0x0022
  27737. +
  27738. +#define PCI_VENDOR_ID_NVIDIA 0x10de
  27739. +#define PCI_DEVICE_ID_NVIDIA_TNT 0x0020
  27740. +#define PCI_DEVICE_ID_NVIDIA_TNT2 0x0028
  27741. +#define PCI_DEVICE_ID_NVIDIA_UTNT2 0x0029
  27742. +#define PCI_DEVICE_ID_NVIDIA_VTNT2 0x002C
  27743. +#define PCI_DEVICE_ID_NVIDIA_UVTNT2 0x002D
  27744. +#define PCI_DEVICE_ID_NVIDIA_ITNT2 0x00A0
  27745. +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_SDR 0x0100
  27746. +#define PCI_DEVICE_ID_NVIDIA_GEFORCE_DDR 0x0101
  27747. +#define PCI_DEVICE_ID_NVIDIA_QUADRO 0x0103
  27748. +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX 0x0110
  27749. +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_MX2 0x0111
  27750. +#define PCI_DEVICE_ID_NVIDIA_QUADRO2_MXR 0x0113
  27751. +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS 0x0150
  27752. +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_GTS2 0x0151
  27753. +#define PCI_DEVICE_ID_NVIDIA_GEFORCE2_ULTRA 0x0152
  27754. +#define PCI_DEVICE_ID_NVIDIA_QUADRO2_PRO 0x0153
  27755. +
  27756. +#define PCI_VENDOR_ID_IMS 0x10e0
  27757. +#define PCI_DEVICE_ID_IMS_8849 0x8849
  27758. +#define PCI_DEVICE_ID_IMS_TT128 0x9128
  27759. +#define PCI_DEVICE_ID_IMS_TT3D 0x9135
  27760. +
  27761. +#define PCI_VENDOR_ID_TEKRAM2 0x10e1
  27762. +#define PCI_DEVICE_ID_TEKRAM2_690c 0x690c
  27763. +
  27764. +#define PCI_VENDOR_ID_TUNDRA 0x10e3
  27765. +#define PCI_DEVICE_ID_TUNDRA_CA91C042 0x0000
  27766. +
  27767. +#define PCI_VENDOR_ID_AMCC 0x10e8
  27768. +#define PCI_DEVICE_ID_AMCC_MYRINET 0x8043
  27769. +#define PCI_DEVICE_ID_AMCC_PARASTATION 0x8062
  27770. +#define PCI_DEVICE_ID_AMCC_S5933 0x807d
  27771. +#define PCI_DEVICE_ID_AMCC_S5933_HEPC3 0x809c
  27772. +
  27773. +#define PCI_VENDOR_ID_INTERG 0x10ea
  27774. +#define PCI_DEVICE_ID_INTERG_1680 0x1680
  27775. +#define PCI_DEVICE_ID_INTERG_1682 0x1682
  27776. +#define PCI_DEVICE_ID_INTERG_2000 0x2000
  27777. +#define PCI_DEVICE_ID_INTERG_2010 0x2010
  27778. +#define PCI_DEVICE_ID_INTERG_5000 0x5000
  27779. +#define PCI_DEVICE_ID_INTERG_5050 0x5050
  27780. +
  27781. +#define PCI_VENDOR_ID_REALTEK 0x10ec
  27782. +#define PCI_DEVICE_ID_REALTEK_8029 0x8029
  27783. +#define PCI_DEVICE_ID_REALTEK_8129 0x8129
  27784. +#define PCI_DEVICE_ID_REALTEK_8139 0x8139
  27785. +
  27786. +#define PCI_VENDOR_ID_XILINX 0x10ee
  27787. +#define PCI_DEVICE_ID_TURBOPAM 0x4020
  27788. +
  27789. +#define PCI_VENDOR_ID_TRUEVISION 0x10fa
  27790. +#define PCI_DEVICE_ID_TRUEVISION_T1000 0x000c
  27791. +
  27792. +#define PCI_VENDOR_ID_INIT 0x1101
  27793. +#define PCI_DEVICE_ID_INIT_320P 0x9100
  27794. +#define PCI_DEVICE_ID_INIT_360P 0x9500
  27795. +
  27796. +#define PCI_VENDOR_ID_CREATIVE 0x1102 // duplicate: ECTIVA
  27797. +#define PCI_DEVICE_ID_CREATIVE_EMU10K1 0x0002
  27798. +
  27799. +#define PCI_VENDOR_ID_ECTIVA 0x1102 // duplicate: CREATIVE
  27800. +#define PCI_DEVICE_ID_ECTIVA_EV1938 0x8938
  27801. +
  27802. +#define PCI_VENDOR_ID_TTI 0x1103
  27803. +#define PCI_DEVICE_ID_TTI_HPT343 0x0003
  27804. +#define PCI_DEVICE_ID_TTI_HPT366 0x0004
  27805. +
  27806. +#define PCI_VENDOR_ID_VIA 0x1106
  27807. +#define PCI_VENDOR_ID_VIATEC 0x1106
  27808. +#define PCI_DEVICE_ID_VIA_8363_0 0x0305
  27809. +#define PCI_DEVICE_ID_VIA_8371_0 0x0391
  27810. +#define PCI_DEVICE_ID_VIA_8501_0 0x0501
  27811. +#define PCI_DEVICE_ID_VIA_82C505 0x0505
  27812. +#define PCI_DEVICE_ID_VIA_82C561 0x0561
  27813. +#define PCI_DEVICE_ID_VIA_82C586_1 0x0571
  27814. +#define PCI_DEVICE_ID_VIA_82C576 0x0576
  27815. +#define PCI_DEVICE_ID_VIA_82C585 0x0585
  27816. +#define PCI_DEVICE_ID_VIA_82C586_0 0x0586
  27817. +#define PCI_DEVICE_ID_VIA_82C595 0x0595
  27818. +#define PCI_DEVICE_ID_VIA_82C596 0x0596
  27819. +#define PCI_DEVICE_ID_VIA_82C597_0 0x0597
  27820. +#define PCI_DEVICE_ID_VIA_82C598_0 0x0598
  27821. +#define PCI_DEVICE_ID_VIA_8601_0 0x0601
  27822. +#define PCI_DEVICE_ID_VIA_8605_0 0x0605
  27823. +#define PCI_DEVICE_ID_VIA_82C680 0x0680
  27824. +#define PCI_DEVICE_ID_VIA_82C686 0x0686
  27825. +#define PCI_DEVICE_ID_VIA_82C691 0x0691
  27826. +#define PCI_DEVICE_ID_VIA_82C693 0x0693
  27827. +#define PCI_DEVICE_ID_VIA_82C693_1 0x0698
  27828. +#define PCI_DEVICE_ID_VIA_82C926 0x0926
  27829. +#define PCI_DEVICE_ID_VIA_82C576_1 0x1571
  27830. +#define PCI_DEVICE_ID_VIA_82C595_97 0x1595
  27831. +#define PCI_DEVICE_ID_VIA_82C586_2 0x3038
  27832. +#define PCI_DEVICE_ID_VIA_82C586_3 0x3040
  27833. +#define PCI_DEVICE_ID_VIA_RHINE_I 0x3043
  27834. +#define PCI_DEVICE_ID_VIA_6305 0x3044
  27835. +#define PCI_DEVICE_ID_VIA_82C596_3 0x3050
  27836. +#define PCI_DEVICE_ID_VIA_82C596B_3 0x3051
  27837. +#define PCI_DEVICE_ID_VIA_82C686_4 0x3057
  27838. +#define PCI_DEVICE_ID_VIA_82C686_5 0x3058
  27839. +#define PCI_DEVICE_ID_VIA_8233_5 0x3059
  27840. +#define PCI_DEVICE_ID_VIA_8233_7 0x3065
  27841. +#define PCI_DEVICE_ID_VIA_VT6102 0x3065
  27842. +#define PCI_DEVICE_ID_VIA_82C686_6 0x3068
  27843. +#define PCI_DEVICE_ID_VIA_8233_0 0x3074
  27844. +#define PCI_DEVICE_ID_VIA_VT6105 0x3106
  27845. +#define PCI_DEVICE_ID_VIA_8233C_0 0x3109
  27846. +#define PCI_DEVICE_ID_VIA_8633_0 0x3091
  27847. +#define PCI_DEVICE_ID_VIA_8367_0 0x3099
  27848. +#define PCI_DEVICE_ID_VIA_86C100A 0x6100
  27849. +#define PCI_DEVICE_ID_VIA_8231 0x8231
  27850. +#define PCI_DEVICE_ID_VIA_8231_4 0x8235
  27851. +#define PCI_DEVICE_ID_VIA_8365_1 0x8305
  27852. +#define PCI_DEVICE_ID_VIA_8371_1 0x8391
  27853. +#define PCI_DEVICE_ID_VIA_8501_1 0x8501
  27854. +#define PCI_DEVICE_ID_VIA_82C597_1 0x8597
  27855. +#define PCI_DEVICE_ID_VIA_82C598_1 0x8598
  27856. +#define PCI_DEVICE_ID_VIA_8601_1 0x8601
  27857. +#define PCI_DEVICE_ID_VIA_8505_1 0X8605
  27858. +#define PCI_DEVICE_ID_VIA_8633_1 0xB091
  27859. +#define PCI_DEVICE_ID_VIA_8367_1 0xB099
  27860. +
  27861. +#define PCI_VENDOR_ID_SIEMENS 0x110A
  27862. +#define PCI_DEVICE_ID_SIEMENS_DSCC4 0x2102
  27863. +
  27864. +#define PCI_VENDOR_ID_SMC2 0x1113
  27865. +#define PCI_DEVICE_ID_SMC2_1211TX 0x1211
  27866. +#define PCI_DEVICE_ID_SMC2_1211 0x1211
  27867. +#define PCI_DEVICE_ID_SMC2_1216 0x1216
  27868. +
  27869. +#define PCI_VENDOR_ID_VORTEX 0x1119
  27870. +#define PCI_DEVICE_ID_VORTEX_GDT60x0 0x0000
  27871. +#define PCI_DEVICE_ID_VORTEX_GDT6000B 0x0001
  27872. +#define PCI_DEVICE_ID_VORTEX_GDT6x10 0x0002
  27873. +#define PCI_DEVICE_ID_VORTEX_GDT6x20 0x0003
  27874. +#define PCI_DEVICE_ID_VORTEX_GDT6530 0x0004
  27875. +#define PCI_DEVICE_ID_VORTEX_GDT6550 0x0005
  27876. +#define PCI_DEVICE_ID_VORTEX_GDT6x17 0x0006
  27877. +#define PCI_DEVICE_ID_VORTEX_GDT6x27 0x0007
  27878. +#define PCI_DEVICE_ID_VORTEX_GDT6537 0x0008
  27879. +#define PCI_DEVICE_ID_VORTEX_GDT6557 0x0009
  27880. +#define PCI_DEVICE_ID_VORTEX_GDT6x15 0x000a
  27881. +#define PCI_DEVICE_ID_VORTEX_GDT6x25 0x000b
  27882. +#define PCI_DEVICE_ID_VORTEX_GDT6535 0x000c
  27883. +#define PCI_DEVICE_ID_VORTEX_GDT6555 0x000d
  27884. +#define PCI_DEVICE_ID_VORTEX_GDT6x17RP 0x0100
  27885. +#define PCI_DEVICE_ID_VORTEX_GDT6x27RP 0x0101
  27886. +#define PCI_DEVICE_ID_VORTEX_GDT6537RP 0x0102
  27887. +#define PCI_DEVICE_ID_VORTEX_GDT6557RP 0x0103
  27888. +#define PCI_DEVICE_ID_VORTEX_GDT6x11RP 0x0104
  27889. +#define PCI_DEVICE_ID_VORTEX_GDT6x21RP 0x0105
  27890. +#define PCI_DEVICE_ID_VORTEX_GDT6x17RP1 0x0110
  27891. +#define PCI_DEVICE_ID_VORTEX_GDT6x27RP1 0x0111
  27892. +#define PCI_DEVICE_ID_VORTEX_GDT6537RP1 0x0112
  27893. +#define PCI_DEVICE_ID_VORTEX_GDT6557RP1 0x0113
  27894. +#define PCI_DEVICE_ID_VORTEX_GDT6x11RP1 0x0114
  27895. +#define PCI_DEVICE_ID_VORTEX_GDT6x21RP1 0x0115
  27896. +#define PCI_DEVICE_ID_VORTEX_GDT6x17RP2 0x0120
  27897. +#define PCI_DEVICE_ID_VORTEX_GDT6x27RP2 0x0121
  27898. +#define PCI_DEVICE_ID_VORTEX_GDT6537RP2 0x0122
  27899. +#define PCI_DEVICE_ID_VORTEX_GDT6557RP2 0x0123
  27900. +#define PCI_DEVICE_ID_VORTEX_GDT6x11RP2 0x0124
  27901. +#define PCI_DEVICE_ID_VORTEX_GDT6x21RP2 0x0125
  27902. +
  27903. +#define PCI_VENDOR_ID_EF 0x111a
  27904. +#define PCI_DEVICE_ID_EF_ATM_FPGA 0x0000
  27905. +#define PCI_DEVICE_ID_EF_ATM_ASIC 0x0002
  27906. +
  27907. +#define PCI_VENDOR_ID_IDT 0x111d
  27908. +#define PCI_DEVICE_ID_IDT_IDT77201 0x0001
  27909. +
  27910. +#define PCI_VENDOR_ID_FORE 0x1127
  27911. +#define PCI_DEVICE_ID_FORE_PCA200PC 0x0210
  27912. +#define PCI_DEVICE_ID_FORE_PCA200E 0x0300
  27913. +
  27914. +#define PCI_VENDOR_ID_IMAGINGTECH 0x112f
  27915. +#define PCI_DEVICE_ID_IMAGINGTECH_ICPCI 0x0000
  27916. +
  27917. +#define PCI_VENDOR_ID_PHILIPS 0x1131
  27918. +#define PCI_DEVICE_ID_PHILIPS_SAA7145 0x7145
  27919. +#define PCI_DEVICE_ID_PHILIPS_SAA7146 0x7146
  27920. +#define PCI_DEVICE_ID_PHILIPS_SAA9730 0x9730
  27921. +
  27922. +#define PCI_VENDOR_ID_EICON 0x1133
  27923. +#define PCI_DEVICE_ID_EICON_DIVA20PRO 0xe001
  27924. +#define PCI_DEVICE_ID_EICON_DIVA20 0xe002
  27925. +#define PCI_DEVICE_ID_EICON_DIVA20PRO_U 0xe003
  27926. +#define PCI_DEVICE_ID_EICON_DIVA20_U 0xe004
  27927. +#define PCI_DEVICE_ID_EICON_DIVA201 0xe005
  27928. +#define PCI_DEVICE_ID_EICON_MAESTRA 0xe010
  27929. +#define PCI_DEVICE_ID_EICON_MAESTRAQ 0xe012
  27930. +#define PCI_DEVICE_ID_EICON_MAESTRAQ_U 0xe013
  27931. +#define PCI_DEVICE_ID_EICON_MAESTRAP 0xe014
  27932. +
  27933. +#define PCI_VENDOR_ID_CYCLONE 0x113c
  27934. +#define PCI_DEVICE_ID_CYCLONE_SDK 0x0001
  27935. +
  27936. +#define PCI_VENDOR_ID_ALLIANCE 0x1142
  27937. +#define PCI_DEVICE_ID_ALLIANCE_PROMOTIO 0x3210
  27938. +#define PCI_DEVICE_ID_ALLIANCE_PROVIDEO 0x6422
  27939. +#define PCI_DEVICE_ID_ALLIANCE_AT24 0x6424
  27940. +#define PCI_DEVICE_ID_ALLIANCE_AT3D 0x643d
  27941. +
  27942. +#define PCI_VENDOR_ID_SYSKONNECT 0x1148
  27943. +#define PCI_DEVICE_ID_SYSKONNECT_FP 0x4000
  27944. +#define PCI_DEVICE_ID_SYSKONNECT_TR 0x4200
  27945. +#define PCI_DEVICE_ID_SYSKONNECT_GE 0x4300
  27946. +
  27947. +#define PCI_VENDOR_ID_VMIC 0x114a
  27948. +#define PCI_DEVICE_ID_VMIC_VME 0x7587
  27949. +
  27950. +#define PCI_VENDOR_ID_DIGI 0x114f
  27951. +#define PCI_DEVICE_ID_DIGI_EPC 0x0002
  27952. +#define PCI_DEVICE_ID_DIGI_RIGHTSWITCH 0x0003
  27953. +#define PCI_DEVICE_ID_DIGI_XEM 0x0004
  27954. +#define PCI_DEVICE_ID_DIGI_XR 0x0005
  27955. +#define PCI_DEVICE_ID_DIGI_CX 0x0006
  27956. +#define PCI_DEVICE_ID_DIGI_XRJ 0x0009
  27957. +#define PCI_DEVICE_ID_DIGI_EPCJ 0x000a
  27958. +#define PCI_DEVICE_ID_DIGI_XR_920 0x0027
  27959. +#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_E 0x0070
  27960. +#define PCI_DEVICE_ID_DIGI_DF_M_E 0x0071
  27961. +#define PCI_DEVICE_ID_DIGI_DF_M_IOM2_A 0x0072
  27962. +#define PCI_DEVICE_ID_DIGI_DF_M_A 0x0073
  27963. +
  27964. +#define PCI_VENDOR_ID_MUTECH 0x1159
  27965. +#define PCI_DEVICE_ID_MUTECH_MV1000 0x0001
  27966. +
  27967. +#define PCI_VENDOR_ID_XIRCOM 0x115d
  27968. +#define PCI_DEVICE_ID_XIRCOM_X3201_ETH 0x0003
  27969. +#define PCI_DEVICE_ID_XIRCOM_X3201_MDM 0x0103
  27970. +
  27971. +#define PCI_VENDOR_ID_RENDITION 0x1163
  27972. +#define PCI_DEVICE_ID_RENDITION_VERITE 0x0001
  27973. +#define PCI_DEVICE_ID_RENDITION_VERITE2100 0x2000
  27974. +
  27975. +#define PCI_VENDOR_ID_SERVERWORKS 0x1166
  27976. +#define PCI_DEVICE_ID_SERVERWORKS_HE 0x0008
  27977. +#define PCI_DEVICE_ID_SERVERWORKS_LE 0x0009
  27978. +#define PCI_DEVICE_ID_SERVERWORKS_CIOB30 0x0010
  27979. +#define PCI_DEVICE_ID_SERVERWORKS_CMIC_HE 0x0011
  27980. +#define PCI_DEVICE_ID_SERVERWORKS_OSB4 0x0200
  27981. +#define PCI_DEVICE_ID_SERVERWORKS_CSB5 0x0201
  27982. +#define PCI_DEVICE_ID_SERVERWORKS_OSB4IDE 0x0211
  27983. +#define PCI_DEVICE_ID_SERVERWORKS_CSB5IDE 0x0212
  27984. +#define PCI_DEVICE_ID_SERVERWORKS_OSB4USB 0x0220
  27985. +#define PCI_DEVICE_ID_SERVERWORKS_CSB5USB PCI_DEVICE_ID_SERVERWORKS_OSB4USB
  27986. +#define PCI_DEVICE_ID_SERVERWORKS_CSB5ISA 0x0230
  27987. +
  27988. +#define PCI_VENDOR_ID_SBE 0x1176
  27989. +#define PCI_DEVICE_ID_SBE_WANXL100 0x0301
  27990. +#define PCI_DEVICE_ID_SBE_WANXL200 0x0302
  27991. +#define PCI_DEVICE_ID_SBE_WANXL400 0x0104
  27992. +
  27993. +#define PCI_VENDOR_ID_TOSHIBA 0x1179
  27994. +#define PCI_DEVICE_ID_TOSHIBA_601 0x0601
  27995. +#define PCI_DEVICE_ID_TOSHIBA_TOPIC95 0x060a
  27996. +#define PCI_DEVICE_ID_TOSHIBA_TOPIC97 0x060f
  27997. +
  27998. +#define PCI_VENDOR_ID_RICOH 0x1180
  27999. +#define PCI_DEVICE_ID_RICOH_RL5C465 0x0465
  28000. +#define PCI_DEVICE_ID_RICOH_RL5C466 0x0466
  28001. +#define PCI_DEVICE_ID_RICOH_RL5C475 0x0475
  28002. +#define PCI_DEVICE_ID_RICOH_RL5C476 0x0476
  28003. +#define PCI_DEVICE_ID_RICOH_RL5C478 0x0478
  28004. +
  28005. +#define PCI_VENDOR_ID_DLINK 0x1186
  28006. +#define PCI_DEVICE_ID_DFE530TXP 0x1300
  28007. +#define PCI_DEVICE_ID_DFE530TXS 0x1002
  28008. +
  28009. +#define PCI_VENDOR_ID_ARTOP 0x1191
  28010. +#define PCI_DEVICE_ID_ARTOP_ATP8400 0x0004
  28011. +#define PCI_DEVICE_ID_ARTOP_ATP850UF 0x0005
  28012. +#define PCI_DEVICE_ID_ARTOP_ATP860 0x0006
  28013. +#define PCI_DEVICE_ID_ARTOP_ATP860R 0x0007
  28014. +#define PCI_DEVICE_ID_ARTOP_AEC7610 0x8002
  28015. +#define PCI_DEVICE_ID_ARTOP_AEC7612UW 0x8010
  28016. +#define PCI_DEVICE_ID_ARTOP_AEC7612U 0x8020
  28017. +#define PCI_DEVICE_ID_ARTOP_AEC7612S 0x8030
  28018. +#define PCI_DEVICE_ID_ARTOP_AEC7612D 0x8040
  28019. +#define PCI_DEVICE_ID_ARTOP_AEC7612SUW 0x8050
  28020. +#define PCI_DEVICE_ID_ARTOP_8060 0x8060
  28021. +
  28022. +#define PCI_VENDOR_ID_ZEITNET 0x1193
  28023. +#define PCI_DEVICE_ID_ZEITNET_1221 0x0001
  28024. +#define PCI_DEVICE_ID_ZEITNET_1225 0x0002
  28025. +
  28026. +#define PCI_VENDOR_ID_OMEGA 0x119b
  28027. +#define PCI_DEVICE_ID_OMEGA_82C092G 0x1221
  28028. +
  28029. +#define PCI_VENDOR_ID_FUJITSU_ME 0x119e
  28030. +#define PCI_DEVICE_ID_FUJITSU_FS155 0x0001
  28031. +#define PCI_DEVICE_ID_FUJITSU_FS50 0x0003
  28032. +
  28033. +#define PCI_SUBVENDOR_ID_KEYSPAN 0x11a9
  28034. +#define PCI_SUBDEVICE_ID_KEYSPAN_SX2 0x5334
  28035. +
  28036. +#define PCI_VENDOR_ID_GALILEO 0x11ab
  28037. +#define PCI_DEVICE_ID_GALILEO_GT64011 0x4146
  28038. +#define PCI_DEVICE_ID_GALILEO_GT64111 0x4146
  28039. +#define PCI_DEVICE_ID_GALILEO_GT96100 0x9652
  28040. +#define PCI_DEVICE_ID_GALILEO_GT96100A 0x9653
  28041. +
  28042. +#define PCI_VENDOR_ID_LINKSYS 0x11ad
  28043. +#define PCI_VENDOR_ID_LITEON 0x11ad
  28044. +#define PCI_DEVICE_ID_LITEON_LNE100TX 0x0002
  28045. +#define PCI_DEVICE_ID_LC82C115 0xC115
  28046. +
  28047. +#define PCI_VENDOR_ID_V3 0x11b0
  28048. +#define PCI_DEVICE_ID_V3_V960 0x0001
  28049. +#define PCI_DEVICE_ID_V3_V350 0x0001
  28050. +#define PCI_DEVICE_ID_V3_V961 0x0002
  28051. +#define PCI_DEVICE_ID_V3_V351 0x0002
  28052. +
  28053. +#define PCI_VENDOR_ID_NP 0x11bc
  28054. +#define PCI_DEVICE_ID_NP_PCI_FDDI 0x0001
  28055. +
  28056. +#define PCI_VENDOR_ID_ATT 0x11c1
  28057. +#define PCI_DEVICE_ID_ATT_L56XMF 0x0440
  28058. +#define PCI_DEVICE_ID_ATT_VENUS_MODEM 0x480
  28059. +
  28060. +#define PCI_VENDOR_ID_SPECIALIX 0x11cb
  28061. +#define PCI_DEVICE_ID_SPECIALIX_IO8 0x2000
  28062. +#define PCI_DEVICE_ID_SPECIALIX_XIO 0x4000
  28063. +#define PCI_DEVICE_ID_SPECIALIX_RIO 0x8000
  28064. +#define PCI_SUBDEVICE_ID_SPECIALIX_SPEED4 0xa004
  28065. +
  28066. +#define PCI_VENDOR_ID_AURAVISION 0x11d1
  28067. +#define PCI_DEVICE_ID_AURAVISION_VXP524 0x01f7
  28068. +
  28069. +#define PCI_VENDOR_ID_ANALOG_DEVICES 0x11d4
  28070. +#define PCI_DEVICE_ID_AD1889JS 0x1889
  28071. +
  28072. +#define PCI_VENDOR_ID_IKON 0x11d5
  28073. +#define PCI_DEVICE_ID_IKON_10115 0x0115
  28074. +#define PCI_DEVICE_ID_IKON_10117 0x0117
  28075. +
  28076. +#define PCI_VENDOR_ID_ZORAN 0x11de
  28077. +#define PCI_DEVICE_ID_ZORAN_36057 0x6057
  28078. +#define PCI_DEVICE_ID_ZORAN_36120 0x6120
  28079. +
  28080. +#define PCI_VENDOR_ID_KINETIC 0x11f4
  28081. +#define PCI_DEVICE_ID_KINETIC_2915 0x2915
  28082. +
  28083. +#define PCI_VENDOR_ID_COMPEX 0x11f6
  28084. +#define PCI_DEVICE_ID_COMPEX_ENET100VG4 0x0112
  28085. +#define PCI_DEVICE_ID_COMPEX_RL2000 0x1401
  28086. +#define PCI_DEVICE_ID_COMPEX_RL100ATX 0x2011
  28087. +
  28088. +#define PCI_VENDOR_ID_RP 0x11fe
  28089. +#define PCI_DEVICE_ID_RP32INTF 0x0001
  28090. +#define PCI_DEVICE_ID_RP8INTF 0x0002
  28091. +#define PCI_DEVICE_ID_RP16INTF 0x0003
  28092. +#define PCI_DEVICE_ID_RP4QUAD 0x0004
  28093. +#define PCI_DEVICE_ID_RP8OCTA 0x0005
  28094. +#define PCI_DEVICE_ID_RP8J 0x0006
  28095. +#define PCI_DEVICE_ID_RPP4 0x000A
  28096. +#define PCI_DEVICE_ID_RPP8 0x000B
  28097. +#define PCI_DEVICE_ID_RP8M 0x000C
  28098. +
  28099. +#define PCI_VENDOR_ID_CYCLADES 0x120e
  28100. +#define PCI_DEVICE_ID_CYCLOM_Y_Lo 0x0100
  28101. +#define PCI_DEVICE_ID_CYCLOM_Y_Hi 0x0101
  28102. +#define PCI_DEVICE_ID_CYCLOM_4Y_Lo 0x0102
  28103. +#define PCI_DEVICE_ID_CYCLOM_4Y_Hi 0x0103
  28104. +#define PCI_DEVICE_ID_CYCLOM_8Y_Lo 0x0104
  28105. +#define PCI_DEVICE_ID_CYCLOM_8Y_Hi 0x0105
  28106. +#define PCI_DEVICE_ID_CYCLOM_Z_Lo 0x0200
  28107. +#define PCI_DEVICE_ID_CYCLOM_Z_Hi 0x0201
  28108. +#define PCI_DEVICE_ID_PC300_RX_2 0x0300
  28109. +#define PCI_DEVICE_ID_PC300_RX_1 0x0301
  28110. +#define PCI_DEVICE_ID_PC300_TE_2 0x0310
  28111. +#define PCI_DEVICE_ID_PC300_TE_1 0x0311
  28112. +
  28113. +#define PCI_VENDOR_ID_ESSENTIAL 0x120f
  28114. +#define PCI_DEVICE_ID_ESSENTIAL_ROADRUNNER 0x0001
  28115. +
  28116. +#define PCI_VENDOR_ID_O2 0x1217
  28117. +#define PCI_DEVICE_ID_O2_6729 0x6729
  28118. +#define PCI_DEVICE_ID_O2_6730 0x673a
  28119. +#define PCI_DEVICE_ID_O2_6832 0x6832
  28120. +#define PCI_DEVICE_ID_O2_6836 0x6836
  28121. +
  28122. +#define PCI_VENDOR_ID_3DFX 0x121a
  28123. +#define PCI_DEVICE_ID_3DFX_VOODOO 0x0001
  28124. +#define PCI_DEVICE_ID_3DFX_VOODOO2 0x0002
  28125. +#define PCI_DEVICE_ID_3DFX_BANSHEE 0x0003
  28126. +#define PCI_DEVICE_ID_3DFX_VOODOO3 0x0005
  28127. +
  28128. +#define PCI_VENDOR_ID_SIGMADES 0x1236
  28129. +#define PCI_DEVICE_ID_SIGMADES_6425 0x6401
  28130. +
  28131. +#define PCI_VENDOR_ID_CCUBE 0x123f
  28132. +
  28133. +#define PCI_VENDOR_ID_AVM 0x1244
  28134. +#define PCI_DEVICE_ID_AVM_B1 0x0700
  28135. +#define PCI_DEVICE_ID_AVM_C4 0x0800
  28136. +#define PCI_DEVICE_ID_AVM_A1 0x0a00
  28137. +#define PCI_DEVICE_ID_AVM_A1_V2 0x0e00
  28138. +#define PCI_DEVICE_ID_AVM_C2 0x1100
  28139. +#define PCI_DEVICE_ID_AVM_T1 0x1200
  28140. +
  28141. +#define PCI_VENDOR_ID_DIPIX 0x1246
  28142. +
  28143. +#define PCI_VENDOR_ID_STALLION 0x124d
  28144. +#define PCI_DEVICE_ID_STALLION_ECHPCI832 0x0000
  28145. +#define PCI_DEVICE_ID_STALLION_ECHPCI864 0x0002
  28146. +#define PCI_DEVICE_ID_STALLION_EIOPCI 0x0003
  28147. +
  28148. +#define PCI_VENDOR_ID_OPTIBASE 0x1255
  28149. +#define PCI_DEVICE_ID_OPTIBASE_FORGE 0x1110
  28150. +#define PCI_DEVICE_ID_OPTIBASE_FUSION 0x1210
  28151. +#define PCI_DEVICE_ID_OPTIBASE_VPLEX 0x2110
  28152. +#define PCI_DEVICE_ID_OPTIBASE_VPLEXCC 0x2120
  28153. +#define PCI_DEVICE_ID_OPTIBASE_VQUEST 0x2130
  28154. +
  28155. +#define PCI_VENDOR_ID_ESS 0x125d
  28156. +#define PCI_DEVICE_ID_ESS_ESS1968 0x1968
  28157. +#define PCI_DEVICE_ID_ESS_AUDIOPCI 0x1969
  28158. +#define PCI_DEVICE_ID_ESS_ESS1978 0x1978
  28159. +
  28160. +#define PCI_VENDOR_ID_HARRIS 0x1260
  28161. +#define PCI_DEVICE_ID_HARRIS_PRISM2 0x3873
  28162. +
  28163. +#define PCI_VENDOR_ID_SATSAGEM 0x1267
  28164. +#define PCI_DEVICE_ID_SATSAGEM_NICCY 0x1016
  28165. +#define PCI_DEVICE_ID_SATSAGEM_PCR2101 0x5352
  28166. +#define PCI_DEVICE_ID_SATSAGEM_TELSATTURBO 0x5a4b
  28167. +
  28168. +#define PCI_VENDOR_ID_HUGHES 0x1273
  28169. +#define PCI_DEVICE_ID_HUGHES_DIRECPC 0x0002
  28170. +
  28171. +#define PCI_VENDOR_ID_ENSONIQ 0x1274
  28172. +#define PCI_DEVICE_ID_ENSONIQ_CT5880 0x5880
  28173. +#define PCI_DEVICE_ID_ENSONIQ_ES1370 0x5000
  28174. +#define PCI_DEVICE_ID_ENSONIQ_ES1371 0x1371
  28175. +
  28176. +#define PCI_VENDOR_ID_ROCKWELL 0x127A
  28177. +
  28178. +#define PCI_VENDOR_ID_DAVICOM 0x1282
  28179. +#define PCI_DEVICE_ID_DM9009 0x9009
  28180. +#define PCI_DEVICE_ID_DM9102 0x9102
  28181. +
  28182. +#define PCI_VENDOR_ID_ITE 0x1283
  28183. +#define PCI_DEVICE_ID_ITE_IT8172G_AUDIO 0x0801
  28184. +#define PCI_DEVICE_ID_ITE_IT8172G 0x8172
  28185. +#define PCI_DEVICE_ID_ITE_8872 0x8872
  28186. +
  28187. +
  28188. +/* formerly Platform Tech */
  28189. +#define PCI_VENDOR_ID_ESS_OLD 0x1285
  28190. +#define PCI_DEVICE_ID_ESS_ESS0100 0x0100
  28191. +
  28192. +#define PCI_VENDOR_ID_ALTEON 0x12ae
  28193. +#define PCI_DEVICE_ID_ALTEON_ACENIC 0x0001
  28194. +
  28195. +#define PCI_VENDOR_ID_USR 0x12B9
  28196. +
  28197. +#define PCI_VENDOR_ID_HOLTEK 0x12c3
  28198. +#define PCI_DEVICE_ID_HOLTEK_HT80232 0x0058
  28199. +
  28200. +#define PCI_SUBVENDOR_ID_CONNECT_TECH 0x12c4
  28201. +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_232 0x0001
  28202. +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_232 0x0002
  28203. +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_232 0x0003
  28204. +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485 0x0004
  28205. +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485_4_4 0x0005
  28206. +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_485 0x0006
  28207. +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_485_2_2 0x0007
  28208. +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_485 0x0008
  28209. +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485_2_6 0x0009
  28210. +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH081101V1 0x000A
  28211. +#define PCI_SUBDEVICE_ID_CONNECT_TECH_BH041101V1 0x000B
  28212. +
  28213. +#define PCI_VENDOR_ID_PICTUREL 0x12c5
  28214. +#define PCI_DEVICE_ID_PICTUREL_PCIVST 0x0081
  28215. +
  28216. +#define PCI_VENDOR_ID_NVIDIA_SGS 0x12d2
  28217. +#define PCI_DEVICE_ID_NVIDIA_SGS_RIVA128 0x0018
  28218. +
  28219. +#define PCI_SUBVENDOR_ID_CHASE_PCIFAST 0x12E0
  28220. +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST4 0x0031
  28221. +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST8 0x0021
  28222. +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST16 0x0011
  28223. +#define PCI_SUBDEVICE_ID_CHASE_PCIFAST16FMC 0x0041
  28224. +#define PCI_SUBVENDOR_ID_CHASE_PCIRAS 0x124D
  28225. +#define PCI_SUBDEVICE_ID_CHASE_PCIRAS4 0xF001
  28226. +#define PCI_SUBDEVICE_ID_CHASE_PCIRAS8 0xF010
  28227. +
  28228. +#define PCI_VENDOR_ID_AUREAL 0x12eb
  28229. +#define PCI_DEVICE_ID_AUREAL_VORTEX_1 0x0001
  28230. +#define PCI_DEVICE_ID_AUREAL_VORTEX_2 0x0002
  28231. +
  28232. +#define PCI_VENDOR_ID_CBOARDS 0x1307
  28233. +#define PCI_DEVICE_ID_CBOARDS_DAS1602_16 0x0001
  28234. +
  28235. +#define PCI_VENDOR_ID_SIIG 0x131f
  28236. +#define PCI_DEVICE_ID_SIIG_1S_10x_550 0x1000
  28237. +#define PCI_DEVICE_ID_SIIG_1S_10x_650 0x1001
  28238. +#define PCI_DEVICE_ID_SIIG_1S_10x_850 0x1002
  28239. +#define PCI_DEVICE_ID_SIIG_1S1P_10x_550 0x1010
  28240. +#define PCI_DEVICE_ID_SIIG_1S1P_10x_650 0x1011
  28241. +#define PCI_DEVICE_ID_SIIG_1S1P_10x_850 0x1012
  28242. +#define PCI_DEVICE_ID_SIIG_1P_10x 0x1020
  28243. +#define PCI_DEVICE_ID_SIIG_2P_10x 0x1021
  28244. +#define PCI_DEVICE_ID_SIIG_2S_10x_550 0x1030
  28245. +#define PCI_DEVICE_ID_SIIG_2S_10x_650 0x1031
  28246. +#define PCI_DEVICE_ID_SIIG_2S_10x_850 0x1032
  28247. +#define PCI_DEVICE_ID_SIIG_2S1P_10x_550 0x1034
  28248. +#define PCI_DEVICE_ID_SIIG_2S1P_10x_650 0x1035
  28249. +#define PCI_DEVICE_ID_SIIG_2S1P_10x_850 0x1036
  28250. +#define PCI_DEVICE_ID_SIIG_4S_10x_550 0x1050
  28251. +#define PCI_DEVICE_ID_SIIG_4S_10x_650 0x1051
  28252. +#define PCI_DEVICE_ID_SIIG_4S_10x_850 0x1052
  28253. +#define PCI_DEVICE_ID_SIIG_1S_20x_550 0x2000
  28254. +#define PCI_DEVICE_ID_SIIG_1S_20x_650 0x2001
  28255. +#define PCI_DEVICE_ID_SIIG_1S_20x_850 0x2002
  28256. +#define PCI_DEVICE_ID_SIIG_1P_20x 0x2020
  28257. +#define PCI_DEVICE_ID_SIIG_2P_20x 0x2021
  28258. +#define PCI_DEVICE_ID_SIIG_2S_20x_550 0x2030
  28259. +#define PCI_DEVICE_ID_SIIG_2S_20x_650 0x2031
  28260. +#define PCI_DEVICE_ID_SIIG_2S_20x_850 0x2032
  28261. +#define PCI_DEVICE_ID_SIIG_2P1S_20x_550 0x2040
  28262. +#define PCI_DEVICE_ID_SIIG_2P1S_20x_650 0x2041
  28263. +#define PCI_DEVICE_ID_SIIG_2P1S_20x_850 0x2042
  28264. +#define PCI_DEVICE_ID_SIIG_1S1P_20x_550 0x2010
  28265. +#define PCI_DEVICE_ID_SIIG_1S1P_20x_650 0x2011
  28266. +#define PCI_DEVICE_ID_SIIG_1S1P_20x_850 0x2012
  28267. +#define PCI_DEVICE_ID_SIIG_4S_20x_550 0x2050
  28268. +#define PCI_DEVICE_ID_SIIG_4S_20x_650 0x2051
  28269. +#define PCI_DEVICE_ID_SIIG_4S_20x_850 0x2052
  28270. +#define PCI_DEVICE_ID_SIIG_2S1P_20x_550 0x2060
  28271. +#define PCI_DEVICE_ID_SIIG_2S1P_20x_650 0x2061
  28272. +#define PCI_DEVICE_ID_SIIG_2S1P_20x_850 0x2062
  28273. +
  28274. +#define PCI_VENDOR_ID_ADMTEK 0x1317
  28275. +#define PCI_DEVICE_ID_ADMTEK_0985 0x0985
  28276. +
  28277. +#define PCI_VENDOR_ID_DOMEX 0x134a
  28278. +#define PCI_DEVICE_ID_DOMEX_DMX3191D 0x0001
  28279. +
  28280. +#define PCI_VENDOR_ID_QUATECH 0x135C
  28281. +#define PCI_DEVICE_ID_QUATECH_QSC100 0x0010
  28282. +#define PCI_DEVICE_ID_QUATECH_DSC100 0x0020
  28283. +#define PCI_DEVICE_ID_QUATECH_DSC200 0x0030
  28284. +#define PCI_DEVICE_ID_QUATECH_QSC200 0x0040
  28285. +#define PCI_DEVICE_ID_QUATECH_ESC100D 0x0050
  28286. +#define PCI_DEVICE_ID_QUATECH_ESC100M 0x0060
  28287. +
  28288. +#define PCI_VENDOR_ID_SEALEVEL 0x135e
  28289. +#define PCI_DEVICE_ID_SEALEVEL_U530 0x7101
  28290. +#define PCI_DEVICE_ID_SEALEVEL_UCOMM2 0x7201
  28291. +#define PCI_DEVICE_ID_SEALEVEL_UCOMM422 0x7402
  28292. +#define PCI_DEVICE_ID_SEALEVEL_UCOMM232 0x7202
  28293. +#define PCI_DEVICE_ID_SEALEVEL_COMM4 0x7401
  28294. +#define PCI_DEVICE_ID_SEALEVEL_COMM8 0x7801
  28295. +
  28296. +#define PCI_VENDOR_ID_HYPERCOPE 0x1365
  28297. +#define PCI_DEVICE_ID_HYPERCOPE_PLX 0x9050
  28298. +#define PCI_SUBDEVICE_ID_HYPERCOPE_OLD_ERGO 0x0104
  28299. +#define PCI_SUBDEVICE_ID_HYPERCOPE_ERGO 0x0106
  28300. +#define PCI_SUBDEVICE_ID_HYPERCOPE_METRO 0x0107
  28301. +#define PCI_SUBDEVICE_ID_HYPERCOPE_CHAMP2 0x0108
  28302. +#define PCI_SUBDEVICE_ID_HYPERCOPE_PLEXUS 0x0109
  28303. +
  28304. +#define PCI_VENDOR_ID_KAWASAKI 0x136b
  28305. +#define PCI_DEVICE_ID_MCHIP_KL5A72002 0xff01
  28306. +
  28307. +#define PCI_VENDOR_ID_LMC 0x1376
  28308. +#define PCI_DEVICE_ID_LMC_HSSI 0x0003
  28309. +#define PCI_DEVICE_ID_LMC_DS3 0x0004
  28310. +#define PCI_DEVICE_ID_LMC_SSI 0x0005
  28311. +#define PCI_DEVICE_ID_LMC_T1 0x0006
  28312. +
  28313. +#define PCI_VENDOR_ID_NETGEAR 0x1385
  28314. +#define PCI_DEVICE_ID_NETGEAR_MA301 0x4100
  28315. +#define PCI_DEVICE_ID_NETGEAR_GA620 0x620a
  28316. +#define PCI_DEVICE_ID_NETGEAR_GA622 0x622a
  28317. +
  28318. +#define PCI_VENDOR_ID_APPLICOM 0x1389
  28319. +#define PCI_DEVICE_ID_APPLICOM_PCIGENERIC 0x0001
  28320. +#define PCI_DEVICE_ID_APPLICOM_PCI2000IBS_CAN 0x0002
  28321. +#define PCI_DEVICE_ID_APPLICOM_PCI2000PFB 0x0003
  28322. +
  28323. +#define PCI_VENDOR_ID_MOXA 0x1393
  28324. +#define PCI_DEVICE_ID_MOXA_C104 0x1040
  28325. +#define PCI_DEVICE_ID_MOXA_C168 0x1680
  28326. +#define PCI_DEVICE_ID_MOXA_CP204J 0x2040
  28327. +#define PCI_DEVICE_ID_MOXA_C218 0x2180
  28328. +#define PCI_DEVICE_ID_MOXA_C320 0x3200
  28329. +
  28330. +#define PCI_VENDOR_ID_CCD 0x1397
  28331. +#define PCI_DEVICE_ID_CCD_2BD0 0x2bd0
  28332. +#define PCI_DEVICE_ID_CCD_B000 0xb000
  28333. +#define PCI_DEVICE_ID_CCD_B006 0xb006
  28334. +#define PCI_DEVICE_ID_CCD_B007 0xb007
  28335. +#define PCI_DEVICE_ID_CCD_B008 0xb008
  28336. +#define PCI_DEVICE_ID_CCD_B009 0xb009
  28337. +#define PCI_DEVICE_ID_CCD_B00A 0xb00a
  28338. +#define PCI_DEVICE_ID_CCD_B00B 0xb00b
  28339. +#define PCI_DEVICE_ID_CCD_B00C 0xb00c
  28340. +#define PCI_DEVICE_ID_CCD_B100 0xb100
  28341. +
  28342. +#define PCI_VENDOR_ID_MICROGATE 0x13c0
  28343. +#define PCI_DEVICE_ID_MICROGATE_USC 0x0010
  28344. +#define PCI_DEVICE_ID_MICROGATE_SCC 0x0020
  28345. +#define PCI_DEVICE_ID_MICROGATE_SCA 0x0030
  28346. +
  28347. +#define PCI_VENDOR_ID_3WARE 0x13C1
  28348. +#define PCI_DEVICE_ID_3WARE_1000 0x1000
  28349. +
  28350. +#define PCI_VENDOR_ID_ABOCOM 0x13D1
  28351. +#define PCI_DEVICE_ID_ABOCOM_2BD1 0x2BD1
  28352. +
  28353. +#define PCI_VENDOR_ID_CMEDIA 0x13f6
  28354. +#define PCI_DEVICE_ID_CMEDIA_CM8338A 0x0100
  28355. +#define PCI_DEVICE_ID_CMEDIA_CM8338B 0x0101
  28356. +#define PCI_DEVICE_ID_CMEDIA_CM8738 0x0111
  28357. +#define PCI_DEVICE_ID_CMEDIA_CM8738B 0x0112
  28358. +
  28359. +#define PCI_VENDOR_ID_LAVA 0x1407
  28360. +#define PCI_DEVICE_ID_LAVA_DSERIAL 0x0100 /* 2x 16550 */
  28361. +#define PCI_DEVICE_ID_LAVA_QUATRO_A 0x0101 /* 2x 16550, half of 4 port */
  28362. +#define PCI_DEVICE_ID_LAVA_QUATRO_B 0x0102 /* 2x 16550, half of 4 port */
  28363. +#define PCI_DEVICE_ID_LAVA_PORT_PLUS 0x0200 /* 2x 16650 */
  28364. +#define PCI_DEVICE_ID_LAVA_QUAD_A 0x0201 /* 2x 16650, half of 4 port */
  28365. +#define PCI_DEVICE_ID_LAVA_QUAD_B 0x0202 /* 2x 16650, half of 4 port */
  28366. +#define PCI_DEVICE_ID_LAVA_SSERIAL 0x0500 /* 1x 16550 */
  28367. +#define PCI_DEVICE_ID_LAVA_PORT_650 0x0600 /* 1x 16650 */
  28368. +#define PCI_DEVICE_ID_LAVA_PARALLEL 0x8000
  28369. +#define PCI_DEVICE_ID_LAVA_DUAL_PAR_A 0x8002 /* The Lava Dual Parallel is */
  28370. +#define PCI_DEVICE_ID_LAVA_DUAL_PAR_B 0x8003 /* two PCI devices on a card */
  28371. +#define PCI_DEVICE_ID_LAVA_BOCA_IOPPAR 0x8800
  28372. +
  28373. +#define PCI_VENDOR_ID_TIMEDIA 0x1409
  28374. +#define PCI_DEVICE_ID_TIMEDIA_1889 0x7168
  28375. +
  28376. +#define PCI_VENDOR_ID_OXSEMI 0x1415
  28377. +#define PCI_DEVICE_ID_OXSEMI_12PCI840 0x8403
  28378. +#define PCI_DEVICE_ID_OXSEMI_16PCI954 0x9501
  28379. +#define PCI_DEVICE_ID_OXSEMI_16PCI952 0x950A
  28380. +#define PCI_DEVICE_ID_OXSEMI_16PCI95N 0x9511
  28381. +#define PCI_DEVICE_ID_OXSEMI_16PCI954PP 0x9513
  28382. +
  28383. +#define PCI_VENDOR_ID_AIRONET 0x14b9
  28384. +#define PCI_DEVICE_ID_AIRONET_4800_1 0x0001
  28385. +#define PCI_DEVICE_ID_AIRONET_4800 0x4500 // values switched? see
  28386. +#define PCI_DEVICE_ID_AIRONET_4500 0x4800 // drivers/net/aironet4500_card.c
  28387. +
  28388. +#define PCI_VENDOR_ID_TITAN 0x14D2
  28389. +#define PCI_DEVICE_ID_TITAN_010L 0x8001
  28390. +#define PCI_DEVICE_ID_TITAN_100L 0x8010
  28391. +#define PCI_DEVICE_ID_TITAN_110L 0x8011
  28392. +#define PCI_DEVICE_ID_TITAN_200L 0x8020
  28393. +#define PCI_DEVICE_ID_TITAN_210L 0x8021
  28394. +#define PCI_DEVICE_ID_TITAN_400L 0x8040
  28395. +#define PCI_DEVICE_ID_TITAN_800L 0x8080
  28396. +#define PCI_DEVICE_ID_TITAN_100 0xA001
  28397. +#define PCI_DEVICE_ID_TITAN_200 0xA005
  28398. +#define PCI_DEVICE_ID_TITAN_400 0xA003
  28399. +#define PCI_DEVICE_ID_TITAN_800B 0xA004
  28400. +
  28401. +#define PCI_VENDOR_ID_PANACOM 0x14d4
  28402. +#define PCI_DEVICE_ID_PANACOM_QUADMODEM 0x0400
  28403. +#define PCI_DEVICE_ID_PANACOM_DUALMODEM 0x0402
  28404. +
  28405. +#define PCI_VENDOR_ID_BROADCOM 0x14e4
  28406. +#define PCI_DEVICE_ID_TIGON3_5700 0x1644
  28407. +#define PCI_DEVICE_ID_TIGON3_5701 0x1645
  28408. +#define PCI_DEVICE_ID_TIGON3_5702 0x1646
  28409. +#define PCI_DEVICE_ID_TIGON3_5703 0x1647
  28410. +#define PCI_DEVICE_ID_TIGON3_5704 0x1648
  28411. +#define PCI_DEVICE_ID_TIGON3_5702FE 0x164d
  28412. +#define PCI_DEVICE_ID_TIGON3_5705 0x1653
  28413. +#define PCI_DEVICE_ID_TIGON3_5705_2 0x1654
  28414. +#define PCI_DEVICE_ID_TIGON3_5705M 0x165d
  28415. +#define PCI_DEVICE_ID_TIGON3_5705M_2 0x165e
  28416. +#define PCI_DEVICE_ID_TIGON3_5782 0x1696
  28417. +#define PCI_DEVICE_ID_TIGON3_5788 0x169c
  28418. +#define PCI_DEVICE_ID_TIGON3_5702X 0x16a6
  28419. +#define PCI_DEVICE_ID_TIGON3_5703X 0x16a7
  28420. +#define PCI_DEVICE_ID_TIGON3_5704S 0x16a8
  28421. +#define PCI_DEVICE_ID_TIGON3_5702A3 0x16c6
  28422. +#define PCI_DEVICE_ID_TIGON3_5703A3 0x16c7
  28423. +#define PCI_DEVICE_ID_TIGON3_5901 0x170d
  28424. +#define PCI_DEVICE_ID_TIGON3_5901_2 0x170e
  28425. +
  28426. +#define PCI_VENDOR_ID_SYBA 0x1592
  28427. +#define PCI_DEVICE_ID_SYBA_2P_EPP 0x0782
  28428. +#define PCI_DEVICE_ID_SYBA_1P_ECP 0x0783
  28429. +
  28430. +#define PCI_VENDOR_ID_MORETON 0x15aa
  28431. +#define PCI_DEVICE_ID_RASTEL_2PORT 0x2000
  28432. +
  28433. +#define PCI_VENDOR_ID_ZOLTRIX 0x15b0
  28434. +#define PCI_DEVICE_ID_ZOLTRIX_2BD0 0x2bd0
  28435. +
  28436. +#define PCI_VENDOR_ID_PDC 0x15e9
  28437. +#define PCI_DEVICE_ID_PDC_1841 0x1841
  28438. +
  28439. +#define PCI_VENDOR_ID_SYMPHONY 0x1c1c
  28440. +#define PCI_DEVICE_ID_SYMPHONY_101 0x0001
  28441. +
  28442. +#define PCI_VENDOR_ID_TEKRAM 0x1de1
  28443. +#define PCI_DEVICE_ID_TEKRAM_DC290 0xdc29
  28444. +
  28445. +#define PCI_VENDOR_ID_3DLABS 0x3d3d
  28446. +#define PCI_DEVICE_ID_3DLABS_300SX 0x0001
  28447. +#define PCI_DEVICE_ID_3DLABS_500TX 0x0002
  28448. +#define PCI_DEVICE_ID_3DLABS_DELTA 0x0003
  28449. +#define PCI_DEVICE_ID_3DLABS_PERMEDIA 0x0004
  28450. +#define PCI_DEVICE_ID_3DLABS_MX 0x0006
  28451. +#define PCI_DEVICE_ID_3DLABS_PERMEDIA2 0x0007
  28452. +#define PCI_DEVICE_ID_3DLABS_GAMMA 0x0008
  28453. +#define PCI_DEVICE_ID_3DLABS_PERMEDIA2V 0x0009
  28454. +
  28455. +#define PCI_VENDOR_ID_AVANCE 0x4005
  28456. +#define PCI_DEVICE_ID_AVANCE_ALG2064 0x2064
  28457. +#define PCI_DEVICE_ID_AVANCE_2302 0x2302
  28458. +
  28459. +#define PCI_VENDOR_ID_AKS 0x416c
  28460. +#define PCI_DEVICE_ID_AKS_ALADDINCARD 0x0100
  28461. +#define PCI_DEVICE_ID_AKS_CPC 0x0200
  28462. +
  28463. +#define PCI_VENDOR_ID_NETVIN 0x4a14
  28464. +#define PCI_DEVICE_ID_NETVIN_NV5000SC 0x5000
  28465. +
  28466. +#define PCI_VENDOR_ID_S3 0x5333
  28467. +#define PCI_DEVICE_ID_S3_PLATO_PXS 0x0551
  28468. +#define PCI_DEVICE_ID_S3_ViRGE 0x5631
  28469. +#define PCI_DEVICE_ID_S3_TRIO 0x8811
  28470. +#define PCI_DEVICE_ID_S3_AURORA64VP 0x8812
  28471. +#define PCI_DEVICE_ID_S3_TRIO64UVP 0x8814
  28472. +#define PCI_DEVICE_ID_S3_ViRGE_VX 0x883d
  28473. +#define PCI_DEVICE_ID_S3_868 0x8880
  28474. +#define PCI_DEVICE_ID_S3_928 0x88b0
  28475. +#define PCI_DEVICE_ID_S3_864_1 0x88c0
  28476. +#define PCI_DEVICE_ID_S3_864_2 0x88c1
  28477. +#define PCI_DEVICE_ID_S3_964_1 0x88d0
  28478. +#define PCI_DEVICE_ID_S3_964_2 0x88d1
  28479. +#define PCI_DEVICE_ID_S3_968 0x88f0
  28480. +#define PCI_DEVICE_ID_S3_TRIO64V2 0x8901
  28481. +#define PCI_DEVICE_ID_S3_PLATO_PXG 0x8902
  28482. +#define PCI_DEVICE_ID_S3_ViRGE_DXGX 0x8a01
  28483. +#define PCI_DEVICE_ID_S3_ViRGE_GX2 0x8a10
  28484. +#define PCI_DEVICE_ID_S3_ViRGE_MX 0x8c01
  28485. +#define PCI_DEVICE_ID_S3_ViRGE_MXP 0x8c02
  28486. +#define PCI_DEVICE_ID_S3_ViRGE_MXPMV 0x8c03
  28487. +#define PCI_DEVICE_ID_S3_SONICVIBES 0xca00
  28488. +
  28489. +#define PCI_VENDOR_ID_DCI 0x6666
  28490. +#define PCI_DEVICE_ID_DCI_PCCOM4 0x0001
  28491. +#define PCI_DEVICE_ID_DCI_PCCOM8 0x0002
  28492. +
  28493. +#define PCI_VENDOR_ID_GENROCO 0x5555
  28494. +#define PCI_DEVICE_ID_GENROCO_HFP832 0x0003
  28495. +
  28496. +#define PCI_VENDOR_ID_INTEL 0x8086
  28497. +#define PCI_DEVICE_ID_INTEL_21145 0x0039
  28498. +#define PCI_DEVICE_ID_INTEL_82375 0x0482
  28499. +#define PCI_DEVICE_ID_INTEL_82424 0x0483
  28500. +#define PCI_DEVICE_ID_INTEL_82378 0x0484
  28501. +#define PCI_DEVICE_ID_INTEL_82430 0x0486
  28502. +#define PCI_DEVICE_ID_INTEL_82434 0x04a3
  28503. +#define PCI_DEVICE_ID_INTEL_I960 0x0960
  28504. +#define PCI_DEVICE_ID_INTEL_82542 0x1000
  28505. +#define PCI_DEVICE_ID_INTEL_82543GC_FIBER 0x1001
  28506. +#define PCI_DEVICE_ID_INTEL_82543GC_COPPER 0x1004
  28507. +#define PCI_DEVICE_ID_INTEL_82544EI_COPPER 0x1008
  28508. +#define PCI_DEVICE_ID_INTEL_82544EI_FIBER 0x1009
  28509. +#define PCI_DEVICE_ID_INTEL_82544GC_COPPER 0x100C
  28510. +#define PCI_DEVICE_ID_INTEL_82544GC_LOM 0x100D
  28511. +#define PCI_DEVICE_ID_INTEL_82540EM 0x100E
  28512. +#define PCI_DEVICE_ID_INTEL_82545EM_COPPER 0x100F
  28513. +#define PCI_DEVICE_ID_INTEL_82546EB_COPPER 0x1010
  28514. +#define PCI_DEVICE_ID_INTEL_82545EM_FIBER 0x1011
  28515. +#define PCI_DEVICE_ID_INTEL_82546EB_FIBER 0x1012
  28516. +#define PCI_DEVICE_ID_INTEL_82540EM_LOM 0x1015
  28517. +#define PCI_DEVICE_ID_INTEL_ID1029 0x1029
  28518. +#define PCI_DEVICE_ID_INTEL_ID1030 0x1030
  28519. +#define PCI_DEVICE_ID_INTEL_ID1031 0x1031
  28520. +#define PCI_DEVICE_ID_INTEL_ID1038 0x1038
  28521. +#define PCI_DEVICE_ID_INTEL_ID1039 0x1039
  28522. +#define PCI_DEVICE_ID_INTEL_ID103A 0x103A
  28523. +#define PCI_DEVICE_ID_INTEL_82562ET 0x1031
  28524. +#define PCI_DEVICE_ID_INTEL_82559ER 0x1209
  28525. +#define PCI_DEVICE_ID_INTEL_82092AA_0 0x1221
  28526. +#define PCI_DEVICE_ID_INTEL_82092AA_1 0x1222
  28527. +#define PCI_DEVICE_ID_INTEL_7116 0x1223
  28528. +#define PCI_DEVICE_ID_INTEL_82596 0x1226
  28529. +#define PCI_DEVICE_ID_INTEL_82865 0x1227
  28530. +#define PCI_DEVICE_ID_INTEL_82557 0x1229
  28531. +#define PCI_DEVICE_ID_INTEL_82437 0x122d
  28532. +#define PCI_DEVICE_ID_INTEL_82371FB_0 0x122e
  28533. +#define PCI_DEVICE_ID_INTEL_82371FB_1 0x1230
  28534. +#define PCI_DEVICE_ID_INTEL_82371MX 0x1234
  28535. +#define PCI_DEVICE_ID_INTEL_82437MX 0x1235
  28536. +#define PCI_DEVICE_ID_INTEL_82441 0x1237
  28537. +#define PCI_DEVICE_ID_INTEL_82380FB 0x124b
  28538. +#define PCI_DEVICE_ID_INTEL_82439 0x1250
  28539. +#define PCI_DEVICE_ID_INTEL_80960_RP 0x1960
  28540. +#define PCI_DEVICE_ID_INTEL_82801AA_0 0x2410
  28541. +#define PCI_DEVICE_ID_INTEL_82801AA_1 0x2411
  28542. +#define PCI_DEVICE_ID_INTEL_82801AA_2 0x2412
  28543. +#define PCI_DEVICE_ID_INTEL_82801AA_3 0x2413
  28544. +#define PCI_DEVICE_ID_INTEL_82801AA_5 0x2415
  28545. +#define PCI_DEVICE_ID_INTEL_82801AA_6 0x2416
  28546. +#define PCI_DEVICE_ID_INTEL_82801AA_8 0x2418
  28547. +#define PCI_DEVICE_ID_INTEL_82801AB_0 0x2420
  28548. +#define PCI_DEVICE_ID_INTEL_82801AB_1 0x2421
  28549. +#define PCI_DEVICE_ID_INTEL_82801AB_2 0x2422
  28550. +#define PCI_DEVICE_ID_INTEL_82801AB_3 0x2423
  28551. +#define PCI_DEVICE_ID_INTEL_82801AB_5 0x2425
  28552. +#define PCI_DEVICE_ID_INTEL_82801AB_6 0x2426
  28553. +#define PCI_DEVICE_ID_INTEL_82801AB_8 0x2428
  28554. +#define PCI_DEVICE_ID_INTEL_82801BA_0 0x2440
  28555. +#define PCI_DEVICE_ID_INTEL_82801BA_1 0x2442
  28556. +#define PCI_DEVICE_ID_INTEL_82801BA_2 0x2443
  28557. +#define PCI_DEVICE_ID_INTEL_82801BA_3 0x2444
  28558. +#define PCI_DEVICE_ID_INTEL_82801BA_4 0x2445
  28559. +#define PCI_DEVICE_ID_INTEL_82801BA_5 0x2446
  28560. +#define PCI_DEVICE_ID_INTEL_82801BA_6 0x2448
  28561. +#define PCI_DEVICE_ID_INTEL_82801BA_7 0x2449
  28562. +#define PCI_DEVICE_ID_INTEL_82562 0x2449
  28563. +#define PCI_DEVICE_ID_INTEL_82801BA_8 0x244a
  28564. +#define PCI_DEVICE_ID_INTEL_82801BA_9 0x244b
  28565. +#define PCI_DEVICE_ID_INTEL_82801BA_10 0x244c
  28566. +#define PCI_DEVICE_ID_INTEL_82801BA_11 0x244e
  28567. +#define PCI_DEVICE_ID_INTEL_82801CA_0 0x2480
  28568. +#define PCI_DEVICE_ID_INTEL_82801CA_2 0x2482
  28569. +#define PCI_DEVICE_ID_INTEL_82801CA_3 0x2483
  28570. +#define PCI_DEVICE_ID_INTEL_82801CA_4 0x2484
  28571. +#define PCI_DEVICE_ID_INTEL_82801CA_5 0x2485
  28572. +#define PCI_DEVICE_ID_INTEL_82801CA_6 0x2486
  28573. +#define PCI_DEVICE_ID_INTEL_82801CA_7 0x2487
  28574. +#define PCI_DEVICE_ID_INTEL_82801CA_10 0x248a
  28575. +#define PCI_DEVICE_ID_INTEL_82801CA_11 0x248b
  28576. +#define PCI_DEVICE_ID_INTEL_82801CA_12 0x248c
  28577. +#define PCI_DEVICE_ID_INTEL_80310 0x530d
  28578. +#define PCI_DEVICE_ID_INTEL_82371SB_0 0x7000
  28579. +#define PCI_DEVICE_ID_INTEL_82371SB_1 0x7010
  28580. +#define PCI_DEVICE_ID_INTEL_82371SB_2 0x7020
  28581. +#define PCI_DEVICE_ID_INTEL_82437VX 0x7030
  28582. +#define PCI_DEVICE_ID_INTEL_82439TX 0x7100
  28583. +#define PCI_DEVICE_ID_INTEL_82371AB_0 0x7110
  28584. +#define PCI_DEVICE_ID_INTEL_82371AB 0x7111
  28585. +#define PCI_DEVICE_ID_INTEL_82371AB_2 0x7112
  28586. +#define PCI_DEVICE_ID_INTEL_82371AB_3 0x7113
  28587. +#define PCI_DEVICE_ID_INTEL_82810_MC1 0x7120
  28588. +#define PCI_DEVICE_ID_INTEL_82810_IG1 0x7121
  28589. +#define PCI_DEVICE_ID_INTEL_82810_MC3 0x7122
  28590. +#define PCI_DEVICE_ID_INTEL_82810_IG3 0x7123
  28591. +#define PCI_DEVICE_ID_INTEL_82443LX_0 0x7180
  28592. +#define PCI_DEVICE_ID_INTEL_82443LX_1 0x7181
  28593. +#define PCI_DEVICE_ID_INTEL_82443BX_0 0x7190
  28594. +#define PCI_DEVICE_ID_INTEL_82443BX_1 0x7191
  28595. +#define PCI_DEVICE_ID_INTEL_82443BX_2 0x7192
  28596. +#define PCI_DEVICE_ID_INTEL_82443MX_0 0x7198
  28597. +#define PCI_DEVICE_ID_INTEL_82443MX_1 0x7199
  28598. +#define PCI_DEVICE_ID_INTEL_82443MX_2 0x719a
  28599. +#define PCI_DEVICE_ID_INTEL_82443MX_3 0x719b
  28600. +#define PCI_DEVICE_ID_INTEL_82372FB_0 0x7600
  28601. +#define PCI_DEVICE_ID_INTEL_82372FB_1 0x7601
  28602. +#define PCI_DEVICE_ID_INTEL_82372FB_2 0x7602
  28603. +#define PCI_DEVICE_ID_INTEL_82372FB_3 0x7603
  28604. +#define PCI_DEVICE_ID_INTEL_82454GX 0x84c4
  28605. +#define PCI_DEVICE_ID_INTEL_82450GX 0x84c5
  28606. +#define PCI_DEVICE_ID_INTEL_82451NX 0x84ca
  28607. +
  28608. +#define PCI_VENDOR_ID_COMPUTONE 0x8e0e
  28609. +#define PCI_DEVICE_ID_COMPUTONE_IP2EX 0x0291
  28610. +#define PCI_DEVICE_ID_COMPUTONE_PG 0x0302
  28611. +#define PCI_SUBVENDOR_ID_COMPUTONE 0x8e0e
  28612. +#define PCI_SUBDEVICE_ID_COMPUTONE_PG4 0x0001
  28613. +#define PCI_SUBDEVICE_ID_COMPUTONE_PG8 0x0002
  28614. +#define PCI_SUBDEVICE_ID_COMPUTONE_PG6 0x0003
  28615. +
  28616. +#define PCI_VENDOR_ID_KTI 0x8e2e
  28617. +#define PCI_DEVICE_ID_KTI_ET32P2 0x3000
  28618. +
  28619. +#define PCI_VENDOR_ID_ADAPTEC 0x9004
  28620. +#define PCI_DEVICE_ID_ADAPTEC_7810 0x1078
  28621. +#define PCI_DEVICE_ID_ADAPTEC_7821 0x2178
  28622. +#define PCI_DEVICE_ID_ADAPTEC_38602 0x3860
  28623. +#define PCI_DEVICE_ID_ADAPTEC_7850 0x5078
  28624. +#define PCI_DEVICE_ID_ADAPTEC_7855 0x5578
  28625. +#define PCI_DEVICE_ID_ADAPTEC_5800 0x5800
  28626. +#define PCI_DEVICE_ID_ADAPTEC_3860 0x6038
  28627. +#define PCI_DEVICE_ID_ADAPTEC_1480A 0x6075
  28628. +#define PCI_DEVICE_ID_ADAPTEC_7860 0x6078
  28629. +#define PCI_DEVICE_ID_ADAPTEC_7861 0x6178
  28630. +#define PCI_DEVICE_ID_ADAPTEC_7870 0x7078
  28631. +#define PCI_DEVICE_ID_ADAPTEC_7871 0x7178
  28632. +#define PCI_DEVICE_ID_ADAPTEC_7872 0x7278
  28633. +#define PCI_DEVICE_ID_ADAPTEC_7873 0x7378
  28634. +#define PCI_DEVICE_ID_ADAPTEC_7874 0x7478
  28635. +#define PCI_DEVICE_ID_ADAPTEC_7895 0x7895
  28636. +#define PCI_DEVICE_ID_ADAPTEC_7880 0x8078
  28637. +#define PCI_DEVICE_ID_ADAPTEC_7881 0x8178
  28638. +#define PCI_DEVICE_ID_ADAPTEC_7882 0x8278
  28639. +#define PCI_DEVICE_ID_ADAPTEC_7883 0x8378
  28640. +#define PCI_DEVICE_ID_ADAPTEC_7884 0x8478
  28641. +#define PCI_DEVICE_ID_ADAPTEC_7885 0x8578
  28642. +#define PCI_DEVICE_ID_ADAPTEC_7886 0x8678
  28643. +#define PCI_DEVICE_ID_ADAPTEC_7887 0x8778
  28644. +#define PCI_DEVICE_ID_ADAPTEC_7888 0x8878
  28645. +#define PCI_DEVICE_ID_ADAPTEC_1030 0x8b78
  28646. +
  28647. +#define PCI_VENDOR_ID_ADAPTEC2 0x9005
  28648. +#define PCI_DEVICE_ID_ADAPTEC2_2940U2 0x0010
  28649. +#define PCI_DEVICE_ID_ADAPTEC2_2930U2 0x0011
  28650. +#define PCI_DEVICE_ID_ADAPTEC2_7890B 0x0013
  28651. +#define PCI_DEVICE_ID_ADAPTEC2_7890 0x001f
  28652. +#define PCI_DEVICE_ID_ADAPTEC2_3940U2 0x0050
  28653. +#define PCI_DEVICE_ID_ADAPTEC2_3950U2D 0x0051
  28654. +#define PCI_DEVICE_ID_ADAPTEC2_7896 0x005f
  28655. +#define PCI_DEVICE_ID_ADAPTEC2_7892A 0x0080
  28656. +#define PCI_DEVICE_ID_ADAPTEC2_7892B 0x0081
  28657. +#define PCI_DEVICE_ID_ADAPTEC2_7892D 0x0083
  28658. +#define PCI_DEVICE_ID_ADAPTEC2_7892P 0x008f
  28659. +#define PCI_DEVICE_ID_ADAPTEC2_7899A 0x00c0
  28660. +#define PCI_DEVICE_ID_ADAPTEC2_7899B 0x00c1
  28661. +#define PCI_DEVICE_ID_ADAPTEC2_7899D 0x00c3
  28662. +#define PCI_DEVICE_ID_ADAPTEC2_7899P 0x00cf
  28663. +
  28664. +#define PCI_VENDOR_ID_ATRONICS 0x907f
  28665. +#define PCI_DEVICE_ID_ATRONICS_2015 0x2015
  28666. +
  28667. +#define PCI_VENDOR_ID_HOLTEK2 0x9412
  28668. +#define PCI_DEVICE_ID_HOLTEK2_6565 0x6565
  28669. +
  28670. +#define PCI_VENDOR_ID_NETMOS 0x9710
  28671. +#define PCI_DEVICE_ID_NETMOS_9735 0x9735
  28672. +#define PCI_DEVICE_ID_NETMOS_9835 0x9835
  28673. +
  28674. +#define PCI_SUBVENDOR_ID_EXSYS 0xd84d
  28675. +#define PCI_SUBDEVICE_ID_EXSYS_4014 0x4014
  28676. +
  28677. +#define PCI_VENDOR_ID_TIGERJET 0xe159
  28678. +#define PCI_DEVICE_ID_TIGERJET_300 0x0001
  28679. +#define PCI_DEVICE_ID_TIGERJET_100 0x0002
  28680. +
  28681. +#define PCI_VENDOR_ID_ARK 0xedd8
  28682. +#define PCI_DEVICE_ID_ARK_STING 0xa091
  28683. +#define PCI_DEVICE_ID_ARK_STINGARK 0xa099
  28684. +#define PCI_DEVICE_ID_ARK_2000MT 0xa0a1
  28685. +
  28686. diff -Naur grub-0.97.orig/netboot/pci_io.c grub-0.97/netboot/pci_io.c
  28687. --- grub-0.97.orig/netboot/pci_io.c 1970-01-01 00:00:00.000000000 +0000
  28688. +++ grub-0.97/netboot/pci_io.c 2005-08-31 19:03:35.000000000 +0000
  28689. @@ -0,0 +1,431 @@
  28690. +/*
  28691. +** Support for NE2000 PCI clones added David Monro June 1997
  28692. +** Generalised to other NICs by Ken Yap July 1997
  28693. +**
  28694. +** Most of this is taken from:
  28695. +**
  28696. +** /usr/src/linux/drivers/pci/pci.c
  28697. +** /usr/src/linux/include/linux/pci.h
  28698. +** /usr/src/linux/arch/i386/bios32.c
  28699. +** /usr/src/linux/include/linux/bios32.h
  28700. +** /usr/src/linux/drivers/net/ne.c
  28701. +*/
  28702. +#define PCBIOS
  28703. +#include "grub.h"
  28704. +#include "pci.h"
  28705. +
  28706. +#ifdef CONFIG_PCI_DIRECT
  28707. +#define PCIBIOS_SUCCESSFUL 0x00
  28708. +
  28709. +#define DEBUG 0
  28710. +
  28711. +/*
  28712. + * Functions for accessing PCI configuration space with type 1 accesses
  28713. + */
  28714. +
  28715. +#define CONFIG_CMD(bus, device_fn, where) (0x80000000 | (bus << 16) | (device_fn << 8) | (where & ~3))
  28716. +
  28717. +int pcibios_read_config_byte(unsigned int bus, unsigned int device_fn,
  28718. + unsigned int where, uint8_t *value)
  28719. +{
  28720. + outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  28721. + *value = inb(0xCFC + (where&3));
  28722. + return PCIBIOS_SUCCESSFUL;
  28723. +}
  28724. +
  28725. +int pcibios_read_config_word (unsigned int bus,
  28726. + unsigned int device_fn, unsigned int where, uint16_t *value)
  28727. +{
  28728. + outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  28729. + *value = inw(0xCFC + (where&2));
  28730. + return PCIBIOS_SUCCESSFUL;
  28731. +}
  28732. +
  28733. +int pcibios_read_config_dword (unsigned int bus, unsigned int device_fn,
  28734. + unsigned int where, uint32_t *value)
  28735. +{
  28736. + outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  28737. + *value = inl(0xCFC);
  28738. + return PCIBIOS_SUCCESSFUL;
  28739. +}
  28740. +
  28741. +int pcibios_write_config_byte (unsigned int bus, unsigned int device_fn,
  28742. + unsigned int where, uint8_t value)
  28743. +{
  28744. + outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  28745. + outb(value, 0xCFC + (where&3));
  28746. + return PCIBIOS_SUCCESSFUL;
  28747. +}
  28748. +
  28749. +int pcibios_write_config_word (unsigned int bus, unsigned int device_fn,
  28750. + unsigned int where, uint16_t value)
  28751. +{
  28752. + outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  28753. + outw(value, 0xCFC + (where&2));
  28754. + return PCIBIOS_SUCCESSFUL;
  28755. +}
  28756. +
  28757. +int pcibios_write_config_dword (unsigned int bus, unsigned int device_fn, unsigned int where, uint32_t value)
  28758. +{
  28759. + outl(CONFIG_CMD(bus,device_fn,where), 0xCF8);
  28760. + outl(value, 0xCFC);
  28761. + return PCIBIOS_SUCCESSFUL;
  28762. +}
  28763. +
  28764. +#undef CONFIG_CMD
  28765. +
  28766. +#else /* CONFIG_PCI_DIRECT not defined */
  28767. +
  28768. +#if !defined(PCBIOS)
  28769. +#error "The pcibios can only be used when the PCBIOS support is compiled in"
  28770. +#endif
  28771. +
  28772. +
  28773. +#define KERN_CODE_SEG 0X8
  28774. +/* Stuff for asm */
  28775. +#define save_flags(x) \
  28776. +__asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */ :"memory")
  28777. +
  28778. +#define cli() __asm__ __volatile__ ("cli": : :"memory")
  28779. +
  28780. +#define restore_flags(x) \
  28781. +__asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory")
  28782. +
  28783. +
  28784. +
  28785. +static struct {
  28786. + unsigned long address;
  28787. + unsigned short segment;
  28788. +} bios32_indirect = { 0, KERN_CODE_SEG };
  28789. +
  28790. +static long pcibios_entry = 0;
  28791. +static struct {
  28792. + unsigned long address;
  28793. + unsigned short segment;
  28794. +} pci_indirect = { 0, KERN_CODE_SEG };
  28795. +
  28796. +static unsigned long bios32_service(unsigned long service)
  28797. +{
  28798. + unsigned char return_code; /* %al */
  28799. + unsigned long address; /* %ebx */
  28800. + unsigned long length; /* %ecx */
  28801. + unsigned long entry; /* %edx */
  28802. + unsigned long flags;
  28803. +
  28804. + save_flags(flags);
  28805. + __asm__(
  28806. +#ifdef ABSOLUTE_WITHOUT_ASTERISK
  28807. + "lcall (%%edi)"
  28808. +#else
  28809. + "lcall *(%%edi)"
  28810. +#endif
  28811. + : "=a" (return_code),
  28812. + "=b" (address),
  28813. + "=c" (length),
  28814. + "=d" (entry)
  28815. + : "0" (service),
  28816. + "1" (0),
  28817. + "D" (&bios32_indirect));
  28818. + restore_flags(flags);
  28819. +
  28820. + switch (return_code) {
  28821. + case 0:
  28822. + return address + entry;
  28823. + case 0x80: /* Not present */
  28824. + printf("bios32_service(%d) : not present\n", service);
  28825. + return 0;
  28826. + default: /* Shouldn't happen */
  28827. + printf("bios32_service(%d) : returned %#X, mail drew@colorado.edu\n",
  28828. + service, return_code);
  28829. + return 0;
  28830. + }
  28831. +}
  28832. +
  28833. +int pcibios_read_config_byte(unsigned int bus,
  28834. + unsigned int device_fn, unsigned int where, uint8_t *value)
  28835. +{
  28836. + unsigned long ret;
  28837. + unsigned long bx = (bus << 8) | device_fn;
  28838. + unsigned long flags;
  28839. +
  28840. + save_flags(flags);
  28841. + __asm__(
  28842. +#ifdef ABSOLUTE_WITHOUT_ASTERISK
  28843. + "lcall (%%esi)\n\t"
  28844. +#else
  28845. + "lcall *(%%esi)\n\t"
  28846. +#endif
  28847. + "jc 1f\n\t"
  28848. + "xor %%ah, %%ah\n"
  28849. + "1:"
  28850. + : "=c" (*value),
  28851. + "=a" (ret)
  28852. + : "1" (PCIBIOS_READ_CONFIG_BYTE),
  28853. + "b" (bx),
  28854. + "D" ((long) where),
  28855. + "S" (&pci_indirect));
  28856. + restore_flags(flags);
  28857. + return (int) (ret & 0xff00) >> 8;
  28858. +}
  28859. +
  28860. +int pcibios_read_config_word(unsigned int bus,
  28861. + unsigned int device_fn, unsigned int where, uint16_t *value)
  28862. +{
  28863. + unsigned long ret;
  28864. + unsigned long bx = (bus << 8) | device_fn;
  28865. + unsigned long flags;
  28866. +
  28867. + save_flags(flags);
  28868. + __asm__(
  28869. +#ifdef ABSOLUTE_WITHOUT_ASTERISK
  28870. + "lcall (%%esi)\n\t"
  28871. +#else
  28872. + "lcall *(%%esi)\n\t"
  28873. +#endif
  28874. + "jc 1f\n\t"
  28875. + "xor %%ah, %%ah\n"
  28876. + "1:"
  28877. + : "=c" (*value),
  28878. + "=a" (ret)
  28879. + : "1" (PCIBIOS_READ_CONFIG_WORD),
  28880. + "b" (bx),
  28881. + "D" ((long) where),
  28882. + "S" (&pci_indirect));
  28883. + restore_flags(flags);
  28884. + return (int) (ret & 0xff00) >> 8;
  28885. +}
  28886. +
  28887. +int pcibios_read_config_dword(unsigned int bus,
  28888. + unsigned int device_fn, unsigned int where, uint32_t *value)
  28889. +{
  28890. + unsigned long ret;
  28891. + unsigned long bx = (bus << 8) | device_fn;
  28892. + unsigned long flags;
  28893. +
  28894. + save_flags(flags);
  28895. + __asm__(
  28896. +#ifdef ABSOLUTE_WITHOUT_ASTERISK
  28897. + "lcall (%%esi)\n\t"
  28898. +#else
  28899. + "lcall *(%%esi)\n\t"
  28900. +#endif
  28901. + "jc 1f\n\t"
  28902. + "xor %%ah, %%ah\n"
  28903. + "1:"
  28904. + : "=c" (*value),
  28905. + "=a" (ret)
  28906. + : "1" (PCIBIOS_READ_CONFIG_DWORD),
  28907. + "b" (bx),
  28908. + "D" ((long) where),
  28909. + "S" (&pci_indirect));
  28910. + restore_flags(flags);
  28911. + return (int) (ret & 0xff00) >> 8;
  28912. +}
  28913. +
  28914. +int pcibios_write_config_byte (unsigned int bus,
  28915. + unsigned int device_fn, unsigned int where, uint8_t value)
  28916. +{
  28917. + unsigned long ret;
  28918. + unsigned long bx = (bus << 8) | device_fn;
  28919. + unsigned long flags;
  28920. +
  28921. + save_flags(flags); cli();
  28922. + __asm__(
  28923. +#ifdef ABSOLUTE_WITHOUT_ASTERISK
  28924. + "lcall (%%esi)\n\t"
  28925. +#else
  28926. + "lcall *(%%esi)\n\t"
  28927. +#endif
  28928. + "jc 1f\n\t"
  28929. + "xor %%ah, %%ah\n"
  28930. + "1:"
  28931. + : "=a" (ret)
  28932. + : "0" (PCIBIOS_WRITE_CONFIG_BYTE),
  28933. + "c" (value),
  28934. + "b" (bx),
  28935. + "D" ((long) where),
  28936. + "S" (&pci_indirect));
  28937. + restore_flags(flags);
  28938. + return (int) (ret & 0xff00) >> 8;
  28939. +}
  28940. +
  28941. +int pcibios_write_config_word (unsigned int bus,
  28942. + unsigned int device_fn, unsigned int where, uint16_t value)
  28943. +{
  28944. + unsigned long ret;
  28945. + unsigned long bx = (bus << 8) | device_fn;
  28946. + unsigned long flags;
  28947. +
  28948. + save_flags(flags); cli();
  28949. + __asm__(
  28950. +#ifdef ABSOLUTE_WITHOUT_ASTERISK
  28951. + "lcall (%%esi)\n\t"
  28952. +#else
  28953. + "lcall *(%%esi)\n\t"
  28954. +#endif
  28955. + "jc 1f\n\t"
  28956. + "xor %%ah, %%ah\n"
  28957. + "1:"
  28958. + : "=a" (ret)
  28959. + : "0" (PCIBIOS_WRITE_CONFIG_WORD),
  28960. + "c" (value),
  28961. + "b" (bx),
  28962. + "D" ((long) where),
  28963. + "S" (&pci_indirect));
  28964. + restore_flags(flags);
  28965. + return (int) (ret & 0xff00) >> 8;
  28966. +}
  28967. +
  28968. +int pcibios_write_config_dword (unsigned int bus,
  28969. + unsigned int device_fn, unsigned int where, uint32_t value)
  28970. +{
  28971. + unsigned long ret;
  28972. + unsigned long bx = (bus << 8) | device_fn;
  28973. + unsigned long flags;
  28974. +
  28975. + save_flags(flags); cli();
  28976. + __asm__(
  28977. +#ifdef ABSOLUTE_WITHOUT_ASTERISK
  28978. + "lcall (%%esi)\n\t"
  28979. +#else
  28980. + "lcall *(%%esi)\n\t"
  28981. +#endif
  28982. + "jc 1f\n\t"
  28983. + "xor %%ah, %%ah\n"
  28984. + "1:"
  28985. + : "=a" (ret)
  28986. + : "0" (PCIBIOS_WRITE_CONFIG_DWORD),
  28987. + "c" (value),
  28988. + "b" (bx),
  28989. + "D" ((long) where),
  28990. + "S" (&pci_indirect));
  28991. + restore_flags(flags);
  28992. + return (int) (ret & 0xff00) >> 8;
  28993. +}
  28994. +
  28995. +static void check_pcibios(void)
  28996. +{
  28997. + unsigned long signature;
  28998. + unsigned char present_status;
  28999. + unsigned char major_revision;
  29000. + unsigned char minor_revision;
  29001. + unsigned long flags;
  29002. + int pack;
  29003. +
  29004. + if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
  29005. + pci_indirect.address = pcibios_entry;
  29006. +
  29007. + save_flags(flags);
  29008. + __asm__(
  29009. +#ifdef ABSOLUTE_WITHOUT_ASTERISK
  29010. + "lcall (%%edi)\n\t"
  29011. +#else
  29012. + "lcall *(%%edi)\n\t"
  29013. +#endif
  29014. + "jc 1f\n\t"
  29015. + "xor %%ah, %%ah\n"
  29016. + "1:\tshl $8, %%eax\n\t"
  29017. + "movw %%bx, %%ax"
  29018. + : "=d" (signature),
  29019. + "=a" (pack)
  29020. + : "1" (PCIBIOS_PCI_BIOS_PRESENT),
  29021. + "D" (&pci_indirect)
  29022. + : "bx", "cx");
  29023. + restore_flags(flags);
  29024. +
  29025. + present_status = (pack >> 16) & 0xff;
  29026. + major_revision = (pack >> 8) & 0xff;
  29027. + minor_revision = pack & 0xff;
  29028. + if (present_status || (signature != PCI_SIGNATURE)) {
  29029. + printf("ERROR: BIOS32 says PCI BIOS, but no PCI "
  29030. + "BIOS????\n");
  29031. + pcibios_entry = 0;
  29032. + }
  29033. +#if DEBUG
  29034. + if (pcibios_entry) {
  29035. + printf ("pcibios_init : PCI BIOS revision %hhX.%hhX"
  29036. + " entry at %#X\n", major_revision,
  29037. + minor_revision, pcibios_entry);
  29038. + }
  29039. +#endif
  29040. + }
  29041. +}
  29042. +
  29043. +static void pcibios_init(void)
  29044. +{
  29045. + union bios32 *check;
  29046. + unsigned char sum;
  29047. + int i, length;
  29048. + unsigned long bios32_entry = 0;
  29049. +
  29050. + EnterFunction("pcibios_init");
  29051. + /*
  29052. + * Follow the standard procedure for locating the BIOS32 Service
  29053. + * directory by scanning the permissible address range from
  29054. + * 0xe0000 through 0xfffff for a valid BIOS32 structure.
  29055. + *
  29056. + */
  29057. +
  29058. + for (check = (union bios32 *) 0xe0000; check <= (union bios32 *) 0xffff0; ++check) {
  29059. + if (check->fields.signature != BIOS32_SIGNATURE)
  29060. + continue;
  29061. + length = check->fields.length * 16;
  29062. + if (!length)
  29063. + continue;
  29064. + sum = 0;
  29065. + for (i = 0; i < length ; ++i)
  29066. + sum += check->chars[i];
  29067. + if (sum != 0)
  29068. + continue;
  29069. + if (check->fields.revision != 0) {
  29070. + printf("pcibios_init : unsupported revision %d at %#X, mail drew@colorado.edu\n",
  29071. + check->fields.revision, check);
  29072. + continue;
  29073. + }
  29074. +#if DEBUG
  29075. + printf("pcibios_init : BIOS32 Service Directory "
  29076. + "structure at %#X\n", check);
  29077. +#endif
  29078. + if (!bios32_entry) {
  29079. + if (check->fields.entry >= 0x100000) {
  29080. + printf("pcibios_init: entry in high "
  29081. + "memory, giving up\n");
  29082. + return;
  29083. + } else {
  29084. + bios32_entry = check->fields.entry;
  29085. +#if DEBUG
  29086. + printf("pcibios_init : BIOS32 Service Directory"
  29087. + " entry at %#X\n", bios32_entry);
  29088. +#endif
  29089. + bios32_indirect.address = bios32_entry;
  29090. + }
  29091. + }
  29092. + }
  29093. + if (bios32_entry)
  29094. + check_pcibios();
  29095. + LeaveFunction("pcibios_init");
  29096. +}
  29097. +
  29098. +#endif /* CONFIG_PCI_DIRECT not defined*/
  29099. +
  29100. +unsigned long pcibios_bus_base(unsigned int bus __unused)
  29101. +{
  29102. + /* architecturally this must be 0 */
  29103. + return 0;
  29104. +}
  29105. +
  29106. +void find_pci(int type, struct pci_device *dev)
  29107. +{
  29108. + EnterFunction("find_pci");
  29109. +#ifndef CONFIG_PCI_DIRECT
  29110. + if (!pcibios_entry) {
  29111. + pcibios_init();
  29112. + }
  29113. + if (!pcibios_entry) {
  29114. + printf("pci_init: no BIOS32 detected\n");
  29115. + return;
  29116. + }
  29117. +#endif
  29118. + LeaveFunction("find_pci");
  29119. + return scan_pci_bus(type, dev);
  29120. +}
  29121. diff -Naur grub-0.97.orig/netboot/pcnet32.c grub-0.97/netboot/pcnet32.c
  29122. --- grub-0.97.orig/netboot/pcnet32.c 1970-01-01 00:00:00.000000000 +0000
  29123. +++ grub-0.97/netboot/pcnet32.c 2005-08-31 22:57:50.000000000 +0000
  29124. @@ -0,0 +1,1004 @@
  29125. +/**************************************************************************
  29126. +*
  29127. +* pcnet32.c -- Etherboot device driver for the AMD PCnet32
  29128. +* Written 2003-2003 by Timothy Legge <tlegge@rogers.com>
  29129. +*
  29130. +* This program is free software; you can redistribute it and/or modify
  29131. +* it under the terms of the GNU General Public License as published by
  29132. +* the Free Software Foundation; either version 2 of the License, or
  29133. +* (at your option) any later version.
  29134. +*
  29135. +* This program is distributed in the hope that it will be useful,
  29136. +* but WITHOUT ANY WARRANTY; without even the implied warranty of
  29137. +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  29138. +* GNU General Public License for more details.
  29139. +*
  29140. +* You should have received a copy of the GNU General Public License
  29141. +* along with this program; if not, write to the Free Software
  29142. +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  29143. +*
  29144. +* Portions of this code based on:
  29145. +* pcnet32.c: An AMD PCnet32 ethernet driver for linux:
  29146. +*
  29147. +* (C) 1996-1999 Thomas Bogendoerfer
  29148. +* See Linux Driver for full information
  29149. +*
  29150. +* The transmit and poll functions were written with reference to:
  29151. +* lance.c - LANCE NIC driver for Etherboot written by Ken Yap
  29152. +*
  29153. +* Linux Driver Version 1.27a, 10.02.2002
  29154. +*
  29155. +*
  29156. +* REVISION HISTORY:
  29157. +* ================
  29158. +* v1.0 08-06-2003 timlegge Initial port of Linux driver
  29159. +* v1.1 08-23-2003 timlegge Add multicast support
  29160. +* v1.2 01-17-2004 timlegge Initial driver output cleanup
  29161. +* v1.3 03-29-2004 timlegge More driver cleanup
  29162. +*
  29163. +* Indent Options: indent -kr -i8
  29164. +***************************************************************************/
  29165. +
  29166. +/* to get some global routines like printf */
  29167. +#include "etherboot.h"
  29168. +/* to get the interface to the body of the program */
  29169. +#include "nic.h"
  29170. +/* to get the PCI support functions, if this is a PCI NIC */
  29171. +#include "pci.h"
  29172. +/* Include the time functions */
  29173. +#include "timer.h"
  29174. +#include "mii.h"
  29175. +/* void hex_dump(const char *data, const unsigned int len); */
  29176. +
  29177. +/* Etherboot Specific definations */
  29178. +#define drv_version "v1.3"
  29179. +#define drv_date "03-29-2004"
  29180. +
  29181. +typedef unsigned char u8;
  29182. +typedef signed char s8;
  29183. +typedef unsigned short u16;
  29184. +typedef signed short s16;
  29185. +typedef unsigned int u32;
  29186. +typedef signed int s32;
  29187. +
  29188. +static u32 ioaddr; /* Globally used for the card's io address */
  29189. +
  29190. +#ifdef EDEBUG
  29191. +#define dprintf(x) printf x
  29192. +#else
  29193. +#define dprintf(x)
  29194. +#endif
  29195. +
  29196. +/* Condensed operations for readability. */
  29197. +#define virt_to_le32desc(addr) cpu_to_le32(virt_to_bus(addr))
  29198. +#define le32desc_to_virt(addr) bus_to_virt(le32_to_cpu(addr))
  29199. +
  29200. +/* End Etherboot Specific */
  29201. +
  29202. +int cards_found /* __initdata */ ;
  29203. +
  29204. +#ifdef REMOVE
  29205. +/* FIXME: Remove these they are probably pointless */
  29206. +
  29207. +/*
  29208. + * VLB I/O addresses
  29209. + */
  29210. +static unsigned int pcnet32_portlist[] /*__initdata */ =
  29211. +{ 0x300, 0x320, 0x340, 0x360, 0 };
  29212. +
  29213. +static int pcnet32_debug = 1;
  29214. +static int tx_start = 1; /* Mapping -- 0:20, 1:64, 2:128, 3:~220 (depends on chip vers) */
  29215. +static int pcnet32vlb; /* check for VLB cards ? */
  29216. +
  29217. +static struct net_device *pcnet32_dev;
  29218. +
  29219. +static int max_interrupt_work = 80;
  29220. +static int rx_copybreak = 200;
  29221. +#endif
  29222. +#define PCNET32_PORT_AUI 0x00
  29223. +#define PCNET32_PORT_10BT 0x01
  29224. +#define PCNET32_PORT_GPSI 0x02
  29225. +#define PCNET32_PORT_MII 0x03
  29226. +
  29227. +#define PCNET32_PORT_PORTSEL 0x03
  29228. +#define PCNET32_PORT_ASEL 0x04
  29229. +#define PCNET32_PORT_100 0x40
  29230. +#define PCNET32_PORT_FD 0x80
  29231. +
  29232. +#define PCNET32_DMA_MASK 0xffffffff
  29233. +
  29234. +/*
  29235. + * table to translate option values from tulip
  29236. + * to internal options
  29237. + */
  29238. +static unsigned char options_mapping[] = {
  29239. + PCNET32_PORT_ASEL, /* 0 Auto-select */
  29240. + PCNET32_PORT_AUI, /* 1 BNC/AUI */
  29241. + PCNET32_PORT_AUI, /* 2 AUI/BNC */
  29242. + PCNET32_PORT_ASEL, /* 3 not supported */
  29243. + PCNET32_PORT_10BT | PCNET32_PORT_FD, /* 4 10baseT-FD */
  29244. + PCNET32_PORT_ASEL, /* 5 not supported */
  29245. + PCNET32_PORT_ASEL, /* 6 not supported */
  29246. + PCNET32_PORT_ASEL, /* 7 not supported */
  29247. + PCNET32_PORT_ASEL, /* 8 not supported */
  29248. + PCNET32_PORT_MII, /* 9 MII 10baseT */
  29249. + PCNET32_PORT_MII | PCNET32_PORT_FD, /* 10 MII 10baseT-FD */
  29250. + PCNET32_PORT_MII, /* 11 MII (autosel) */
  29251. + PCNET32_PORT_10BT, /* 12 10BaseT */
  29252. + PCNET32_PORT_MII | PCNET32_PORT_100, /* 13 MII 100BaseTx */
  29253. + PCNET32_PORT_MII | PCNET32_PORT_100 | PCNET32_PORT_FD, /* 14 MII 100BaseTx-FD */
  29254. + PCNET32_PORT_ASEL /* 15 not supported */
  29255. +};
  29256. +
  29257. +#define MAX_UNITS 8 /* More are supported, limit only on options */
  29258. +static int options[MAX_UNITS];
  29259. +static int full_duplex[MAX_UNITS];
  29260. +
  29261. +/*
  29262. + * Theory of Operation
  29263. + *
  29264. + * This driver uses the same software structure as the normal lance
  29265. + * driver. So look for a verbose description in lance.c. The differences
  29266. + * to the normal lance driver is the use of the 32bit mode of PCnet32
  29267. + * and PCnetPCI chips. Because these chips are 32bit chips, there is no
  29268. + * 16MB limitation and we don't need bounce buffers.
  29269. + */
  29270. +
  29271. +
  29272. +
  29273. +/*
  29274. + * Set the number of Tx and Rx buffers, using Log_2(# buffers).
  29275. + * Reasonable default values are 4 Tx buffers, and 16 Rx buffers.
  29276. + * That translates to 2 (4 == 2^^2) and 4 (16 == 2^^4).
  29277. + */
  29278. +#ifndef PCNET32_LOG_TX_BUFFERS
  29279. +#define PCNET32_LOG_TX_BUFFERS 1
  29280. +#define PCNET32_LOG_RX_BUFFERS 2
  29281. +#endif
  29282. +
  29283. +#define TX_RING_SIZE (1 << (PCNET32_LOG_TX_BUFFERS))
  29284. +#define TX_RING_MOD_MASK (TX_RING_SIZE - 1)
  29285. +/* FIXME: Fix this to allow multiple tx_ring descriptors */
  29286. +#define TX_RING_LEN_BITS 0x0000 /*PCNET32_LOG_TX_BUFFERS) << 12) */
  29287. +
  29288. +#define RX_RING_SIZE (1 << (PCNET32_LOG_RX_BUFFERS))
  29289. +#define RX_RING_MOD_MASK (RX_RING_SIZE - 1)
  29290. +#define RX_RING_LEN_BITS ((PCNET32_LOG_RX_BUFFERS) << 4)
  29291. +
  29292. +#define PKT_BUF_SZ 1544
  29293. +
  29294. +/* Offsets from base I/O address. */
  29295. +#define PCNET32_WIO_RDP 0x10
  29296. +#define PCNET32_WIO_RAP 0x12
  29297. +#define PCNET32_WIO_RESET 0x14
  29298. +#define PCNET32_WIO_BDP 0x16
  29299. +
  29300. +#define PCNET32_DWIO_RDP 0x10
  29301. +#define PCNET32_DWIO_RAP 0x14
  29302. +#define PCNET32_DWIO_RESET 0x18
  29303. +#define PCNET32_DWIO_BDP 0x1C
  29304. +
  29305. +#define PCNET32_TOTAL_SIZE 0x20
  29306. +
  29307. +/* Buffers for the tx and Rx */
  29308. +
  29309. +/* Create a static buffer of size PKT_BUF_SZ for each
  29310. +TX Descriptor. All descriptors point to a
  29311. +part of this buffer */
  29312. +static unsigned char txb[PKT_BUF_SZ * TX_RING_SIZE];
  29313. +// __attribute__ ((aligned(16)));
  29314. +
  29315. +/* Create a static buffer of size PKT_BUF_SZ for each
  29316. +RX Descriptor All descriptors point to a
  29317. +part of this buffer */
  29318. +static unsigned char rxb[RX_RING_SIZE * PKT_BUF_SZ];
  29319. +// __attribute__ ((aligned(16)));
  29320. +
  29321. +/* The PCNET32 Rx and Tx ring descriptors. */
  29322. +struct pcnet32_rx_head {
  29323. + u32 base;
  29324. + s16 buf_length;
  29325. + s16 status;
  29326. + u32 msg_length;
  29327. + u32 reserved;
  29328. +};
  29329. +
  29330. +struct pcnet32_tx_head {
  29331. + u32 base;
  29332. + s16 length;
  29333. + s16 status;
  29334. + u32 misc;
  29335. + u32 reserved;
  29336. +};
  29337. +
  29338. +/* The PCNET32 32-Bit initialization block, described in databook. */
  29339. +struct pcnet32_init_block {
  29340. + u16 mode;
  29341. + u16 tlen_rlen;
  29342. + u8 phys_addr[6];
  29343. + u16 reserved;
  29344. + u32 filter[2];
  29345. + /* Receive and transmit ring base, along with extra bits. */
  29346. + u32 rx_ring;
  29347. + u32 tx_ring;
  29348. +};
  29349. +/* PCnet32 access functions */
  29350. +struct pcnet32_access {
  29351. + u16(*read_csr) (unsigned long, int);
  29352. + void (*write_csr) (unsigned long, int, u16);
  29353. + u16(*read_bcr) (unsigned long, int);
  29354. + void (*write_bcr) (unsigned long, int, u16);
  29355. + u16(*read_rap) (unsigned long);
  29356. + void (*write_rap) (unsigned long, u16);
  29357. + void (*reset) (unsigned long);
  29358. +};
  29359. +
  29360. +/* Define the TX Descriptor */
  29361. +static struct pcnet32_tx_head tx_ring[TX_RING_SIZE]
  29362. + __attribute__ ((aligned(16)));
  29363. +
  29364. +
  29365. +/* Define the RX Descriptor */
  29366. +static struct pcnet32_rx_head rx_ring[RX_RING_SIZE]
  29367. + __attribute__ ((aligned(16)));
  29368. +
  29369. +/* May need to be moved to mii.h */
  29370. +struct mii_if_info {
  29371. + int phy_id;
  29372. + int advertising;
  29373. + unsigned int full_duplex:1; /* is full duplex? */
  29374. +};
  29375. +
  29376. +/*
  29377. + * The first three fields of pcnet32_private are read by the ethernet device
  29378. + * so we allocate the structure should be allocated by pci_alloc_consistent().
  29379. + */
  29380. +#define MII_CNT 4
  29381. +struct pcnet32_private {
  29382. + struct pcnet32_init_block init_block;
  29383. + struct pci_dev *pci_dev; /* Pointer to the associated pci device structure */
  29384. + const char *name;
  29385. + /* The saved address of a sent-in-place packet/buffer, for skfree(). */
  29386. + struct sk_buff *tx_skbuff[TX_RING_SIZE];
  29387. + struct sk_buff *rx_skbuff[RX_RING_SIZE];
  29388. + struct pcnet32_access a;
  29389. + unsigned int cur_rx, cur_tx; /* The next free ring entry */
  29390. + char tx_full;
  29391. + int options;
  29392. + int shared_irq:1, /* shared irq possible */
  29393. + ltint:1, /* enable TxDone-intr inhibitor */
  29394. + dxsuflo:1, /* disable transmit stop on uflo */
  29395. + mii:1; /* mii port available */
  29396. + struct mii_if_info mii_if;
  29397. + unsigned char phys[MII_CNT];
  29398. + struct net_device *next;
  29399. + int full_duplex:1;
  29400. +} lpx;
  29401. +
  29402. +static struct pcnet32_private *lp;
  29403. +
  29404. +static int mdio_read(struct nic *nic __unused, int phy_id, int reg_num);
  29405. +#if 0
  29406. +static void mdio_write(struct nic *nic __unused, int phy_id, int reg_num,
  29407. + int val);
  29408. +#endif
  29409. +enum pci_flags_bit {
  29410. + PCI_USES_IO = 1, PCI_USES_MEM = 2, PCI_USES_MASTER = 4,
  29411. + PCI_ADDR0 = 0x10 << 0, PCI_ADDR1 = 0x10 << 1, PCI_ADDR2 =
  29412. + 0x10 << 2, PCI_ADDR3 = 0x10 << 3,
  29413. +};
  29414. +
  29415. +
  29416. +static u16 pcnet32_wio_read_csr(unsigned long addr, int index)
  29417. +{
  29418. + outw(index, addr + PCNET32_WIO_RAP);
  29419. + return inw(addr + PCNET32_WIO_RDP);
  29420. +}
  29421. +
  29422. +static void pcnet32_wio_write_csr(unsigned long addr, int index, u16 val)
  29423. +{
  29424. + outw(index, addr + PCNET32_WIO_RAP);
  29425. + outw(val, addr + PCNET32_WIO_RDP);
  29426. +}
  29427. +
  29428. +static u16 pcnet32_wio_read_bcr(unsigned long addr, int index)
  29429. +{
  29430. + outw(index, addr + PCNET32_WIO_RAP);
  29431. + return inw(addr + PCNET32_WIO_BDP);
  29432. +}
  29433. +
  29434. +static void pcnet32_wio_write_bcr(unsigned long addr, int index, u16 val)
  29435. +{
  29436. + outw(index, addr + PCNET32_WIO_RAP);
  29437. + outw(val, addr + PCNET32_WIO_BDP);
  29438. +}
  29439. +
  29440. +static u16 pcnet32_wio_read_rap(unsigned long addr)
  29441. +{
  29442. + return inw(addr + PCNET32_WIO_RAP);
  29443. +}
  29444. +
  29445. +static void pcnet32_wio_write_rap(unsigned long addr, u16 val)
  29446. +{
  29447. + outw(val, addr + PCNET32_WIO_RAP);
  29448. +}
  29449. +
  29450. +static void pcnet32_wio_reset(unsigned long addr)
  29451. +{
  29452. + inw(addr + PCNET32_WIO_RESET);
  29453. +}
  29454. +
  29455. +static int pcnet32_wio_check(unsigned long addr)
  29456. +{
  29457. + outw(88, addr + PCNET32_WIO_RAP);
  29458. + return (inw(addr + PCNET32_WIO_RAP) == 88);
  29459. +}
  29460. +
  29461. +static struct pcnet32_access pcnet32_wio = {
  29462. + read_csr:pcnet32_wio_read_csr,
  29463. + write_csr:pcnet32_wio_write_csr,
  29464. + read_bcr:pcnet32_wio_read_bcr,
  29465. + write_bcr:pcnet32_wio_write_bcr,
  29466. + read_rap:pcnet32_wio_read_rap,
  29467. + write_rap:pcnet32_wio_write_rap,
  29468. + reset:pcnet32_wio_reset
  29469. +};
  29470. +
  29471. +static u16 pcnet32_dwio_read_csr(unsigned long addr, int index)
  29472. +{
  29473. + outl(index, addr + PCNET32_DWIO_RAP);
  29474. + return (inl(addr + PCNET32_DWIO_RDP) & 0xffff);
  29475. +}
  29476. +
  29477. +static void pcnet32_dwio_write_csr(unsigned long addr, int index, u16 val)
  29478. +{
  29479. + outl(index, addr + PCNET32_DWIO_RAP);
  29480. + outl(val, addr + PCNET32_DWIO_RDP);
  29481. +}
  29482. +
  29483. +static u16 pcnet32_dwio_read_bcr(unsigned long addr, int index)
  29484. +{
  29485. + outl(index, addr + PCNET32_DWIO_RAP);
  29486. + return (inl(addr + PCNET32_DWIO_BDP) & 0xffff);
  29487. +}
  29488. +
  29489. +static void pcnet32_dwio_write_bcr(unsigned long addr, int index, u16 val)
  29490. +{
  29491. + outl(index, addr + PCNET32_DWIO_RAP);
  29492. + outl(val, addr + PCNET32_DWIO_BDP);
  29493. +}
  29494. +
  29495. +static u16 pcnet32_dwio_read_rap(unsigned long addr)
  29496. +{
  29497. + return (inl(addr + PCNET32_DWIO_RAP) & 0xffff);
  29498. +}
  29499. +
  29500. +static void pcnet32_dwio_write_rap(unsigned long addr, u16 val)
  29501. +{
  29502. + outl(val, addr + PCNET32_DWIO_RAP);
  29503. +}
  29504. +
  29505. +static void pcnet32_dwio_reset(unsigned long addr)
  29506. +{
  29507. + inl(addr + PCNET32_DWIO_RESET);
  29508. +}
  29509. +
  29510. +static int pcnet32_dwio_check(unsigned long addr)
  29511. +{
  29512. + outl(88, addr + PCNET32_DWIO_RAP);
  29513. + return ((inl(addr + PCNET32_DWIO_RAP) & 0xffff) == 88);
  29514. +}
  29515. +
  29516. +static struct pcnet32_access pcnet32_dwio = {
  29517. + read_csr:pcnet32_dwio_read_csr,
  29518. + write_csr:pcnet32_dwio_write_csr,
  29519. + read_bcr:pcnet32_dwio_read_bcr,
  29520. + write_bcr:pcnet32_dwio_write_bcr,
  29521. + read_rap:pcnet32_dwio_read_rap,
  29522. + write_rap:pcnet32_dwio_write_rap,
  29523. + reset:pcnet32_dwio_reset
  29524. +};
  29525. +
  29526. +
  29527. +/* Initialize the PCNET32 Rx and Tx rings. */
  29528. +static int pcnet32_init_ring(struct nic *nic)
  29529. +{
  29530. + int i;
  29531. +
  29532. + lp->tx_full = 0;
  29533. + lp->cur_rx = lp->cur_tx = 0;
  29534. +
  29535. + for (i = 0; i < RX_RING_SIZE; i++) {
  29536. + rx_ring[i].base = (u32) virt_to_le32desc(&rxb[i]);
  29537. + rx_ring[i].buf_length = le16_to_cpu(-PKT_BUF_SZ);
  29538. + rx_ring[i].status = le16_to_cpu(0x8000);
  29539. + }
  29540. +
  29541. + /* The Tx buffer address is filled in as needed, but we do need to clear
  29542. + the upper ownership bit. */
  29543. + for (i = 0; i < TX_RING_SIZE; i++) {
  29544. + tx_ring[i].base = 0;
  29545. + tx_ring[i].status = 0;
  29546. + }
  29547. +
  29548. +
  29549. + lp->init_block.tlen_rlen =
  29550. + le16_to_cpu(TX_RING_LEN_BITS | RX_RING_LEN_BITS);
  29551. + for (i = 0; i < 6; i++)
  29552. + lp->init_block.phys_addr[i] = nic->node_addr[i];
  29553. + lp->init_block.rx_ring = (u32) virt_to_le32desc(&rx_ring[0]);
  29554. + lp->init_block.tx_ring = (u32) virt_to_le32desc(&tx_ring[0]);
  29555. + return 0;
  29556. +}
  29557. +
  29558. +/**************************************************************************
  29559. +RESET - Reset adapter
  29560. +***************************************************************************/
  29561. +static void pcnet32_reset(struct nic *nic)
  29562. +{
  29563. + /* put the card in its initial state */
  29564. + u16 val;
  29565. + int i;
  29566. +
  29567. + /* Reset the PCNET32 */
  29568. + lp->a.reset(ioaddr);
  29569. +
  29570. + /* switch pcnet32 to 32bit mode */
  29571. + lp->a.write_bcr(ioaddr, 20, 2);
  29572. +
  29573. + /* set/reset autoselect bit */
  29574. + val = lp->a.read_bcr(ioaddr, 2) & ~2;
  29575. + if (lp->options & PCNET32_PORT_ASEL)
  29576. + val |= 2;
  29577. + lp->a.write_bcr(ioaddr, 2, val);
  29578. + /* handle full duplex setting */
  29579. + if (lp->full_duplex) {
  29580. + val = lp->a.read_bcr(ioaddr, 9) & ~3;
  29581. + if (lp->options & PCNET32_PORT_FD) {
  29582. + val |= 1;
  29583. + if (lp->options ==
  29584. + (PCNET32_PORT_FD | PCNET32_PORT_AUI))
  29585. + val |= 2;
  29586. + } else if (lp->options & PCNET32_PORT_ASEL) {
  29587. + /* workaround of xSeries250, turn on for 79C975 only */
  29588. + i = ((lp->a.
  29589. + read_csr(ioaddr,
  29590. + 88) | (lp->a.read_csr(ioaddr,
  29591. + 89) << 16)) >>
  29592. + 12) & 0xffff;
  29593. + if (i == 0x2627)
  29594. + val |= 3;
  29595. + }
  29596. + lp->a.write_bcr(ioaddr, 9, val);
  29597. + }
  29598. +
  29599. + /* set/reset GPSI bit in test register */
  29600. + val = lp->a.read_csr(ioaddr, 124) & ~0x10;
  29601. + if ((lp->options & PCNET32_PORT_PORTSEL) == PCNET32_PORT_GPSI)
  29602. + val |= 0x10;
  29603. + lp->a.write_csr(ioaddr, 124, val);
  29604. +
  29605. + if (lp->mii && !(lp->options & PCNET32_PORT_ASEL)) {
  29606. + val = lp->a.read_bcr(ioaddr, 32) & ~0x38; /* disable Auto Negotiation, set 10Mpbs, HD */
  29607. + if (lp->options & PCNET32_PORT_FD)
  29608. + val |= 0x10;
  29609. + if (lp->options & PCNET32_PORT_100)
  29610. + val |= 0x08;
  29611. + lp->a.write_bcr(ioaddr, 32, val);
  29612. + } else {
  29613. + if (lp->options & PCNET32_PORT_ASEL) { /* enable auto negotiate, setup, disable fd */
  29614. + val = lp->a.read_bcr(ioaddr, 32) & ~0x98;
  29615. + val |= 0x20;
  29616. + lp->a.write_bcr(ioaddr, 32, val);
  29617. + }
  29618. + }
  29619. +
  29620. +#ifdef DO_DXSUFLO
  29621. + if (lp->dxsuflo) { /* Disable transmit stop on underflow */
  29622. + val = lp->a.read_csr(ioaddr, 3);
  29623. + val |= 0x40;
  29624. + lp->a.write_csr(ioaddr, 3, val);
  29625. + }
  29626. +#endif
  29627. +
  29628. + if (lp->ltint) { /* Enable TxDone-intr inhibitor */
  29629. + val = lp->a.read_csr(ioaddr, 5);
  29630. + val |= (1 << 14);
  29631. + lp->a.write_csr(ioaddr, 5, val);
  29632. + }
  29633. + lp->init_block.mode =
  29634. + le16_to_cpu((lp->options & PCNET32_PORT_PORTSEL) << 7);
  29635. + lp->init_block.filter[0] = 0xffffffff;
  29636. + lp->init_block.filter[1] = 0xffffffff;
  29637. +
  29638. + pcnet32_init_ring(nic);
  29639. +
  29640. +
  29641. + /* Re-initialize the PCNET32, and start it when done. */
  29642. + lp->a.write_csr(ioaddr, 1,
  29643. + (virt_to_bus(&lp->init_block)) & 0xffff);
  29644. + lp->a.write_csr(ioaddr, 2, (virt_to_bus(&lp->init_block)) >> 16);
  29645. + lp->a.write_csr(ioaddr, 4, 0x0915);
  29646. + lp->a.write_csr(ioaddr, 0, 0x0001);
  29647. +
  29648. +
  29649. + i = 0;
  29650. + while (i++ < 100)
  29651. + if (lp->a.read_csr(ioaddr, 0) & 0x0100)
  29652. + break;
  29653. + /*
  29654. + * We used to clear the InitDone bit, 0x0100, here but Mark Stockton
  29655. + * reports that doing so triggers a bug in the '974.
  29656. + */
  29657. + lp->a.write_csr(ioaddr, 0, 0x0042);
  29658. +
  29659. + dprintf(("pcnet32 open, csr0 %hX.\n", lp->a.read_csr(ioaddr, 0)));
  29660. +
  29661. +}
  29662. +
  29663. +/**************************************************************************
  29664. +POLL - Wait for a frame
  29665. +***************************************************************************/
  29666. +static int pcnet32_poll(struct nic *nic __unused, int retrieve)
  29667. +{
  29668. + /* return true if there's an ethernet packet ready to read */
  29669. + /* nic->packet should contain data on return */
  29670. + /* nic->packetlen should contain length of data */
  29671. +
  29672. + int status;
  29673. + int entry;
  29674. +
  29675. + entry = lp->cur_rx & RX_RING_MOD_MASK;
  29676. + status = ((short) le16_to_cpu(rx_ring[entry].status) >> 8);
  29677. +
  29678. + if (status < 0)
  29679. + return 0;
  29680. +
  29681. + if ( ! retrieve ) return 1;
  29682. +
  29683. + if (status == 0x03) {
  29684. + nic->packetlen =
  29685. + (le32_to_cpu(rx_ring[entry].msg_length) & 0xfff) - 4;
  29686. + memcpy(nic->packet, &rxb[entry], nic->packetlen);
  29687. +
  29688. + /* Andrew Boyd of QNX reports that some revs of the 79C765
  29689. + * clear the buffer length */
  29690. + rx_ring[entry].buf_length = le16_to_cpu(-PKT_BUF_SZ);
  29691. + rx_ring[entry].status |= le16_to_cpu(0x8000); /* prime for next receive */
  29692. + /* Switch to the next Rx ring buffer */
  29693. + lp->cur_rx++;
  29694. +
  29695. + } else {
  29696. + return 0;
  29697. + }
  29698. +
  29699. + return 1;
  29700. +}
  29701. +
  29702. +/**************************************************************************
  29703. +TRANSMIT - Transmit a frame
  29704. +***************************************************************************/
  29705. +static void pcnet32_transmit(struct nic *nic __unused, const char *d, /* Destination */
  29706. + unsigned int t, /* Type */
  29707. + unsigned int s, /* size */
  29708. + const char *p)
  29709. +{ /* Packet */
  29710. + /* send the packet to destination */
  29711. + unsigned long time;
  29712. + u8 *ptxb;
  29713. + u16 nstype;
  29714. + u16 status;
  29715. + int entry = 0; /*lp->cur_tx & TX_RING_MOD_MASK; */
  29716. +
  29717. + status = 0x8300;
  29718. + /* point to the current txb incase multiple tx_rings are used */
  29719. + ptxb = txb + (lp->cur_tx * PKT_BUF_SZ);
  29720. +
  29721. + /* copy the packet to ring buffer */
  29722. + memcpy(ptxb, d, ETH_ALEN); /* dst */
  29723. + memcpy(ptxb + ETH_ALEN, nic->node_addr, ETH_ALEN); /* src */
  29724. + nstype = htons((u16) t); /* type */
  29725. + memcpy(ptxb + 2 * ETH_ALEN, (u8 *) & nstype, 2); /* type */
  29726. + memcpy(ptxb + ETH_HLEN, p, s);
  29727. +
  29728. + s += ETH_HLEN;
  29729. + while (s < ETH_ZLEN) /* pad to min length */
  29730. + ptxb[s++] = '\0';
  29731. +
  29732. + tx_ring[entry].length = le16_to_cpu(-s);
  29733. + tx_ring[entry].misc = 0x00000000;
  29734. + tx_ring[entry].base = (u32) virt_to_le32desc(ptxb);
  29735. +
  29736. + /* we set the top byte as the very last thing */
  29737. + tx_ring[entry].status = le16_to_cpu(status);
  29738. +
  29739. +
  29740. + /* Trigger an immediate send poll */
  29741. + lp->a.write_csr(ioaddr, 0, 0x0048);
  29742. +
  29743. + /* wait for transmit complete */
  29744. + lp->cur_tx = 0; /* (lp->cur_tx + 1); */
  29745. + time = currticks() + TICKS_PER_SEC; /* wait one second */
  29746. + while (currticks() < time &&
  29747. + ((short) le16_to_cpu(tx_ring[entry].status) < 0));
  29748. +
  29749. + if ((short) le16_to_cpu(tx_ring[entry].status) < 0)
  29750. + printf("PCNET32 timed out on transmit\n");
  29751. +
  29752. + /* Stop pointing at the current txb
  29753. + * otherwise the card continues to send the packet */
  29754. + tx_ring[entry].base = 0;
  29755. +
  29756. +}
  29757. +
  29758. +/**************************************************************************
  29759. +DISABLE - Turn off ethernet interface
  29760. +***************************************************************************/
  29761. +static void pcnet32_disable(struct dev *dev __unused)
  29762. +{
  29763. + /* Stop the PCNET32 here -- it ocassionally polls memory if we don't */
  29764. + lp->a.write_csr(ioaddr, 0, 0x0004);
  29765. +
  29766. + /*
  29767. + * Switch back to 16-bit mode to avoid problesm with dumb
  29768. + * DOS packet driver after a warm reboot
  29769. + */
  29770. + lp->a.write_bcr(ioaddr, 20, 4);
  29771. +}
  29772. +
  29773. +/**************************************************************************
  29774. +IRQ - Enable, Disable, or Force interrupts
  29775. +***************************************************************************/
  29776. +static void pcnet32_irq(struct nic *nic __unused, irq_action_t action __unused)
  29777. +{
  29778. + switch ( action ) {
  29779. + case DISABLE :
  29780. + break;
  29781. + case ENABLE :
  29782. + break;
  29783. + case FORCE :
  29784. + break;
  29785. + }
  29786. +}
  29787. +
  29788. +/**************************************************************************
  29789. +PROBE - Look for an adapter, this routine's visible to the outside
  29790. +You should omit the last argument struct pci_device * for a non-PCI NIC
  29791. +***************************************************************************/
  29792. +static int pcnet32_probe(struct dev *dev, struct pci_device *pci)
  29793. +{
  29794. + struct nic *nic = (struct nic *) dev;
  29795. + int i, media;
  29796. + int fdx, mii, fset, dxsuflo, ltint;
  29797. + int chip_version;
  29798. + char *chipname;
  29799. + struct pcnet32_access *a = NULL;
  29800. + u8 promaddr[6];
  29801. +
  29802. + int shared = 1;
  29803. + if (pci->ioaddr == 0)
  29804. + return 0;
  29805. +
  29806. + /* BASE is used throughout to address the card */
  29807. + ioaddr = pci->ioaddr;
  29808. + printf("pcnet32.c: Found %s, Vendor=0x%hX Device=0x%hX\n",
  29809. + pci->name, pci->vendor, pci->dev_id);
  29810. +
  29811. + nic->irqno = 0;
  29812. + nic->ioaddr = pci->ioaddr & ~3;
  29813. +
  29814. + /* reset the chip */
  29815. + pcnet32_wio_reset(ioaddr);
  29816. +
  29817. + /* NOTE: 16-bit check is first, otherwise some older PCnet chips fail */
  29818. + if (pcnet32_wio_read_csr(ioaddr, 0) == 4
  29819. + && pcnet32_wio_check(ioaddr)) {
  29820. + a = &pcnet32_wio;
  29821. + } else {
  29822. + pcnet32_dwio_reset(ioaddr);
  29823. + if (pcnet32_dwio_read_csr(ioaddr, 0) == 4
  29824. + && pcnet32_dwio_check(ioaddr)) {
  29825. + a = &pcnet32_dwio;
  29826. + } else
  29827. + return 0;
  29828. + }
  29829. +
  29830. + chip_version =
  29831. + a->read_csr(ioaddr, 88) | (a->read_csr(ioaddr, 89) << 16);
  29832. +
  29833. + dprintf(("PCnet chip version is %0xhX\n", chip_version));
  29834. + if ((chip_version & 0xfff) != 0x003)
  29835. + return 0;
  29836. +
  29837. + /* initialize variables */
  29838. + fdx = mii = fset = dxsuflo = ltint = 0;
  29839. + chip_version = (chip_version >> 12) & 0xffff;
  29840. +
  29841. + switch (chip_version) {
  29842. + case 0x2420:
  29843. + chipname = "PCnet/PCI 79C970"; /* PCI */
  29844. + break;
  29845. + case 0x2430:
  29846. + if (shared)
  29847. + chipname = "PCnet/PCI 79C970"; /* 970 gives the wrong chip id back */
  29848. + else
  29849. + chipname = "PCnet/32 79C965"; /* 486/VL bus */
  29850. + break;
  29851. + case 0x2621:
  29852. + chipname = "PCnet/PCI II 79C970A"; /* PCI */
  29853. + fdx = 1;
  29854. + break;
  29855. + case 0x2623:
  29856. + chipname = "PCnet/FAST 79C971"; /* PCI */
  29857. + fdx = 1;
  29858. + mii = 1;
  29859. + fset = 1;
  29860. + ltint = 1;
  29861. + break;
  29862. + case 0x2624:
  29863. + chipname = "PCnet/FAST+ 79C972"; /* PCI */
  29864. + fdx = 1;
  29865. + mii = 1;
  29866. + fset = 1;
  29867. + break;
  29868. + case 0x2625:
  29869. + chipname = "PCnet/FAST III 79C973"; /* PCI */
  29870. + fdx = 1;
  29871. + mii = 1;
  29872. + break;
  29873. + case 0x2626:
  29874. + chipname = "PCnet/Home 79C978"; /* PCI */
  29875. + fdx = 1;
  29876. + /*
  29877. + * This is based on specs published at www.amd.com. This section
  29878. + * assumes that a card with a 79C978 wants to go into 1Mb HomePNA
  29879. + * mode. The 79C978 can also go into standard ethernet, and there
  29880. + * probably should be some sort of module option to select the
  29881. + * mode by which the card should operate
  29882. + */
  29883. + /* switch to home wiring mode */
  29884. + media = a->read_bcr(ioaddr, 49);
  29885. +
  29886. + printf("media reset to %#x.\n", media);
  29887. + a->write_bcr(ioaddr, 49, media);
  29888. + break;
  29889. + case 0x2627:
  29890. + chipname = "PCnet/FAST III 79C975"; /* PCI */
  29891. + fdx = 1;
  29892. + mii = 1;
  29893. + break;
  29894. + default:
  29895. + printf("PCnet version %#x, no PCnet32 chip.\n",
  29896. + chip_version);
  29897. + return 0;
  29898. + }
  29899. +
  29900. + /*
  29901. + * On selected chips turn on the BCR18:NOUFLO bit. This stops transmit
  29902. + * starting until the packet is loaded. Strike one for reliability, lose
  29903. + * one for latency - although on PCI this isnt a big loss. Older chips
  29904. + * have FIFO's smaller than a packet, so you can't do this.
  29905. + */
  29906. +
  29907. + if (fset) {
  29908. + a->write_bcr(ioaddr, 18,
  29909. + (a->read_bcr(ioaddr, 18) | 0x0800));
  29910. + a->write_csr(ioaddr, 80,
  29911. + (a->read_csr(ioaddr, 80) & 0x0C00) | 0x0c00);
  29912. + dxsuflo = 1;
  29913. + ltint = 1;
  29914. + }
  29915. +
  29916. + dprintf(("%s at %hX,", chipname, ioaddr));
  29917. +
  29918. + /* read PROM address */
  29919. + for (i = 0; i < 6; i++)
  29920. + promaddr[i] = inb(ioaddr + i);
  29921. +
  29922. + /* Update the nic structure with the MAC Address */
  29923. + for (i = 0; i < ETH_ALEN; i++) {
  29924. + nic->node_addr[i] = promaddr[i];
  29925. + }
  29926. + /* Print out some hardware info */
  29927. + printf("%s: %! at ioaddr %hX, ", pci->name, nic->node_addr,
  29928. + ioaddr);
  29929. +
  29930. + /* Set to pci bus master */
  29931. + adjust_pci_device(pci);
  29932. +
  29933. + /* point to private storage */
  29934. + lp = &lpx;
  29935. +
  29936. +#if EBDEBUG
  29937. + if (((chip_version + 1) & 0xfffe) == 0x2624) { /* Version 0x2623 or 0x2624 */
  29938. + i = a->read_csr(ioaddr, 80) & 0x0C00; /* Check tx_start_pt */
  29939. + dprintf((" tx_start_pt(0x%hX):", i));
  29940. + switch (i >> 10) {
  29941. + case 0:
  29942. + dprintf((" 20 bytes,"));
  29943. + break;
  29944. + case 1:
  29945. + dprintf((" 64 bytes,"));
  29946. + break;
  29947. + case 2:
  29948. + dprintf((" 128 bytes,"));
  29949. + break;
  29950. + case 3:
  29951. + dprintf(("~220 bytes,"));
  29952. + break;
  29953. + }
  29954. + i = a->read_bcr(ioaddr, 18); /* Check Burst/Bus control */
  29955. + dprintf((" BCR18(%hX):", i & 0xffff));
  29956. + if (i & (1 << 5))
  29957. + dprintf(("BurstWrEn "));
  29958. + if (i & (1 << 6))
  29959. + dprintf(("BurstRdEn "));
  29960. + if (i & (1 << 7))
  29961. + dprintf(("DWordIO "));
  29962. + if (i & (1 << 11))
  29963. + dprintf(("NoUFlow "));
  29964. + i = a->read_bcr(ioaddr, 25);
  29965. + dprintf((" SRAMSIZE=0x%hX,", i << 8));
  29966. + i = a->read_bcr(ioaddr, 26);
  29967. + dprintf((" SRAM_BND=0x%hX,", i << 8));
  29968. + i = a->read_bcr(ioaddr, 27);
  29969. + if (i & (1 << 14))
  29970. + dprintf(("LowLatRx"));
  29971. + }
  29972. +#endif
  29973. + lp->name = chipname;
  29974. + lp->shared_irq = shared;
  29975. + lp->full_duplex = fdx;
  29976. + lp->dxsuflo = dxsuflo;
  29977. + lp->ltint = ltint;
  29978. + lp->mii = mii;
  29979. + /* FIXME: Fix Options for only one card */
  29980. + if ((cards_found >= MAX_UNITS)
  29981. + || ((unsigned int) options[cards_found] > sizeof(options_mapping)))
  29982. + lp->options = PCNET32_PORT_ASEL;
  29983. + else
  29984. + lp->options = options_mapping[options[cards_found]];
  29985. +
  29986. + if (fdx && !(lp->options & PCNET32_PORT_ASEL) &&
  29987. + ((cards_found >= MAX_UNITS) || full_duplex[cards_found]))
  29988. + lp->options |= PCNET32_PORT_FD;
  29989. +
  29990. + if (!a) {
  29991. + printf("No access methods\n");
  29992. + return 0;
  29993. + }
  29994. + lp->a = *a;
  29995. +
  29996. + /* detect special T1/E1 WAN card by checking for MAC address */
  29997. + if (nic->node_addr[0] == 0x00 && nic->node_addr[1] == 0xe0
  29998. + && nic->node_addr[2] == 0x75)
  29999. + lp->options = PCNET32_PORT_FD | PCNET32_PORT_GPSI;
  30000. +
  30001. + lp->init_block.mode = le16_to_cpu(0x0003); /* Disable Rx and Tx. */
  30002. + lp->init_block.tlen_rlen =
  30003. + le16_to_cpu(TX_RING_LEN_BITS | RX_RING_LEN_BITS);
  30004. + for (i = 0; i < 6; i++)
  30005. + lp->init_block.phys_addr[i] = nic->node_addr[i];
  30006. + lp->init_block.filter[0] = 0xffffffff;
  30007. + lp->init_block.filter[1] = 0xffffffff;
  30008. + lp->init_block.rx_ring = virt_to_bus(&rx_ring);
  30009. + lp->init_block.tx_ring = virt_to_bus(&tx_ring);
  30010. +
  30011. + /* switch pcnet32 to 32bit mode */
  30012. + a->write_bcr(ioaddr, 20, 2);
  30013. +
  30014. +
  30015. + a->write_csr(ioaddr, 1, (virt_to_bus(&lp->init_block)) & 0xffff);
  30016. + a->write_csr(ioaddr, 2, (virt_to_bus(&lp->init_block)) >> 16);
  30017. +
  30018. + /*
  30019. + * To auto-IRQ we enable the initialization-done and DMA error
  30020. + * interrupts. For ISA boards we get a DMA error, but VLB and PCI
  30021. + * boards will work.
  30022. + */
  30023. + /* Trigger an initialization just for the interrupt. */
  30024. +
  30025. + a->write_csr(ioaddr, 0, 0x41);
  30026. + mdelay(1);
  30027. +
  30028. + cards_found++;
  30029. +
  30030. + /* point to NIC specific routines */
  30031. + pcnet32_reset(nic);
  30032. + if (1) {
  30033. + int tmp;
  30034. + int phy, phy_idx = 0;
  30035. + u16 mii_lpa;
  30036. + lp->phys[0] = 1; /* Default Setting */
  30037. + for (phy = 1; phy < 32 && phy_idx < MII_CNT; phy++) {
  30038. + int mii_status = mdio_read(nic, phy, MII_BMSR);
  30039. + if (mii_status != 0xffff && mii_status != 0x0000) {
  30040. + lp->phys[phy_idx++] = phy;
  30041. + lp->mii_if.advertising =
  30042. + mdio_read(nic, phy, MII_ADVERTISE);
  30043. + if ((mii_status & 0x0040) == 0) {
  30044. + tmp = phy;
  30045. + dprintf (("MII PHY found at address %d, status "
  30046. + "%hX advertising %hX\n", phy, mii_status,
  30047. + lp->mii_if.advertising));
  30048. + }
  30049. + }
  30050. + }
  30051. + if (phy_idx == 0)
  30052. + printf("No MII transceiver found!\n");
  30053. + lp->mii_if.phy_id = lp->phys[0];
  30054. +
  30055. + lp->mii_if.advertising =
  30056. + mdio_read(nic, lp->phys[0], MII_ADVERTISE);
  30057. +
  30058. + mii_lpa = mdio_read(nic, lp->phys[0], MII_LPA);
  30059. + lp->mii_if.advertising &= mii_lpa;
  30060. + if (lp->mii_if.advertising & ADVERTISE_100FULL)
  30061. + printf("100Mbps Full-Duplex\n");
  30062. + else if (lp->mii_if.advertising & ADVERTISE_100HALF)
  30063. + printf("100Mbps Half-Duplex\n");
  30064. + else if (lp->mii_if.advertising & ADVERTISE_10FULL)
  30065. + printf("10Mbps Full-Duplex\n");
  30066. + else if (lp->mii_if.advertising & ADVERTISE_10HALF)
  30067. + printf("10Mbps Half-Duplex\n");
  30068. + else
  30069. + printf("\n");
  30070. + }
  30071. +
  30072. + nic->poll = pcnet32_poll;
  30073. + nic->transmit = pcnet32_transmit;
  30074. + dev->disable = pcnet32_disable;
  30075. + nic->irq = pcnet32_irq;
  30076. +
  30077. + return 1;
  30078. +}
  30079. +static int mdio_read(struct nic *nic __unused, int phy_id, int reg_num)
  30080. +{
  30081. + u16 val_out;
  30082. + int phyaddr;
  30083. +
  30084. + if (!lp->mii)
  30085. + return 0;
  30086. +
  30087. + phyaddr = lp->a.read_bcr(ioaddr, 33);
  30088. +
  30089. + lp->a.write_bcr(ioaddr, 33,
  30090. + ((phy_id & 0x1f) << 5) | (reg_num & 0x1f));
  30091. + val_out = lp->a.read_bcr(ioaddr, 34);
  30092. + lp->a.write_bcr(ioaddr, 33, phyaddr);
  30093. +
  30094. + return val_out;
  30095. +}
  30096. +
  30097. +#if 0
  30098. +static void mdio_write(struct nic *nic __unused, int phy_id, int reg_num,
  30099. + int val)
  30100. +{
  30101. + int phyaddr;
  30102. +
  30103. + if (!lp->mii)
  30104. + return;
  30105. +
  30106. + phyaddr = lp->a.read_bcr(ioaddr, 33);
  30107. +
  30108. + lp->a.write_bcr(ioaddr, 33,
  30109. + ((phy_id & 0x1f) << 5) | (reg_num & 0x1f));
  30110. + lp->a.write_bcr(ioaddr, 34, val);
  30111. + lp->a.write_bcr(ioaddr, 33, phyaddr);
  30112. +}
  30113. +#endif
  30114. +
  30115. +static struct pci_id pcnet32_nics[] = {
  30116. + PCI_ROM(0x1022, 0x2000, "lancepci", "AMD Lance/PCI"),
  30117. + PCI_ROM(0x1022, 0x2625, "pcnetfastiii", "AMD Lance/PCI PCNet/32"),
  30118. + PCI_ROM(0x1022, 0x2001, "amdhomepna", "AMD Lance/HomePNA"),
  30119. +};
  30120. +
  30121. +struct pci_driver pcnet32_driver = {
  30122. + .type = NIC_DRIVER,
  30123. + .name = "PCNET32/PCI",
  30124. + .probe = pcnet32_probe,
  30125. + .ids = pcnet32_nics,
  30126. + .id_count = sizeof(pcnet32_nics) / sizeof(pcnet32_nics[0]),
  30127. + .class = 0,
  30128. +};
  30129. diff -Naur grub-0.97.orig/netboot/pic8259.c grub-0.97/netboot/pic8259.c
  30130. --- grub-0.97.orig/netboot/pic8259.c 1970-01-01 00:00:00.000000000 +0000
  30131. +++ grub-0.97/netboot/pic8259.c 2005-08-31 19:03:35.000000000 +0000
  30132. @@ -0,0 +1,267 @@
  30133. +/*
  30134. + * Basic support for controlling the 8259 Programmable Interrupt Controllers.
  30135. + *
  30136. + * Initially written by Michael Brown (mcb30).
  30137. + */
  30138. +
  30139. +#include <etherboot.h>
  30140. +#include <pic8259.h>
  30141. +
  30142. +#ifdef DEBUG_IRQ
  30143. +#define DBG(...) printf ( __VA_ARGS__ )
  30144. +#else
  30145. +#define DBG(...)
  30146. +#endif
  30147. +
  30148. +/* Current locations of trivial IRQ handler. These will change at
  30149. + * runtime when relocation is used; the handler needs to be copied to
  30150. + * base memory before being installed.
  30151. + */
  30152. +void (*trivial_irq_handler)P((void)) = _trivial_irq_handler;
  30153. +uint16_t volatile *trivial_irq_trigger_count = &_trivial_irq_trigger_count;
  30154. +segoff_t *trivial_irq_chain_to = &_trivial_irq_chain_to;
  30155. +uint8_t *trivial_irq_chain = &_trivial_irq_chain;
  30156. +irq_t trivial_irq_installed_on = IRQ_NONE;
  30157. +
  30158. +/* Previous trigger count for trivial IRQ handler */
  30159. +static uint16_t trivial_irq_previous_trigger_count = 0;
  30160. +
  30161. +/* Install a handler for the specified IRQ. Address of previous
  30162. + * handler will be stored in previous_handler. Enabled/disabled state
  30163. + * of IRQ will be preserved across call, therefore if the handler does
  30164. + * chaining, ensure that either (a) IRQ is disabled before call, or
  30165. + * (b) previous_handler points directly to the place that the handler
  30166. + * picks up its chain-to address.
  30167. + */
  30168. +
  30169. +int install_irq_handler ( irq_t irq, segoff_t *handler,
  30170. + uint8_t *previously_enabled,
  30171. + segoff_t *previous_handler ) {
  30172. + segoff_t *irq_vector = IRQ_VECTOR ( irq );
  30173. + *previously_enabled = irq_enabled ( irq );
  30174. +
  30175. + if ( irq > IRQ_MAX ) {
  30176. + DBG ( "Invalid IRQ number %d\n" );
  30177. + return 0;
  30178. + }
  30179. +
  30180. + previous_handler->segment = irq_vector->segment;
  30181. + previous_handler->offset = irq_vector->offset;
  30182. + if ( *previously_enabled ) disable_irq ( irq );
  30183. + DBG ( "Installing handler at %hx:%hx for IRQ %d, leaving %s\n",
  30184. + handler->segment, handler->offset, irq,
  30185. + ( *previously_enabled ? "enabled" : "disabled" ) );
  30186. + DBG ( "...(previous handler at %hx:%hx)\n",
  30187. + previous_handler->segment, previous_handler->offset );
  30188. + irq_vector->segment = handler->segment;
  30189. + irq_vector->offset = handler->offset;
  30190. + if ( *previously_enabled ) enable_irq ( irq );
  30191. + return 1;
  30192. +}
  30193. +
  30194. +/* Remove handler for the specified IRQ. Routine checks that another
  30195. + * handler has not been installed that chains to handler before
  30196. + * uninstalling handler. Enabled/disabled state of the IRQ will be
  30197. + * restored to that specified by previously_enabled.
  30198. + */
  30199. +
  30200. +int remove_irq_handler ( irq_t irq, segoff_t *handler,
  30201. + uint8_t *previously_enabled,
  30202. + segoff_t *previous_handler ) {
  30203. + segoff_t *irq_vector = IRQ_VECTOR ( irq );
  30204. +
  30205. + if ( irq > IRQ_MAX ) {
  30206. + DBG ( "Invalid IRQ number %d\n" );
  30207. + return 0;
  30208. + }
  30209. + if ( ( irq_vector->segment != handler->segment ) ||
  30210. + ( irq_vector->offset != handler->offset ) ) {
  30211. + DBG ( "Cannot remove handler for IRQ %d\n" );
  30212. + return 0;
  30213. + }
  30214. +
  30215. + DBG ( "Removing handler for IRQ %d\n", irq );
  30216. + disable_irq ( irq );
  30217. + irq_vector->segment = previous_handler->segment;
  30218. + irq_vector->offset = previous_handler->offset;
  30219. + if ( *previously_enabled ) enable_irq ( irq );
  30220. + return 1;
  30221. +}
  30222. +
  30223. +/* Install the trivial IRQ handler. This routine installs the
  30224. + * handler, tests it and enables the IRQ.
  30225. + */
  30226. +
  30227. +int install_trivial_irq_handler ( irq_t irq ) {
  30228. + segoff_t trivial_irq_handler_segoff = SEGOFF(trivial_irq_handler);
  30229. +
  30230. + if ( trivial_irq_installed_on != IRQ_NONE ) {
  30231. + DBG ( "Can install trivial IRQ handler only once\n" );
  30232. + return 0;
  30233. + }
  30234. + if ( SEGMENT(trivial_irq_handler) > 0xffff ) {
  30235. + DBG ( "Trivial IRQ handler not in base memory\n" );
  30236. + return 0;
  30237. + }
  30238. +
  30239. + DBG ( "Installing trivial IRQ handler on IRQ %d\n", irq );
  30240. + if ( ! install_irq_handler ( irq, &trivial_irq_handler_segoff,
  30241. + trivial_irq_chain,
  30242. + trivial_irq_chain_to ) )
  30243. + return 0;
  30244. + trivial_irq_installed_on = irq;
  30245. +
  30246. + DBG ( "Testing trivial IRQ handler\n" );
  30247. + disable_irq ( irq );
  30248. + *trivial_irq_trigger_count = 0;
  30249. + trivial_irq_previous_trigger_count = 0;
  30250. + fake_irq ( irq );
  30251. + if ( ! trivial_irq_triggered ( irq ) ) {
  30252. + DBG ( "Installation of trivial IRQ handler failed\n" );
  30253. + remove_trivial_irq_handler ( irq );
  30254. + return 0;
  30255. + }
  30256. + DBG ( "Trivial IRQ handler installed successfully\n" );
  30257. + enable_irq ( irq );
  30258. + return 1;
  30259. +}
  30260. +
  30261. +/* Remove the trivial IRQ handler.
  30262. + */
  30263. +
  30264. +int remove_trivial_irq_handler ( irq_t irq ) {
  30265. + segoff_t trivial_irq_handler_segoff = SEGOFF(trivial_irq_handler);
  30266. +
  30267. + if ( trivial_irq_installed_on == IRQ_NONE ) return 1;
  30268. + if ( irq != trivial_irq_installed_on ) {
  30269. + DBG ( "Cannot uninstall trivial IRQ handler from IRQ %d; "
  30270. + "is installed on IRQ %d\n", irq,
  30271. + trivial_irq_installed_on );
  30272. + return 0;
  30273. + }
  30274. +
  30275. + if ( ! remove_irq_handler ( irq, &trivial_irq_handler_segoff,
  30276. + trivial_irq_chain,
  30277. + trivial_irq_chain_to ) )
  30278. + return 0;
  30279. +
  30280. + if ( trivial_irq_triggered ( trivial_irq_installed_on ) ) {
  30281. + DBG ( "Sending EOI for unwanted trivial IRQ\n" );
  30282. + send_specific_eoi ( trivial_irq_installed_on );
  30283. + }
  30284. +
  30285. + trivial_irq_installed_on = IRQ_NONE;
  30286. + return 1;
  30287. +}
  30288. +
  30289. +/* Safe method to detect whether or not trivial IRQ has been
  30290. + * triggered. Using this call avoids potential race conditions. This
  30291. + * call will return success only once per trigger.
  30292. + */
  30293. +
  30294. +int trivial_irq_triggered ( irq_t irq ) {
  30295. + uint16_t trivial_irq_this_trigger_count = *trivial_irq_trigger_count;
  30296. + int triggered = ( trivial_irq_this_trigger_count -
  30297. + trivial_irq_previous_trigger_count );
  30298. +
  30299. + /* irq is not used at present, but we have it in the API for
  30300. + * future-proofing; in case we want the facility to have
  30301. + * multiple trivial IRQ handlers installed simultaneously.
  30302. + *
  30303. + * Avoid compiler warning about unused variable.
  30304. + */
  30305. + if ( irq == IRQ_NONE ) {};
  30306. +
  30307. + trivial_irq_previous_trigger_count = trivial_irq_this_trigger_count;
  30308. + return triggered ? 1 : 0;
  30309. +}
  30310. +
  30311. +/* Copy trivial IRQ handler to a new location. Typically used to copy
  30312. + * the handler into base memory; when relocation is being used we need
  30313. + * to do this before installing the handler.
  30314. + *
  30315. + * Call with target=NULL in order to restore the handler to its
  30316. + * original location.
  30317. + */
  30318. +
  30319. +int copy_trivial_irq_handler ( void *target, size_t target_size ) {
  30320. + irq_t currently_installed_on = trivial_irq_installed_on;
  30321. + uint32_t offset = ( target == NULL ? 0 :
  30322. + target - &_trivial_irq_handler_start );
  30323. +
  30324. + if (( target != NULL ) && ( target_size < TRIVIAL_IRQ_HANDLER_SIZE )) {
  30325. + DBG ( "Insufficient space to copy trivial IRQ handler\n" );
  30326. + return 0;
  30327. + }
  30328. +
  30329. + if ( currently_installed_on != IRQ_NONE ) {
  30330. + DBG ("WARNING: relocating trivial IRQ handler while in use\n");
  30331. + if ( ! remove_trivial_irq_handler ( currently_installed_on ) )
  30332. + return 0;
  30333. + }
  30334. +
  30335. + /* Do the actual copy */
  30336. + if ( target != NULL ) {
  30337. + DBG ( "Copying trivial IRQ handler to %hx:%hx\n",
  30338. + SEGMENT(target), OFFSET(target) );
  30339. + memcpy ( target, &_trivial_irq_handler_start,
  30340. + TRIVIAL_IRQ_HANDLER_SIZE );
  30341. + } else {
  30342. + DBG ( "Restoring trivial IRQ handler to original location\n" );
  30343. + }
  30344. + /* Update all the pointers to structures within the handler */
  30345. + trivial_irq_handler = ( void (*)P((void)) )
  30346. + ( (void*)_trivial_irq_handler + offset );
  30347. + trivial_irq_trigger_count = (uint16_t*)
  30348. + ( (void*)&_trivial_irq_trigger_count + offset );
  30349. + trivial_irq_chain_to = (segoff_t*)
  30350. + ( (void*)&_trivial_irq_chain_to + offset );
  30351. + trivial_irq_chain = (uint8_t*)
  30352. + ( (void*)&_trivial_irq_chain + offset );
  30353. +
  30354. + if ( currently_installed_on != IRQ_NONE ) {
  30355. + if ( ! install_trivial_irq_handler ( currently_installed_on ) )
  30356. + return 0;
  30357. + }
  30358. + return 1;
  30359. +}
  30360. +
  30361. +/* Send non-specific EOI(s). This seems to be inherently unsafe.
  30362. + */
  30363. +
  30364. +void send_nonspecific_eoi ( irq_t irq ) {
  30365. + DBG ( "Sending non-specific EOI for IRQ %d\n", irq );
  30366. + if ( irq >= IRQ_PIC_CUTOFF ) {
  30367. + outb ( ICR_EOI_NON_SPECIFIC, PIC2_ICR );
  30368. + }
  30369. + outb ( ICR_EOI_NON_SPECIFIC, PIC1_ICR );
  30370. +}
  30371. +
  30372. +/* Send specific EOI(s).
  30373. + */
  30374. +
  30375. +void send_specific_eoi ( irq_t irq ) {
  30376. + DBG ( "Sending specific EOI for IRQ %d\n", irq );
  30377. + outb ( ICR_EOI_SPECIFIC | ICR_VALUE(irq), ICR_REG(irq) );
  30378. + if ( irq >= IRQ_PIC_CUTOFF ) {
  30379. + outb ( ICR_EOI_SPECIFIC | ICR_VALUE(CHAINED_IRQ),
  30380. + ICR_REG(CHAINED_IRQ) );
  30381. + }
  30382. +}
  30383. +
  30384. +/* Dump current 8259 status: enabled IRQs and handler addresses.
  30385. + */
  30386. +
  30387. +#ifdef DEBUG_IRQ
  30388. +void dump_irq_status ( void ) {
  30389. + int irq = 0;
  30390. +
  30391. + for ( irq = 0; irq < 16; irq++ ) {
  30392. + if ( irq_enabled ( irq ) ) {
  30393. + printf ( "IRQ%d enabled, ISR at %hx:%hx\n", irq,
  30394. + IRQ_VECTOR(irq)->segment,
  30395. + IRQ_VECTOR(irq)->offset );
  30396. + }
  30397. + }
  30398. +}
  30399. +#endif
  30400. diff -Naur grub-0.97.orig/netboot/pic8259.h grub-0.97/netboot/pic8259.h
  30401. --- grub-0.97.orig/netboot/pic8259.h 1970-01-01 00:00:00.000000000 +0000
  30402. +++ grub-0.97/netboot/pic8259.h 2005-08-31 19:03:35.000000000 +0000
  30403. @@ -0,0 +1,99 @@
  30404. +/*
  30405. + * Basic support for controlling the 8259 Programmable Interrupt Controllers.
  30406. + *
  30407. + * Initially written by Michael Brown (mcb30).
  30408. + */
  30409. +
  30410. +#ifndef PIC8259_H
  30411. +#define PIC8259_H
  30412. +
  30413. +/* For segoff_t */
  30414. +#include <segoff.h>
  30415. +
  30416. +#define IRQ_PIC_CUTOFF (8)
  30417. +
  30418. +/* 8259 register locations */
  30419. +#define PIC1_ICW1 (0x20)
  30420. +#define PIC1_OCW2 (0x20)
  30421. +#define PIC1_OCW3 (0x20)
  30422. +#define PIC1_ICR (0x20)
  30423. +#define PIC1_IRR (0x20)
  30424. +#define PIC1_ISR (0x20)
  30425. +#define PIC1_ICW2 (0x21)
  30426. +#define PIC1_ICW3 (0x21)
  30427. +#define PIC1_ICW4 (0x21)
  30428. +#define PIC1_IMR (0x21)
  30429. +#define PIC2_ICW1 (0xa0)
  30430. +#define PIC2_OCW2 (0xa0)
  30431. +#define PIC2_OCW3 (0xa0)
  30432. +#define PIC2_ICR (0xa0)
  30433. +#define PIC2_IRR (0xa0)
  30434. +#define PIC2_ISR (0xa0)
  30435. +#define PIC2_ICW2 (0xa1)
  30436. +#define PIC2_ICW3 (0xa1)
  30437. +#define PIC2_ICW4 (0xa1)
  30438. +#define PIC2_IMR (0xa1)
  30439. +
  30440. +/* Register command values */
  30441. +#define OCW3_ID (0x08)
  30442. +#define OCW3_READ_IRR (0x03)
  30443. +#define OCW3_READ_ISR (0x02)
  30444. +#define ICR_EOI_NON_SPECIFIC (0x20)
  30445. +#define ICR_EOI_NOP (0x40)
  30446. +#define ICR_EOI_SPECIFIC (0x60)
  30447. +#define ICR_EOI_SET_PRIORITY (0xc0)
  30448. +
  30449. +/* Macros to enable/disable IRQs */
  30450. +#define IMR_REG(x) ( (x) < IRQ_PIC_CUTOFF ? PIC1_IMR : PIC2_IMR )
  30451. +#define IMR_BIT(x) ( 1 << ( (x) % IRQ_PIC_CUTOFF ) )
  30452. +#define irq_enabled(x) ( ( inb ( IMR_REG(x) ) & IMR_BIT(x) ) == 0 )
  30453. +#define enable_irq(x) outb ( inb( IMR_REG(x) ) & ~IMR_BIT(x), IMR_REG(x) )
  30454. +#define disable_irq(x) outb ( inb( IMR_REG(x) ) | IMR_BIT(x), IMR_REG(x) )
  30455. +
  30456. +/* Macros for acknowledging IRQs */
  30457. +#define ICR_REG(x) ( (x) < IRQ_PIC_CUTOFF ? PIC1_ICR : PIC2_ICR )
  30458. +#define ICR_VALUE(x) ( (x) % IRQ_PIC_CUTOFF )
  30459. +#define CHAINED_IRQ 2
  30460. +
  30461. +/* Utility macros to convert IRQ numbers to INT numbers and INT vectors */
  30462. +#define IRQ_INT(x) ( (x)<IRQ_PIC_CUTOFF ? (x)+0x08 : (x)-IRQ_PIC_CUTOFF+0x70 )
  30463. +#define INT_VECTOR(x) ( (segoff_t*) phys_to_virt( 4 * (x) ) )
  30464. +#define IRQ_VECTOR(x) ( INT_VECTOR ( IRQ_INT(x) ) )
  30465. +
  30466. +/* Other constants */
  30467. +typedef uint8_t irq_t;
  30468. +#define IRQ_MAX (15)
  30469. +#define IRQ_NONE (0xff)
  30470. +
  30471. +/* Labels in assembly code (in pcbios.S)
  30472. + */
  30473. +extern void _trivial_irq_handler_start;
  30474. +extern void _trivial_irq_handler ( void );
  30475. +extern volatile uint16_t _trivial_irq_trigger_count;
  30476. +extern segoff_t _trivial_irq_chain_to;
  30477. +extern uint8_t _trivial_irq_chain;
  30478. +extern void _trivial_irq_handler_end;
  30479. +#define TRIVIAL_IRQ_HANDLER_SIZE \
  30480. + ((uint32_t)( &_trivial_irq_handler_end - &_trivial_irq_handler_start ))
  30481. +
  30482. +/* Function prototypes
  30483. + */
  30484. +int install_irq_handler ( irq_t irq, segoff_t *handler,
  30485. + uint8_t *previously_enabled,
  30486. + segoff_t *previous_handler );
  30487. +int remove_irq_handler ( irq_t irq, segoff_t *handler,
  30488. + uint8_t *previously_enabled,
  30489. + segoff_t *previous_handler );
  30490. +int install_trivial_irq_handler ( irq_t irq );
  30491. +int remove_trivial_irq_handler ( irq_t irq );
  30492. +int trivial_irq_triggered ( irq_t irq );
  30493. +int copy_trivial_irq_handler ( void *target, size_t target_size );
  30494. +void send_non_specific_eoi ( irq_t irq );
  30495. +void send_specific_eoi ( irq_t irq );
  30496. +#ifdef DEBUG_IRQ
  30497. +void dump_irq_status ( void );
  30498. +#else
  30499. +#define dump_irq_status()
  30500. +#endif
  30501. +
  30502. +#endif /* PIC8259_H */
  30503. diff -Naur grub-0.97.orig/netboot/pnic.c grub-0.97/netboot/pnic.c
  30504. --- grub-0.97.orig/netboot/pnic.c 1970-01-01 00:00:00.000000000 +0000
  30505. +++ grub-0.97/netboot/pnic.c 2005-08-31 19:03:35.000000000 +0000
  30506. @@ -0,0 +1,267 @@
  30507. +/**************************************************************************
  30508. +Etherboot - BOOTP/TFTP Bootstrap Program
  30509. +Bochs Pseudo NIC driver for Etherboot
  30510. +***************************************************************************/
  30511. +
  30512. +/*
  30513. + * This program is free software; you can redistribute it and/or
  30514. + * modify it under the terms of the GNU General Public License as
  30515. + * published by the Free Software Foundation; either version 2, or (at
  30516. + * your option) any later version.
  30517. + *
  30518. + * See pnic_api.h for an explanation of the Bochs Pseudo NIC.
  30519. + */
  30520. +
  30521. +/* to get some global routines like printf */
  30522. +#include "etherboot.h"
  30523. +/* to get the interface to the body of the program */
  30524. +#include "nic.h"
  30525. +/* to get the PCI support functions, if this is a PCI NIC */
  30526. +#include "pci.h"
  30527. +
  30528. +/* PNIC API */
  30529. +#include "pnic_api.h"
  30530. +
  30531. +/* Private data structure */
  30532. +typedef struct {
  30533. + uint16_t api_version;
  30534. +} pnic_priv_data_t;
  30535. +
  30536. +/* Function prototypes */
  30537. +static int pnic_api_check ( uint16_t api_version );
  30538. +
  30539. +/* NIC specific static variables go here */
  30540. +static uint8_t tx_buffer[ETH_FRAME_LEN];
  30541. +
  30542. +/*
  30543. + * Utility functions: issue a PNIC command, retrieve result. Use
  30544. + * pnic_command_quiet if you don't want failure codes to be
  30545. + * automatically printed. Returns the PNIC status code.
  30546. + *
  30547. + * Set output_length to NULL only if you expect to receive exactly
  30548. + * output_max_length bytes, otherwise it'll complain that you didn't
  30549. + * get enough data (on the assumption that if you not interested in
  30550. + * discovering the output length then you're expecting a fixed amount
  30551. + * of data).
  30552. + */
  30553. +
  30554. +static uint16_t pnic_command_quiet ( struct nic *nic, uint16_t command,
  30555. + void *input, uint16_t input_length,
  30556. + void *output, uint16_t output_max_length,
  30557. + uint16_t *output_length ) {
  30558. + int i;
  30559. + uint16_t status;
  30560. + uint16_t _output_length;
  30561. +
  30562. + if ( input != NULL ) {
  30563. + /* Write input length */
  30564. + outw ( input_length, nic->ioaddr + PNIC_REG_LEN );
  30565. + /* Write input data */
  30566. + for ( i = 0; i < input_length; i++ ) {
  30567. + outb( ((char*)input)[i], nic->ioaddr + PNIC_REG_DATA );
  30568. + }
  30569. + }
  30570. + /* Write command */
  30571. + outw ( command, nic->ioaddr + PNIC_REG_CMD );
  30572. + /* Retrieve status */
  30573. + status = inw ( nic->ioaddr + PNIC_REG_STAT );
  30574. + /* Retrieve output length */
  30575. + _output_length = inw ( nic->ioaddr + PNIC_REG_LEN );
  30576. + if ( output_length == NULL ) {
  30577. + if ( _output_length != output_max_length ) {
  30578. + printf ( "pnic_command %#hx: wrong data length "
  30579. + "returned (expected %d, got %d)\n", command,
  30580. + output_max_length, _output_length );
  30581. + }
  30582. + } else {
  30583. + *output_length = _output_length;
  30584. + }
  30585. + if ( output != NULL ) {
  30586. + if ( _output_length > output_max_length ) {
  30587. + printf ( "pnic_command %#hx: output buffer too small "
  30588. + "(have %d, need %d)\n", command,
  30589. + output_max_length, _output_length );
  30590. + _output_length = output_max_length;
  30591. + }
  30592. + /* Retrieve output data */
  30593. + for ( i = 0; i < _output_length; i++ ) {
  30594. + ((char*)output)[i] =
  30595. + inb ( nic->ioaddr + PNIC_REG_DATA );
  30596. + }
  30597. + }
  30598. + return status;
  30599. +}
  30600. +
  30601. +static uint16_t pnic_command ( struct nic *nic, uint16_t command,
  30602. + void *input, uint16_t input_length,
  30603. + void *output, uint16_t output_max_length,
  30604. + uint16_t *output_length ) {
  30605. + pnic_priv_data_t *priv = (pnic_priv_data_t*)nic->priv_data;
  30606. + uint16_t status = pnic_command_quiet ( nic, command,
  30607. + input, input_length,
  30608. + output, output_max_length,
  30609. + output_length );
  30610. + if ( status == PNIC_STATUS_OK ) return status;
  30611. + printf ( "PNIC command %#hx (len %#hx) failed with status %#hx\n",
  30612. + command, input_length, status );
  30613. + if ( priv->api_version ) pnic_api_check(priv->api_version);
  30614. + return status;
  30615. +}
  30616. +
  30617. +/* Check API version matches that of NIC */
  30618. +static int pnic_api_check ( uint16_t api_version ) {
  30619. + if ( api_version != PNIC_API_VERSION ) {
  30620. + printf ( "Warning: API version mismatch! "
  30621. + "(NIC's is %d.%d, ours is %d.%d)\n",
  30622. + api_version >> 8, api_version & 0xff,
  30623. + PNIC_API_VERSION >> 8, PNIC_API_VERSION & 0xff );
  30624. + }
  30625. + if ( api_version < PNIC_API_VERSION ) {
  30626. + printf ( "*** You may need to update your copy of Bochs ***\n" );
  30627. + }
  30628. + return ( api_version == PNIC_API_VERSION );
  30629. +}
  30630. +
  30631. +/**************************************************************************
  30632. +POLL - Wait for a frame
  30633. +***************************************************************************/
  30634. +static int pnic_poll(struct nic *nic, int retrieve)
  30635. +{
  30636. + uint16_t length;
  30637. + uint16_t qlen;
  30638. +
  30639. + /* Check receive queue length to see if there's anything to
  30640. + * get. Necessary since once we've called PNIC_CMD_RECV we
  30641. + * have to read out the packet, otherwise it's lost forever.
  30642. + */
  30643. + if ( pnic_command ( nic, PNIC_CMD_RECV_QLEN, NULL, 0,
  30644. + &qlen, sizeof(qlen), NULL )
  30645. + != PNIC_STATUS_OK ) return ( 0 );
  30646. + if ( qlen == 0 ) return ( 0 );
  30647. +
  30648. + /* There is a packet ready. Return 1 if we're only checking. */
  30649. + if ( ! retrieve ) return ( 1 );
  30650. +
  30651. + /* Retrieve the packet */
  30652. + if ( pnic_command ( nic, PNIC_CMD_RECV, NULL, 0,
  30653. + nic->packet, ETH_FRAME_LEN, &length )
  30654. + != PNIC_STATUS_OK ) return ( 0 );
  30655. + nic->packetlen = length;
  30656. + return ( 1 );
  30657. +}
  30658. +
  30659. +/**************************************************************************
  30660. +TRANSMIT - Transmit a frame
  30661. +***************************************************************************/
  30662. +static void pnic_transmit(
  30663. + struct nic *nic,
  30664. + const char *dest, /* Destination */
  30665. + unsigned int type, /* Type */
  30666. + unsigned int size, /* size */
  30667. + const char *data) /* Packet */
  30668. +{
  30669. + unsigned int nstype = htons ( type );
  30670. +
  30671. + if ( ( ETH_HLEN + size ) >= ETH_FRAME_LEN ) {
  30672. + printf ( "pnic_transmit: packet too large\n" );
  30673. + return;
  30674. + }
  30675. +
  30676. + /* Assemble packet */
  30677. + memcpy ( tx_buffer, dest, ETH_ALEN );
  30678. + memcpy ( tx_buffer + ETH_ALEN, nic->node_addr, ETH_ALEN );
  30679. + memcpy ( tx_buffer + 2 * ETH_ALEN, &nstype, 2 );
  30680. + memcpy ( tx_buffer + ETH_HLEN, data, size );
  30681. +
  30682. + pnic_command ( nic, PNIC_CMD_XMIT, tx_buffer, ETH_HLEN + size,
  30683. + NULL, 0, NULL );
  30684. +}
  30685. +
  30686. +/**************************************************************************
  30687. +DISABLE - Turn off ethernet interface
  30688. +***************************************************************************/
  30689. +static void pnic_disable(struct dev *dev)
  30690. +{
  30691. + struct nic *nic = (struct nic *)dev;
  30692. + pnic_command ( nic, PNIC_CMD_RESET, NULL, 0, NULL, 0, NULL );
  30693. +}
  30694. +
  30695. +/**************************************************************************
  30696. +IRQ - Handle card interrupt status
  30697. +***************************************************************************/
  30698. +static void pnic_irq ( struct nic *nic, irq_action_t action )
  30699. +{
  30700. + uint8_t enabled;
  30701. +
  30702. + switch ( action ) {
  30703. + case DISABLE :
  30704. + case ENABLE :
  30705. + enabled = ( action == ENABLE ? 1 : 0 );
  30706. + pnic_command ( nic, PNIC_CMD_MASK_IRQ,
  30707. + &enabled, sizeof(enabled), NULL, 0, NULL );
  30708. + break;
  30709. + case FORCE :
  30710. + pnic_command ( nic, PNIC_CMD_FORCE_IRQ,
  30711. + NULL, 0, NULL, 0, NULL );
  30712. + break;
  30713. + }
  30714. +}
  30715. +
  30716. +/**************************************************************************
  30717. +PROBE - Look for an adapter, this routine's visible to the outside
  30718. +***************************************************************************/
  30719. +
  30720. +static int pnic_probe(struct dev *dev, struct pci_device *pci)
  30721. +{
  30722. + struct nic *nic = (struct nic *)dev;
  30723. + static pnic_priv_data_t priv;
  30724. + uint16_t status;
  30725. +
  30726. + printf(" - ");
  30727. +
  30728. + /* Clear private data structure and chain it in */
  30729. + memset ( &priv, 0, sizeof(priv) );
  30730. + nic->priv_data = &priv;
  30731. +
  30732. + /* Mask the bit that says "this is an io addr" */
  30733. + nic->ioaddr = pci->ioaddr & ~3;
  30734. + nic->irqno = pci->irq;
  30735. + /* Not sure what this does, but the rtl8139 driver does it */
  30736. + adjust_pci_device(pci);
  30737. +
  30738. + status = pnic_command_quiet( nic, PNIC_CMD_API_VER, NULL, 0,
  30739. + &priv.api_version,
  30740. + sizeof(priv.api_version), NULL );
  30741. + if ( status != PNIC_STATUS_OK ) {
  30742. + printf ( "PNIC failed installation check, code %#hx\n",
  30743. + status );
  30744. + return 0;
  30745. + }
  30746. + pnic_api_check(priv.api_version);
  30747. + status = pnic_command ( nic, PNIC_CMD_READ_MAC, NULL, 0,
  30748. + nic->node_addr, ETH_ALEN, NULL );
  30749. + printf ( "Detected Bochs Pseudo NIC MAC %! (API v%d.%d) at %#hx\n",
  30750. + nic->node_addr, priv.api_version>>8, priv.api_version&0xff,
  30751. + nic->ioaddr );
  30752. +
  30753. + /* point to NIC specific routines */
  30754. + dev->disable = pnic_disable;
  30755. + nic->poll = pnic_poll;
  30756. + nic->transmit = pnic_transmit;
  30757. + nic->irq = pnic_irq;
  30758. + return 1;
  30759. +}
  30760. +
  30761. +static struct pci_id pnic_nics[] = {
  30762. +/* genrules.pl doesn't let us use macros for PCI IDs...*/
  30763. +PCI_ROM(0xfefe, 0xefef, "pnic", "Bochs Pseudo NIC Adaptor"),
  30764. +};
  30765. +
  30766. +struct pci_driver pnic_driver = {
  30767. + .type = NIC_DRIVER,
  30768. + .name = "PNIC",
  30769. + .probe = pnic_probe,
  30770. + .ids = pnic_nics,
  30771. + .id_count = sizeof(pnic_nics)/sizeof(pnic_nics[0]),
  30772. + .class = 0,
  30773. +};
  30774. diff -Naur grub-0.97.orig/netboot/pnic_api.h grub-0.97/netboot/pnic_api.h
  30775. --- grub-0.97.orig/netboot/pnic_api.h 1970-01-01 00:00:00.000000000 +0000
  30776. +++ grub-0.97/netboot/pnic_api.h 2005-08-31 19:03:35.000000000 +0000
  30777. @@ -0,0 +1,59 @@
  30778. +/*
  30779. + * Constants etc. for the Bochs/Etherboot pseudo-NIC
  30780. + *
  30781. + * This header file must be valid C and C++.
  30782. + *
  30783. + * Operation of the pseudo-NIC (PNIC) is pretty simple. To write a
  30784. + * command plus data, first write the length of the data to
  30785. + * PNIC_REG_LEN, then write the data a byte at a type to
  30786. + * PNIC_REG_DATA, then write the command code to PNIC_REG_CMD. The
  30787. + * status will be available from PNIC_REG_STAT. The length of any
  30788. + * data returned will be in PNIC_REG_LEN and can be read a byte at a
  30789. + * time from PNIC_REG_DATA.
  30790. + */
  30791. +
  30792. +/*
  30793. + * PCI parameters
  30794. + */
  30795. +#define PNIC_PCI_VENDOR 0xfefe /* Hopefully these won't clash with */
  30796. +#define PNIC_PCI_DEVICE 0xefef /* any real PCI device IDs. */
  30797. +
  30798. +/*
  30799. + * 'Hardware' register addresses, offset from io_base
  30800. + */
  30801. +#define PNIC_REG_CMD 0x00 /* Command register, 2 bytes, write only */
  30802. +#define PNIC_REG_STAT 0x00 /* Status register, 2 bytes, read only */
  30803. +#define PNIC_REG_LEN 0x02 /* Length register, 2 bytes, read-write */
  30804. +#define PNIC_REG_DATA 0x04 /* Data port, 1 byte, read-write */
  30805. +/*
  30806. + * PNIC_MAX_REG used in Bochs to claim i/o space
  30807. + */
  30808. +#define PNIC_MAX_REG 0x04
  30809. +
  30810. +/*
  30811. + * Command code definitions: write these into PNIC_REG_CMD
  30812. + */
  30813. +#define PNIC_CMD_NOOP 0x0000
  30814. +#define PNIC_CMD_API_VER 0x0001
  30815. +#define PNIC_CMD_READ_MAC 0x0002
  30816. +#define PNIC_CMD_RESET 0x0003
  30817. +#define PNIC_CMD_XMIT 0x0004
  30818. +#define PNIC_CMD_RECV 0x0005
  30819. +#define PNIC_CMD_RECV_QLEN 0x0006
  30820. +#define PNIC_CMD_MASK_IRQ 0x0007
  30821. +#define PNIC_CMD_FORCE_IRQ 0x0008
  30822. +
  30823. +/*
  30824. + * Status code definitions: read these from PNIC_REG_STAT
  30825. + *
  30826. + * We avoid using status codes that might be confused with
  30827. + * randomly-read data (e.g. 0x0000, 0xffff etc.)
  30828. + */
  30829. +#define PNIC_STATUS_OK 0x4f4b /* 'OK' */
  30830. +#define PNIC_STATUS_UNKNOWN_CMD 0x3f3f /* '??' */
  30831. +
  30832. +/*
  30833. + * Other miscellaneous information
  30834. + */
  30835. +
  30836. +#define PNIC_API_VERSION 0x0101 /* 1.1 */
  30837. diff -Naur grub-0.97.orig/netboot/pxe.h grub-0.97/netboot/pxe.h
  30838. --- grub-0.97.orig/netboot/pxe.h 1970-01-01 00:00:00.000000000 +0000
  30839. +++ grub-0.97/netboot/pxe.h 2005-08-31 19:03:35.000000000 +0000
  30840. @@ -0,0 +1,521 @@
  30841. +/*
  30842. + * Copyright (c) 2000 Alfred Perlstein <alfred@freebsd.org>
  30843. + * All rights reserved.
  30844. + * Copyright (c) 2000 Paul Saab <ps@freebsd.org>
  30845. + * All rights reserved.
  30846. + * Copyright (c) 2000 John Baldwin <jhb@freebsd.org>
  30847. + * All rights reserved.
  30848. + *
  30849. + * Redistribution and use in source and binary forms, with or without
  30850. + * modification, are permitted provided that the following conditions
  30851. + * are met:
  30852. + * 1. Redistributions of source code must retain the above copyright
  30853. + * notice, this list of conditions and the following disclaimer.
  30854. + * 2. Redistributions in binary form must reproduce the above copyright
  30855. + * notice, this list of conditions and the following disclaimer in the
  30856. + * documentation and/or other materials provided with the distribution.
  30857. + *
  30858. + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  30859. + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  30860. + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  30861. + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  30862. + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  30863. + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  30864. + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  30865. + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30866. + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30867. + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30868. + * SUCH DAMAGE.
  30869. + *
  30870. + * $FreeBSD: src/sys/boot/i386/libi386/pxe.h,v 1.4.2.2 2000/09/10 02:52:18 ps Exp $
  30871. + */
  30872. +
  30873. +/*
  30874. + * The typedefs and structures declared in this file
  30875. + * clearly violate style(9), the reason for this is to conform to the
  30876. + * typedefs/structure-names used in the Intel literature to avoid confusion.
  30877. + *
  30878. + * It's for your own good. :)
  30879. + */
  30880. +
  30881. +/* SEGOFF16_t defined in separate header for Etherboot
  30882. + */
  30883. +#include <segoff.h>
  30884. +
  30885. +/* It seems that intel didn't think about ABI,
  30886. + * either that or 16bit ABI != 32bit ABI (which seems reasonable)
  30887. + * I have to thank Intel for the hair loss I incurred trying to figure
  30888. + * out why PXE was mis-reading structures I was passing it (at least
  30889. + * from my point of view)
  30890. + *
  30891. + * Solution: use gcc's '__attribute__ ((packed))' to correctly align
  30892. + * structures passed into PXE
  30893. + * Question: does this really work for PXE's expected ABI?
  30894. + */
  30895. +#define PACKED __attribute__ ((packed))
  30896. +
  30897. +#define S_SIZE(s) s, sizeof(s) - 1
  30898. +
  30899. +#define IP_STR "%d.%d.%d.%d"
  30900. +#define IP_ARGS(ip) \
  30901. + (int)(ip >> 24) & 0xff, (int)(ip >> 16) & 0xff, \
  30902. + (int)(ip >> 8) & 0xff, (int)ip & 0xff
  30903. +
  30904. +#define MAC_STR "%02x:%02x:%02x:%02x:%02x:%02x"
  30905. +#define MAC_ARGS(mac) \
  30906. + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]
  30907. +
  30908. +#define PXENFSROOTPATH "/pxeroot"
  30909. +
  30910. +typedef struct {
  30911. + uint16_t Seg_Addr;
  30912. + uint32_t Phy_Addr;
  30913. + uint16_t Seg_Size;
  30914. +} PACKED SEGDESC_t; /* PACKED is required, otherwise gcc pads this out to 12
  30915. + bytes - mbrown@fensystems.co.uk (mcb30) 17/5/03 */
  30916. +
  30917. +typedef uint16_t SEGSEL_t;
  30918. +typedef uint16_t PXENV_STATUS_t;
  30919. +typedef uint32_t IP4_t;
  30920. +typedef uint32_t ADDR32_t;
  30921. +typedef uint16_t UDP_PORT_t;
  30922. +
  30923. +#define MAC_ADDR_LEN 16
  30924. +typedef uint8_t MAC_ADDR[MAC_ADDR_LEN];
  30925. +
  30926. +/* PXENV+ */
  30927. +typedef struct {
  30928. + uint8_t Signature[6]; /* 'PXENV+' */
  30929. + uint16_t Version; /* MSB = major, LSB = minor */
  30930. + uint8_t Length; /* structure length */
  30931. + uint8_t Checksum; /* checksum pad */
  30932. + SEGOFF16_t RMEntry; /* SEG:OFF to PXE entry point */
  30933. + /* don't use PMOffset and PMSelector (from the 2.1 PXE manual) */
  30934. + uint32_t PMOffset; /* Protected mode entry */
  30935. + SEGSEL_t PMSelector; /* Protected mode selector */
  30936. + SEGSEL_t StackSeg; /* Stack segment address */
  30937. + uint16_t StackSize; /* Stack segment size (bytes) */
  30938. + SEGSEL_t BC_CodeSeg; /* BC Code segment address */
  30939. + uint16_t BC_CodeSize; /* BC Code segment size (bytes) */
  30940. + SEGSEL_t BC_DataSeg; /* BC Data segment address */
  30941. + uint16_t BC_DataSize; /* BC Data segment size (bytes) */
  30942. + SEGSEL_t UNDIDataSeg; /* UNDI Data segment address */
  30943. + uint16_t UNDIDataSize; /* UNDI Data segment size (bytes) */
  30944. + SEGSEL_t UNDICodeSeg; /* UNDI Code segment address */
  30945. + uint16_t UNDICodeSize; /* UNDI Code segment size (bytes) */
  30946. + SEGOFF16_t PXEPtr; /* SEG:OFF to !PXE struct,
  30947. + only present when Version > 2.1 */
  30948. +} PACKED pxenv_t;
  30949. +
  30950. +/* !PXE */
  30951. +typedef struct {
  30952. + uint8_t Signature[4];
  30953. + uint8_t StructLength;
  30954. + uint8_t StructCksum;
  30955. + uint8_t StructRev;
  30956. + uint8_t reserved_1;
  30957. + SEGOFF16_t UNDIROMID;
  30958. + SEGOFF16_t BaseROMID;
  30959. + SEGOFF16_t EntryPointSP;
  30960. + SEGOFF16_t EntryPointESP;
  30961. + SEGOFF16_t StatusCallout;
  30962. + uint8_t reserved_2;
  30963. + uint8_t SegDescCn;
  30964. + SEGSEL_t FirstSelector;
  30965. + SEGDESC_t Stack;
  30966. + SEGDESC_t UNDIData;
  30967. + SEGDESC_t UNDICode;
  30968. + SEGDESC_t UNDICodeWrite;
  30969. + SEGDESC_t BC_Data;
  30970. + SEGDESC_t BC_Code;
  30971. + SEGDESC_t BC_CodeWrite;
  30972. +} PACKED pxe_t;
  30973. +
  30974. +#define PXENV_START_UNDI 0x0000
  30975. +typedef struct {
  30976. + PXENV_STATUS_t Status;
  30977. + uint16_t ax;
  30978. + uint16_t bx;
  30979. + uint16_t dx;
  30980. + uint16_t di;
  30981. + uint16_t es;
  30982. +} PACKED t_PXENV_START_UNDI;
  30983. +
  30984. +#define PXENV_UNDI_STARTUP 0x0001
  30985. +typedef struct {
  30986. + PXENV_STATUS_t Status;
  30987. +} PACKED t_PXENV_UNDI_STARTUP;
  30988. +
  30989. +#define PXENV_UNDI_CLEANUP 0x0002
  30990. +typedef struct {
  30991. + PXENV_STATUS_t Status;
  30992. +} PACKED t_PXENV_UNDI_CLEANUP;
  30993. +
  30994. +#define PXENV_UNDI_INITIALIZE 0x0003
  30995. +typedef struct {
  30996. + PXENV_STATUS_t Status;
  30997. + ADDR32_t ProtocolIni; /* Phys addr of a copy of the driver module */
  30998. + uint8_t reserved[8];
  30999. +} PACKED t_PXENV_UNDI_INITIALIZE;
  31000. +
  31001. +
  31002. +#define MAXNUM_MCADDR 8
  31003. +typedef struct {
  31004. + uint16_t MCastAddrCount;
  31005. + MAC_ADDR McastAddr[MAXNUM_MCADDR];
  31006. +} PACKED t_PXENV_UNDI_MCAST_ADDRESS;
  31007. +
  31008. +#define PXENV_UNDI_RESET_ADAPTER 0x0004
  31009. +typedef struct {
  31010. + PXENV_STATUS_t Status;
  31011. + t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
  31012. +} PACKED t_PXENV_UNDI_RESET;
  31013. +
  31014. +#define PXENV_UNDI_SHUTDOWN 0x0005
  31015. +typedef struct {
  31016. + PXENV_STATUS_t Status;
  31017. +} PACKED t_PXENV_UNDI_SHUTDOWN;
  31018. +
  31019. +#define PXENV_UNDI_OPEN 0x0006
  31020. +typedef struct {
  31021. + PXENV_STATUS_t Status;
  31022. + uint16_t OpenFlag;
  31023. + uint16_t PktFilter;
  31024. +# define FLTR_DIRECTED 0x0001
  31025. +# define FLTR_BRDCST 0x0002
  31026. +# define FLTR_PRMSCS 0x0003
  31027. +# define FLTR_SRC_RTG 0x0004
  31028. +
  31029. + t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
  31030. +} PACKED t_PXENV_UNDI_OPEN;
  31031. +
  31032. +#define PXENV_UNDI_CLOSE 0x0007
  31033. +typedef struct {
  31034. + PXENV_STATUS_t Status;
  31035. +} PACKED t_PXENV_UNDI_CLOSE;
  31036. +
  31037. +#define PXENV_UNDI_TRANSMIT 0x0008
  31038. +typedef struct {
  31039. + PXENV_STATUS_t Status;
  31040. + uint8_t Protocol;
  31041. +# define P_UNKNOWN 0
  31042. +# define P_IP 1
  31043. +# define P_ARP 2
  31044. +# define P_RARP 3
  31045. +
  31046. + uint8_t XmitFlag;
  31047. +# define XMT_DESTADDR 0x0000
  31048. +# define XMT_BROADCAST 0x0001
  31049. +
  31050. + SEGOFF16_t DestAddr;
  31051. + SEGOFF16_t TBD;
  31052. + uint32_t Reserved[2];
  31053. +} PACKED t_PXENV_UNDI_TRANSMIT;
  31054. +
  31055. +#define MAX_DATA_BLKS 8
  31056. +typedef struct {
  31057. + uint16_t ImmedLength;
  31058. + SEGOFF16_t Xmit;
  31059. + uint16_t DataBlkCount;
  31060. + struct DataBlk {
  31061. + uint8_t TDPtrType;
  31062. + uint8_t TDRsvdByte;
  31063. + uint16_t TDDataLen;
  31064. + SEGOFF16_t TDDataPtr;
  31065. + } DataBlock[MAX_DATA_BLKS];
  31066. +} PACKED t_PXENV_UNDI_TBD;
  31067. +
  31068. +#define PXENV_UNDI_SET_MCAST_ADDRESS 0x0009
  31069. +typedef struct {
  31070. + PXENV_STATUS_t Status;
  31071. + t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
  31072. +} PACKED t_PXENV_UNDI_SET_MCAST_ADDR;
  31073. +
  31074. +#define PXENV_UNDI_SET_STATION_ADDRESS 0x000A
  31075. +typedef struct {
  31076. + PXENV_STATUS_t Status;
  31077. + MAC_ADDR StationAddress; /* Temp MAC addres to use */
  31078. +} PACKED t_PXENV_UNDI_SET_STATION_ADDRESS;
  31079. +
  31080. +#define PXENV_UNDI_SET_PACKET_FILTER 0x000B
  31081. +typedef struct {
  31082. + PXENV_STATUS_t Status;
  31083. + uint8_t filter; /* see UNDI_OPEN (0x0006) */
  31084. +} PACKED t_PXENV_UNDI_SET_PACKET_FILTER;
  31085. +
  31086. +#define PXENV_UNDI_GET_INFORMATION 0x000C
  31087. +typedef struct {
  31088. + PXENV_STATUS_t Status;
  31089. + uint16_t BaseIo; /* Adapter base I/O address */
  31090. + uint16_t IntNumber; /* Adapter IRQ number */
  31091. + uint16_t MaxTranUnit; /* Adapter maximum transmit unit */
  31092. + uint16_t HwType; /* Type of protocol at the hardware addr */
  31093. +# define ETHER_TYPE 1
  31094. +# define EXP_ETHER_TYPE 2
  31095. +# define IEEE_TYPE 6
  31096. +# define ARCNET_TYPE 7
  31097. +
  31098. + uint16_t HwAddrLen; /* Length of hardware address */
  31099. + MAC_ADDR CurrentNodeAddress; /* Current hardware address */
  31100. + MAC_ADDR PermNodeAddress; /* Permanent hardware address */
  31101. + SEGSEL_t ROMAddress; /* Real mode ROM segment address */
  31102. + uint16_t RxBufCt; /* Receive queue length */
  31103. + uint16_t TxBufCt; /* Transmit queue length */
  31104. +} PACKED t_PXENV_UNDI_GET_INFORMATION;
  31105. +
  31106. +#define PXENV_UNDI_GET_STATISTICS 0x000D
  31107. +typedef struct {
  31108. + PXENV_STATUS_t Status;
  31109. + uint32_t XmitGoodFrames; /* Number of successful transmissions */
  31110. + uint32_t RcvGoodFrames; /* Number of good frames received */
  31111. + uint32_t RcvCRCErrors; /* Number of frames with CRC errors */
  31112. + uint32_t RcvResourceErrors; /* Number of frames dropped */
  31113. +} PACKED t_PXENV_UNDI_GET_STATISTICS;
  31114. +
  31115. +#define PXENV_UNDI_CLEAR_STATISTICS 0x000E
  31116. +typedef struct {
  31117. + PXENV_STATUS_t Status;
  31118. +} PACKED t_PXENV_UNDI_CLEAR_STATISTICS;
  31119. +
  31120. +#define PXENV_UNDI_INITIATE_DIAGS 0x000F
  31121. +typedef struct {
  31122. + PXENV_STATUS_t Status;
  31123. +} PACKED t_PXENV_UNDI_INITIATE_DIAGS;
  31124. +
  31125. +#define PXENV_UNDI_FORCE_INTERRUPT 0x0010
  31126. +typedef struct {
  31127. + PXENV_STATUS_t Status;
  31128. +} PACKED t_PXENV_UNDI_FORCE_INTERRUPT;
  31129. +
  31130. +#define PXENV_UNDI_GET_MCAST_ADDRESS 0x0011
  31131. +typedef struct {
  31132. + PXENV_STATUS_t Status;
  31133. + IP4_t InetAddr; /* IP mulicast address */
  31134. + MAC_ADDR MediaAddr; /* MAC multicast address */
  31135. +} PACKED t_PXENV_UNDI_GET_MCAST_ADDR;
  31136. +
  31137. +#define PXENV_UNDI_GET_NIC_TYPE 0x0012
  31138. +typedef struct {
  31139. + PXENV_STATUS_t Status;
  31140. + uint8_t NicType; /* Type of NIC */
  31141. +# define PCI_NIC 2
  31142. +# define PnP_NIC 3
  31143. +# define CardBus_NIC 4
  31144. +
  31145. + union {
  31146. + struct {
  31147. + uint16_t Vendor_ID;
  31148. + uint16_t Dev_ID;
  31149. + uint8_t Base_Class;
  31150. + uint8_t Sub_Class;
  31151. + uint8_t Prog_Intf;
  31152. + uint8_t Rev;
  31153. + uint16_t BusDevFunc;
  31154. + uint16_t SubVendor_ID;
  31155. + uint16_t SubDevice_ID;
  31156. + } pci, cardbus;
  31157. + struct {
  31158. + uint32_t EISA_Dev_ID;
  31159. + uint8_t Base_Class;
  31160. + uint8_t Sub_Class;
  31161. + uint8_t Prog_Intf;
  31162. + uint16_t CardSelNum;
  31163. + } pnp;
  31164. + } info;
  31165. +} PACKED t_PXENV_UNDI_GET_NIC_TYPE;
  31166. +
  31167. +#define PXENV_UNDI_GET_IFACE_INFO 0x0013
  31168. +typedef struct {
  31169. + PXENV_STATUS_t Status;
  31170. + uint8_t IfaceType[16]; /* Name of MAC type in ASCII. */
  31171. + uint32_t LinkSpeed; /* Defined in NDIS 2.0 spec */
  31172. + uint32_t ServiceFlags; /* Defined in NDIS 2.0 spec */
  31173. + uint32_t Reserved[4]; /* must be 0 */
  31174. +} PACKED t_PXENV_UNDI_GET_IFACE_INFO;
  31175. +
  31176. +#define PXENV_UNDI_ISR 0x0014
  31177. +typedef struct {
  31178. + PXENV_STATUS_t Status;
  31179. + uint16_t FuncFlag; /* PXENV_UNDI_ISR_OUT_xxx */
  31180. + uint16_t BufferLength; /* Length of Frame */
  31181. + uint16_t FrameLength; /* Total length of reciever frame */
  31182. + uint16_t FrameHeaderLength; /* Length of the media header in Frame */
  31183. + SEGOFF16_t Frame; /* receive buffer */
  31184. + uint8_t ProtType; /* Protocol type */
  31185. + uint8_t PktType; /* Packet Type */
  31186. +# define PXENV_UNDI_ISR_IN_START 1
  31187. +# define PXENV_UNDI_ISR_IN_PROCESS 2
  31188. +# define PXENV_UNDI_ISR_IN_GET_NEXT 3
  31189. +
  31190. + /* one of these will be returned for PXENV_UNDI_ISR_IN_START */
  31191. +# define PXENV_UNDI_ISR_OUT_OURS 0
  31192. +# define PXENV_UNDI_ISR_OUT_NOT_OURS 1
  31193. +
  31194. + /*
  31195. + * one of these will bre returnd for PXEND_UNDI_ISR_IN_PROCESS
  31196. + * and PXENV_UNDI_ISR_IN_GET_NEXT
  31197. + */
  31198. +# define PXENV_UNDI_ISR_OUT_DONE 0
  31199. +# define PXENV_UNDI_ISR_OUT_TRANSMIT 2
  31200. +# define PXENV_UNDI_ISR_OUT_RECEIVE 3
  31201. +# define PXENV_UNDI_ISR_OUT_BUSY 4
  31202. +} PACKED t_PXENV_UNDI_ISR;
  31203. +
  31204. +#define PXENV_STOP_UNDI 0x0015
  31205. +typedef struct {
  31206. + PXENV_STATUS_t Status;
  31207. +} PACKED t_PXENV_STOP_UNDI;
  31208. +
  31209. +#define PXENV_TFTP_OPEN 0x0020
  31210. +typedef struct {
  31211. + PXENV_STATUS_t Status;
  31212. + IP4_t ServerIPAddress;
  31213. + IP4_t GatewayIPAddress;
  31214. + uint8_t FileName[128];
  31215. + UDP_PORT_t TFTPPort;
  31216. + uint16_t PacketSize;
  31217. +} PACKED t_PXENV_TFTP_OPEN;
  31218. +
  31219. +#define PXENV_TFTP_CLOSE 0x0021
  31220. +typedef struct {
  31221. + PXENV_STATUS_t Status;
  31222. +} PACKED t_PXENV_TFTP_CLOSE;
  31223. +
  31224. +#define PXENV_TFTP_READ 0x0022
  31225. +typedef struct {
  31226. + PXENV_STATUS_t Status;
  31227. + uint16_t PacketNumber;
  31228. + uint16_t BufferSize;
  31229. + SEGOFF16_t Buffer;
  31230. +} PACKED t_PXENV_TFTP_READ;
  31231. +
  31232. +#define PXENV_TFTP_READ_FILE 0x0023
  31233. +typedef struct {
  31234. + PXENV_STATUS_t Status;
  31235. + uint8_t FileName[128];
  31236. + uint32_t BufferSize;
  31237. + ADDR32_t Buffer;
  31238. + IP4_t ServerIPAddress;
  31239. + IP4_t GatewayIPAdress;
  31240. + IP4_t McastIPAdress;
  31241. + UDP_PORT_t TFTPClntPort;
  31242. + UDP_PORT_t TFTPSrvPort;
  31243. + uint16_t TFTPOpenTimeOut;
  31244. + uint16_t TFTPReopenDelay;
  31245. +} PACKED t_PXENV_TFTP_READ_FILE;
  31246. +
  31247. +#define PXENV_TFTP_GET_FSIZE 0x0025
  31248. +typedef struct {
  31249. + PXENV_STATUS_t Status;
  31250. + IP4_t ServerIPAddress;
  31251. + IP4_t GatewayIPAdress;
  31252. + uint8_t FileName[128];
  31253. + uint32_t FileSize;
  31254. +} PACKED t_PXENV_TFTP_GET_FSIZE;
  31255. +
  31256. +#define PXENV_UDP_OPEN 0x0030
  31257. +typedef struct {
  31258. + PXENV_STATUS_t Status;
  31259. + IP4_t src_ip; /* IP address of this station */
  31260. +} PACKED t_PXENV_UDP_OPEN;
  31261. +
  31262. +#define PXENV_UDP_CLOSE 0x0031
  31263. +typedef struct {
  31264. + PXENV_STATUS_t status;
  31265. +} PACKED t_PXENV_UDP_CLOSE;
  31266. +
  31267. +#define PXENV_UDP_READ 0x0032
  31268. +typedef struct {
  31269. + PXENV_STATUS_t status;
  31270. + IP4_t src_ip; /* IP of sender */
  31271. + IP4_t dest_ip; /* Only accept packets sent to this IP */
  31272. + UDP_PORT_t s_port; /* UDP source port of sender */
  31273. + UDP_PORT_t d_port; /* Only accept packets sent to this port */
  31274. + uint16_t buffer_size; /* Size of the packet buffer */
  31275. + SEGOFF16_t buffer; /* SEG:OFF to the packet buffer */
  31276. +} PACKED t_PXENV_UDP_READ;
  31277. +
  31278. +#define PXENV_UDP_WRITE 0x0033
  31279. +typedef struct {
  31280. + PXENV_STATUS_t status;
  31281. + IP4_t ip; /* dest ip addr */
  31282. + IP4_t gw; /* ip gateway */
  31283. + UDP_PORT_t src_port; /* source udp port */
  31284. + UDP_PORT_t dst_port; /* destination udp port */
  31285. + uint16_t buffer_size; /* Size of the packet buffer */
  31286. + SEGOFF16_t buffer; /* SEG:OFF to the packet buffer */
  31287. +} PACKED t_PXENV_UDP_WRITE;
  31288. +
  31289. +#define PXENV_UNLOAD_STACK 0x0070
  31290. +typedef struct {
  31291. + PXENV_STATUS_t Status;
  31292. + uint8_t reserved[10];
  31293. +} PACKED t_PXENV_UNLOAD_STACK;
  31294. +
  31295. +
  31296. +#define PXENV_GET_CACHED_INFO 0x0071
  31297. +typedef struct {
  31298. + PXENV_STATUS_t Status;
  31299. + uint16_t PacketType; /* type (defined right here) */
  31300. +# define PXENV_PACKET_TYPE_DHCP_DISCOVER 1
  31301. +# define PXENV_PACKET_TYPE_DHCP_ACK 2
  31302. +# define PXENV_PACKET_TYPE_BINL_REPLY 3
  31303. + uint16_t BufferSize; /* max to copy, leave at 0 for pointer */
  31304. + SEGOFF16_t Buffer; /* copy to, leave at 0 for pointer */
  31305. + uint16_t BufferLimit; /* max size of buffer in BC dataseg ? */
  31306. +} PACKED t_PXENV_GET_CACHED_INFO;
  31307. +
  31308. +
  31309. +/* structure filled in by PXENV_GET_CACHED_INFO
  31310. + * (how we determine which IP we downloaded the initial bootstrap from)
  31311. + * words can't describe...
  31312. + */
  31313. +typedef struct {
  31314. + uint8_t opcode;
  31315. +# define BOOTP_REQ 1
  31316. +# define BOOTP_REP 2
  31317. + uint8_t Hardware; /* hardware type */
  31318. + uint8_t Hardlen; /* hardware addr len */
  31319. + uint8_t Gatehops; /* zero it */
  31320. + uint32_t ident; /* random number chosen by client */
  31321. + uint16_t seconds; /* seconds since did initial bootstrap */
  31322. + uint16_t Flags; /* seconds since did initial bootstrap */
  31323. +# define BOOTP_BCAST 0x8000 /* ? */
  31324. + IP4_t cip; /* Client IP */
  31325. + IP4_t yip; /* Your IP */
  31326. + IP4_t sip; /* IP to use for next boot stage */
  31327. + IP4_t gip; /* Relay IP ? */
  31328. + MAC_ADDR CAddr; /* Client hardware address */
  31329. + uint8_t Sname[64]; /* Server's hostname (Optional) */
  31330. + uint8_t bootfile[128]; /* boot filename */
  31331. + union {
  31332. +# if 1
  31333. +# define BOOTP_DHCPVEND 1024 /* DHCP extended vendor field size */
  31334. +# else
  31335. +# define BOOTP_DHCPVEND 312 /* DHCP standard vendor field size */
  31336. +# endif
  31337. + uint8_t d[BOOTP_DHCPVEND]; /* raw array of vendor/dhcp options */
  31338. + struct {
  31339. + uint8_t magic[4]; /* DHCP magic cookie */
  31340. +# ifndef VM_RFC1048
  31341. +# define VM_RFC1048 0x63825363L /* ? */
  31342. +# endif
  31343. + uint32_t flags; /* bootp flags/opcodes */
  31344. + uint8_t pad[56]; /* I don't think intel knows what a
  31345. + union does... */
  31346. + } v;
  31347. + } vendor;
  31348. +} PACKED BOOTPLAYER;
  31349. +
  31350. +#define PXENV_RESTART_TFTP 0x0073
  31351. +#define t_PXENV_RESTART_TFTP t_PXENV_TFTP_READ_FILE
  31352. +
  31353. +#define PXENV_START_BASE 0x0075
  31354. +typedef struct {
  31355. + PXENV_STATUS_t Status;
  31356. +} PACKED t_PXENV_START_BASE;
  31357. +
  31358. +#define PXENV_STOP_BASE 0x0076
  31359. +typedef struct {
  31360. + PXENV_STATUS_t Status;
  31361. +} PACKED t_PXENV_STOP_BASE;
  31362. diff -Naur grub-0.97.orig/netboot/r8169.c grub-0.97/netboot/r8169.c
  31363. --- grub-0.97.orig/netboot/r8169.c 1970-01-01 00:00:00.000000000 +0000
  31364. +++ grub-0.97/netboot/r8169.c 2005-08-31 19:03:35.000000000 +0000
  31365. @@ -0,0 +1,854 @@
  31366. +/**************************************************************************
  31367. +* r8169.c: Etherboot device driver for the RealTek RTL-8169 Gigabit
  31368. +* Written 2003 by Timothy Legge <tlegge@rogers.com>
  31369. +*
  31370. +* This program is free software; you can redistribute it and/or modify
  31371. +* it under the terms of the GNU General Public License as published by
  31372. +* the Free Software Foundation; either version 2 of the License, or
  31373. +* (at your option) any later version.
  31374. +*
  31375. +* This program is distributed in the hope that it will be useful,
  31376. +* but WITHOUT ANY WARRANTY; without even the implied warranty of
  31377. +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  31378. +* GNU General Public License for more details.
  31379. +*
  31380. +* You should have received a copy of the GNU General Public License
  31381. +* along with this program; if not, write to the Free Software
  31382. +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  31383. +*
  31384. +* Portions of this code based on:
  31385. +* r8169.c: A RealTek RTL-8169 Gigabit Ethernet driver
  31386. +* for Linux kernel 2.4.x.
  31387. +*
  31388. +* Written 2002 ShuChen <shuchen@realtek.com.tw>
  31389. +* See Linux Driver for full information
  31390. +*
  31391. +* Linux Driver Version 1.27a, 10.02.2002
  31392. +*
  31393. +* Thanks to:
  31394. +* Jean Chen of RealTek Semiconductor Corp. for
  31395. +* providing the evaluation NIC used to develop
  31396. +* this driver. RealTek's support for Etherboot
  31397. +* is appreciated.
  31398. +*
  31399. +* REVISION HISTORY:
  31400. +* ================
  31401. +*
  31402. +* v1.0 11-26-2003 timlegge Initial port of Linux driver
  31403. +* v1.5 01-17-2004 timlegge Initial driver output cleanup
  31404. +* v1.6 03-27-2004 timlegge Additional Cleanup
  31405. +*
  31406. +* Indent Options: indent -kr -i8
  31407. +***************************************************************************/
  31408. +
  31409. +/* to get some global routines like printf */
  31410. +#include "etherboot.h"
  31411. +/* to get the interface to the body of the program */
  31412. +#include "nic.h"
  31413. +/* to get the PCI support functions, if this is a PCI NIC */
  31414. +#include "pci.h"
  31415. +#include "timer.h"
  31416. +
  31417. +#define drv_version "v1.6"
  31418. +#define drv_date "03-27-2004"
  31419. +
  31420. +typedef unsigned char u8;
  31421. +typedef signed char s8;
  31422. +typedef unsigned short u16;
  31423. +typedef signed short s16;
  31424. +typedef unsigned int u32;
  31425. +typedef signed int s32;
  31426. +
  31427. +#define HZ 1000
  31428. +
  31429. +static u32 ioaddr;
  31430. +
  31431. +#ifdef EDEBUG
  31432. +#define dprintf(x) printf x
  31433. +#else
  31434. +#define dprintf(x)
  31435. +#endif
  31436. +
  31437. +/* Condensed operations for readability. */
  31438. +#define virt_to_le32desc(addr) cpu_to_le32(virt_to_bus(addr))
  31439. +#define le32desc_to_virt(addr) bus_to_virt(le32_to_cpu(addr))
  31440. +
  31441. +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
  31442. +
  31443. +/* media options
  31444. + _10_Half = 0x01,
  31445. + _10_Full = 0x02,
  31446. + _100_Half = 0x04,
  31447. + _100_Full = 0x08,
  31448. + _1000_Full = 0x10,
  31449. +*/
  31450. +static int media = -1;
  31451. +
  31452. +#if 0
  31453. +/* Maximum events (Rx packets, etc.) to handle at each interrupt. */
  31454. +static int max_interrupt_work = 20;
  31455. +#endif
  31456. +
  31457. +#if 0
  31458. +/* Maximum number of multicast addresses to filter (vs. Rx-all-multicast).
  31459. + The RTL chips use a 64 element hash table based on the Ethernet CRC. */
  31460. +static int multicast_filter_limit = 32;
  31461. +#endif
  31462. +
  31463. +/* MAC address length*/
  31464. +#define MAC_ADDR_LEN 6
  31465. +
  31466. +/* max supported gigabit ethernet frame size -- must be at least (dev->mtu+14+4).*/
  31467. +#define MAX_ETH_FRAME_SIZE 1536
  31468. +
  31469. +#define TX_FIFO_THRESH 256 /* In bytes */
  31470. +
  31471. +#define RX_FIFO_THRESH 7 /* 7 means NO threshold, Rx buffer level before first PCI xfer. */
  31472. +#define RX_DMA_BURST 6 /* Maximum PCI burst, '6' is 1024 */
  31473. +#define TX_DMA_BURST 6 /* Maximum PCI burst, '6' is 1024 */
  31474. +#define EarlyTxThld 0x3F /* 0x3F means NO early transmit */
  31475. +#define RxPacketMaxSize 0x0800 /* Maximum size supported is 16K-1 */
  31476. +#define InterFrameGap 0x03 /* 3 means InterFrameGap = the shortest one */
  31477. +
  31478. +#define NUM_TX_DESC 1 /* Number of Tx descriptor registers */
  31479. +#define NUM_RX_DESC 4 /* Number of Rx descriptor registers */
  31480. +#define RX_BUF_SIZE 1536 /* Rx Buffer size */
  31481. +
  31482. +#define RTL_MIN_IO_SIZE 0x80
  31483. +#define TX_TIMEOUT (6*HZ)
  31484. +
  31485. +/* write/read MMIO register */
  31486. +#define RTL_W8(reg, val8) writeb ((val8), ioaddr + (reg))
  31487. +#define RTL_W16(reg, val16) writew ((val16), ioaddr + (reg))
  31488. +#define RTL_W32(reg, val32) writel ((val32), ioaddr + (reg))
  31489. +#define RTL_R8(reg) readb (ioaddr + (reg))
  31490. +#define RTL_R16(reg) readw (ioaddr + (reg))
  31491. +#define RTL_R32(reg) ((unsigned long) readl (ioaddr + (reg)))
  31492. +
  31493. +enum RTL8169_registers {
  31494. + MAC0 = 0, /* Ethernet hardware address. */
  31495. + MAR0 = 8, /* Multicast filter. */
  31496. + TxDescStartAddr = 0x20,
  31497. + TxHDescStartAddr = 0x28,
  31498. + FLASH = 0x30,
  31499. + ERSR = 0x36,
  31500. + ChipCmd = 0x37,
  31501. + TxPoll = 0x38,
  31502. + IntrMask = 0x3C,
  31503. + IntrStatus = 0x3E,
  31504. + TxConfig = 0x40,
  31505. + RxConfig = 0x44,
  31506. + RxMissed = 0x4C,
  31507. + Cfg9346 = 0x50,
  31508. + Config0 = 0x51,
  31509. + Config1 = 0x52,
  31510. + Config2 = 0x53,
  31511. + Config3 = 0x54,
  31512. + Config4 = 0x55,
  31513. + Config5 = 0x56,
  31514. + MultiIntr = 0x5C,
  31515. + PHYAR = 0x60,
  31516. + TBICSR = 0x64,
  31517. + TBI_ANAR = 0x68,
  31518. + TBI_LPAR = 0x6A,
  31519. + PHYstatus = 0x6C,
  31520. + RxMaxSize = 0xDA,
  31521. + CPlusCmd = 0xE0,
  31522. + RxDescStartAddr = 0xE4,
  31523. + EarlyTxThres = 0xEC,
  31524. + FuncEvent = 0xF0,
  31525. + FuncEventMask = 0xF4,
  31526. + FuncPresetState = 0xF8,
  31527. + FuncForceEvent = 0xFC,
  31528. +};
  31529. +
  31530. +enum RTL8169_register_content {
  31531. + /*InterruptStatusBits */
  31532. + SYSErr = 0x8000,
  31533. + PCSTimeout = 0x4000,
  31534. + SWInt = 0x0100,
  31535. + TxDescUnavail = 0x80,
  31536. + RxFIFOOver = 0x40,
  31537. + RxUnderrun = 0x20,
  31538. + RxOverflow = 0x10,
  31539. + TxErr = 0x08,
  31540. + TxOK = 0x04,
  31541. + RxErr = 0x02,
  31542. + RxOK = 0x01,
  31543. +
  31544. + /*RxStatusDesc */
  31545. + RxRES = 0x00200000,
  31546. + RxCRC = 0x00080000,
  31547. + RxRUNT = 0x00100000,
  31548. + RxRWT = 0x00400000,
  31549. +
  31550. + /*ChipCmdBits */
  31551. + CmdReset = 0x10,
  31552. + CmdRxEnb = 0x08,
  31553. + CmdTxEnb = 0x04,
  31554. + RxBufEmpty = 0x01,
  31555. +
  31556. + /*Cfg9346Bits */
  31557. + Cfg9346_Lock = 0x00,
  31558. + Cfg9346_Unlock = 0xC0,
  31559. +
  31560. + /*rx_mode_bits */
  31561. + AcceptErr = 0x20,
  31562. + AcceptRunt = 0x10,
  31563. + AcceptBroadcast = 0x08,
  31564. + AcceptMulticast = 0x04,
  31565. + AcceptMyPhys = 0x02,
  31566. + AcceptAllPhys = 0x01,
  31567. +
  31568. + /*RxConfigBits */
  31569. + RxCfgFIFOShift = 13,
  31570. + RxCfgDMAShift = 8,
  31571. +
  31572. + /*TxConfigBits */
  31573. + TxInterFrameGapShift = 24,
  31574. + TxDMAShift = 8, /* DMA burst value (0-7) is shift this many bits */
  31575. +
  31576. + /*rtl8169_PHYstatus */
  31577. + TBI_Enable = 0x80,
  31578. + TxFlowCtrl = 0x40,
  31579. + RxFlowCtrl = 0x20,
  31580. + _1000bpsF = 0x10,
  31581. + _100bps = 0x08,
  31582. + _10bps = 0x04,
  31583. + LinkStatus = 0x02,
  31584. + FullDup = 0x01,
  31585. +
  31586. + /*GIGABIT_PHY_registers */
  31587. + PHY_CTRL_REG = 0,
  31588. + PHY_STAT_REG = 1,
  31589. + PHY_AUTO_NEGO_REG = 4,
  31590. + PHY_1000_CTRL_REG = 9,
  31591. +
  31592. + /*GIGABIT_PHY_REG_BIT */
  31593. + PHY_Restart_Auto_Nego = 0x0200,
  31594. + PHY_Enable_Auto_Nego = 0x1000,
  31595. +
  31596. + /* PHY_STAT_REG = 1; */
  31597. + PHY_Auto_Neco_Comp = 0x0020,
  31598. +
  31599. + /* PHY_AUTO_NEGO_REG = 4; */
  31600. + PHY_Cap_10_Half = 0x0020,
  31601. + PHY_Cap_10_Full = 0x0040,
  31602. + PHY_Cap_100_Half = 0x0080,
  31603. + PHY_Cap_100_Full = 0x0100,
  31604. +
  31605. + /* PHY_1000_CTRL_REG = 9; */
  31606. + PHY_Cap_1000_Full = 0x0200,
  31607. +
  31608. + PHY_Cap_Null = 0x0,
  31609. +
  31610. + /*_MediaType*/
  31611. + _10_Half = 0x01,
  31612. + _10_Full = 0x02,
  31613. + _100_Half = 0x04,
  31614. + _100_Full = 0x08,
  31615. + _1000_Full = 0x10,
  31616. +
  31617. + /*_TBICSRBit*/
  31618. + TBILinkOK = 0x02000000,
  31619. +};
  31620. +
  31621. +static struct {
  31622. + const char *name;
  31623. + u8 version; /* depend on RTL8169 docs */
  31624. + u32 RxConfigMask; /* should clear the bits supported by this chip */
  31625. +} rtl_chip_info[] = {
  31626. + {
  31627. +"RTL-8169", 0x00, 0xff7e1880,},};
  31628. +
  31629. +enum _DescStatusBit {
  31630. + OWNbit = 0x80000000,
  31631. + EORbit = 0x40000000,
  31632. + FSbit = 0x20000000,
  31633. + LSbit = 0x10000000,
  31634. +};
  31635. +
  31636. +struct TxDesc {
  31637. + u32 status;
  31638. + u32 vlan_tag;
  31639. + u32 buf_addr;
  31640. + u32 buf_Haddr;
  31641. +};
  31642. +
  31643. +struct RxDesc {
  31644. + u32 status;
  31645. + u32 vlan_tag;
  31646. + u32 buf_addr;
  31647. + u32 buf_Haddr;
  31648. +};
  31649. +
  31650. +/* The descriptors for this card are required to be aligned on
  31651. +256 byte boundaries. As the align attribute does not do more than
  31652. +16 bytes of alignment it requires some extra steps. Add 256 to the
  31653. +size of the array and the init_ring adjusts the alignment */
  31654. +
  31655. +/* Define the TX Descriptor */
  31656. +static u8 tx_ring[NUM_TX_DESC * sizeof(struct TxDesc) + 256];
  31657. +
  31658. +/* Create a static buffer of size RX_BUF_SZ for each
  31659. +TX Descriptor. All descriptors point to a
  31660. +part of this buffer */
  31661. +static unsigned char txb[NUM_TX_DESC * RX_BUF_SIZE];
  31662. +
  31663. +/* Define the RX Descriptor */
  31664. +static u8 rx_ring[NUM_RX_DESC * sizeof(struct TxDesc) + 256];
  31665. +
  31666. +/* Create a static buffer of size RX_BUF_SZ for each
  31667. +RX Descriptor All descriptors point to a
  31668. +part of this buffer */
  31669. +static unsigned char rxb[NUM_RX_DESC * RX_BUF_SIZE];
  31670. +
  31671. +struct rtl8169_private {
  31672. + void *mmio_addr; /* memory map physical address */
  31673. + int chipset;
  31674. + unsigned long cur_rx; /* Index into the Rx descriptor buffer of next Rx pkt. */
  31675. + unsigned long cur_tx; /* Index into the Tx descriptor buffer of next Rx pkt. */
  31676. + unsigned char *TxDescArrays; /* Index of Tx Descriptor buffer */
  31677. + unsigned char *RxDescArrays; /* Index of Rx Descriptor buffer */
  31678. + struct TxDesc *TxDescArray; /* Index of 256-alignment Tx Descriptor buffer */
  31679. + struct RxDesc *RxDescArray; /* Index of 256-alignment Rx Descriptor buffer */
  31680. + unsigned char *RxBufferRing[NUM_RX_DESC]; /* Index of Rx Buffer array */
  31681. + unsigned char *Tx_skbuff[NUM_TX_DESC];
  31682. +} tpx;
  31683. +
  31684. +static struct rtl8169_private *tpc;
  31685. +
  31686. +static const u16 rtl8169_intr_mask =
  31687. + SYSErr | PCSTimeout | RxUnderrun | RxOverflow | RxFIFOOver | TxErr |
  31688. + TxOK | RxErr | RxOK;
  31689. +static const unsigned int rtl8169_rx_config =
  31690. + (RX_FIFO_THRESH << RxCfgFIFOShift) | (RX_DMA_BURST << RxCfgDMAShift);
  31691. +
  31692. +void mdio_write(int RegAddr, int value)
  31693. +{
  31694. + int i;
  31695. +
  31696. + RTL_W32(PHYAR, 0x80000000 | (RegAddr & 0xFF) << 16 | value);
  31697. + udelay(1000);
  31698. +
  31699. + for (i = 2000; i > 0; i--) {
  31700. + /* Check if the RTL8169 has completed writing to the specified MII register */
  31701. + if (!(RTL_R32(PHYAR) & 0x80000000)) {
  31702. + break;
  31703. + } else {
  31704. + udelay(100);
  31705. + }
  31706. + }
  31707. +}
  31708. +
  31709. +int mdio_read(int RegAddr)
  31710. +{
  31711. + int i, value = -1;
  31712. +
  31713. + RTL_W32(PHYAR, 0x0 | (RegAddr & 0xFF) << 16);
  31714. + udelay(1000);
  31715. +
  31716. + for (i = 2000; i > 0; i--) {
  31717. + /* Check if the RTL8169 has completed retrieving data from the specified MII register */
  31718. + if (RTL_R32(PHYAR) & 0x80000000) {
  31719. + value = (int) (RTL_R32(PHYAR) & 0xFFFF);
  31720. + break;
  31721. + } else {
  31722. + udelay(100);
  31723. + }
  31724. + }
  31725. + return value;
  31726. +}
  31727. +
  31728. +static int rtl8169_init_board(struct pci_device *pdev)
  31729. +{
  31730. + int i;
  31731. + unsigned long rtreg_base, rtreg_len;
  31732. + u32 tmp;
  31733. +
  31734. + rtreg_base = pci_bar_start(pdev, PCI_BASE_ADDRESS_1);
  31735. + rtreg_len = pci_bar_size(pdev, PCI_BASE_ADDRESS_1);
  31736. +
  31737. + /* check for weird/broken PCI region reporting */
  31738. + if (rtreg_len < RTL_MIN_IO_SIZE) {
  31739. + printf("Invalid PCI region size(s), aborting\n");
  31740. + }
  31741. +
  31742. + adjust_pci_device(pdev);
  31743. +/* pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM); */
  31744. +
  31745. + /* ioremap MMIO region */
  31746. + ioaddr = (unsigned long) ioremap(rtreg_base, rtreg_len);
  31747. + if (ioaddr == 0)
  31748. + return 0;
  31749. +
  31750. + tpc->mmio_addr = &ioaddr;
  31751. + /* Soft reset the chip. */
  31752. + RTL_W8(ChipCmd, CmdReset);
  31753. +
  31754. + /* Check that the chip has finished the reset. */
  31755. + for (i = 1000; i > 0; i--)
  31756. + if ((RTL_R8(ChipCmd) & CmdReset) == 0)
  31757. + break;
  31758. + else
  31759. + udelay(10);
  31760. +
  31761. + /* identify chip attached to board */
  31762. + tmp = RTL_R32(TxConfig);
  31763. + tmp = ((tmp & 0x7c000000) + ((tmp & 0x00800000) << 2)) >> 24;
  31764. +
  31765. + for (i = ARRAY_SIZE(rtl_chip_info) - 1; i >= 0; i--)
  31766. + if (tmp == rtl_chip_info[i].version) {
  31767. + tpc->chipset = i;
  31768. + goto match;
  31769. + }
  31770. + /* if unknown chip, assume array element #0, original RTL-8169 in this case */
  31771. + dprintf(("PCI device: unknown chip version, assuming RTL-8169\n"));
  31772. + dprintf(("PCI device: TxConfig = 0x%hX\n",
  31773. + (unsigned long) RTL_R32(TxConfig)));
  31774. + tpc->chipset = 0;
  31775. + return 1;
  31776. + match:
  31777. + return 0;
  31778. +
  31779. +}
  31780. +
  31781. +/**************************************************************************
  31782. +IRQ - Wait for a frame
  31783. +***************************************************************************/
  31784. +void r8169_irq ( struct nic *nic __unused, irq_action_t action ) {
  31785. + int intr_status = 0;
  31786. + int interested = RxUnderrun | RxOverflow | RxFIFOOver | RxErr | RxOK;
  31787. +
  31788. + switch ( action ) {
  31789. + case DISABLE:
  31790. + case ENABLE:
  31791. + intr_status = RTL_R16(IntrStatus);
  31792. + /* h/w no longer present (hotplug?) or major error,
  31793. + bail */
  31794. + if (intr_status == 0xFFFF)
  31795. + break;
  31796. +
  31797. + intr_status = intr_status & ~interested;
  31798. + if ( action == ENABLE )
  31799. + intr_status = intr_status | interested;
  31800. + RTL_W16(IntrMask, intr_status);
  31801. + break;
  31802. + case FORCE :
  31803. + RTL_W8(TxPoll, (RTL_R8(TxPoll) | 0x01));
  31804. + break;
  31805. + }
  31806. +}
  31807. +
  31808. +/**************************************************************************
  31809. +POLL - Wait for a frame
  31810. +***************************************************************************/
  31811. +static int r8169_poll(struct nic *nic, int retreive)
  31812. +{
  31813. + /* return true if there's an ethernet packet ready to read */
  31814. + /* nic->packet should contain data on return */
  31815. + /* nic->packetlen should contain length of data */
  31816. + int cur_rx;
  31817. + unsigned int intr_status = 0;
  31818. + cur_rx = tpc->cur_rx;
  31819. + if ((tpc->RxDescArray[cur_rx].status & OWNbit) == 0) {
  31820. + /* There is a packet ready */
  31821. + if(!retreive)
  31822. + return 1;
  31823. + intr_status = RTL_R16(IntrStatus);
  31824. + /* h/w no longer present (hotplug?) or major error,
  31825. + bail */
  31826. + if (intr_status == 0xFFFF)
  31827. + return 0;
  31828. + RTL_W16(IntrStatus, intr_status &
  31829. + ~(RxFIFOOver | RxOverflow | RxOK));
  31830. +
  31831. + if (!(tpc->RxDescArray[cur_rx].status & RxRES)) {
  31832. + nic->packetlen = (int) (tpc->RxDescArray[cur_rx].
  31833. + status & 0x00001FFF) - 4;
  31834. + memcpy(nic->packet, tpc->RxBufferRing[cur_rx],
  31835. + nic->packetlen);
  31836. + if (cur_rx == NUM_RX_DESC - 1)
  31837. + tpc->RxDescArray[cur_rx].status =
  31838. + (OWNbit | EORbit) + RX_BUF_SIZE;
  31839. + else
  31840. + tpc->RxDescArray[cur_rx].status =
  31841. + OWNbit + RX_BUF_SIZE;
  31842. + tpc->RxDescArray[cur_rx].buf_addr =
  31843. + virt_to_bus(tpc->RxBufferRing[cur_rx]);
  31844. + } else
  31845. + printf("Error Rx");
  31846. + /* FIXME: shouldn't I reset the status on an error */
  31847. + cur_rx = (cur_rx + 1) % NUM_RX_DESC;
  31848. + tpc->cur_rx = cur_rx;
  31849. + RTL_W16(IntrStatus, intr_status &
  31850. + (RxFIFOOver | RxOverflow | RxOK));
  31851. +
  31852. + return 1;
  31853. +
  31854. + }
  31855. + tpc->cur_rx = cur_rx;
  31856. + /* FIXME: There is no reason to do this as cur_rx did not change */
  31857. +
  31858. + return (0); /* initially as this is called to flush the input */
  31859. +
  31860. +}
  31861. +
  31862. +/**************************************************************************
  31863. +TRANSMIT - Transmit a frame
  31864. +***************************************************************************/
  31865. +static void r8169_transmit(struct nic *nic, const char *d, /* Destination */
  31866. + unsigned int t, /* Type */
  31867. + unsigned int s, /* size */
  31868. + const char *p)
  31869. +{ /* Packet */
  31870. + /* send the packet to destination */
  31871. +
  31872. + u16 nstype;
  31873. + u32 to;
  31874. + u8 *ptxb;
  31875. + int entry = tpc->cur_tx % NUM_TX_DESC;
  31876. +
  31877. + /* point to the current txb incase multiple tx_rings are used */
  31878. + ptxb = tpc->Tx_skbuff[entry * MAX_ETH_FRAME_SIZE];
  31879. + memcpy(ptxb, d, ETH_ALEN);
  31880. + memcpy(ptxb + ETH_ALEN, nic->node_addr, ETH_ALEN);
  31881. + nstype = htons((u16) t);
  31882. + memcpy(ptxb + 2 * ETH_ALEN, (u8 *) & nstype, 2);
  31883. + memcpy(ptxb + ETH_HLEN, p, s);
  31884. + s += ETH_HLEN;
  31885. + s &= 0x0FFF;
  31886. + while (s < ETH_ZLEN)
  31887. + ptxb[s++] = '\0';
  31888. +
  31889. + tpc->TxDescArray[entry].buf_addr = virt_to_bus(ptxb);
  31890. + if (entry != (NUM_TX_DESC - 1))
  31891. + tpc->TxDescArray[entry].status =
  31892. + (OWNbit | FSbit | LSbit) | ((s > ETH_ZLEN) ? s :
  31893. + ETH_ZLEN);
  31894. + else
  31895. + tpc->TxDescArray[entry].status =
  31896. + (OWNbit | EORbit | FSbit | LSbit) | ((s > ETH_ZLEN) ? s
  31897. + : ETH_ZLEN);
  31898. + RTL_W8(TxPoll, 0x40); /* set polling bit */
  31899. +
  31900. + tpc->cur_tx++;
  31901. + to = currticks() + TX_TIMEOUT;
  31902. + while ((tpc->TxDescArray[entry].status & OWNbit) && (currticks() < to)); /* wait */
  31903. +
  31904. + if (currticks() >= to) {
  31905. + printf("TX Time Out");
  31906. + }
  31907. +}
  31908. +
  31909. +static void rtl8169_set_rx_mode(struct nic *nic __unused)
  31910. +{
  31911. + u32 mc_filter[2]; /* Multicast hash filter */
  31912. + int rx_mode;
  31913. + u32 tmp = 0;
  31914. +
  31915. + /* IFF_ALLMULTI */
  31916. + /* Too many to filter perfectly -- accept all multicasts. */
  31917. + rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
  31918. + mc_filter[1] = mc_filter[0] = 0xffffffff;
  31919. +
  31920. + tmp =
  31921. + rtl8169_rx_config | rx_mode | (RTL_R32(RxConfig) &
  31922. + rtl_chip_info[tpc->chipset].
  31923. + RxConfigMask);
  31924. +
  31925. + RTL_W32(RxConfig, tmp);
  31926. + RTL_W32(MAR0 + 0, mc_filter[0]);
  31927. + RTL_W32(MAR0 + 4, mc_filter[1]);
  31928. +}
  31929. +static void rtl8169_hw_start(struct nic *nic)
  31930. +{
  31931. + u32 i;
  31932. +
  31933. + /* Soft reset the chip. */
  31934. + RTL_W8(ChipCmd, CmdReset);
  31935. +
  31936. + /* Check that the chip has finished the reset. */
  31937. + for (i = 1000; i > 0; i--) {
  31938. + if ((RTL_R8(ChipCmd) & CmdReset) == 0)
  31939. + break;
  31940. + else
  31941. + udelay(10);
  31942. + }
  31943. +
  31944. + RTL_W8(Cfg9346, Cfg9346_Unlock);
  31945. + RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb);
  31946. + RTL_W8(EarlyTxThres, EarlyTxThld);
  31947. +
  31948. + /* For gigabit rtl8169 */
  31949. + RTL_W16(RxMaxSize, RxPacketMaxSize);
  31950. +
  31951. + /* Set Rx Config register */
  31952. + i = rtl8169_rx_config | (RTL_R32(RxConfig) &
  31953. + rtl_chip_info[tpc->chipset].RxConfigMask);
  31954. + RTL_W32(RxConfig, i);
  31955. +
  31956. + /* Set DMA burst size and Interframe Gap Time */
  31957. + RTL_W32(TxConfig,
  31958. + (TX_DMA_BURST << TxDMAShift) | (InterFrameGap <<
  31959. + TxInterFrameGapShift));
  31960. +
  31961. +
  31962. + tpc->cur_rx = 0;
  31963. +
  31964. + RTL_W32(TxDescStartAddr, virt_to_le32desc(tpc->TxDescArray));
  31965. + RTL_W32(RxDescStartAddr, virt_to_le32desc(tpc->RxDescArray));
  31966. + RTL_W8(Cfg9346, Cfg9346_Lock);
  31967. + udelay(10);
  31968. +
  31969. + RTL_W32(RxMissed, 0);
  31970. +
  31971. + rtl8169_set_rx_mode(nic);
  31972. +
  31973. + /* no early-rx interrupts */
  31974. + RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xF000);
  31975. +}
  31976. +
  31977. +static void rtl8169_init_ring(struct nic *nic __unused)
  31978. +{
  31979. + int i;
  31980. +
  31981. + tpc->cur_rx = 0;
  31982. + tpc->cur_tx = 0;
  31983. + memset(tpc->TxDescArray, 0x0, NUM_TX_DESC * sizeof(struct TxDesc));
  31984. + memset(tpc->RxDescArray, 0x0, NUM_RX_DESC * sizeof(struct RxDesc));
  31985. +
  31986. + for (i = 0; i < NUM_TX_DESC; i++) {
  31987. + tpc->Tx_skbuff[i] = &txb[i];
  31988. + }
  31989. +
  31990. + for (i = 0; i < NUM_RX_DESC; i++) {
  31991. + if (i == (NUM_RX_DESC - 1))
  31992. + tpc->RxDescArray[i].status =
  31993. + (OWNbit | EORbit) + RX_BUF_SIZE;
  31994. + else
  31995. + tpc->RxDescArray[i].status = OWNbit + RX_BUF_SIZE;
  31996. +
  31997. + tpc->RxBufferRing[i] = &rxb[i * RX_BUF_SIZE];
  31998. + tpc->RxDescArray[i].buf_addr =
  31999. + virt_to_bus(tpc->RxBufferRing[i]);
  32000. + }
  32001. +}
  32002. +
  32003. +/**************************************************************************
  32004. +RESET - Finish setting up the ethernet interface
  32005. +***************************************************************************/
  32006. +static void r8169_reset(struct nic *nic)
  32007. +{
  32008. + int i;
  32009. + u8 diff;
  32010. + u32 TxPhyAddr, RxPhyAddr;
  32011. +
  32012. + tpc->TxDescArrays = tx_ring;
  32013. + if (tpc->TxDescArrays == 0)
  32014. + printf("Allot Error");
  32015. + /* Tx Desscriptor needs 256 bytes alignment; */
  32016. + TxPhyAddr = virt_to_bus(tpc->TxDescArrays);
  32017. + diff = 256 - (TxPhyAddr - ((TxPhyAddr >> 8) << 8));
  32018. + TxPhyAddr += diff;
  32019. + tpc->TxDescArray = (struct TxDesc *) (tpc->TxDescArrays + diff);
  32020. +
  32021. + tpc->RxDescArrays = rx_ring;
  32022. + /* Rx Desscriptor needs 256 bytes alignment; */
  32023. + RxPhyAddr = virt_to_bus(tpc->RxDescArrays);
  32024. + diff = 256 - (RxPhyAddr - ((RxPhyAddr >> 8) << 8));
  32025. + RxPhyAddr += diff;
  32026. + tpc->RxDescArray = (struct RxDesc *) (tpc->RxDescArrays + diff);
  32027. +
  32028. + if (tpc->TxDescArrays == NULL || tpc->RxDescArrays == NULL) {
  32029. + printf("Allocate RxDescArray or TxDescArray failed\n");
  32030. + return;
  32031. + }
  32032. +
  32033. + rtl8169_init_ring(nic);
  32034. + rtl8169_hw_start(nic);
  32035. + /* Construct a perfect filter frame with the mac address as first match
  32036. + * and broadcast for all others */
  32037. + for (i = 0; i < 192; i++)
  32038. + txb[i] = 0xFF;
  32039. +
  32040. + txb[0] = nic->node_addr[0];
  32041. + txb[1] = nic->node_addr[1];
  32042. + txb[2] = nic->node_addr[2];
  32043. + txb[3] = nic->node_addr[3];
  32044. + txb[4] = nic->node_addr[4];
  32045. + txb[5] = nic->node_addr[5];
  32046. +}
  32047. +
  32048. +/**************************************************************************
  32049. +DISABLE - Turn off ethernet interface
  32050. +***************************************************************************/
  32051. +static void r8169_disable(struct dev *dev __unused)
  32052. +{
  32053. + int i;
  32054. + /* Stop the chip's Tx and Rx DMA processes. */
  32055. + RTL_W8(ChipCmd, 0x00);
  32056. +
  32057. + /* Disable interrupts by clearing the interrupt mask. */
  32058. + RTL_W16(IntrMask, 0x0000);
  32059. +
  32060. + RTL_W32(RxMissed, 0);
  32061. +
  32062. + tpc->TxDescArrays = NULL;
  32063. + tpc->RxDescArrays = NULL;
  32064. + tpc->TxDescArray = NULL;
  32065. + tpc->RxDescArray = NULL;
  32066. + for (i = 0; i < NUM_RX_DESC; i++) {
  32067. + tpc->RxBufferRing[i] = NULL;
  32068. + }
  32069. +}
  32070. +
  32071. +/**************************************************************************
  32072. +PROBE - Look for an adapter, this routine's visible to the outside
  32073. +***************************************************************************/
  32074. +
  32075. +#define board_found 1
  32076. +#define valid_link 0
  32077. +static int r8169_probe(struct dev *dev, struct pci_device *pci)
  32078. +{
  32079. + struct nic *nic = (struct nic *) dev;
  32080. + static int board_idx = -1;
  32081. + static int printed_version = 0;
  32082. + int i, rc;
  32083. + int option = -1, Cap10_100 = 0, Cap1000 = 0;
  32084. +
  32085. + printf("r8169.c: Found %s, Vendor=%hX Device=%hX\n",
  32086. + pci->name, pci->vendor, pci->dev_id);
  32087. +
  32088. + board_idx++;
  32089. +
  32090. + printed_version = 1;
  32091. +
  32092. + /* point to private storage */
  32093. + tpc = &tpx;
  32094. +
  32095. + rc = rtl8169_init_board(pci); /* Return code is meaningless */
  32096. +
  32097. + /* Get MAC address. FIXME: read EEPROM */
  32098. + for (i = 0; i < MAC_ADDR_LEN; i++)
  32099. + nic->node_addr[i] = RTL_R8(MAC0 + i);
  32100. +
  32101. + dprintf(("%s: Identified chip type is '%s'.\n", pci->name,
  32102. + rtl_chip_info[tpc->chipset].name));
  32103. + /* Print out some hardware info */
  32104. + printf("%s: %! at ioaddr %hX, ", pci->name, nic->node_addr,
  32105. + ioaddr);
  32106. +
  32107. + /* if TBI is not endbled */
  32108. + if (!(RTL_R8(PHYstatus) & TBI_Enable)) {
  32109. + int val = mdio_read(PHY_AUTO_NEGO_REG);
  32110. +
  32111. + option = media;
  32112. + /* Force RTL8169 in 10/100/1000 Full/Half mode. */
  32113. + if (option > 0) {
  32114. + printf(" Force-mode Enabled.\n");
  32115. + Cap10_100 = 0, Cap1000 = 0;
  32116. + switch (option) {
  32117. + case _10_Half:
  32118. + Cap10_100 = PHY_Cap_10_Half;
  32119. + Cap1000 = PHY_Cap_Null;
  32120. + break;
  32121. + case _10_Full:
  32122. + Cap10_100 = PHY_Cap_10_Full;
  32123. + Cap1000 = PHY_Cap_Null;
  32124. + break;
  32125. + case _100_Half:
  32126. + Cap10_100 = PHY_Cap_100_Half;
  32127. + Cap1000 = PHY_Cap_Null;
  32128. + break;
  32129. + case _100_Full:
  32130. + Cap10_100 = PHY_Cap_100_Full;
  32131. + Cap1000 = PHY_Cap_Null;
  32132. + break;
  32133. + case _1000_Full:
  32134. + Cap10_100 = PHY_Cap_Null;
  32135. + Cap1000 = PHY_Cap_1000_Full;
  32136. + break;
  32137. + default:
  32138. + break;
  32139. + }
  32140. + /* leave PHY_AUTO_NEGO_REG bit4:0 unchanged */
  32141. + mdio_write(PHY_AUTO_NEGO_REG,
  32142. + Cap10_100 | (val & 0x1F));
  32143. + mdio_write(PHY_1000_CTRL_REG, Cap1000);
  32144. + } else {
  32145. + dprintf(("Auto-negotiation Enabled.\n",
  32146. + pci->name));
  32147. +
  32148. + /* enable 10/100 Full/Half Mode, leave PHY_AUTO_NEGO_REG bit4:0 unchanged */
  32149. + mdio_write(PHY_AUTO_NEGO_REG,
  32150. + PHY_Cap_10_Half | PHY_Cap_10_Full |
  32151. + PHY_Cap_100_Half | PHY_Cap_100_Full |
  32152. + (val & 0x1F));
  32153. +
  32154. + /* enable 1000 Full Mode */
  32155. + mdio_write(PHY_1000_CTRL_REG, PHY_Cap_1000_Full);
  32156. +
  32157. + }
  32158. +
  32159. + /* Enable auto-negotiation and restart auto-nigotiation */
  32160. + mdio_write(PHY_CTRL_REG,
  32161. + PHY_Enable_Auto_Nego | PHY_Restart_Auto_Nego);
  32162. + udelay(100);
  32163. +
  32164. + /* wait for auto-negotiation process */
  32165. + for (i = 10000; i > 0; i--) {
  32166. + /* Check if auto-negotiation complete */
  32167. + if (mdio_read(PHY_STAT_REG) & PHY_Auto_Neco_Comp) {
  32168. + udelay(100);
  32169. + option = RTL_R8(PHYstatus);
  32170. + if (option & _1000bpsF) {
  32171. + printf
  32172. + ("1000Mbps Full-duplex operation.\n");
  32173. + } else {
  32174. + printf
  32175. + ("%sMbps %s-duplex operation.\n",
  32176. + (option & _100bps) ? "100" :
  32177. + "10",
  32178. + (option & FullDup) ? "Full" :
  32179. + "Half");
  32180. + }
  32181. + break;
  32182. + } else {
  32183. + udelay(100);
  32184. + }
  32185. + } /* end for-loop to wait for auto-negotiation process */
  32186. +
  32187. + } else {
  32188. + udelay(100);
  32189. + printf
  32190. + ("%s: 1000Mbps Full-duplex operation, TBI Link %s!\n",
  32191. + pci->name,
  32192. + (RTL_R32(TBICSR) & TBILinkOK) ? "OK" : "Failed");
  32193. +
  32194. + }
  32195. +
  32196. + r8169_reset(nic);
  32197. + /* point to NIC specific routines */
  32198. + dev->disable = r8169_disable;
  32199. + nic->poll = r8169_poll;
  32200. + nic->transmit = r8169_transmit;
  32201. + nic->irqno = pci->irq;
  32202. + nic->irq = r8169_irq;
  32203. + nic->ioaddr = ioaddr;
  32204. + return 1;
  32205. +
  32206. +}
  32207. +
  32208. +static struct pci_id r8169_nics[] = {
  32209. + PCI_ROM(0x10ec, 0x8169, "r8169", "RealTek RTL8169 Gigabit Ethernet"),
  32210. +};
  32211. +
  32212. +struct pci_driver r8169_driver = {
  32213. + .type = NIC_DRIVER,
  32214. + .name = "r8169/PCI",
  32215. + .probe = r8169_probe,
  32216. + .ids = r8169_nics,
  32217. + .id_count = sizeof(r8169_nics) / sizeof(r8169_nics[0]),
  32218. + .class = 0,
  32219. +};
  32220. diff -Naur grub-0.97.orig/netboot/rtl8139.c grub-0.97/netboot/rtl8139.c
  32221. --- grub-0.97.orig/netboot/rtl8139.c 2003-07-09 11:45:38.000000000 +0000
  32222. +++ grub-0.97/netboot/rtl8139.c 2005-08-31 19:03:35.000000000 +0000
  32223. @@ -17,6 +17,8 @@
  32224. /*********************************************************************/
  32225. /*
  32226. + 28 Dec 2002 ken_yap@users.sourceforge.net (Ken Yap)
  32227. + Put in virt_to_bus calls to allow Etherboot relocation.
  32228. 06 Apr 2001 ken_yap@users.sourceforge.net (Ken Yap)
  32229. Following email from Hyun-Joon Cha, added a disable routine, otherwise
  32230. @@ -63,7 +65,6 @@
  32231. #include "etherboot.h"
  32232. #include "nic.h"
  32233. #include "pci.h"
  32234. -#include "cards.h"
  32235. #include "timer.h"
  32236. #define RTL_TIMEOUT (1*TICKS_PER_SEC)
  32237. @@ -112,9 +113,19 @@
  32238. * definitions we will probably never need to know about. */
  32239. };
  32240. +enum RxEarlyStatusBits {
  32241. + ERGood=0x08, ERBad=0x04, EROVW=0x02, EROK=0x01
  32242. +};
  32243. +
  32244. enum ChipCmdBits {
  32245. CmdReset=0x10, CmdRxEnb=0x08, CmdTxEnb=0x04, RxBufEmpty=0x01, };
  32246. +enum IntrMaskBits {
  32247. + SERR=0x8000, TimeOut=0x4000, LenChg=0x2000,
  32248. + FOVW=0x40, PUN_LinkChg=0x20, RXOVW=0x10,
  32249. + TER=0x08, TOK=0x04, RER=0x02, ROK=0x01
  32250. +};
  32251. +
  32252. /* Interrupt register bits, using my own meaningful names. */
  32253. enum IntrStatusBits {
  32254. PCIErr=0x8000, PCSTimeout=0x4000, CableLenChange= 0x2000,
  32255. @@ -155,74 +166,68 @@
  32256. AcceptMulticast=0x04, AcceptMyPhys=0x02, AcceptAllPhys=0x01,
  32257. };
  32258. -static int ioaddr;
  32259. static unsigned int cur_rx,cur_tx;
  32260. /* The RTL8139 can only transmit from a contiguous, aligned memory block. */
  32261. static unsigned char tx_buffer[TX_BUF_SIZE] __attribute__((aligned(4)));
  32262. -
  32263. -/* I know that this is a MEGA HACK, but the tagged boot image specification
  32264. - * states that we can do whatever we want below 0x10000 - so we do! */
  32265. -/* But we still give the user the choice of using an internal buffer
  32266. - just in case - Ken */
  32267. -#ifdef USE_LOWMEM_BUFFER
  32268. -#define rx_ring ((unsigned char *)(0x10000 - (RX_BUF_LEN + 16)))
  32269. -#else
  32270. static unsigned char rx_ring[RX_BUF_LEN+16] __attribute__((aligned(4)));
  32271. -#endif
  32272. -struct nic *rtl8139_probe(struct nic *nic, unsigned short *probeaddrs,
  32273. - struct pci_device *pci);
  32274. -static int read_eeprom(int location);
  32275. +static int rtl8139_probe(struct dev *dev, struct pci_device *pci);
  32276. +static int read_eeprom(struct nic *nic, int location, int addr_len);
  32277. static void rtl_reset(struct nic *nic);
  32278. static void rtl_transmit(struct nic *nic, const char *destaddr,
  32279. unsigned int type, unsigned int len, const char *data);
  32280. -static int rtl_poll(struct nic *nic);
  32281. -static void rtl_disable(struct nic*);
  32282. +static int rtl_poll(struct nic *nic, int retrieve);
  32283. +static void rtl_disable(struct dev *);
  32284. +static void rtl_irq(struct nic *nic, irq_action_t action);
  32285. -struct nic *rtl8139_probe(struct nic *nic, unsigned short *probeaddrs,
  32286. - struct pci_device *pci)
  32287. +static int rtl8139_probe(struct dev *dev, struct pci_device *pci)
  32288. {
  32289. + struct nic *nic = (struct nic *)dev;
  32290. int i;
  32291. int speed10, fullduplex;
  32292. + int addr_len;
  32293. + unsigned short *ap = (unsigned short*)nic->node_addr;
  32294. /* There are enough "RTL8139" strings on the console already, so
  32295. * be brief and concentrate on the interesting pieces of info... */
  32296. printf(" - ");
  32297. /* Mask the bit that says "this is an io addr" */
  32298. - ioaddr = probeaddrs[0] & ~3;
  32299. + nic->ioaddr = pci->ioaddr & ~3;
  32300. +
  32301. + /* Copy IRQ from PCI information */
  32302. + nic->irqno = pci->irq;
  32303. adjust_pci_device(pci);
  32304. /* Bring the chip out of low-power mode. */
  32305. - outb(0x00, ioaddr + Config1);
  32306. -
  32307. - if (read_eeprom(0) != 0xffff) {
  32308. - unsigned short *ap = (unsigned short*)nic->node_addr;
  32309. - for (i = 0; i < 3; i++)
  32310. - *ap++ = read_eeprom(i + 7);
  32311. - } else {
  32312. - unsigned char *ap = (unsigned char*)nic->node_addr;
  32313. - for (i = 0; i < ETH_ALEN; i++)
  32314. - *ap++ = inb(ioaddr + MAC0 + i);
  32315. - }
  32316. + outb(0x00, nic->ioaddr + Config1);
  32317. - speed10 = inb(ioaddr + MediaStatus) & MSRSpeed10;
  32318. - fullduplex = inw(ioaddr + MII_BMCR) & BMCRDuplex;
  32319. - printf("ioaddr %#hX, addr %! %sMbps %s-duplex\n", ioaddr,
  32320. - nic->node_addr, speed10 ? "10" : "100",
  32321. - fullduplex ? "full" : "half");
  32322. + addr_len = read_eeprom(nic,0,8) == 0x8129 ? 8 : 6;
  32323. + for (i = 0; i < 3; i++)
  32324. + *ap++ = read_eeprom(nic,i + 7,addr_len);
  32325. +
  32326. + speed10 = inb(nic->ioaddr + MediaStatus) & MSRSpeed10;
  32327. + fullduplex = inw(nic->ioaddr + MII_BMCR) & BMCRDuplex;
  32328. + printf("ioaddr %#hX, irq %d, addr %! %sMbps %s-duplex\n", nic->ioaddr,
  32329. + nic->irqno, nic->node_addr, speed10 ? "10" : "100",
  32330. + fullduplex ? "full" : "half");
  32331. rtl_reset(nic);
  32332. - nic->reset = rtl_reset;
  32333. - nic->poll = rtl_poll;
  32334. + if (inb(nic->ioaddr + MediaStatus) & MSRLinkFail) {
  32335. + printf("Cable not connected or other link failure\n");
  32336. + return(0);
  32337. + }
  32338. +
  32339. + dev->disable = rtl_disable;
  32340. + nic->poll = rtl_poll;
  32341. nic->transmit = rtl_transmit;
  32342. - nic->disable = rtl_disable;
  32343. + nic->irq = rtl_irq;
  32344. - return nic;
  32345. + return 1;
  32346. }
  32347. /* Serial EEPROM section. */
  32348. @@ -244,22 +249,23 @@
  32349. #define eeprom_delay() inl(ee_addr)
  32350. /* The EEPROM commands include the alway-set leading bit. */
  32351. -#define EE_WRITE_CMD (5 << 6)
  32352. -#define EE_READ_CMD (6 << 6)
  32353. -#define EE_ERASE_CMD (7 << 6)
  32354. +#define EE_WRITE_CMD (5)
  32355. +#define EE_READ_CMD (6)
  32356. +#define EE_ERASE_CMD (7)
  32357. -static int read_eeprom(int location)
  32358. +static int read_eeprom(struct nic *nic, int location, int addr_len)
  32359. {
  32360. int i;
  32361. unsigned int retval = 0;
  32362. - long ee_addr = ioaddr + Cfg9346;
  32363. - int read_cmd = location | EE_READ_CMD;
  32364. + long ee_addr = nic->ioaddr + Cfg9346;
  32365. + int read_cmd = location | (EE_READ_CMD << addr_len);
  32366. outb(EE_ENB & ~EE_CS, ee_addr);
  32367. outb(EE_ENB, ee_addr);
  32368. + eeprom_delay();
  32369. /* Shift the read command bits out. */
  32370. - for (i = 10; i >= 0; i--) {
  32371. + for (i = 4 + addr_len; i >= 0; i--) {
  32372. int dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
  32373. outb(EE_ENB | dataval, ee_addr);
  32374. eeprom_delay();
  32375. @@ -279,31 +285,51 @@
  32376. /* Terminate the EEPROM access. */
  32377. outb(~EE_CS, ee_addr);
  32378. + eeprom_delay();
  32379. return retval;
  32380. }
  32381. +static const unsigned int rtl8139_rx_config =
  32382. + (RX_BUF_LEN_IDX << 11) |
  32383. + (RX_FIFO_THRESH << 13) |
  32384. + (RX_DMA_BURST << 8);
  32385. +
  32386. +static void set_rx_mode(struct nic *nic) {
  32387. + unsigned int mc_filter[2];
  32388. + int rx_mode;
  32389. + /* !IFF_PROMISC */
  32390. + rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
  32391. + mc_filter[1] = mc_filter[0] = 0xffffffff;
  32392. +
  32393. + outl(rtl8139_rx_config | rx_mode, nic->ioaddr + RxConfig);
  32394. +
  32395. + outl(mc_filter[0], nic->ioaddr + MAR0 + 0);
  32396. + outl(mc_filter[1], nic->ioaddr + MAR0 + 4);
  32397. +}
  32398. +
  32399. static void rtl_reset(struct nic* nic)
  32400. {
  32401. int i;
  32402. - outb(CmdReset, ioaddr + ChipCmd);
  32403. + outb(CmdReset, nic->ioaddr + ChipCmd);
  32404. cur_rx = 0;
  32405. cur_tx = 0;
  32406. /* Give the chip 10ms to finish the reset. */
  32407. load_timer2(10*TICKS_PER_MS);
  32408. - while ((inb(ioaddr + ChipCmd) & CmdReset) != 0 && timer2_running())
  32409. + while ((inb(nic->ioaddr + ChipCmd) & CmdReset) != 0 &&
  32410. + timer2_running())
  32411. /* wait */;
  32412. for (i = 0; i < ETH_ALEN; i++)
  32413. - outb(nic->node_addr[i], ioaddr + MAC0 + i);
  32414. + outb(nic->node_addr[i], nic->ioaddr + MAC0 + i);
  32415. /* Must enable Tx/Rx before setting transfer thresholds! */
  32416. - outb(CmdRxEnb | CmdTxEnb, ioaddr + ChipCmd);
  32417. + outb(CmdRxEnb | CmdTxEnb, nic->ioaddr + ChipCmd);
  32418. outl((RX_FIFO_THRESH<<13) | (RX_BUF_LEN_IDX<<11) | (RX_DMA_BURST<<8),
  32419. - ioaddr + RxConfig); /* accept no frames yet! */
  32420. - outl((TX_DMA_BURST<<8)|0x03000000, ioaddr + TxConfig);
  32421. + nic->ioaddr + RxConfig); /* accept no frames yet! */
  32422. + outl((TX_DMA_BURST<<8)|0x03000000, nic->ioaddr + TxConfig);
  32423. /* The Linux driver changes Config1 here to use a different LED pattern
  32424. * for half duplex or full/autodetect duplex (for full/autodetect, the
  32425. @@ -316,19 +342,26 @@
  32426. #ifdef DEBUG_RX
  32427. printf("rx ring address is %X\n",(unsigned long)rx_ring);
  32428. #endif
  32429. - outl((unsigned long)rx_ring, ioaddr + RxBuf);
  32430. + outl((unsigned long)virt_to_bus(rx_ring), nic->ioaddr + RxBuf);
  32431. +
  32432. +
  32433. - /* Start the chip's Tx and Rx process. */
  32434. - outl(0, ioaddr + RxMissed);
  32435. - /* set_rx_mode */
  32436. - outb(AcceptBroadcast|AcceptMyPhys, ioaddr + RxConfig);
  32437. /* If we add multicast support, the MAR0 register would have to be
  32438. * initialized to 0xffffffffffffffff (two 32 bit accesses). Etherboot
  32439. * only needs broadcast (for ARP/RARP/BOOTP/DHCP) and unicast. */
  32440. - outb(CmdRxEnb | CmdTxEnb, ioaddr + ChipCmd);
  32441. + outb(CmdRxEnb | CmdTxEnb, nic->ioaddr + ChipCmd);
  32442. +
  32443. + outl(rtl8139_rx_config, nic->ioaddr + RxConfig);
  32444. +
  32445. + /* Start the chip's Tx and Rx process. */
  32446. + outl(0, nic->ioaddr + RxMissed);
  32447. +
  32448. + /* set_rx_mode */
  32449. + set_rx_mode(nic);
  32450. +
  32451. /* Disable all known interrupts by setting the interrupt mask. */
  32452. - outw(0, ioaddr + IntrMask);
  32453. + outw(0, nic->ioaddr + IntrMask);
  32454. }
  32455. static void rtl_transmit(struct nic *nic, const char *destaddr,
  32456. @@ -337,10 +370,11 @@
  32457. unsigned int status, to, nstype;
  32458. unsigned long txstatus;
  32459. + /* nstype assignment moved up here to avoid gcc 3.0.3 compiler bug */
  32460. + nstype = htons(type);
  32461. memcpy(tx_buffer, destaddr, ETH_ALEN);
  32462. memcpy(tx_buffer + ETH_ALEN, nic->node_addr, ETH_ALEN);
  32463. - nstype = htons(type);
  32464. - memcpy(tx_buffer + 2 * ETH_ALEN, (char*)&nstype, 2);
  32465. + memcpy(tx_buffer + 2 * ETH_ALEN, &nstype, 2);
  32466. memcpy(tx_buffer + ETH_HLEN, data, len);
  32467. len += ETH_HLEN;
  32468. @@ -354,22 +388,22 @@
  32469. tx_buffer[len++] = '\0';
  32470. }
  32471. - outl((unsigned long)tx_buffer, ioaddr + TxAddr0 + cur_tx*4);
  32472. + outl((unsigned long)virt_to_bus(tx_buffer), nic->ioaddr + TxAddr0 + cur_tx*4);
  32473. outl(((TX_FIFO_THRESH<<11) & 0x003f0000) | len,
  32474. - ioaddr + TxStatus0 + cur_tx*4);
  32475. + nic->ioaddr + TxStatus0 + cur_tx*4);
  32476. to = currticks() + RTL_TIMEOUT;
  32477. do {
  32478. - status = inw(ioaddr + IntrStatus);
  32479. + status = inw(nic->ioaddr + IntrStatus);
  32480. /* Only acknlowledge interrupt sources we can properly handle
  32481. * here - the RxOverflow/RxFIFOOver MUST be handled in the
  32482. * rtl_poll() function. */
  32483. - outw(status & (TxOK | TxErr | PCIErr), ioaddr + IntrStatus);
  32484. + outw(status & (TxOK | TxErr | PCIErr), nic->ioaddr + IntrStatus);
  32485. if ((status & (TxOK | TxErr | PCIErr)) != 0) break;
  32486. } while (currticks() < to);
  32487. - txstatus = inl(ioaddr+ TxStatus0 + cur_tx*4);
  32488. + txstatus = inl(nic->ioaddr+ TxStatus0 + cur_tx*4);
  32489. if (status & TxOK) {
  32490. cur_tx = (cur_tx + 1) % NUM_TX_DESC;
  32491. @@ -386,19 +420,22 @@
  32492. }
  32493. }
  32494. -static int rtl_poll(struct nic *nic)
  32495. +static int rtl_poll(struct nic *nic, int retrieve)
  32496. {
  32497. unsigned int status;
  32498. unsigned int ring_offs;
  32499. unsigned int rx_size, rx_status;
  32500. - if (inb(ioaddr + ChipCmd) & RxBufEmpty) {
  32501. + if (inb(nic->ioaddr + ChipCmd) & RxBufEmpty) {
  32502. return 0;
  32503. }
  32504. - status = inw(ioaddr + IntrStatus);
  32505. + /* There is a packet ready */
  32506. + if ( ! retrieve ) return 1;
  32507. +
  32508. + status = inw(nic->ioaddr + IntrStatus);
  32509. /* See below for the rest of the interrupt acknowledges. */
  32510. - outw(status & ~(RxFIFOOver | RxOverflow | RxOK), ioaddr + IntrStatus);
  32511. + outw(status & ~(RxFIFOOver | RxOverflow | RxOK), nic->ioaddr + IntrStatus);
  32512. #ifdef DEBUG_RX
  32513. printf("rtl_poll: int %hX ", status);
  32514. @@ -438,21 +475,77 @@
  32515. nic->packet[12], nic->packet[13], rx_status);
  32516. #endif
  32517. cur_rx = (cur_rx + rx_size + 4 + 3) & ~3;
  32518. - outw(cur_rx - 16, ioaddr + RxBufPtr);
  32519. + outw(cur_rx - 16, nic->ioaddr + RxBufPtr);
  32520. /* See RTL8139 Programming Guide V0.1 for the official handling of
  32521. * Rx overflow situations. The document itself contains basically no
  32522. * usable information, except for a few exception handling rules. */
  32523. - outw(status & (RxFIFOOver | RxOverflow | RxOK), ioaddr + IntrStatus);
  32524. + outw(status & (RxFIFOOver | RxOverflow | RxOK), nic->ioaddr + IntrStatus);
  32525. return 1;
  32526. }
  32527. -static void rtl_disable(struct nic *nic)
  32528. +static void rtl_irq(struct nic *nic, irq_action_t action)
  32529. {
  32530. + unsigned int mask;
  32531. + /* Bit of a guess as to which interrupts we should allow */
  32532. + unsigned int interested = ROK | RER | RXOVW | FOVW | SERR;
  32533. +
  32534. + switch ( action ) {
  32535. + case DISABLE :
  32536. + case ENABLE :
  32537. + mask = inw(nic->ioaddr + IntrMask);
  32538. + mask = mask & ~interested;
  32539. + if ( action == ENABLE ) mask = mask | interested;
  32540. + outw(mask, nic->ioaddr + IntrMask);
  32541. + break;
  32542. + case FORCE :
  32543. + /* Apparently writing a 1 to this read-only bit of a
  32544. + * read-only and otherwise unrelated register will
  32545. + * force an interrupt. If you ever want to see how
  32546. + * not to write a datasheet, read the one for the
  32547. + * RTL8139...
  32548. + */
  32549. + outb(EROK, nic->ioaddr + RxEarlyStatus);
  32550. + break;
  32551. + }
  32552. +}
  32553. +
  32554. +static void rtl_disable(struct dev *dev)
  32555. +{
  32556. + struct nic *nic = (struct nic *)dev;
  32557. + /* merge reset and disable */
  32558. + rtl_reset(nic);
  32559. +
  32560. /* reset the chip */
  32561. - outb(CmdReset, ioaddr + ChipCmd);
  32562. + outb(CmdReset, nic->ioaddr + ChipCmd);
  32563. /* 10 ms timeout */
  32564. load_timer2(10*TICKS_PER_MS);
  32565. - while ((inb(ioaddr + ChipCmd) & CmdReset) != 0 && timer2_running())
  32566. + while ((inb(nic->ioaddr + ChipCmd) & CmdReset) != 0 && timer2_running())
  32567. /* wait */;
  32568. }
  32569. +
  32570. +static struct pci_id rtl8139_nics[] = {
  32571. +PCI_ROM(0x10ec, 0x8129, "rtl8129", "Realtek 8129"),
  32572. +PCI_ROM(0x10ec, 0x8139, "rtl8139", "Realtek 8139"),
  32573. +PCI_ROM(0x10ec, 0x8138, "rtl8139b", "Realtek 8139B"),
  32574. +PCI_ROM(0x1186, 0x1300, "dfe538", "DFE530TX+/DFE538TX"),
  32575. +PCI_ROM(0x1113, 0x1211, "smc1211-1", "SMC EZ10/100"),
  32576. +PCI_ROM(0x1112, 0x1211, "smc1211", "SMC EZ10/100"),
  32577. +PCI_ROM(0x1500, 0x1360, "delta8139", "Delta Electronics 8139"),
  32578. +PCI_ROM(0x4033, 0x1360, "addtron8139", "Addtron Technology 8139"),
  32579. +PCI_ROM(0x1186, 0x1340, "dfe690txd", "D-Link DFE690TXD"),
  32580. +PCI_ROM(0x13d1, 0xab06, "fe2000vx", "AboCom FE2000VX"),
  32581. +PCI_ROM(0x1259, 0xa117, "allied8139", "Allied Telesyn 8139"),
  32582. +PCI_ROM(0x14ea, 0xab06, "fnw3603tx", "Planex FNW-3603-TX"),
  32583. +PCI_ROM(0x14ea, 0xab07, "fnw3800tx", "Planex FNW-3800-TX"),
  32584. +PCI_ROM(0xffff, 0x8139, "clone-rtl8139", "Cloned 8139"),
  32585. +};
  32586. +
  32587. +struct pci_driver rtl8139_driver = {
  32588. + .type = NIC_DRIVER,
  32589. + .name = "RTL8139",
  32590. + .probe = rtl8139_probe,
  32591. + .ids = rtl8139_nics,
  32592. + .id_count = sizeof(rtl8139_nics)/sizeof(rtl8139_nics[0]),
  32593. + .class = 0,
  32594. +};
  32595. diff -Naur grub-0.97.orig/netboot/segoff.h grub-0.97/netboot/segoff.h
  32596. --- grub-0.97.orig/netboot/segoff.h 1970-01-01 00:00:00.000000000 +0000
  32597. +++ grub-0.97/netboot/segoff.h 2005-08-31 19:03:35.000000000 +0000
  32598. @@ -0,0 +1,43 @@
  32599. +/*
  32600. + * Segment:offset types and macros
  32601. + *
  32602. + * Initially written by Michael Brown (mcb30).
  32603. + */
  32604. +
  32605. +#ifndef SEGOFF_H
  32606. +#define SEGOFF_H
  32607. +
  32608. +#include <stdint.h>
  32609. +#include <io.h>
  32610. +
  32611. +/* Segment:offset structure. Note that the order within the structure
  32612. + * is offset:segment.
  32613. + */
  32614. +typedef struct {
  32615. + uint16_t offset;
  32616. + uint16_t segment;
  32617. +} segoff_t;
  32618. +
  32619. +/* For PXE stuff */
  32620. +typedef segoff_t SEGOFF16_t;
  32621. +
  32622. +/* Macros for converting from virtual to segment:offset addresses,
  32623. + * when we don't actually care which of the many isomorphic results we
  32624. + * get.
  32625. + */
  32626. +#ifdef DEBUG_SEGMENT
  32627. +uint16_t SEGMENT ( const void * const ptr ) {
  32628. + uint32_t phys = virt_to_phys ( ptr );
  32629. + if ( phys > 0xfffff ) {
  32630. + printf ( "FATAL ERROR: segment address out of range\n" );
  32631. + }
  32632. + return phys >> 4;
  32633. +}
  32634. +#else
  32635. +#define SEGMENT(x) ( virt_to_phys ( x ) >> 4 )
  32636. +#endif
  32637. +#define OFFSET(x) ( virt_to_phys ( x ) & 0xf )
  32638. +#define SEGOFF(x) { OFFSET(x), SEGMENT(x) }
  32639. +#define VIRTUAL(x,y) ( phys_to_virt ( ( ( x ) << 4 ) + ( y ) ) )
  32640. +
  32641. +#endif /* SEGOFF_H */
  32642. diff -Naur grub-0.97.orig/netboot/sis900.c grub-0.97/netboot/sis900.c
  32643. --- grub-0.97.orig/netboot/sis900.c 2003-07-09 11:45:38.000000000 +0000
  32644. +++ grub-0.97/netboot/sis900.c 2005-08-31 20:02:38.000000000 +0000
  32645. @@ -27,6 +27,11 @@
  32646. /* Revision History */
  32647. /*
  32648. + 07 Dec 2003 timlegge - Enabled Multicast Support
  32649. + 06 Dec 2003 timlegge - Fixed relocation issue in 5.2
  32650. + 04 Jan 2002 Chien-Yu Chen, Doug Ambrisko, Marty Connor Patch to Etherboot 5.0.5
  32651. + Added support for the SiS 630ET plus various bug fixes from linux kernel
  32652. + source 2.4.17.
  32653. 01 March 2001 mdc 1.0
  32654. Initial Release. Tested with PCI based sis900 card and ThinkNIC
  32655. computer.
  32656. @@ -35,13 +40,12 @@
  32657. Testet with SIS730S chipset + ICS1893
  32658. */
  32659. -
  32660. /* Includes */
  32661. #include "etherboot.h"
  32662. #include "nic.h"
  32663. #include "pci.h"
  32664. -#include "cards.h"
  32665. +#include "timer.h"
  32666. #include "sis900.h"
  32667. @@ -51,6 +55,7 @@
  32668. static unsigned short vendor, dev_id;
  32669. static unsigned long ioaddr;
  32670. +static u8 pci_revision;
  32671. static unsigned int cur_phy;
  32672. @@ -58,15 +63,10 @@
  32673. static BufferDesc txd;
  32674. static BufferDesc rxd[NUM_RX_DESC];
  32675. -
  32676. -#ifdef USE_LOWMEM_BUFFER
  32677. -#define txb ((char *)0x10000 - TX_BUF_SIZE)
  32678. -#define rxb ((char *)0x10000 - NUM_RX_DESC*RX_BUF_SIZE - TX_BUF_SIZE)
  32679. -#else
  32680. static unsigned char txb[TX_BUF_SIZE];
  32681. static unsigned char rxb[NUM_RX_DESC * RX_BUF_SIZE];
  32682. -#endif
  32683. +#if 0
  32684. static struct mac_chip_info {
  32685. const char *name;
  32686. u16 vendor_id, device_id, flags;
  32687. @@ -78,11 +78,13 @@
  32688. PCI_COMMAND_IO|PCI_COMMAND_MASTER, SIS900_TOTAL_SIZE},
  32689. {0,0,0,0,0} /* 0 terminated list. */
  32690. };
  32691. +#endif
  32692. static void sis900_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex);
  32693. static void amd79c901_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex);
  32694. static void ics1893_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex);
  32695. static void rtl8201_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex);
  32696. +static void vt6103_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex);
  32697. static struct mii_chip_info {
  32698. const char * name;
  32699. @@ -96,6 +98,7 @@
  32700. {"AMD 79C901 HomePNA PHY", 0x0000, 0x35c8, amd79c901_read_mode},
  32701. {"ICS 1893 Integrated PHYceiver" , 0x0015, 0xf441,ics1893_read_mode},
  32702. {"RTL 8201 10/100Mbps Phyceiver" , 0x0000, 0x8201,rtl8201_read_mode},
  32703. + {"VIA 6103 10/100Mbps Phyceiver", 0x0101, 0x8f20,vt6103_read_mode},
  32704. {0,0,0,0}
  32705. };
  32706. @@ -106,24 +109,32 @@
  32707. u16 status;
  32708. } mii;
  32709. -
  32710. // PCI to ISA bridge for SIS640E access
  32711. -static struct pci_device pci_isa_bridge_list[] = {
  32712. +static struct pci_id pci_isa_bridge_list[] = {
  32713. { 0x1039, 0x0008,
  32714. - "SIS 85C503/5513 PCI to ISA bridge", 0, 0, 0, 0},
  32715. - {0, 0, NULL, 0, 0, 0, 0}
  32716. + "SIS 85C503/5513 PCI to ISA bridge"},
  32717. +};
  32718. +
  32719. +struct pci_driver sis_bridge_driver = {
  32720. + .type = BRIDGE_DRIVER,
  32721. + .name = "",
  32722. + .probe = 0,
  32723. + .ids = pci_isa_bridge_list,
  32724. + .id_count = sizeof(pci_isa_bridge_list)/sizeof(pci_isa_bridge_list[0]),
  32725. + .class = 0,
  32726. };
  32727. /* Function Prototypes */
  32728. -struct nic *sis900_probe(struct nic *nic, unsigned short *io_addrs, struct pci_device *pci);
  32729. +static int sis900_probe(struct dev *dev, struct pci_device *pci);
  32730. static u16 sis900_read_eeprom(int location);
  32731. static void sis900_mdio_reset(long mdio_addr);
  32732. static void sis900_mdio_idle(long mdio_addr);
  32733. static u16 sis900_mdio_read(int phy_id, int location);
  32734. +#if 0
  32735. static void sis900_mdio_write(int phy_id, int location, int val);
  32736. -
  32737. +#endif
  32738. static void sis900_init(struct nic *nic);
  32739. static void sis900_reset(struct nic *nic);
  32740. @@ -136,9 +147,11 @@
  32741. static void sis900_transmit(struct nic *nic, const char *d,
  32742. unsigned int t, unsigned int s, const char *p);
  32743. -static int sis900_poll(struct nic *nic);
  32744. +static int sis900_poll(struct nic *nic, int retrieve);
  32745. +
  32746. +static void sis900_disable(struct dev *dev);
  32747. -static void sis900_disable(struct nic *nic);
  32748. +static void sis900_irq(struct nic *nic, irq_action_t action);
  32749. /**
  32750. * sis900_get_mac_addr: - Get MAC address for stand alone SiS900 model
  32751. @@ -149,7 +162,7 @@
  32752. * MAC address is read from read_eeprom() into @net_dev->dev_addr.
  32753. */
  32754. -static int sis900_get_mac_addr(struct pci_device * pci_dev , struct nic *nic)
  32755. +static int sis900_get_mac_addr(struct pci_device * pci_dev __unused, struct nic *nic)
  32756. {
  32757. u16 signature;
  32758. int i;
  32759. @@ -168,6 +181,50 @@
  32760. }
  32761. /**
  32762. + * sis96x_get_mac_addr: - Get MAC address for SiS962 or SiS963 model
  32763. + * @pci_dev: the sis900 pci device
  32764. + * @net_dev: the net device to get address for
  32765. + *
  32766. + * SiS962 or SiS963 model, use EEPROM to store MAC address. And EEPROM
  32767. + * is shared by
  32768. + * LAN and 1394. When access EEPROM, send EEREQ signal to hardware first
  32769. + * and wait for EEGNT. If EEGNT is ON, EEPROM is permitted to be access
  32770. + * by LAN, otherwise is not. After MAC address is read from EEPROM, send
  32771. + * EEDONE signal to refuse EEPROM access by LAN.
  32772. + * The EEPROM map of SiS962 or SiS963 is different to SiS900.
  32773. + * The signature field in SiS962 or SiS963 spec is meaningless.
  32774. + * MAC address is read into @net_dev->dev_addr.
  32775. + */
  32776. +
  32777. +static int sis96x_get_mac_addr(struct pci_device * pci_dev __unused, struct nic *nic)
  32778. +{
  32779. +/* long ioaddr = net_dev->base_addr; */
  32780. + long ee_addr = ioaddr + mear;
  32781. + u32 waittime = 0;
  32782. + int i;
  32783. +
  32784. + printf("Alternate function\n");
  32785. +
  32786. + outl(EEREQ, ee_addr);
  32787. + while(waittime < 2000) {
  32788. + if(inl(ee_addr) & EEGNT) {
  32789. +
  32790. + /* get MAC address from EEPROM */
  32791. + for (i = 0; i < 3; i++)
  32792. + ((u16 *)(nic->node_addr))[i] = sis900_read_eeprom(i+EEPROMMACAddr);
  32793. +
  32794. + outl(EEDONE, ee_addr);
  32795. + return 1;
  32796. + } else {
  32797. + udelay(1);
  32798. + waittime ++;
  32799. + }
  32800. + }
  32801. + outl(EEDONE, ee_addr);
  32802. + return 0;
  32803. +}
  32804. +
  32805. +/**
  32806. * sis630e_get_mac_addr: - Get MAC address for SiS630E model
  32807. * @pci_dev: the sis900 pci device
  32808. * @net_dev: the net device to get address for
  32809. @@ -177,17 +234,21 @@
  32810. * MAC address is read into @net_dev->dev_addr.
  32811. */
  32812. -static int sis630e_get_mac_addr(struct pci_device * pci_dev, struct nic *nic)
  32813. +static int sis630e_get_mac_addr(struct pci_device * pci_dev __unused, struct nic *nic)
  32814. {
  32815. u8 reg;
  32816. int i;
  32817. - struct pci_device *p;
  32818. -
  32819. - // find PCI to ISA bridge
  32820. - eth_pci_init(pci_isa_bridge_list);
  32821. + struct pci_device p[1];
  32822. - /* the firts entry in this list should contain bus/devfn */
  32823. - p = pci_isa_bridge_list;
  32824. + /* find PCI to ISA bridge */
  32825. + memset(p, 0, sizeof(p));
  32826. + do {
  32827. + find_pci(BRIDGE_DRIVER, p);
  32828. + } while(p->driver && p->driver != &sis_bridge_driver);
  32829. +
  32830. + /* error on failure */
  32831. + if (!p->driver)
  32832. + return 0;
  32833. pcibios_read_config_byte(p->bus,p->devfn, 0x48, &reg);
  32834. pcibios_write_config_byte(p->bus,p->devfn, 0x48, reg | 0x40);
  32835. @@ -201,7 +262,43 @@
  32836. return 1;
  32837. }
  32838. -
  32839. +
  32840. +/**
  32841. + * sis630e_get_mac_addr: - Get MAC address for SiS630E model
  32842. + * @pci_dev: the sis900 pci device
  32843. + * @net_dev: the net device to get address for
  32844. + *
  32845. + * SiS630E model, use APC CMOS RAM to store MAC address.
  32846. + * APC CMOS RAM is accessed through ISA bridge.
  32847. + * MAC address is read into @net_dev->dev_addr.
  32848. + */
  32849. +
  32850. +static int sis635_get_mac_addr(struct pci_device * pci_dev __unused, struct nic *nic)
  32851. +{
  32852. + u32 rfcrSave;
  32853. + u32 i;
  32854. +
  32855. +
  32856. + rfcrSave = inl(rfcr + ioaddr);
  32857. +
  32858. + outl(rfcrSave | RELOAD, ioaddr + cr);
  32859. + outl(0, ioaddr + cr);
  32860. +
  32861. + /* disable packet filtering before setting filter */
  32862. + outl(rfcrSave & ~RFEN, rfcr + ioaddr);
  32863. +
  32864. + /* load MAC addr to filter data register */
  32865. + for (i = 0 ; i < 3 ; i++) {
  32866. + outl((i << RFADDR_shift), ioaddr + rfcr);
  32867. + *( ((u16 *)nic->node_addr) + i) = inw(ioaddr + rfdr);
  32868. + }
  32869. +
  32870. + /* enable packet filitering */
  32871. + outl(rfcrSave | RFEN, rfcr + ioaddr);
  32872. +
  32873. + return 1;
  32874. +}
  32875. +
  32876. /*
  32877. * Function: sis900_probe
  32878. *
  32879. @@ -216,19 +313,21 @@
  32880. * Returns: struct nic *: pointer to NIC data structure
  32881. */
  32882. -struct nic *sis900_probe(struct nic *nic, unsigned short *io_addrs, struct pci_device *pci)
  32883. +static int sis900_probe(struct dev *dev, struct pci_device *pci)
  32884. {
  32885. + struct nic *nic = (struct nic *)dev;
  32886. int i;
  32887. int found=0;
  32888. int phy_addr;
  32889. - u16 signature;
  32890. u8 revision;
  32891. int ret;
  32892. - if (io_addrs == 0 || *io_addrs == 0)
  32893. - return NULL;
  32894. + if (pci->ioaddr == 0)
  32895. + return 0;
  32896. - ioaddr = *io_addrs & ~3;
  32897. + nic->irqno = 0;
  32898. + nic->ioaddr = pci->ioaddr & ~3;
  32899. + ioaddr = pci->ioaddr & ~3;
  32900. vendor = pci->vendor;
  32901. dev_id = pci->dev_id;
  32902. @@ -240,19 +339,29 @@
  32903. /* get MAC address */
  32904. ret = 0;
  32905. pcibios_read_config_byte(pci->bus,pci->devfn, PCI_REVISION, &revision);
  32906. - if (revision == SIS630E_900_REV || revision == SIS630EA1_900_REV)
  32907. - ret = sis630e_get_mac_addr(pci, nic);
  32908. - else if (revision == SIS630S_900_REV)
  32909. +
  32910. + /* save for use later in sis900_reset() */
  32911. + pci_revision = revision;
  32912. +
  32913. + if (revision == SIS630E_900_REV)
  32914. ret = sis630e_get_mac_addr(pci, nic);
  32915. + else if ((revision > 0x81) && (revision <= 0x90))
  32916. + ret = sis635_get_mac_addr(pci, nic);
  32917. + else if (revision == SIS96x_900_REV)
  32918. + ret = sis96x_get_mac_addr(pci, nic);
  32919. else
  32920. ret = sis900_get_mac_addr(pci, nic);
  32921. if (ret == 0)
  32922. {
  32923. printf ("sis900_probe: Error MAC address not found\n");
  32924. - return NULL;
  32925. + return 0;
  32926. }
  32927. + /* 630ET : set the mii access mode as software-mode */
  32928. + if (revision == SIS630ET_900_REV)
  32929. + outl(ACCESSMODE | inl(ioaddr + cr), ioaddr + cr);
  32930. +
  32931. printf("\nsis900_probe: MAC addr %! at ioaddr %#hX\n",
  32932. nic->node_addr, ioaddr);
  32933. printf("sis900_probe: Vendor:%#hX Device:%#hX\n", vendor, dev_id);
  32934. @@ -264,7 +373,7 @@
  32935. for (phy_addr = 0; phy_addr < 32; phy_addr++) {
  32936. u16 mii_status;
  32937. u16 phy_id0, phy_id1;
  32938. -
  32939. +
  32940. mii_status = sis900_mdio_read(phy_addr, MII_STATUS);
  32941. if (mii_status == 0xffff || mii_status == 0x0000)
  32942. /* the mii is not accessable, try next one */
  32943. @@ -272,7 +381,7 @@
  32944. phy_id0 = sis900_mdio_read(phy_addr, MII_PHY_ID0);
  32945. phy_id1 = sis900_mdio_read(phy_addr, MII_PHY_ID1);
  32946. -
  32947. +
  32948. /* search our mii table for the current mii */
  32949. for (i = 0; mii_chip_table[i].phy_id1; i++) {
  32950. @@ -294,7 +403,7 @@
  32951. if (found == 0) {
  32952. printf("sis900_probe: No MII transceivers found!\n");
  32953. - return NULL;
  32954. + return 0;
  32955. }
  32956. /* Arbitrarily select the last PHY found as current PHY */
  32957. @@ -304,15 +413,14 @@
  32958. /* initialize device */
  32959. sis900_init(nic);
  32960. - nic->reset = sis900_init;
  32961. + dev->disable = sis900_disable;
  32962. nic->poll = sis900_poll;
  32963. nic->transmit = sis900_transmit;
  32964. - nic->disable = sis900_disable;
  32965. + nic->irq = sis900_irq;
  32966. - return nic;
  32967. + return 1;
  32968. }
  32969. -
  32970. /*
  32971. * EEPROM Routines: These functions read and write to EEPROM for
  32972. * retrieving the MAC address and other configuration information about
  32973. @@ -322,7 +430,6 @@
  32974. /* Delay between EEPROM clock transitions. */
  32975. #define eeprom_delay() inl(ee_addr)
  32976. -
  32977. /* Function: sis900_read_eeprom
  32978. *
  32979. * Description: reads and returns a given location from EEPROM
  32980. @@ -378,7 +485,6 @@
  32981. #define sis900_mdio_delay() inl(mdio_addr)
  32982. -
  32983. /*
  32984. Read and write the MII management registers using software-generated
  32985. serial MDIO protocol. Note that the command bits and data bits are
  32986. @@ -432,9 +538,11 @@
  32987. outl(MDC, mdio_addr);
  32988. sis900_mdio_delay();
  32989. }
  32990. + outl(0x00, mdio_addr);
  32991. return retval;
  32992. }
  32993. +#if 0
  32994. static void sis900_mdio_write(int phy_id, int location, int value)
  32995. {
  32996. long mdio_addr = ioaddr + mear;
  32997. @@ -471,10 +579,11 @@
  32998. outb(MDC, mdio_addr);
  32999. sis900_mdio_delay();
  33000. }
  33001. + outl(0x00, mdio_addr);
  33002. return;
  33003. }
  33004. +#endif
  33005. -
  33006. /* Function: sis900_init
  33007. *
  33008. * Description: resets the ethernet controller chip and various
  33009. @@ -500,10 +609,9 @@
  33010. sis900_check_mode(nic);
  33011. - outl(RxENA, ioaddr + cr);
  33012. + outl(RxENA| inl(ioaddr + cr), ioaddr + cr);
  33013. }
  33014. -
  33015. /*
  33016. * Function: sis900_reset
  33017. *
  33018. @@ -515,7 +623,7 @@
  33019. */
  33020. static void
  33021. -sis900_reset(struct nic *nic)
  33022. +sis900_reset(struct nic *nic __unused)
  33023. {
  33024. int i = 0;
  33025. u32 status = TxRCMP | RxRCMP;
  33026. @@ -524,16 +632,19 @@
  33027. outl(0, ioaddr + imr);
  33028. outl(0, ioaddr + rfcr);
  33029. - outl(RxRESET | TxRESET | RESET, ioaddr + cr);
  33030. -
  33031. + outl(RxRESET | TxRESET | RESET | inl(ioaddr + cr), ioaddr + cr);
  33032. +
  33033. /* Check that the chip has finished the reset. */
  33034. while (status && (i++ < 1000)) {
  33035. status ^= (inl(isr + ioaddr) & status);
  33036. }
  33037. - outl(PESEL, ioaddr + cfg);
  33038. +
  33039. + if( (pci_revision == SIS635A_900_REV) || (pci_revision == SIS900B_900_REV) )
  33040. + outl(PESEL | RND_CNT, ioaddr + cfg);
  33041. + else
  33042. + outl(PESEL, ioaddr + cfg);
  33043. }
  33044. -
  33045. /* Function: sis_init_rxfilter
  33046. *
  33047. * Description: sets receive filter address to our MAC address
  33048. @@ -552,7 +663,7 @@
  33049. rfcrSave = inl(rfcr + ioaddr);
  33050. /* disable packet filtering before setting filter */
  33051. - outl(rfcrSave & ~RFEN, rfcr);
  33052. + outl(rfcrSave & ~RFEN, rfcr + ioaddr);
  33053. /* load MAC addr to filter data register */
  33054. for (i = 0 ; i < 3 ; i++) {
  33055. @@ -571,7 +682,6 @@
  33056. outl(rfcrSave | RFEN, rfcr + ioaddr);
  33057. }
  33058. -
  33059. /*
  33060. * Function: sis_init_txd
  33061. *
  33062. @@ -583,20 +693,19 @@
  33063. */
  33064. static void
  33065. -sis900_init_txd(struct nic *nic)
  33066. +sis900_init_txd(struct nic *nic __unused)
  33067. {
  33068. txd.link = (u32) 0;
  33069. txd.cmdsts = (u32) 0;
  33070. - txd.bufptr = (u32) &txb[0];
  33071. + txd.bufptr = virt_to_bus(&txb[0]);
  33072. /* load Transmit Descriptor Register */
  33073. - outl((u32) &txd, ioaddr + txdp);
  33074. + outl(virt_to_bus(&txd), ioaddr + txdp);
  33075. if (sis900_debug > 0)
  33076. printf("sis900_init_txd: TX descriptor register loaded with: %X\n",
  33077. inl(ioaddr + txdp));
  33078. }
  33079. -
  33080. /* Function: sis_init_rxd
  33081. *
  33082. * Description: initializes the Rx descriptor ring
  33083. @@ -607,7 +716,7 @@
  33084. */
  33085. static void
  33086. -sis900_init_rxd(struct nic *nic)
  33087. +sis900_init_rxd(struct nic *nic __unused)
  33088. {
  33089. int i;
  33090. @@ -615,16 +724,16 @@
  33091. /* init RX descriptor */
  33092. for (i = 0; i < NUM_RX_DESC; i++) {
  33093. - rxd[i].link = (i+1 < NUM_RX_DESC) ? (u32) &rxd[i+1] : (u32) &rxd[0];
  33094. + rxd[i].link = virt_to_bus((i+1 < NUM_RX_DESC) ? &rxd[i+1] : &rxd[0]);
  33095. rxd[i].cmdsts = (u32) RX_BUF_SIZE;
  33096. - rxd[i].bufptr = (u32) &rxb[i*RX_BUF_SIZE];
  33097. + rxd[i].bufptr = virt_to_bus(&rxb[i*RX_BUF_SIZE]);
  33098. if (sis900_debug > 0)
  33099. printf("sis900_init_rxd: rxd[%d]=%X link=%X cmdsts=%X bufptr=%X\n",
  33100. i, &rxd[i], rxd[i].link, rxd[i].cmdsts, rxd[i].bufptr);
  33101. }
  33102. /* load Receive Descriptor Register */
  33103. - outl((u32) &rxd[0], ioaddr + rxdp);
  33104. + outl(virt_to_bus(&rxd[0]), ioaddr + rxdp);
  33105. if (sis900_debug > 0)
  33106. printf("sis900_init_rxd: RX descriptor register loaded with: %X\n",
  33107. @@ -632,7 +741,6 @@
  33108. }
  33109. -
  33110. /* Function: sis_init_rxd
  33111. *
  33112. * Description:
  33113. @@ -644,25 +752,36 @@
  33114. * Returns: void.
  33115. */
  33116. -static void sis900_set_rx_mode(struct nic *nic)
  33117. +static void sis900_set_rx_mode(struct nic *nic __unused)
  33118. {
  33119. - int i;
  33120. + int i, table_entries;
  33121. + u32 rx_mode;
  33122. + u16 mc_filter[16] = {0}; /* 256/128 bits multicast hash table */
  33123. +
  33124. + if((pci_revision == SIS635A_900_REV) || (pci_revision == SIS900B_900_REV))
  33125. + table_entries = 16;
  33126. + else
  33127. + table_entries = 8;
  33128. - /* Configure Multicast Hash Table in Receive Filter
  33129. - to reject all MCAST packets */
  33130. - for (i = 0; i < 8; i++) {
  33131. + /* accept all multicast packet */
  33132. + rx_mode = RFAAB | RFAAM;
  33133. + for (i = 0; i < table_entries; i++)
  33134. + mc_filter[i] = 0xffff;
  33135. +
  33136. + /* update Multicast Hash Table in Receive Filter */
  33137. + for (i = 0; i < table_entries; i++) {
  33138. /* why plus 0x04? That makes the correct value for hash table. */
  33139. outl((u32)(0x00000004+i) << RFADDR_shift, ioaddr + rfcr);
  33140. - outl((u32)(0x0), ioaddr + rfdr);
  33141. + outl(mc_filter[i], ioaddr + rfdr);
  33142. }
  33143. - /* Accept Broadcast packets, destination addresses that match
  33144. +
  33145. + /* Accept Broadcast and multicast packets, destination addresses that match
  33146. our MAC address */
  33147. - outl(RFEN | RFAAB, ioaddr + rfcr);
  33148. + outl(RFEN | rx_mode, ioaddr + rfcr);
  33149. return;
  33150. }
  33151. -
  33152. /* Function: sis900_check_mode
  33153. *
  33154. * Description: checks the state of transmit and receive
  33155. @@ -674,15 +793,21 @@
  33156. */
  33157. static void
  33158. -sis900_check_mode (struct nic *nic)
  33159. +sis900_check_mode(struct nic *nic)
  33160. {
  33161. int speed, duplex;
  33162. u32 tx_flags = 0, rx_flags = 0;
  33163. mii.chip_info->read_mode(nic, cur_phy, &speed, &duplex);
  33164. - tx_flags = TxATP | (TX_DMA_BURST << TxMXDMA_shift) | (TX_FILL_THRESH << TxFILLT_shift);
  33165. - rx_flags = RX_DMA_BURST << RxMXDMA_shift;
  33166. + if( inl(ioaddr + cfg) & EDB_MASTER_EN ) {
  33167. + tx_flags = TxATP | (DMA_BURST_64 << TxMXDMA_shift) | (TX_FILL_THRESH << TxFILLT_shift);
  33168. + rx_flags = DMA_BURST_64 << RxMXDMA_shift;
  33169. + }
  33170. + else {
  33171. + tx_flags = TxATP | (DMA_BURST_512 << TxMXDMA_shift) | (TX_FILL_THRESH << TxFILLT_shift);
  33172. + rx_flags = DMA_BURST_512 << RxMXDMA_shift;
  33173. + }
  33174. if (speed == HW_SPEED_HOME || speed == HW_SPEED_10_MBPS) {
  33175. rx_flags |= (RxDRNT_10 << RxDRNT_shift);
  33176. @@ -702,7 +827,6 @@
  33177. outl (rx_flags, ioaddr + rxcfg);
  33178. }
  33179. -
  33180. /* Function: sis900_read_mode
  33181. *
  33182. * Description: retrieves and displays speed and duplex
  33183. @@ -714,24 +838,33 @@
  33184. */
  33185. static void
  33186. -sis900_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex)
  33187. +sis900_read_mode(struct nic *nic __unused, int phy_addr, int *speed, int *duplex)
  33188. {
  33189. int i = 0;
  33190. u32 status;
  33191. + u16 phy_id0, phy_id1;
  33192. /* STSOUT register is Latched on Transition, read operation updates it */
  33193. while (i++ < 2)
  33194. status = sis900_mdio_read(phy_addr, MII_STSOUT);
  33195. - if (status & MII_STSOUT_SPD)
  33196. - *speed = HW_SPEED_100_MBPS;
  33197. - else
  33198. - *speed = HW_SPEED_10_MBPS;
  33199. -
  33200. - if (status & MII_STSOUT_DPLX)
  33201. - *duplex = FDX_CAPABLE_FULL_SELECTED;
  33202. - else
  33203. - *duplex = FDX_CAPABLE_HALF_SELECTED;
  33204. + *speed = HW_SPEED_10_MBPS;
  33205. + *duplex = FDX_CAPABLE_HALF_SELECTED;
  33206. +
  33207. + if (status & (MII_NWAY_TX | MII_NWAY_TX_FDX))
  33208. + *speed = HW_SPEED_100_MBPS;
  33209. + if (status & ( MII_NWAY_TX_FDX | MII_NWAY_T_FDX))
  33210. + *duplex = FDX_CAPABLE_FULL_SELECTED;
  33211. +
  33212. + /* Workaround for Realtek RTL8201 PHY issue */
  33213. + phy_id0 = sis900_mdio_read(phy_addr, MII_PHY_ID0);
  33214. + phy_id1 = sis900_mdio_read(phy_addr, MII_PHY_ID1);
  33215. + if((phy_id0 == 0x0000) && ((phy_id1 & 0xFFF0) == 0x8200)){
  33216. + if(sis900_mdio_read(phy_addr, MII_CONTROL) & MII_CNTL_FDX)
  33217. + *duplex = FDX_CAPABLE_FULL_SELECTED;
  33218. + if(sis900_mdio_read(phy_addr, 0x0019) & 0x01)
  33219. + *speed = HW_SPEED_100_MBPS;
  33220. + }
  33221. if (status & MII_STSOUT_LINK_FAIL)
  33222. printf("sis900_read_mode: Media Link Off\n");
  33223. @@ -743,7 +876,6 @@
  33224. "full" : "half");
  33225. }
  33226. -
  33227. /* Function: amd79c901_read_mode
  33228. *
  33229. * Description: retrieves and displays speed and duplex
  33230. @@ -755,7 +887,7 @@
  33231. */
  33232. static void
  33233. -amd79c901_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex)
  33234. +amd79c901_read_mode(struct nic *nic __unused, int phy_addr, int *speed, int *duplex)
  33235. {
  33236. int i;
  33237. u16 status;
  33238. @@ -796,7 +928,6 @@
  33239. }
  33240. }
  33241. -
  33242. /**
  33243. * ics1893_read_mode: - read media mode for ICS1893 PHY
  33244. * @net_dev: the net device to read mode for
  33245. @@ -808,7 +939,7 @@
  33246. * to determine the speed and duplex mode for sis900
  33247. */
  33248. -static void ics1893_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex)
  33249. +static void ics1893_read_mode(struct nic *nic __unused, int phy_addr, int *speed, int *duplex)
  33250. {
  33251. int i = 0;
  33252. u32 status;
  33253. @@ -848,7 +979,7 @@
  33254. * to determine the speed and duplex mode for sis900
  33255. */
  33256. -static void rtl8201_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex)
  33257. +static void rtl8201_read_mode(struct nic *nic __unused, int phy_addr, int *speed, int *duplex)
  33258. {
  33259. u32 status;
  33260. @@ -878,7 +1009,51 @@
  33261. *duplex == FDX_CAPABLE_FULL_SELECTED ?
  33262. "full" : "half");
  33263. else
  33264. - printf("rtl9201_read_config_mode: Media Link Off\n");
  33265. + printf("rtl8201_read_config_mode: Media Link Off\n");
  33266. +}
  33267. +
  33268. +/**
  33269. + * vt6103_read_mode: - read media mode for vt6103 phy
  33270. + * @nic: the net device to read mode for
  33271. + * @phy_addr: mii phy address
  33272. + * @speed: the transmit speed to be determined
  33273. + * @duplex: the duplex mode to be determined
  33274. + *
  33275. + * read MII_STATUS register from rtl8201 phy
  33276. + * to determine the speed and duplex mode for sis900
  33277. + */
  33278. +
  33279. +static void vt6103_read_mode(struct nic *nic __unused, int phy_addr, int *speed, int *duplex)
  33280. +{
  33281. + u32 status;
  33282. +
  33283. + status = sis900_mdio_read(phy_addr, MII_STATUS);
  33284. +
  33285. + if (status & MII_STAT_CAN_TX_FDX) {
  33286. + *speed = HW_SPEED_100_MBPS;
  33287. + *duplex = FDX_CAPABLE_FULL_SELECTED;
  33288. + }
  33289. + else if (status & MII_STAT_CAN_TX) {
  33290. + *speed = HW_SPEED_100_MBPS;
  33291. + *duplex = FDX_CAPABLE_HALF_SELECTED;
  33292. + }
  33293. + else if (status & MII_STAT_CAN_T_FDX) {
  33294. + *speed = HW_SPEED_10_MBPS;
  33295. + *duplex = FDX_CAPABLE_FULL_SELECTED;
  33296. + }
  33297. + else if (status & MII_STAT_CAN_T) {
  33298. + *speed = HW_SPEED_10_MBPS;
  33299. + *duplex = FDX_CAPABLE_HALF_SELECTED;
  33300. + }
  33301. +
  33302. + if (status & MII_STAT_LINK)
  33303. + printf("vt6103_read_mode: Media Link On %s %s-duplex \n",
  33304. + *speed == HW_SPEED_100_MBPS ?
  33305. + "100mbps" : "10mbps",
  33306. + *duplex == FDX_CAPABLE_FULL_SELECTED ?
  33307. + "full" : "half");
  33308. + else
  33309. + printf("vt6103_read_config_mode: Media Link Off\n");
  33310. }
  33311. /* Function: sis900_transmit
  33312. @@ -900,14 +1075,14 @@
  33313. unsigned int s, /* size */
  33314. const char *p) /* Packet */
  33315. {
  33316. - u32 status, to, nstype;
  33317. + u32 to, nstype;
  33318. u32 tx_status;
  33319. /* Stop the transmitter */
  33320. - outl(TxDIS, ioaddr + cr);
  33321. + outl(TxDIS | inl(ioaddr + cr), ioaddr + cr);
  33322. /* load Transmit Descriptor Register */
  33323. - outl((u32) &txd, ioaddr + txdp);
  33324. + outl(virt_to_bus(&txd), ioaddr + txdp);
  33325. if (sis900_debug > 1)
  33326. printf("sis900_transmit: TX descriptor register loaded with: %X\n",
  33327. inl(ioaddr + txdp));
  33328. @@ -929,18 +1104,18 @@
  33329. txb[s++] = '\0';
  33330. /* set the transmit buffer descriptor and enable Transmit State Machine */
  33331. - txd.bufptr = (u32) &txb[0];
  33332. + txd.bufptr = virt_to_bus(&txb[0]);
  33333. txd.cmdsts = (u32) OWN | s;
  33334. /* restart the transmitter */
  33335. - outl(TxENA, ioaddr + cr);
  33336. + outl(TxENA | inl(ioaddr + cr), ioaddr + cr);
  33337. if (sis900_debug > 1)
  33338. printf("sis900_transmit: Queued Tx packet size %d.\n", (int) s);
  33339. to = currticks() + TX_TIMEOUT;
  33340. - while ((((volatile u32) tx_status=txd.cmdsts) & OWN) && (currticks() < to))
  33341. + while ((volatile u32) ( tx_status=txd.cmdsts & OWN) && (currticks() < to))
  33342. /* wait */ ;
  33343. if (currticks() >= to) {
  33344. @@ -955,7 +1130,6 @@
  33345. outl(0, ioaddr + imr);
  33346. }
  33347. -
  33348. /* Function: sis900_poll
  33349. *
  33350. * Description: checks for a received packet and returns it if found.
  33351. @@ -971,7 +1145,7 @@
  33352. */
  33353. static int
  33354. -sis900_poll(struct nic *nic)
  33355. +sis900_poll(struct nic *nic, int retrieve)
  33356. {
  33357. u32 rx_status = rxd[cur_rx].cmdsts;
  33358. int retstat = 0;
  33359. @@ -986,6 +1160,8 @@
  33360. printf("sis900_poll: got a packet: cur_rx:%d, status:%X\n",
  33361. cur_rx, rx_status);
  33362. + if ( ! retrieve ) return 1;
  33363. +
  33364. nic->packetlen = (rx_status & DSIZE) - CRC_SIZE;
  33365. if (rx_status & (ABORT|OVERRUN|TOOLONG|RUNT|RXISERR|CRCERR|FAERR)) {
  33366. @@ -1001,18 +1177,18 @@
  33367. /* return the descriptor and buffer to receive ring */
  33368. rxd[cur_rx].cmdsts = RX_BUF_SIZE;
  33369. - rxd[cur_rx].bufptr = (u32) &rxb[cur_rx*RX_BUF_SIZE];
  33370. + rxd[cur_rx].bufptr = virt_to_bus(&rxb[cur_rx*RX_BUF_SIZE]);
  33371. if (++cur_rx == NUM_RX_DESC)
  33372. cur_rx = 0;
  33373. /* re-enable the potentially idle receive state machine */
  33374. - outl(RxENA , ioaddr + cr);
  33375. + outl(RxENA | inl(ioaddr + cr), ioaddr + cr);
  33376. return retstat;
  33377. +
  33378. }
  33379. -
  33380. /* Function: sis900_disable
  33381. *
  33382. * Description: Turns off interrupts and stops Tx and Rx engines
  33383. @@ -1023,12 +1199,53 @@
  33384. */
  33385. static void
  33386. -sis900_disable(struct nic *nic)
  33387. +sis900_disable(struct dev *dev)
  33388. {
  33389. + struct nic *nic = (struct nic *)dev;
  33390. + /* merge reset and disable */
  33391. + sis900_init(nic);
  33392. +
  33393. /* Disable interrupts by clearing the interrupt mask. */
  33394. outl(0, ioaddr + imr);
  33395. outl(0, ioaddr + ier);
  33396. /* Stop the chip's Tx and Rx Status Machine */
  33397. - outl(RxDIS | TxDIS, ioaddr + cr);
  33398. + outl(RxDIS | TxDIS | inl(ioaddr + cr), ioaddr + cr);
  33399. +}
  33400. +
  33401. +/* Function: sis900_irq
  33402. + *
  33403. + * Description: Enable, Disable, or Force, interrupts
  33404. + *
  33405. + * Arguments: struct nic *nic: NIC data structure
  33406. + * irq_action_t action: Requested action
  33407. + *
  33408. + * Returns: void.
  33409. + */
  33410. +
  33411. +static void
  33412. +sis900_irq(struct nic *nic __unused, irq_action_t action __unused)
  33413. +{
  33414. + switch ( action ) {
  33415. + case DISABLE :
  33416. + break;
  33417. + case ENABLE :
  33418. + break;
  33419. + case FORCE :
  33420. + break;
  33421. + }
  33422. }
  33423. +
  33424. +static struct pci_id sis900_nics[] = {
  33425. +PCI_ROM(0x1039, 0x0900, "sis900", "SIS900"),
  33426. +PCI_ROM(0x1039, 0x7016, "sis7016", "SIS7016"),
  33427. +};
  33428. +
  33429. +struct pci_driver sis900_driver = {
  33430. + .type = NIC_DRIVER,
  33431. + .name = "SIS900",
  33432. + .probe = sis900_probe,
  33433. + .ids = sis900_nics,
  33434. + .id_count = sizeof(sis900_nics)/sizeof(sis900_nics[0]),
  33435. + .class = 0,
  33436. +};
  33437. diff -Naur grub-0.97.orig/netboot/sis900.h grub-0.97/netboot/sis900.h
  33438. --- grub-0.97.orig/netboot/sis900.h 2003-07-09 11:45:38.000000000 +0000
  33439. +++ grub-0.97/netboot/sis900.h 2005-08-31 19:03:35.000000000 +0000
  33440. @@ -39,14 +39,16 @@
  33441. /* Symbolic names for bits in various registers */
  33442. enum sis900_command_register_bits {
  33443. - RESET = 0x00000100,
  33444. - SWI = 0x00000080,
  33445. - RxRESET = 0x00000020,
  33446. - TxRESET = 0x00000010,
  33447. - RxDIS = 0x00000008,
  33448. - RxENA = 0x00000004,
  33449. - TxDIS = 0x00000002,
  33450. - TxENA = 0x00000001
  33451. + RELOAD = 0x00000400,
  33452. + ACCESSMODE = 0x00000200,
  33453. + RESET = 0x00000100,
  33454. + SWI = 0x00000080,
  33455. + RxRESET = 0x00000020,
  33456. + TxRESET = 0x00000010,
  33457. + RxDIS = 0x00000008,
  33458. + RxENA = 0x00000004,
  33459. + TxDIS = 0x00000002,
  33460. + TxENA = 0x00000001
  33461. };
  33462. enum sis900_configuration_register_bits {
  33463. @@ -57,7 +59,10 @@
  33464. EXD = 0x00000010,
  33465. PESEL = 0x00000008,
  33466. LPM = 0x00000004,
  33467. - BEM = 0x00000001
  33468. + BEM = 0x00000001,
  33469. + RND_CNT = 0x00000400,
  33470. + FAIR_BACKOFF = 0x00000200,
  33471. + EDB_MASTER_EN = 0x00002000
  33472. };
  33473. enum sis900_eeprom_access_reigster_bits {
  33474. @@ -108,6 +113,10 @@
  33475. #define TX_DMA_BURST 0
  33476. #define RX_DMA_BURST 0
  33477. +enum sis900_tx_rx_dma{
  33478. + DMA_BURST_512 = 0, DMA_BURST_64 = 5
  33479. +};
  33480. +
  33481. /* transmit FIFO threshholds */
  33482. #define TX_FILL_THRESH 16 /* 1/4 FIFO size */
  33483. #define TxFILLT_shift 8
  33484. @@ -172,6 +181,11 @@
  33485. EEeraseAll = 0x0120,
  33486. EEwriteAll = 0x0110,
  33487. EEaddrMask = 0x013F,
  33488. + EEcmdShift = 16
  33489. +};
  33490. +/* For SiS962 or SiS963, request the eeprom software access */
  33491. +enum sis96x_eeprom_command {
  33492. + EEREQ = 0x00000400, EEDONE = 0x00000200, EEGNT = 0x00000100
  33493. };
  33494. /* Manamgement Data I/O (mdio) frame */
  33495. @@ -236,7 +250,8 @@
  33496. MII_CONFIG1 = 0x0010,
  33497. MII_CONFIG2 = 0x0011,
  33498. MII_STSOUT = 0x0012,
  33499. - MII_MASK = 0x0013
  33500. + MII_MASK = 0x0013,
  33501. + MII_RESV = 0x0014
  33502. };
  33503. /* mii registers specific to AMD 79C901 */
  33504. @@ -320,7 +335,9 @@
  33505. enum sis900_revision_id {
  33506. SIS630A_900_REV = 0x80, SIS630E_900_REV = 0x81,
  33507. - SIS630S_900_REV = 0x82, SIS630EA1_900_REV = 0x83
  33508. + SIS630S_900_REV = 0x82, SIS630EA1_900_REV = 0x83,
  33509. + SIS630ET_900_REV = 0x84, SIS635A_900_REV = 0x90,
  33510. + SIS96x_900_REV = 0X91, SIS900B_900_REV = 0x03
  33511. };
  33512. enum sis630_revision_id {
  33513. diff -Naur grub-0.97.orig/netboot/sis900.txt grub-0.97/netboot/sis900.txt
  33514. --- grub-0.97.orig/netboot/sis900.txt 2003-07-09 11:45:38.000000000 +0000
  33515. +++ grub-0.97/netboot/sis900.txt 1970-01-01 00:00:00.000000000 +0000
  33516. @@ -1,91 +0,0 @@
  33517. -How I added the SIS900 card to Etherboot
  33518. -
  33519. -Author: Marty Connor (mdc@thinguin.org)
  33520. -
  33521. -Date: 25 Febrary 2001
  33522. -
  33523. -Description:
  33524. -
  33525. -This file is intended to help people who want to write an Etherboot
  33526. -driver or port another driver to Etherboot. It is a starting point.
  33527. -Perhaps someday I may write a more detailed description of writing an
  33528. -Etherboot driver. This text should help get people started, and
  33529. -studying sis900.[ch] should help show the basic structure and
  33530. -techniques involved in writing and Etherboot driver.
  33531. -
  33532. -***********************************************************************
  33533. -
  33534. -0. Back up all the files I need to modify:
  33535. -
  33536. -cd etherboot-4.7.20/src
  33537. -cp Makefile Makefile.orig
  33538. -cp config.c config.c.orig
  33539. -cp pci.h pci.h.orig
  33540. -cp NIC NIC.orig
  33541. -cp cards.h cards.h.orig
  33542. -
  33543. -1. Edit src/Makefile to add SIS900FLAGS to defines
  33544. -
  33545. -SIS900FLAGS= -DINCLUDE_SIS900
  33546. -
  33547. -2. edit src/pci.h to add PCI signatures for card
  33548. -
  33549. -#define PCI_VENDOR_ID_SIS 0x1039
  33550. -#define PCI_DEVICE_ID_SIS900 0x0900
  33551. -#define PCI_DEVICE_ID_SIS7016 0x7016
  33552. -
  33553. -3. Edit src/config.c to add the card to the card probe list
  33554. -
  33555. -#if defined(INCLUDE_NS8390) || defined(INCLUDE_EEPRO100) ||
  33556. - defined(INCLUDE_LANCE) || defined(INCLUDE_EPIC100) ||
  33557. - defined(INCLUDE_TULIP) || defined(INCLUDE_OTULIP) ||
  33558. - defined(INCLUDE_3C90X) || defined(INCLUDE_3C595) ||
  33559. - defined(INCLUDE_RTL8139) || defined(INCLUDE_VIA_RHINE) ||
  33560. - defined(INCLUDE_SIS900) || defined(INCLUDE_W89C840)
  33561. -
  33562. -... and ...
  33563. -
  33564. -#ifdef INCLUDE_SIS900
  33565. - { PCI_VENDOR_ID_SIS, PCI_DEVICE_ID_SIS900,
  33566. - "SIS900", 0, 0, 0, 0},
  33567. - { PCI_VENDOR_ID_SIS, PCI_DEVICE_ID_SIS7016,
  33568. - "SIS7016", 0, 0, 0, 0},
  33569. -#endif
  33570. -
  33571. -... and ...
  33572. -
  33573. -#ifdef INCLUDE_SIS900
  33574. - { "SIS900", sis900_probe, pci_ioaddrs },
  33575. -#endif
  33576. -
  33577. -4. Edit NIC to add sis900 and sis7016 to NIC list
  33578. -
  33579. -# SIS 900 and SIS 7016
  33580. -sis900 sis900 0x1039,0x0900
  33581. -sis7016 sis900 0x1039,0x7016
  33582. -
  33583. -5. Edit cards.h to add sis900 probe routine declaration
  33584. -
  33585. -#ifdef INCLUDE_SIS900
  33586. -extern struct nic *sis900_probe(struct nic *, unsigned short *
  33587. - PCI_ARG(struct pci_device *));
  33588. -#endif
  33589. -
  33590. -***********************************************************************
  33591. -
  33592. -At this point, you can begin creating your driver source file. See
  33593. -the "Writing and Etherboot Driver" section of the Etherboot
  33594. -documentation for some hints. See the skel.c file for a starting
  33595. -point. If there is a Linux driver for the card, you may be able to
  33596. -use that. Copy and learn from existing Etherboot drivers (this is GPL
  33597. -/ Open Source software!).
  33598. -
  33599. -Join the etherboot-developers and etherboot-users mailing lists
  33600. -(information is on etherboot.sourceforge.net) for information and
  33601. -assistance. We invite more developers to help improve Etherboot.
  33602. -
  33603. -Visit the http://etherboot.sourceforge.net, http://thinguin.org,
  33604. -http://rom-o-matic.net, and http://ltsp.org sites for information and
  33605. -assistance.
  33606. -
  33607. -Enjoy.
  33608. diff -Naur grub-0.97.orig/netboot/sk_g16.c grub-0.97/netboot/sk_g16.c
  33609. --- grub-0.97.orig/netboot/sk_g16.c 2003-07-09 11:45:38.000000000 +0000
  33610. +++ grub-0.97/netboot/sk_g16.c 1970-01-01 00:00:00.000000000 +0000
  33611. @@ -1,1160 +0,0 @@
  33612. -/**************************************************************************
  33613. -Etherboot - BOOTP/TFTP Bootstrap Program
  33614. -Schneider & Koch G16 NIC driver for Etherboot
  33615. -heavily based on SK G16 driver from Linux 2.0.36
  33616. -Changes to make it work with Etherboot by Georg Baum <Georg.Baum@gmx.de>
  33617. -***************************************************************************/
  33618. -
  33619. -/*-
  33620. - * Copyright (C) 1994 by PJD Weichmann & SWS Bern, Switzerland
  33621. - *
  33622. - * This software may be used and distributed according to the terms
  33623. - * of the GNU Public License, incorporated herein by reference.
  33624. - *
  33625. - * Module : sk_g16.c
  33626. - *
  33627. - * Version : $Revision: 1.4 $
  33628. - *
  33629. - * Author : Patrick J.D. Weichmann
  33630. - *
  33631. - * Date Created : 94/05/26
  33632. - * Last Updated : $Date: 2002/01/02 21:56:40 $
  33633. - *
  33634. - * Description : Schneider & Koch G16 Ethernet Device Driver for
  33635. - * Linux Kernel >= 1.1.22
  33636. - * Update History :
  33637. - *
  33638. --*/
  33639. -
  33640. -/*
  33641. - * The Schneider & Koch (SK) G16 Network device driver is based
  33642. - * on the 'ni6510' driver from Michael Hipp which can be found at
  33643. - * ftp://sunsite.unc.edu/pub/Linux/system/Network/drivers/nidrivers.tar.gz
  33644. - *
  33645. - * Sources: 1) ni6510.c by M. Hipp
  33646. - * 2) depca.c by D.C. Davies
  33647. - * 3) skeleton.c by D. Becker
  33648. - * 4) Am7990 Local Area Network Controller for Ethernet (LANCE),
  33649. - * AMD, Pub. #05698, June 1989
  33650. - *
  33651. - * Many Thanks for helping me to get things working to:
  33652. - *
  33653. - * A. Cox (A.Cox@swansea.ac.uk)
  33654. - * M. Hipp (mhipp@student.uni-tuebingen.de)
  33655. - * R. Bolz (Schneider & Koch, Germany)
  33656. - *
  33657. - * See README.sk_g16 for details about limitations and bugs for the
  33658. - * current version.
  33659. - *
  33660. - * To Do:
  33661. - * - Support of SK_G8 and other SK Network Cards.
  33662. - * - Autoset memory mapped RAM. Check for free memory and then
  33663. - * configure RAM correctly.
  33664. - * - SK_close should really set card in to initial state.
  33665. - * - Test if IRQ 3 is not switched off. Use autoirq() functionality.
  33666. - * (as in /drivers/net/skeleton.c)
  33667. - * - Implement Multicast addressing. At minimum something like
  33668. - * in depca.c.
  33669. - * - Redo the statistics part.
  33670. - * - Try to find out if the board is in 8 Bit or 16 Bit slot.
  33671. - * If in 8 Bit mode don't use IRQ 11.
  33672. - * - (Try to make it slightly faster.)
  33673. - */
  33674. -
  33675. -/* to get some global routines like printf */
  33676. -#include "etherboot.h"
  33677. -/* to get the interface to the body of the program */
  33678. -#include "nic.h"
  33679. -
  33680. -/* From linux/if_ether.h: */
  33681. -#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */
  33682. -
  33683. -#include "sk_g16.h"
  33684. -
  33685. -/*
  33686. - * Schneider & Koch Card Definitions
  33687. - * =================================
  33688. - */
  33689. -
  33690. -#define SK_NAME "SK_G16"
  33691. -
  33692. -/*
  33693. - * SK_G16 Configuration
  33694. - * --------------------
  33695. - */
  33696. -
  33697. -/*
  33698. - * Abbreviations
  33699. - * -------------
  33700. - *
  33701. - * RAM - used for the 16KB shared memory
  33702. - * Boot_ROM, ROM - are used for referencing the BootEPROM
  33703. - *
  33704. - * SK_ADDR is a symbolic constant used to configure
  33705. - * the behaviour of the driver and the SK_G16.
  33706. - *
  33707. - * SK_ADDR defines the address where the RAM will be mapped into the real
  33708. - * host memory.
  33709. - * valid addresses are from 0xa0000 to 0xfc000 in 16Kbyte steps.
  33710. - */
  33711. -
  33712. -#define SK_ADDR 0xcc000
  33713. -
  33714. -/*
  33715. - * In POS3 are bits A14-A19 of the address bus. These bits can be set
  33716. - * to choose the RAM address. That's why we only can choose the RAM address
  33717. - * in 16KB steps.
  33718. - */
  33719. -
  33720. -#define POS_ADDR (rom_addr>>14) /* Do not change this line */
  33721. -
  33722. -/*
  33723. - * SK_G16 I/O PORT's + IRQ's + Boot_ROM locations
  33724. - * ----------------------------------------------
  33725. - */
  33726. -
  33727. -/*
  33728. - * As nearly every card has also SK_G16 a specified I/O Port region and
  33729. - * only a few possible IRQ's.
  33730. - * In the Installation Guide from Schneider & Koch is listed a possible
  33731. - * Interrupt IRQ2. IRQ2 is always IRQ9 in boards with two cascaded interrupt
  33732. - * controllers. So we use in SK_IRQS IRQ9.
  33733. - */
  33734. -
  33735. -/* Don't touch any of the following #defines. */
  33736. -
  33737. -#define SK_IO_PORTS { 0x100, 0x180, 0x208, 0x220, 0x288, 0x320, 0x328, 0x390, 0 }
  33738. -
  33739. -/*
  33740. - * SK_G16 POS REGISTERS
  33741. - * --------------------
  33742. - */
  33743. -
  33744. -/*
  33745. - * SK_G16 has a Programmable Option Select (POS) Register.
  33746. - * The POS is composed of 8 separate registers (POS0-7) which
  33747. - * are I/O mapped on an address set by the W1 switch.
  33748. - *
  33749. - */
  33750. -
  33751. -#define SK_POS_SIZE 8 /* 8 I/O Ports are used by SK_G16 */
  33752. -
  33753. -#define SK_POS0 ioaddr /* Card-ID Low (R) */
  33754. -#define SK_POS1 ioaddr+1 /* Card-ID High (R) */
  33755. -#define SK_POS2 ioaddr+2 /* Card-Enable, Boot-ROM Disable (RW) */
  33756. -#define SK_POS3 ioaddr+3 /* Base address of RAM */
  33757. -#define SK_POS4 ioaddr+4 /* IRQ */
  33758. -
  33759. -/* POS5 - POS7 are unused */
  33760. -
  33761. -/*
  33762. - * SK_G16 MAC PREFIX
  33763. - * -----------------
  33764. - */
  33765. -
  33766. -/*
  33767. - * Scheider & Koch manufacturer code (00:00:a5).
  33768. - * This must be checked, that we are sure it is a SK card.
  33769. - */
  33770. -
  33771. -#define SK_MAC0 0x00
  33772. -#define SK_MAC1 0x00
  33773. -#define SK_MAC2 0x5a
  33774. -
  33775. -/*
  33776. - * SK_G16 ID
  33777. - * ---------
  33778. - */
  33779. -
  33780. -/*
  33781. - * If POS0,POS1 contain the following ID, then we know
  33782. - * at which I/O Port Address we are.
  33783. - */
  33784. -
  33785. -#define SK_IDLOW 0xfd
  33786. -#define SK_IDHIGH 0x6a
  33787. -
  33788. -
  33789. -/*
  33790. - * LANCE POS Bit definitions
  33791. - * -------------------------
  33792. - */
  33793. -
  33794. -#define SK_ROM_RAM_ON (POS2_CARD)
  33795. -#define SK_ROM_RAM_OFF (POS2_EPROM)
  33796. -#define SK_ROM_ON (inb(SK_POS2) & POS2_CARD)
  33797. -#define SK_ROM_OFF (inb(SK_POS2) | POS2_EPROM)
  33798. -#define SK_RAM_ON (inb(SK_POS2) | POS2_CARD)
  33799. -#define SK_RAM_OFF (inb(SK_POS2) & POS2_EPROM)
  33800. -
  33801. -#define POS2_CARD 0x0001 /* 1 = SK_G16 on 0 = off */
  33802. -#define POS2_EPROM 0x0002 /* 1 = Boot EPROM off 0 = on */
  33803. -
  33804. -/*
  33805. - * SK_G16 Memory mapped Registers
  33806. - * ------------------------------
  33807. - *
  33808. - */
  33809. -
  33810. -#define SK_IOREG (board->ioreg) /* LANCE data registers. */
  33811. -#define SK_PORT (board->port) /* Control, Status register */
  33812. -#define SK_IOCOM (board->iocom) /* I/O Command */
  33813. -
  33814. -/*
  33815. - * SK_G16 Status/Control Register bits
  33816. - * -----------------------------------
  33817. - *
  33818. - * (C) Controlreg (S) Statusreg
  33819. - */
  33820. -
  33821. -/*
  33822. - * Register transfer: 0 = no transfer
  33823. - * 1 = transferring data between LANCE and I/O reg
  33824. - */
  33825. -#define SK_IORUN 0x20
  33826. -
  33827. -/*
  33828. - * LANCE interrupt: 0 = LANCE interrupt occurred
  33829. - * 1 = no LANCE interrupt occurred
  33830. - */
  33831. -#define SK_IRQ 0x10
  33832. -
  33833. -#define SK_RESET 0x08 /* Reset SK_CARD: 0 = RESET 1 = normal */
  33834. -#define SK_RW 0x02 /* 0 = write to 1 = read from */
  33835. -#define SK_ADR 0x01 /* 0 = REG DataPort 1 = RAP Reg addr port */
  33836. -
  33837. -
  33838. -#define SK_RREG SK_RW /* Transferdirection to read from lance */
  33839. -#define SK_WREG 0 /* Transferdirection to write to lance */
  33840. -#define SK_RAP SK_ADR /* Destination Register RAP */
  33841. -#define SK_RDATA 0 /* Destination Register REG DataPort */
  33842. -
  33843. -/*
  33844. - * SK_G16 I/O Command
  33845. - * ------------------
  33846. - */
  33847. -
  33848. -/*
  33849. - * Any bitcombination sets the internal I/O bit (transfer will start)
  33850. - * when written to I/O Command
  33851. - */
  33852. -
  33853. -#define SK_DOIO 0x80 /* Do Transfer */
  33854. -
  33855. -/*
  33856. - * LANCE RAP (Register Address Port).
  33857. - * ---------------------------------
  33858. - */
  33859. -
  33860. -/*
  33861. - * The LANCE internal registers are selected through the RAP.
  33862. - * The Registers are:
  33863. - *
  33864. - * CSR0 - Status and Control flags
  33865. - * CSR1 - Low order bits of initialize block (bits 15:00)
  33866. - * CSR2 - High order bits of initialize block (bits 07:00, 15:08 are reserved)
  33867. - * CSR3 - Allows redefinition of the Bus Master Interface.
  33868. - * This register must be set to 0x0002, which means BSWAP = 0,
  33869. - * ACON = 1, BCON = 0;
  33870. - *
  33871. - */
  33872. -
  33873. -#define CSR0 0x00
  33874. -#define CSR1 0x01
  33875. -#define CSR2 0x02
  33876. -#define CSR3 0x03
  33877. -
  33878. -/*
  33879. - * General Definitions
  33880. - * ===================
  33881. - */
  33882. -
  33883. -/*
  33884. - * Set the number of Tx and Rx buffers, using Log_2(# buffers).
  33885. - * We have 16KB RAM which can be accessed by the LANCE. In the
  33886. - * memory are not only the buffers but also the ring descriptors and
  33887. - * the initialize block.
  33888. - * Don't change anything unless you really know what you do.
  33889. - */
  33890. -
  33891. -#define LC_LOG_TX_BUFFERS 1 /* (2 == 2^^1) 2 Transmit buffers */
  33892. -#define LC_LOG_RX_BUFFERS 2 /* (8 == 2^^3) 8 Receive buffers */
  33893. -
  33894. -/* Descriptor ring sizes */
  33895. -
  33896. -#define TMDNUM (1 << (LC_LOG_TX_BUFFERS)) /* 2 Transmit descriptor rings */
  33897. -#define RMDNUM (1 << (LC_LOG_RX_BUFFERS)) /* 8 Receive Buffers */
  33898. -
  33899. -/* Define Mask for setting RMD, TMD length in the LANCE init_block */
  33900. -
  33901. -#define TMDNUMMASK (LC_LOG_TX_BUFFERS << 29)
  33902. -#define RMDNUMMASK (LC_LOG_RX_BUFFERS << 29)
  33903. -
  33904. -/*
  33905. - * Data Buffer size is set to maximum packet length.
  33906. - */
  33907. -
  33908. -#define PKT_BUF_SZ 1518
  33909. -
  33910. -/*
  33911. - * The number of low I/O ports used by the ethercard.
  33912. - */
  33913. -
  33914. -#define ETHERCARD_TOTAL_SIZE SK_POS_SIZE
  33915. -
  33916. -/*
  33917. - * Portreserve is there to mark the Card I/O Port region as used.
  33918. - * Check_region is to check if the region at ioaddr with the size "size"
  33919. - * is free or not.
  33920. - * Snarf_region allocates the I/O Port region.
  33921. - */
  33922. -
  33923. -#ifndef HAVE_PORTRESERVE
  33924. -
  33925. -#define check_region(ioaddr1, size) 0
  33926. -#define request_region(ioaddr1, size,name) do ; while (0)
  33927. -
  33928. -#endif
  33929. -
  33930. -/*
  33931. - * SK_DEBUG
  33932. - *
  33933. - * Here you can choose what level of debugging wanted.
  33934. - *
  33935. - * If SK_DEBUG and SK_DEBUG2 are undefined, then only the
  33936. - * necessary messages will be printed.
  33937. - *
  33938. - * If SK_DEBUG is defined, there will be many debugging prints
  33939. - * which can help to find some mistakes in configuration or even
  33940. - * in the driver code.
  33941. - *
  33942. - * If SK_DEBUG2 is defined, many many messages will be printed
  33943. - * which normally you don't need. I used this to check the interrupt
  33944. - * routine.
  33945. - *
  33946. - * (If you define only SK_DEBUG2 then only the messages for
  33947. - * checking interrupts will be printed!)
  33948. - *
  33949. - * Normal way of live is:
  33950. - *
  33951. - * For the whole thing get going let both symbolic constants
  33952. - * undefined. If you face any problems and you know what's going
  33953. - * on (you know something about the card and you can interpret some
  33954. - * hex LANCE register output) then define SK_DEBUG
  33955. - *
  33956. - */
  33957. -
  33958. -#undef SK_DEBUG /* debugging */
  33959. -#undef SK_DEBUG2 /* debugging with more verbose report */
  33960. -
  33961. -#ifdef SK_DEBUG
  33962. -#define PRINTF(x) printf x
  33963. -#else
  33964. -#define PRINTF(x) /**/
  33965. -#endif
  33966. -
  33967. -#ifdef SK_DEBUG2
  33968. -#define PRINTF2(x) printf x
  33969. -#else
  33970. -#define PRINTF2(x) /**/
  33971. -#endif
  33972. -
  33973. -/*
  33974. - * SK_G16 RAM
  33975. - *
  33976. - * The components are memory mapped and can be set in a region from
  33977. - * 0x00000 through 0xfc000 in 16KB steps.
  33978. - *
  33979. - * The Network components are: dual ported RAM, Prom, I/O Reg, Status-,
  33980. - * Controlregister and I/O Command.
  33981. - *
  33982. - * dual ported RAM: This is the only memory region which the LANCE chip
  33983. - * has access to. From the Lance it is addressed from 0x0000 to
  33984. - * 0x3fbf. The host accesses it normally.
  33985. - *
  33986. - * PROM: The PROM obtains the ETHERNET-MAC-Address. It is realised as a
  33987. - * 8-Bit PROM, this means only the 16 even addresses are used of the
  33988. - * 32 Byte Address region. Access to a odd address results in invalid
  33989. - * data.
  33990. - *
  33991. - * LANCE I/O Reg: The I/O Reg is build of 4 single Registers, Low-Byte Write,
  33992. - * Hi-Byte Write, Low-Byte Read, Hi-Byte Read.
  33993. - * Transfer from or to the LANCE is always in 16Bit so Low and High
  33994. - * registers are always relevant.
  33995. - *
  33996. - * The Data from the Readregister is not the data in the Writeregister!!
  33997. - *
  33998. - * Port: Status- and Controlregister.
  33999. - * Two different registers which share the same address, Status is
  34000. - * read-only, Control is write-only.
  34001. - *
  34002. - * I/O Command:
  34003. - * Any bitcombination written in here starts the transmission between
  34004. - * Host and LANCE.
  34005. - */
  34006. -
  34007. -typedef struct
  34008. -{
  34009. - unsigned char ram[0x3fc0]; /* 16KB dual ported ram */
  34010. - unsigned char rom[0x0020]; /* 32Byte PROM containing 6Byte MAC */
  34011. - unsigned char res1[0x0010]; /* reserved */
  34012. - unsigned volatile short ioreg;/* LANCE I/O Register */
  34013. - unsigned volatile char port; /* Statusregister and Controlregister */
  34014. - unsigned char iocom; /* I/O Command Register */
  34015. -} SK_RAM;
  34016. -
  34017. -/* struct */
  34018. -
  34019. -/*
  34020. - * This is the structure for the dual ported ram. We
  34021. - * have exactly 16 320 Bytes. In here there must be:
  34022. - *
  34023. - * - Initialize Block (starting at a word boundary)
  34024. - * - Receive and Transmit Descriptor Rings (quadword boundary)
  34025. - * - Data Buffers (arbitrary boundary)
  34026. - *
  34027. - * This is because LANCE has on SK_G16 only access to the dual ported
  34028. - * RAM and nowhere else.
  34029. - */
  34030. -
  34031. -struct SK_ram
  34032. -{
  34033. - struct init_block ib;
  34034. - struct tmd tmde[TMDNUM];
  34035. - struct rmd rmde[RMDNUM];
  34036. - char tmdbuf[TMDNUM][PKT_BUF_SZ];
  34037. - char rmdbuf[RMDNUM][PKT_BUF_SZ];
  34038. -};
  34039. -
  34040. -/*
  34041. - * Structure where all necessary information is for ring buffer
  34042. - * management and statistics.
  34043. - */
  34044. -
  34045. -struct priv
  34046. -{
  34047. - struct SK_ram *ram; /* dual ported ram structure */
  34048. - struct rmd *rmdhead; /* start of receive ring descriptors */
  34049. - struct tmd *tmdhead; /* start of transmit ring descriptors */
  34050. - int rmdnum; /* actual used ring descriptor */
  34051. - int tmdnum; /* actual transmit descriptor for transmitting data */
  34052. - int tmdlast; /* last sent descriptor used for error handling, etc */
  34053. - void *rmdbufs[RMDNUM]; /* pointer to the receive buffers */
  34054. - void *tmdbufs[TMDNUM]; /* pointer to the transmit buffers */
  34055. -};
  34056. -
  34057. -/* global variable declaration */
  34058. -
  34059. -/* static variables */
  34060. -
  34061. -static SK_RAM *board; /* pointer to our memory mapped board components */
  34062. -static unsigned short ioaddr; /* base io address */
  34063. -static struct priv p_data;
  34064. -
  34065. -/* Macros */
  34066. -
  34067. -
  34068. -/* Function Prototypes */
  34069. -
  34070. -/*
  34071. - * Device Driver functions
  34072. - * -----------------------
  34073. - * See for short explanation of each function its definitions header.
  34074. - */
  34075. -
  34076. -static int SK_probe1(struct nic *nic, short ioaddr1);
  34077. -
  34078. -static void SK_reset(struct nic *nic);
  34079. -static int SK_poll(struct nic *nic);
  34080. -static void SK_transmit(
  34081. -struct nic *nic,
  34082. -const char *d, /* Destination */
  34083. -unsigned int t, /* Type */
  34084. -unsigned int s, /* size */
  34085. -const char *p); /* Packet */
  34086. -static void SK_disable(struct nic *nic);
  34087. -struct nic *SK_probe(struct nic *nic, unsigned short *probe_addrs);
  34088. -
  34089. -/*
  34090. - * LANCE Functions
  34091. - * ---------------
  34092. - */
  34093. -
  34094. -static int SK_lance_init(struct nic *nic, unsigned short mode);
  34095. -static void SK_reset_board(void);
  34096. -static void SK_set_RAP(int reg_number);
  34097. -static int SK_read_reg(int reg_number);
  34098. -static int SK_rread_reg(void);
  34099. -static void SK_write_reg(int reg_number, int value);
  34100. -
  34101. -/*
  34102. - * Debugging functions
  34103. - * -------------------
  34104. - */
  34105. -
  34106. -static void SK_print_pos(struct nic *nic, char *text);
  34107. -static void SK_print_ram(struct nic *nic);
  34108. -
  34109. -
  34110. -/**************************************************************************
  34111. -RESET - Reset adapter
  34112. -***************************************************************************/
  34113. -static void SK_reset(struct nic *nic)
  34114. -{
  34115. - /* put the card in its initial state */
  34116. - SK_lance_init(nic, MODE_NORMAL);
  34117. -}
  34118. -
  34119. -/**************************************************************************
  34120. -POLL - Wait for a frame
  34121. -***************************************************************************/
  34122. -static int SK_poll(struct nic *nic)
  34123. -{
  34124. - /* return true if there's an ethernet packet ready to read */
  34125. - struct priv *p; /* SK_G16 private structure */
  34126. - struct rmd *rmdp;
  34127. - int csr0, rmdstat, packet_there;
  34128. - PRINTF2(("## %s: At beginning of SK_poll(). CSR0: %#hX\n",
  34129. - SK_NAME, SK_read_reg(CSR0)));
  34130. -
  34131. - p = nic->priv_data;
  34132. - csr0 = SK_read_reg(CSR0); /* store register for checking */
  34133. -
  34134. - /*
  34135. - * Acknowledge all of the current interrupt sources, disable
  34136. - * Interrupts (INEA = 0)
  34137. - */
  34138. -
  34139. - SK_write_reg(CSR0, csr0 & CSR0_CLRALL);
  34140. -
  34141. - if (csr0 & CSR0_ERR) /* LANCE Error */
  34142. - {
  34143. - printf("%s: error: %#hX", SK_NAME, csr0);
  34144. -
  34145. - if (csr0 & CSR0_MISS) /* No place to store packet ? */
  34146. - {
  34147. - printf(", Packet dropped.");
  34148. - }
  34149. - putchar('\n');
  34150. - }
  34151. -
  34152. - rmdp = p->rmdhead + p->rmdnum;
  34153. - packet_there = 0;
  34154. - /* As long as we own the next entry, check status and send
  34155. - * it up to higher layer
  34156. - */
  34157. -
  34158. - while (!( (rmdstat = rmdp->u.s.status) & RX_OWN))
  34159. - {
  34160. - /*
  34161. - * Start and end of packet must be set, because we use
  34162. - * the ethernet maximum packet length (1518) as buffer size.
  34163. - *
  34164. - * Because our buffers are at maximum OFLO and BUFF errors are
  34165. - * not to be concerned (see Data sheet)
  34166. - */
  34167. -
  34168. - if ((rmdstat & (RX_STP | RX_ENP)) != (RX_STP | RX_ENP))
  34169. - {
  34170. - /* Start of a frame > 1518 Bytes ? */
  34171. -
  34172. - if (rmdstat & RX_STP)
  34173. - {
  34174. - printf("%s: packet too long\n", SK_NAME);
  34175. - }
  34176. -
  34177. - /*
  34178. - * All other packets will be ignored until a new frame with
  34179. - * start (RX_STP) set follows.
  34180. - *
  34181. - * What we do is just give descriptor free for new incoming
  34182. - * packets.
  34183. - */
  34184. -
  34185. - rmdp->u.s.status = RX_OWN; /* Relinquish ownership to LANCE */
  34186. -
  34187. - }
  34188. - else if (rmdstat & RX_ERR) /* Receive Error ? */
  34189. - {
  34190. - printf("%s: RX error: %#hX\n", SK_NAME, (int) rmdstat);
  34191. - rmdp->u.s.status = RX_OWN; /* Relinquish ownership to LANCE */
  34192. - }
  34193. - else /* We have a packet which can be queued for the upper layers */
  34194. - {
  34195. -
  34196. - int len = (rmdp->mlen & 0x0fff); /* extract message length from receive buffer */
  34197. -
  34198. - /*
  34199. - * Copy data out of our receive descriptor into nic->packet.
  34200. - *
  34201. - * (rmdp->u.buffer & 0x00ffffff) -> get address of buffer and
  34202. - * ignore status fields)
  34203. - */
  34204. -
  34205. - memcpy(nic->packet, (unsigned char *) (rmdp->u.buffer & 0x00ffffff), nic->packetlen = len);
  34206. - packet_there = 1;
  34207. -
  34208. -
  34209. - /*
  34210. - * Packet is queued and marked for processing so we
  34211. - * free our descriptor
  34212. - */
  34213. -
  34214. - rmdp->u.s.status = RX_OWN;
  34215. -
  34216. - p->rmdnum++;
  34217. - p->rmdnum %= RMDNUM;
  34218. -
  34219. - rmdp = p->rmdhead + p->rmdnum;
  34220. - }
  34221. - }
  34222. - SK_write_reg(CSR0, CSR0_INEA); /* Enable Interrupts */
  34223. - return (packet_there);
  34224. -}
  34225. -
  34226. -/**************************************************************************
  34227. -TRANSMIT - Transmit a frame
  34228. -***************************************************************************/
  34229. -static void SK_transmit(
  34230. -struct nic *nic,
  34231. -const char *d, /* Destination */
  34232. -unsigned int t, /* Type */
  34233. -unsigned int s, /* size */
  34234. -const char *pack) /* Packet */
  34235. -{
  34236. - /* send the packet to destination */
  34237. - struct priv *p; /* SK_G16 private structure */
  34238. - struct tmd *tmdp;
  34239. - short len;
  34240. - int csr0, i, tmdstat;
  34241. -
  34242. - PRINTF2(("## %s: At beginning of SK_transmit(). CSR0: %#hX\n",
  34243. - SK_NAME, SK_read_reg(CSR0)));
  34244. - p = nic->priv_data;
  34245. - tmdp = p->tmdhead + p->tmdnum; /* Which descriptor for transmitting */
  34246. -
  34247. - /* Copy data into dual ported ram */
  34248. -
  34249. - memcpy(&p->ram->tmdbuf[p->tmdnum][0], d, ETH_ALEN); /* dst */
  34250. - memcpy(&p->ram->tmdbuf[p->tmdnum][ETH_ALEN], nic->node_addr, ETH_ALEN); /* src */
  34251. - p->ram->tmdbuf[p->tmdnum][ETH_ALEN + ETH_ALEN] = t >> 8; /* type */
  34252. - p->ram->tmdbuf[p->tmdnum][ETH_ALEN + ETH_ALEN + 1] = t; /* type */
  34253. - memcpy(&p->ram->tmdbuf[p->tmdnum][ETH_HLEN], pack, s);
  34254. - s += ETH_HLEN;
  34255. - while (s < ETH_ZLEN) /* pad to min length */
  34256. - p->ram->tmdbuf[p->tmdnum][s++] = 0;
  34257. - p->ram->tmde[p->tmdnum].status2 = 0x0;
  34258. -
  34259. - /* Evaluate Packet length */
  34260. - len = ETH_ZLEN < s ? s : ETH_ZLEN;
  34261. -
  34262. - /* Fill in Transmit Message Descriptor */
  34263. -
  34264. - tmdp->blen = -len; /* set length to transmit */
  34265. -
  34266. - /*
  34267. - * Packet start and end is always set because we use the maximum
  34268. - * packet length as buffer length.
  34269. - * Relinquish ownership to LANCE
  34270. - */
  34271. -
  34272. - tmdp->u.s.status = TX_OWN | TX_STP | TX_ENP;
  34273. -
  34274. - /* Start Demand Transmission */
  34275. - SK_write_reg(CSR0, CSR0_TDMD | CSR0_INEA);
  34276. -
  34277. - csr0 = SK_read_reg(CSR0); /* store register for checking */
  34278. -
  34279. - /*
  34280. - * Acknowledge all of the current interrupt sources, disable
  34281. - * Interrupts (INEA = 0)
  34282. - */
  34283. -
  34284. - SK_write_reg(CSR0, csr0 & CSR0_CLRALL);
  34285. -
  34286. - if (csr0 & CSR0_ERR) /* LANCE Error */
  34287. - {
  34288. - printf("%s: error: %#hX", SK_NAME, csr0);
  34289. -
  34290. - if (csr0 & CSR0_MISS) /* No place to store packet ? */
  34291. - {
  34292. - printf(", Packet dropped.");
  34293. - }
  34294. - putchar('\n');
  34295. - }
  34296. -
  34297. -
  34298. - /* Set next buffer */
  34299. - p->tmdlast++;
  34300. - p->tmdlast &= TMDNUM-1;
  34301. -
  34302. - tmdstat = tmdp->u.s.status & 0xff00; /* filter out status bits 15:08 */
  34303. -
  34304. - /*
  34305. - * We check status of transmitted packet.
  34306. - * see LANCE data-sheet for error explanation
  34307. - */
  34308. - if (tmdstat & TX_ERR) /* Error occurred */
  34309. - {
  34310. - printf("%s: TX error: %#hX %#hX\n", SK_NAME, (int) tmdstat,
  34311. - (int) tmdp->status2);
  34312. -
  34313. - if (tmdp->status2 & TX_TDR) /* TDR problems? */
  34314. - {
  34315. - printf("%s: tdr-problems \n", SK_NAME);
  34316. - }
  34317. -
  34318. - if (tmdp->status2 & TX_UFLO) /* Underflow error ? */
  34319. - {
  34320. - /*
  34321. - * If UFLO error occurs it will turn transmitter of.
  34322. - * So we must reinit LANCE
  34323. - */
  34324. -
  34325. - SK_lance_init(nic, MODE_NORMAL);
  34326. - }
  34327. -
  34328. - tmdp->status2 = 0; /* Clear error flags */
  34329. - }
  34330. -
  34331. - SK_write_reg(CSR0, CSR0_INEA); /* Enable Interrupts */
  34332. -
  34333. - /* Set pointer to next transmit buffer */
  34334. - p->tmdnum++;
  34335. - p->tmdnum &= TMDNUM-1;
  34336. -
  34337. -}
  34338. -
  34339. -/**************************************************************************
  34340. -DISABLE - Turn off ethernet interface
  34341. -***************************************************************************/
  34342. -static void SK_disable(struct nic *nic)
  34343. -{
  34344. - PRINTF(("## %s: At beginning of SK_disable(). CSR0: %#hX\n",
  34345. - SK_NAME, SK_read_reg(CSR0)));
  34346. - PRINTF(("%s: Shutting %s down CSR0 %#hX\n", SK_NAME, SK_NAME,
  34347. - (int) SK_read_reg(CSR0)));
  34348. -
  34349. - SK_write_reg(CSR0, CSR0_STOP); /* STOP the LANCE */
  34350. -}
  34351. -
  34352. -/**************************************************************************
  34353. -PROBE - Look for an adapter, this routine's visible to the outside
  34354. -***************************************************************************/
  34355. -struct nic *SK_probe(struct nic *nic, unsigned short *probe_addrs)
  34356. -{
  34357. - unsigned short *p;
  34358. - static unsigned short io_addrs[] = SK_IO_PORTS;
  34359. - /* if probe_addrs is 0, then routine can use a hardwired default */
  34360. - putchar('\n');
  34361. - nic->priv_data = &p_data;
  34362. - if (probe_addrs == 0)
  34363. - probe_addrs = io_addrs;
  34364. - for (p = probe_addrs; (ioaddr = *p) != 0; ++p)
  34365. - {
  34366. - long offset1, offset0 = inb(ioaddr);
  34367. - if ((offset0 == SK_IDLOW) &&
  34368. - ((offset1 = inb(ioaddr + 1)) == SK_IDHIGH))
  34369. - if (SK_probe1(nic, ioaddr) >= 0)
  34370. - break;
  34371. - }
  34372. - /* if board found */
  34373. - if (ioaddr != 0)
  34374. - {
  34375. - /* point to NIC specific routines */
  34376. - nic->reset = SK_reset;
  34377. - nic->poll = SK_poll;
  34378. - nic->transmit = SK_transmit;
  34379. - nic->disable = SK_disable;
  34380. - return nic;
  34381. - }
  34382. - /* else */
  34383. - {
  34384. - return 0;
  34385. - }
  34386. -}
  34387. -
  34388. -int SK_probe1(struct nic *nic, short ioaddr1)
  34389. -{
  34390. - int i,j; /* Counters */
  34391. - int sk_addr_flag = 0; /* SK ADDR correct? 1 - no, 0 - yes */
  34392. - unsigned int rom_addr; /* used to store RAM address used for POS_ADDR */
  34393. -
  34394. - struct priv *p; /* SK_G16 private structure */
  34395. -
  34396. - if (SK_ADDR & 0x3fff || SK_ADDR < 0xa0000)
  34397. - {
  34398. - /*
  34399. - * Now here we could use a routine which searches for a free
  34400. - * place in the ram and set SK_ADDR if found. TODO.
  34401. - */
  34402. - printf("%s: SK_ADDR %#hX is not valid. Check configuration.\n",
  34403. - SK_NAME, SK_ADDR);
  34404. - return -1;
  34405. - }
  34406. -
  34407. - rom_addr = SK_ADDR;
  34408. -
  34409. - outb(SK_ROM_RAM_OFF, SK_POS2); /* Boot_ROM + RAM off */
  34410. - outb(POS_ADDR, SK_POS3); /* Set RAM address */
  34411. - outb(SK_ROM_RAM_ON, SK_POS2); /* RAM on, BOOT_ROM on */
  34412. -#ifdef SK_DEBUG
  34413. - SK_print_pos(nic, "POS registers after ROM, RAM config");
  34414. -#endif
  34415. -
  34416. - board = (SK_RAM *) rom_addr;
  34417. - PRINTF(("adr[0]: %hX, adr[1]: %hX, adr[2]: %hX\n",
  34418. - board->rom[0], board->rom[2], board->rom[4]));
  34419. -
  34420. - /* Read in station address */
  34421. - for (i = 0, j = 0; i < ETH_ALEN; i++, j+=2)
  34422. - {
  34423. - *(nic->node_addr+i) = board->rom[j];
  34424. - }
  34425. -
  34426. - /* Check for manufacturer code */
  34427. -#ifdef SK_DEBUG
  34428. - if (!(*(nic->node_addr+0) == SK_MAC0 &&
  34429. - *(nic->node_addr+1) == SK_MAC1 &&
  34430. - *(nic->node_addr+2) == SK_MAC2) )
  34431. - {
  34432. - PRINTF(("## %s: We did not find SK_G16 at RAM location.\n",
  34433. - SK_NAME));
  34434. - return -1; /* NO SK_G16 found */
  34435. - }
  34436. -#endif
  34437. -
  34438. - p = nic->priv_data;
  34439. -
  34440. - /* Initialize private structure */
  34441. -
  34442. - p->ram = (struct SK_ram *) rom_addr; /* Set dual ported RAM addr */
  34443. - p->tmdhead = &(p->ram)->tmde[0]; /* Set TMD head */
  34444. - p->rmdhead = &(p->ram)->rmde[0]; /* Set RMD head */
  34445. -
  34446. - printf("Schneider & Koch G16 at %#hX, mem at %#hX, HW addr: %!\n",
  34447. - (unsigned int) ioaddr, (unsigned int) p->ram, nic->node_addr);
  34448. -
  34449. - /* Initialize buffer pointers */
  34450. -
  34451. - for (i = 0; i < TMDNUM; i++)
  34452. - {
  34453. - p->tmdbufs[i] = p->ram->tmdbuf[i];
  34454. - }
  34455. -
  34456. - for (i = 0; i < RMDNUM; i++)
  34457. - {
  34458. - p->rmdbufs[i] = p->ram->rmdbuf[i];
  34459. - }
  34460. - i = 0;
  34461. -
  34462. - if (!(i = SK_lance_init(nic, MODE_NORMAL))) /* LANCE init OK? */
  34463. - {
  34464. -
  34465. -#ifdef SK_DEBUG
  34466. - /*
  34467. - * This debug block tries to stop LANCE,
  34468. - * reinit LANCE with transmitter and receiver disabled,
  34469. - * then stop again and reinit with NORMAL_MODE
  34470. - */
  34471. -
  34472. - printf("## %s: After lance init. CSR0: %#hX\n",
  34473. - SK_NAME, SK_read_reg(CSR0));
  34474. - SK_write_reg(CSR0, CSR0_STOP);
  34475. - printf("## %s: LANCE stopped. CSR0: %#hX\n",
  34476. - SK_NAME, SK_read_reg(CSR0));
  34477. - SK_lance_init(nic, MODE_DTX | MODE_DRX);
  34478. - printf("## %s: Reinit with DTX + DRX off. CSR0: %#hX\n",
  34479. - SK_NAME, SK_read_reg(CSR0));
  34480. - SK_write_reg(CSR0, CSR0_STOP);
  34481. - printf("## %s: LANCE stopped. CSR0: %#hX\n",
  34482. - SK_NAME, SK_read_reg(CSR0));
  34483. - SK_lance_init(nic, MODE_NORMAL);
  34484. - printf("## %s: LANCE back to normal mode. CSR0: %#hX\n",
  34485. - SK_NAME, SK_read_reg(CSR0));
  34486. - SK_print_pos(nic, "POS regs before returning OK");
  34487. -
  34488. -#endif /* SK_DEBUG */
  34489. -
  34490. - }
  34491. - else /* LANCE init failed */
  34492. - {
  34493. -
  34494. - PRINTF(("## %s: LANCE init failed: CSR0: %#hX\n",
  34495. - SK_NAME, SK_read_reg(CSR0)));
  34496. - return -1;
  34497. - }
  34498. -
  34499. -#ifdef SK_DEBUG
  34500. - SK_print_pos(nic, "End of SK_probe1");
  34501. - SK_print_ram(nic);
  34502. -#endif
  34503. -
  34504. - return 0; /* Initialization done */
  34505. -
  34506. -} /* End of SK_probe1() */
  34507. -
  34508. -static int SK_lance_init(struct nic *nic, unsigned short mode)
  34509. -{
  34510. - int i;
  34511. - struct priv *p = (struct priv *) nic->priv_data;
  34512. - struct tmd *tmdp;
  34513. - struct rmd *rmdp;
  34514. -
  34515. - PRINTF(("## %s: At beginning of LANCE init. CSR0: %#hX\n",
  34516. - SK_NAME, SK_read_reg(CSR0)));
  34517. -
  34518. - /* Reset LANCE */
  34519. - SK_reset_board();
  34520. -
  34521. - /* Initialize TMD's with start values */
  34522. - p->tmdnum = 0; /* First descriptor for transmitting */
  34523. - p->tmdlast = 0; /* First descriptor for reading stats */
  34524. -
  34525. - for (i = 0; i < TMDNUM; i++) /* Init all TMD's */
  34526. - {
  34527. - tmdp = p->tmdhead + i;
  34528. -
  34529. - tmdp->u.buffer = (unsigned long) p->tmdbufs[i]; /* assign buffer */
  34530. -
  34531. - /* Mark TMD as start and end of packet */
  34532. - tmdp->u.s.status = TX_STP | TX_ENP;
  34533. - }
  34534. -
  34535. -
  34536. - /* Initialize RMD's with start values */
  34537. -
  34538. - p->rmdnum = 0; /* First RMD which will be used */
  34539. -
  34540. - for (i = 0; i < RMDNUM; i++) /* Init all RMD's */
  34541. - {
  34542. - rmdp = p->rmdhead + i;
  34543. -
  34544. -
  34545. - rmdp->u.buffer = (unsigned long) p->rmdbufs[i]; /* assign buffer */
  34546. -
  34547. - /*
  34548. - * LANCE must be owner at beginning so that he can fill in
  34549. - * receiving packets, set status and release RMD
  34550. - */
  34551. -
  34552. - rmdp->u.s.status = RX_OWN;
  34553. -
  34554. - rmdp->blen = -PKT_BUF_SZ; /* Buffer Size in a two's complement */
  34555. -
  34556. - rmdp->mlen = 0; /* init message length */
  34557. -
  34558. - }
  34559. -
  34560. - /* Fill LANCE Initialize Block */
  34561. -
  34562. - (p->ram)->ib.mode = mode; /* Set operation mode */
  34563. -
  34564. - for (i = 0; i < ETH_ALEN; i++) /* Set physical address */
  34565. - {
  34566. - (p->ram)->ib.paddr[i] = *(nic->node_addr+i);
  34567. - }
  34568. -
  34569. - for (i = 0; i < 8; i++) /* Set multicast, logical address */
  34570. - {
  34571. - (p->ram)->ib.laddr[i] = 0; /* We do not use logical addressing */
  34572. - }
  34573. -
  34574. - /* Set ring descriptor pointers and set number of descriptors */
  34575. -
  34576. - (p->ram)->ib.rdrp = (int) p->rmdhead | RMDNUMMASK;
  34577. - (p->ram)->ib.tdrp = (int) p->tmdhead | TMDNUMMASK;
  34578. -
  34579. - /* Prepare LANCE Control and Status Registers */
  34580. -
  34581. - SK_write_reg(CSR3, CSR3_ACON); /* Ale Control !!!THIS MUST BE SET!!!! */
  34582. -
  34583. - /*
  34584. - * LANCE addresses the RAM from 0x0000 to 0x3fbf and has no access to
  34585. - * PC Memory locations.
  34586. - *
  34587. - * In structure SK_ram is defined that the first thing in ram
  34588. - * is the initialization block. So his address is for LANCE always
  34589. - * 0x0000
  34590. - *
  34591. - * CSR1 contains low order bits 15:0 of initialization block address
  34592. - * CSR2 is built of:
  34593. - * 7:0 High order bits 23:16 of initialization block address
  34594. - * 15:8 reserved, must be 0
  34595. - */
  34596. -
  34597. - /* Set initialization block address (must be on word boundary) */
  34598. - SK_write_reg(CSR1, 0); /* Set low order bits 15:0 */
  34599. - SK_write_reg(CSR2, 0); /* Set high order bits 23:16 */
  34600. -
  34601. -
  34602. - PRINTF(("## %s: After setting CSR1-3. CSR0: %#hX\n",
  34603. - SK_NAME, SK_read_reg(CSR0)));
  34604. -
  34605. - /* Initialize LANCE */
  34606. -
  34607. - /*
  34608. - * INIT = Initialize, when set, causes the LANCE to begin the
  34609. - * initialization procedure and access the Init Block.
  34610. - */
  34611. -
  34612. - SK_write_reg(CSR0, CSR0_INIT);
  34613. -
  34614. - /* Wait until LANCE finished initialization */
  34615. -
  34616. - SK_set_RAP(CSR0); /* Register Address Pointer to CSR0 */
  34617. -
  34618. - for (i = 0; (i < 100) && !(SK_rread_reg() & CSR0_IDON); i++)
  34619. - ; /* Wait until init done or go ahead if problems (i>=100) */
  34620. -
  34621. - if (i >= 100) /* Something is wrong ! */
  34622. - {
  34623. - printf("%s: can't init am7990, status: %#hX "
  34624. - "init_block: %#hX\n",
  34625. - SK_NAME, (int) SK_read_reg(CSR0),
  34626. - (unsigned int) &(p->ram)->ib);
  34627. -
  34628. -#ifdef SK_DEBUG
  34629. - SK_print_pos(nic, "LANCE INIT failed");
  34630. -#endif
  34631. -
  34632. - return -1; /* LANCE init failed */
  34633. - }
  34634. -
  34635. - PRINTF(("## %s: init done after %d ticks\n", SK_NAME, i));
  34636. -
  34637. - /* Clear Initialize done, enable Interrupts, start LANCE */
  34638. -
  34639. - SK_write_reg(CSR0, CSR0_IDON | CSR0_INEA | CSR0_STRT);
  34640. -
  34641. - PRINTF(("## %s: LANCE started. CSR0: %#hX\n", SK_NAME,
  34642. - SK_read_reg(CSR0)));
  34643. -
  34644. - return 0; /* LANCE is up and running */
  34645. -
  34646. -} /* End of SK_lance_init() */
  34647. -
  34648. -/* LANCE access functions
  34649. - *
  34650. - * ! CSR1-3 can only be accessed when in CSR0 the STOP bit is set !
  34651. - */
  34652. -
  34653. -static void SK_reset_board(void)
  34654. -{
  34655. - int i;
  34656. -
  34657. - PRINTF(("## %s: At beginning of SK_reset_board.\n", SK_NAME));
  34658. - SK_PORT = 0x00; /* Reset active */
  34659. - for (i = 0; i < 10 ; i++) /* Delay min 5ms */
  34660. - ;
  34661. - SK_PORT = SK_RESET; /* Set back to normal operation */
  34662. -
  34663. -} /* End of SK_reset_board() */
  34664. -
  34665. -static void SK_set_RAP(int reg_number)
  34666. -{
  34667. - SK_IOREG = reg_number;
  34668. - SK_PORT = SK_RESET | SK_RAP | SK_WREG;
  34669. - SK_IOCOM = SK_DOIO;
  34670. -
  34671. - while (SK_PORT & SK_IORUN)
  34672. - ;
  34673. -} /* End of SK_set_RAP() */
  34674. -
  34675. -static int SK_read_reg(int reg_number)
  34676. -{
  34677. - SK_set_RAP(reg_number);
  34678. -
  34679. - SK_PORT = SK_RESET | SK_RDATA | SK_RREG;
  34680. - SK_IOCOM = SK_DOIO;
  34681. -
  34682. - while (SK_PORT & SK_IORUN)
  34683. - ;
  34684. - return (SK_IOREG);
  34685. -
  34686. -} /* End of SK_read_reg() */
  34687. -
  34688. -static int SK_rread_reg(void)
  34689. -{
  34690. - SK_PORT = SK_RESET | SK_RDATA | SK_RREG;
  34691. -
  34692. - SK_IOCOM = SK_DOIO;
  34693. -
  34694. - while (SK_PORT & SK_IORUN)
  34695. - ;
  34696. - return (SK_IOREG);
  34697. -
  34698. -} /* End of SK_rread_reg() */
  34699. -
  34700. -static void SK_write_reg(int reg_number, int value)
  34701. -{
  34702. - SK_set_RAP(reg_number);
  34703. -
  34704. - SK_IOREG = value;
  34705. - SK_PORT = SK_RESET | SK_RDATA | SK_WREG;
  34706. - SK_IOCOM = SK_DOIO;
  34707. -
  34708. - while (SK_PORT & SK_IORUN)
  34709. - ;
  34710. -} /* End of SK_write_reg */
  34711. -
  34712. -/*
  34713. - * Debugging functions
  34714. - * -------------------
  34715. - */
  34716. -
  34717. -#ifdef SK_DEBUG
  34718. -static void SK_print_pos(struct nic *nic, char *text)
  34719. -{
  34720. -
  34721. - unsigned char pos0 = inb(SK_POS0),
  34722. - pos1 = inb(SK_POS1),
  34723. - pos2 = inb(SK_POS2),
  34724. - pos3 = inb(SK_POS3),
  34725. - pos4 = inb(SK_POS4);
  34726. -
  34727. -
  34728. - printf("## %s: %s.\n"
  34729. - "## pos0=%#hX pos1=%#hX pos2=%#hX pos3=%#hX pos4=%#hX\n",
  34730. - SK_NAME, text, pos0, pos1, pos2, (pos3<<14), pos4);
  34731. -
  34732. -} /* End of SK_print_pos() */
  34733. -
  34734. -static void SK_print_ram(struct nic *nic)
  34735. -{
  34736. -
  34737. - int i;
  34738. - struct priv *p = (struct priv *) nic->priv_data;
  34739. -
  34740. - printf("## %s: RAM Details.\n"
  34741. - "## RAM at %#hX tmdhead: %#hX rmdhead: %#hX initblock: %#hX\n",
  34742. - SK_NAME,
  34743. - (unsigned int) p->ram,
  34744. - (unsigned int) p->tmdhead,
  34745. - (unsigned int) p->rmdhead,
  34746. - (unsigned int) &(p->ram)->ib);
  34747. -
  34748. - printf("## ");
  34749. -
  34750. - for(i = 0; i < TMDNUM; i++)
  34751. - {
  34752. - if (!(i % 3)) /* Every third line do a newline */
  34753. - {
  34754. - printf("\n## ");
  34755. - }
  34756. - printf("tmdbufs%d: %#hX ", (i+1), (int) p->tmdbufs[i]);
  34757. - }
  34758. - printf("## ");
  34759. -
  34760. - for(i = 0; i < RMDNUM; i++)
  34761. - {
  34762. - if (!(i % 3)) /* Every third line do a newline */
  34763. - {
  34764. - printf("\n## ");
  34765. - }
  34766. - printf("rmdbufs%d: %#hX ", (i+1), (int) p->rmdbufs[i]);
  34767. - }
  34768. - putchar('\n');
  34769. -
  34770. -} /* End of SK_print_ram() */
  34771. -#endif
  34772. diff -Naur grub-0.97.orig/netboot/sk_g16.h grub-0.97/netboot/sk_g16.h
  34773. --- grub-0.97.orig/netboot/sk_g16.h 2003-07-09 11:45:38.000000000 +0000
  34774. +++ grub-0.97/netboot/sk_g16.h 1970-01-01 00:00:00.000000000 +0000
  34775. @@ -1,168 +0,0 @@
  34776. -/*-
  34777. - *
  34778. - * This software may be used and distributed according to the terms
  34779. - * of the GNU Public License, incorporated herein by reference.
  34780. - *
  34781. - * Module : sk_g16.h
  34782. - * Version : $Revision: 1.3 $
  34783. - *
  34784. - * Author : M.Hipp (mhipp@student.uni-tuebingen.de)
  34785. - * changes by : Patrick J.D. Weichmann
  34786. - *
  34787. - * Date Created : 94/05/25
  34788. - *
  34789. - * Description : In here are all necessary definitions of
  34790. - * the am7990 (LANCE) chip used for writing a
  34791. - * network device driver which uses this chip
  34792. - *
  34793. - * $Log: sk_g16.h,v $
  34794. - * Revision 1.3 2000/07/29 19:22:54 okuji
  34795. - * update the network support to etherboot-4.6.4.
  34796. - *
  34797. --*/
  34798. -
  34799. -#ifndef SK_G16_H
  34800. -
  34801. -#define SK_G16_H
  34802. -
  34803. -
  34804. -/*
  34805. - * Control and Status Register 0 (CSR0) bit definitions
  34806. - *
  34807. - * (R=Readable) (W=Writeable) (S=Set on write) (C-Clear on write)
  34808. - *
  34809. - */
  34810. -
  34811. -#define CSR0_ERR 0x8000 /* Error summary (R) */
  34812. -#define CSR0_BABL 0x4000 /* Babble transmitter timeout error (RC) */
  34813. -#define CSR0_CERR 0x2000 /* Collision Error (RC) */
  34814. -#define CSR0_MISS 0x1000 /* Missed packet (RC) */
  34815. -#define CSR0_MERR 0x0800 /* Memory Error (RC) */
  34816. -#define CSR0_RINT 0x0400 /* Receiver Interrupt (RC) */
  34817. -#define CSR0_TINT 0x0200 /* Transmit Interrupt (RC) */
  34818. -#define CSR0_IDON 0x0100 /* Initialization Done (RC) */
  34819. -#define CSR0_INTR 0x0080 /* Interrupt Flag (R) */
  34820. -#define CSR0_INEA 0x0040 /* Interrupt Enable (RW) */
  34821. -#define CSR0_RXON 0x0020 /* Receiver on (R) */
  34822. -#define CSR0_TXON 0x0010 /* Transmitter on (R) */
  34823. -#define CSR0_TDMD 0x0008 /* Transmit Demand (RS) */
  34824. -#define CSR0_STOP 0x0004 /* Stop (RS) */
  34825. -#define CSR0_STRT 0x0002 /* Start (RS) */
  34826. -#define CSR0_INIT 0x0001 /* Initialize (RS) */
  34827. -
  34828. -#define CSR0_CLRALL 0x7f00 /* mask for all clearable bits */
  34829. -
  34830. -/*
  34831. - * Control and Status Register 3 (CSR3) bit definitions
  34832. - *
  34833. - */
  34834. -
  34835. -#define CSR3_BSWAP 0x0004 /* Byte Swap (RW) */
  34836. -#define CSR3_ACON 0x0002 /* ALE Control (RW) */
  34837. -#define CSR3_BCON 0x0001 /* Byte Control (RW) */
  34838. -
  34839. -/*
  34840. - * Initialization Block Mode operation Bit Definitions.
  34841. - */
  34842. -
  34843. -#define MODE_PROM 0x8000 /* Promiscuous Mode */
  34844. -#define MODE_INTL 0x0040 /* Internal Loopback */
  34845. -#define MODE_DRTY 0x0020 /* Disable Retry */
  34846. -#define MODE_COLL 0x0010 /* Force Collision */
  34847. -#define MODE_DTCR 0x0008 /* Disable Transmit CRC) */
  34848. -#define MODE_LOOP 0x0004 /* Loopback */
  34849. -#define MODE_DTX 0x0002 /* Disable the Transmitter */
  34850. -#define MODE_DRX 0x0001 /* Disable the Receiver */
  34851. -
  34852. -#define MODE_NORMAL 0x0000 /* Normal operation mode */
  34853. -
  34854. -/*
  34855. - * Receive message descriptor status bit definitions.
  34856. - */
  34857. -
  34858. -#define RX_OWN 0x80 /* Owner bit 0 = host, 1 = lance */
  34859. -#define RX_ERR 0x40 /* Error Summary */
  34860. -#define RX_FRAM 0x20 /* Framing Error */
  34861. -#define RX_OFLO 0x10 /* Overflow Error */
  34862. -#define RX_CRC 0x08 /* CRC Error */
  34863. -#define RX_BUFF 0x04 /* Buffer Error */
  34864. -#define RX_STP 0x02 /* Start of Packet */
  34865. -#define RX_ENP 0x01 /* End of Packet */
  34866. -
  34867. -
  34868. -/*
  34869. - * Transmit message descriptor status bit definitions.
  34870. - */
  34871. -
  34872. -#define TX_OWN 0x80 /* Owner bit 0 = host, 1 = lance */
  34873. -#define TX_ERR 0x40 /* Error Summary */
  34874. -#define TX_MORE 0x10 /* More the 1 retry needed to Xmit */
  34875. -#define TX_ONE 0x08 /* One retry needed to Xmit */
  34876. -#define TX_DEF 0x04 /* Deferred */
  34877. -#define TX_STP 0x02 /* Start of Packet */
  34878. -#define TX_ENP 0x01 /* End of Packet */
  34879. -
  34880. -/*
  34881. - * Transmit status (2) (valid if TX_ERR == 1)
  34882. - */
  34883. -
  34884. -#define TX_BUFF 0x8000 /* Buffering error (no ENP) */
  34885. -#define TX_UFLO 0x4000 /* Underflow (late memory) */
  34886. -#define TX_LCOL 0x1000 /* Late collision */
  34887. -#define TX_LCAR 0x0400 /* Loss of Carrier */
  34888. -#define TX_RTRY 0x0200 /* Failed after 16 retransmissions */
  34889. -#define TX_TDR 0x003f /* Time-domain-reflectometer-value */
  34890. -
  34891. -
  34892. -/*
  34893. - * Structures used for Communication with the LANCE
  34894. - */
  34895. -
  34896. -/* LANCE Initialize Block */
  34897. -
  34898. -struct init_block
  34899. -{
  34900. - unsigned short mode; /* Mode Register */
  34901. - unsigned char paddr[6]; /* Physical Address (MAC) */
  34902. - unsigned char laddr[8]; /* Logical Filter Address (not used) */
  34903. - unsigned int rdrp; /* Receive Descriptor Ring pointer */
  34904. - unsigned int tdrp; /* Transmit Descriptor Ring pointer */
  34905. -};
  34906. -
  34907. -
  34908. -/* Receive Message Descriptor Entry */
  34909. -
  34910. -struct rmd
  34911. -{
  34912. - union rmd_u
  34913. - {
  34914. - unsigned long buffer; /* Address of buffer */
  34915. - struct rmd_s
  34916. - {
  34917. - unsigned char unused[3];
  34918. - unsigned volatile char status; /* Status Bits */
  34919. - } s;
  34920. - } u;
  34921. - volatile short blen; /* Buffer Length (two's complement) */
  34922. - unsigned short mlen; /* Message Byte Count */
  34923. -};
  34924. -
  34925. -
  34926. -/* Transmit Message Descriptor Entry */
  34927. -
  34928. -struct tmd
  34929. -{
  34930. - union tmd_u
  34931. - {
  34932. - unsigned long buffer; /* Address of buffer */
  34933. - struct tmd_s
  34934. - {
  34935. - unsigned char unused[3];
  34936. - unsigned volatile char status; /* Status Bits */
  34937. - } s;
  34938. - } u;
  34939. - unsigned short blen; /* Buffer Length (two's complement) */
  34940. - unsigned volatile short status2; /* Error Status Bits */
  34941. -};
  34942. -
  34943. -#endif /* End of SK_G16_H */
  34944. diff -Naur grub-0.97.orig/netboot/smc9000.c grub-0.97/netboot/smc9000.c
  34945. --- grub-0.97.orig/netboot/smc9000.c 2003-07-09 11:45:38.000000000 +0000
  34946. +++ grub-0.97/netboot/smc9000.c 1970-01-01 00:00:00.000000000 +0000
  34947. @@ -1,522 +0,0 @@
  34948. - /*------------------------------------------------------------------------
  34949. - * smc9000.c
  34950. - * This is a Etherboot driver for SMC's 9000 series of Ethernet cards.
  34951. - *
  34952. - * Copyright (C) 1998 Daniel Engström <daniel.engstrom@riksnett.no>
  34953. - * Based on the Linux SMC9000 driver, smc9194.c by Eric Stahlman
  34954. - * Copyright (C) 1996 by Erik Stahlman <eric@vt.edu>
  34955. - *
  34956. - * This software may be used and distributed according to the terms
  34957. - * of the GNU Public License, incorporated herein by reference.
  34958. - *
  34959. - * "Features" of the SMC chip:
  34960. - * 4608 byte packet memory. ( for the 91C92/4. Others have more )
  34961. - * EEPROM for configuration
  34962. - * AUI/TP selection
  34963. - *
  34964. - * Authors
  34965. - * Erik Stahlman <erik@vt.edu>
  34966. - * Daniel Engström <daniel.engstrom@riksnett.no>
  34967. - *
  34968. - * History
  34969. - * 98-09-25 Daniel Engström Etherboot driver crated from Eric's
  34970. - * Linux driver.
  34971. - *
  34972. - *---------------------------------------------------------------------------*/
  34973. -#define LINUX_OUT_MACROS 1
  34974. -#define SMC9000_VERBOSE 1
  34975. -#define SMC9000_DEBUG 0
  34976. -
  34977. -#include "etherboot.h"
  34978. -#include "nic.h"
  34979. -#include "cards.h"
  34980. -#include "smc9000.h"
  34981. -
  34982. -# define _outb outb
  34983. -# define _outw outw
  34984. -
  34985. -static const char smc9000_version[] = "Version 0.99 98-09-30";
  34986. -static unsigned int smc9000_base=0;
  34987. -static const char *interfaces[ 2 ] = { "TP", "AUI" };
  34988. -static const char *chip_ids[ 15 ] = {
  34989. - NULL, NULL, NULL,
  34990. - /* 3 */ "SMC91C90/91C92",
  34991. - /* 4 */ "SMC91C94",
  34992. - /* 5 */ "SMC91C95",
  34993. - NULL,
  34994. - /* 7 */ "SMC91C100",
  34995. - /* 8 */ "SMC91C100FD",
  34996. - NULL, NULL, NULL,
  34997. - NULL, NULL, NULL
  34998. -};
  34999. -static const char smc91c96_id[] = "SMC91C96";
  35000. -
  35001. -/*
  35002. - * Function: smc_reset( int ioaddr )
  35003. - * Purpose:
  35004. - * This sets the SMC91xx chip to its normal state, hopefully from whatever
  35005. - * mess that any other DOS driver has put it in.
  35006. - *
  35007. - * Maybe I should reset more registers to defaults in here? SOFTRESET should
  35008. - * do that for me.
  35009. - *
  35010. - * Method:
  35011. - * 1. send a SOFT RESET
  35012. - * 2. wait for it to finish
  35013. - * 3. reset the memory management unit
  35014. - * 4. clear all interrupts
  35015. - *
  35016. -*/
  35017. -static void smc_reset(int ioaddr)
  35018. -{
  35019. - /* This resets the registers mostly to defaults, but doesn't
  35020. - * affect EEPROM. That seems unnecessary */
  35021. - SMC_SELECT_BANK(ioaddr, 0);
  35022. - _outw( RCR_SOFTRESET, ioaddr + RCR );
  35023. -
  35024. - /* this should pause enough for the chip to be happy */
  35025. - SMC_DELAY(ioaddr);
  35026. -
  35027. - /* Set the transmit and receive configuration registers to
  35028. - * default values */
  35029. - _outw(RCR_CLEAR, ioaddr + RCR);
  35030. - _outw(TCR_CLEAR, ioaddr + TCR);
  35031. -
  35032. - /* Reset the MMU */
  35033. - SMC_SELECT_BANK(ioaddr, 2);
  35034. - _outw( MC_RESET, ioaddr + MMU_CMD );
  35035. -
  35036. - /* Note: It doesn't seem that waiting for the MMU busy is needed here,
  35037. - * but this is a place where future chipsets _COULD_ break. Be wary
  35038. - * of issuing another MMU command right after this */
  35039. - _outb(0, ioaddr + INT_MASK);
  35040. -}
  35041. -
  35042. -
  35043. -/*----------------------------------------------------------------------
  35044. - * Function: smc_probe( int ioaddr )
  35045. - *
  35046. - * Purpose:
  35047. - * Tests to see if a given ioaddr points to an SMC9xxx chip.
  35048. - * Returns a 0 on success
  35049. - *
  35050. - * Algorithm:
  35051. - * (1) see if the high byte of BANK_SELECT is 0x33
  35052. - * (2) compare the ioaddr with the base register's address
  35053. - * (3) see if I recognize the chip ID in the appropriate register
  35054. - *
  35055. - * ---------------------------------------------------------------------
  35056. - */
  35057. -static int smc_probe( int ioaddr )
  35058. -{
  35059. - word bank;
  35060. - word revision_register;
  35061. - word base_address_register;
  35062. -
  35063. - /* First, see if the high byte is 0x33 */
  35064. - bank = inw(ioaddr + BANK_SELECT);
  35065. - if ((bank & 0xFF00) != 0x3300) {
  35066. - return -1;
  35067. - }
  35068. - /* The above MIGHT indicate a device, but I need to write to further
  35069. - * test this. */
  35070. - _outw(0x0, ioaddr + BANK_SELECT);
  35071. - bank = inw(ioaddr + BANK_SELECT);
  35072. - if ((bank & 0xFF00) != 0x3300) {
  35073. - return -1;
  35074. - }
  35075. -
  35076. - /* well, we've already written once, so hopefully another time won't
  35077. - * hurt. This time, I need to switch the bank register to bank 1,
  35078. - * so I can access the base address register */
  35079. - SMC_SELECT_BANK(ioaddr, 1);
  35080. - base_address_register = inw(ioaddr + BASE);
  35081. -
  35082. - if (ioaddr != (base_address_register >> 3 & 0x3E0)) {
  35083. -#ifdef SMC9000_VERBOSE
  35084. - printf("SMC9000: IOADDR %hX doesn't match configuration (%hX)."
  35085. - "Probably not a SMC chip\n",
  35086. - ioaddr, base_address_register >> 3 & 0x3E0);
  35087. -#endif
  35088. - /* well, the base address register didn't match. Must not have
  35089. - * been a SMC chip after all. */
  35090. - return -1;
  35091. - }
  35092. -
  35093. -
  35094. - /* check if the revision register is something that I recognize.
  35095. - * These might need to be added to later, as future revisions
  35096. - * could be added. */
  35097. - SMC_SELECT_BANK(ioaddr, 3);
  35098. - revision_register = inw(ioaddr + REVISION);
  35099. - if (!chip_ids[(revision_register >> 4) & 0xF]) {
  35100. - /* I don't recognize this chip, so... */
  35101. -#ifdef SMC9000_VERBOSE
  35102. - printf("SMC9000: IO %hX: Unrecognized revision register:"
  35103. - " %hX, Contact author.\n", ioaddr, revision_register);
  35104. -#endif
  35105. - return -1;
  35106. - }
  35107. -
  35108. - /* at this point I'll assume that the chip is an SMC9xxx.
  35109. - * It might be prudent to check a listing of MAC addresses
  35110. - * against the hardware address, or do some other tests. */
  35111. - return 0;
  35112. -}
  35113. -
  35114. -
  35115. -/**************************************************************************
  35116. - * ETH_RESET - Reset adapter
  35117. - ***************************************************************************/
  35118. -
  35119. -static void smc9000_reset(struct nic *nic)
  35120. -{
  35121. - smc_reset(smc9000_base);
  35122. -}
  35123. -
  35124. -/**************************************************************************
  35125. - * ETH_TRANSMIT - Transmit a frame
  35126. - ***************************************************************************/
  35127. -static void smc9000_transmit(
  35128. - struct nic *nic,
  35129. - const char *d, /* Destination */
  35130. - unsigned int t, /* Type */
  35131. - unsigned int s, /* size */
  35132. - const char *p) /* Packet */
  35133. -{
  35134. - word length; /* real, length incl. header */
  35135. - word numPages;
  35136. - unsigned long time_out;
  35137. - byte packet_no;
  35138. - word status;
  35139. - int i;
  35140. -
  35141. - /* We dont pad here since we can have the hardware doing it for us */
  35142. - length = (s + ETH_HLEN + 1)&~1;
  35143. -
  35144. - /* convert to MMU pages */
  35145. - numPages = length / 256;
  35146. -
  35147. - if (numPages > 7 ) {
  35148. -#ifdef SMC9000_VERBOSE
  35149. - printf("SMC9000: Far too big packet error. \n");
  35150. -#endif
  35151. - return;
  35152. - }
  35153. -
  35154. - /* dont try more than, say 30 times */
  35155. - for (i=0;i<30;i++) {
  35156. - /* now, try to allocate the memory */
  35157. - SMC_SELECT_BANK(smc9000_base, 2);
  35158. - _outw(MC_ALLOC | numPages, smc9000_base + MMU_CMD);
  35159. -
  35160. - status = 0;
  35161. - /* wait for the memory allocation to finnish */
  35162. - for (time_out = currticks() + 5*TICKS_PER_SEC; currticks() < time_out; ) {
  35163. - status = inb(smc9000_base + INTERRUPT);
  35164. - if ( status & IM_ALLOC_INT ) {
  35165. - /* acknowledge the interrupt */
  35166. - _outb(IM_ALLOC_INT, smc9000_base + INTERRUPT);
  35167. - break;
  35168. - }
  35169. - }
  35170. -
  35171. - if ((status & IM_ALLOC_INT) != 0 ) {
  35172. - /* We've got the memory */
  35173. - break;
  35174. - } else {
  35175. - printf("SMC9000: Memory allocation timed out, resetting MMU.\n");
  35176. - _outw(MC_RESET, smc9000_base + MMU_CMD);
  35177. - }
  35178. - }
  35179. -
  35180. - /* If I get here, I _know_ there is a packet slot waiting for me */
  35181. - packet_no = inb(smc9000_base + PNR_ARR + 1);
  35182. - if (packet_no & 0x80) {
  35183. - /* or isn't there? BAD CHIP! */
  35184. - printf("SMC9000: Memory allocation failed. \n");
  35185. - return;
  35186. - }
  35187. -
  35188. - /* we have a packet address, so tell the card to use it */
  35189. - _outb(packet_no, smc9000_base + PNR_ARR);
  35190. -
  35191. - /* point to the beginning of the packet */
  35192. - _outw(PTR_AUTOINC, smc9000_base + POINTER);
  35193. -
  35194. -#if SMC9000_DEBUG > 2
  35195. - printf("Trying to xmit packet of length %hX\n", length );
  35196. -#endif
  35197. -
  35198. - /* send the packet length ( +6 for status, length and ctl byte )
  35199. - * and the status word ( set to zeros ) */
  35200. - _outw(0, smc9000_base + DATA_1 );
  35201. -
  35202. - /* send the packet length ( +6 for status words, length, and ctl) */
  35203. - _outb((length+6) & 0xFF, smc9000_base + DATA_1);
  35204. - _outb((length+6) >> 8 , smc9000_base + DATA_1);
  35205. -
  35206. - /* Write the contents of the packet */
  35207. -
  35208. - /* The ethernet header first... */
  35209. - outsw(smc9000_base + DATA_1, d, ETH_ALEN >> 1);
  35210. - outsw(smc9000_base + DATA_1, nic->node_addr, ETH_ALEN >> 1);
  35211. - _outw(htons(t), smc9000_base + DATA_1);
  35212. -
  35213. - /* ... the data ... */
  35214. - outsw(smc9000_base + DATA_1 , p, s >> 1);
  35215. -
  35216. - /* ... and the last byte, if there is one. */
  35217. - if ((s & 1) == 0) {
  35218. - _outw(0, smc9000_base + DATA_1);
  35219. - } else {
  35220. - _outb(p[s-1], smc9000_base + DATA_1);
  35221. - _outb(0x20, smc9000_base + DATA_1);
  35222. - }
  35223. -
  35224. - /* and let the chipset deal with it */
  35225. - _outw(MC_ENQUEUE , smc9000_base + MMU_CMD);
  35226. -
  35227. - status = 0; time_out = currticks() + 5*TICKS_PER_SEC;
  35228. - do {
  35229. - status = inb(smc9000_base + INTERRUPT);
  35230. -
  35231. - if ((status & IM_TX_INT ) != 0) {
  35232. - word tx_status;
  35233. -
  35234. - /* ack interrupt */
  35235. - _outb(IM_TX_INT, smc9000_base + INTERRUPT);
  35236. -
  35237. - packet_no = inw(smc9000_base + FIFO_PORTS);
  35238. - packet_no &= 0x7F;
  35239. -
  35240. - /* select this as the packet to read from */
  35241. - _outb( packet_no, smc9000_base + PNR_ARR );
  35242. -
  35243. - /* read the first word from this packet */
  35244. - _outw( PTR_AUTOINC | PTR_READ, smc9000_base + POINTER );
  35245. -
  35246. - tx_status = inw( smc9000_base + DATA_1 );
  35247. -
  35248. - if (0 == (tx_status & TS_SUCCESS)) {
  35249. -#ifdef SMC9000_VERBOSE
  35250. - printf("SMC9000: TX FAIL STATUS: %hX \n", tx_status);
  35251. -#endif
  35252. - /* re-enable transmit */
  35253. - SMC_SELECT_BANK(smc9000_base, 0);
  35254. - _outw(inw(smc9000_base + TCR ) | TCR_ENABLE, smc9000_base + TCR );
  35255. - }
  35256. -
  35257. - /* kill the packet */
  35258. - SMC_SELECT_BANK(smc9000_base, 2);
  35259. - _outw(MC_FREEPKT, smc9000_base + MMU_CMD);
  35260. -
  35261. - return;
  35262. - }
  35263. - }while(currticks() < time_out);
  35264. -
  35265. - printf("SMC9000: Waring TX timed out, resetting board\n");
  35266. - smc_reset(smc9000_base);
  35267. - return;
  35268. -}
  35269. -
  35270. -/**************************************************************************
  35271. - * ETH_POLL - Wait for a frame
  35272. - ***************************************************************************/
  35273. -static int smc9000_poll(struct nic *nic)
  35274. -{
  35275. - if(!smc9000_base)
  35276. - return 0;
  35277. -
  35278. - SMC_SELECT_BANK(smc9000_base, 2);
  35279. - if (inw(smc9000_base + FIFO_PORTS) & FP_RXEMPTY)
  35280. - return 0;
  35281. -
  35282. - /* start reading from the start of the packet */
  35283. - _outw(PTR_READ | PTR_RCV | PTR_AUTOINC, smc9000_base + POINTER);
  35284. -
  35285. - /* First read the status and check that we're ok */
  35286. - if (!(inw(smc9000_base + DATA_1) & RS_ERRORS)) {
  35287. - /* Next: read the packet length and mask off the top bits */
  35288. - nic->packetlen = (inw(smc9000_base + DATA_1) & 0x07ff);
  35289. -
  35290. - /* the packet length includes the 3 extra words */
  35291. - nic->packetlen -= 6;
  35292. -#if SMC9000_DEBUG > 2
  35293. - printf(" Reading %d words (and %d byte(s))\n",
  35294. - (nic->packetlen >> 1), nic->packetlen & 1);
  35295. -#endif
  35296. - /* read the packet (and the last "extra" word) */
  35297. - insw(smc9000_base + DATA_1, nic->packet, (nic->packetlen+2) >> 1);
  35298. - /* is there an odd last byte ? */
  35299. - if (nic->packet[nic->packetlen+1] & 0x20)
  35300. - nic->packetlen++;
  35301. -
  35302. - /* error or good, tell the card to get rid of this packet */
  35303. - _outw(MC_RELEASE, smc9000_base + MMU_CMD);
  35304. - return 1;
  35305. - }
  35306. -
  35307. - printf("SMC9000: RX error\n");
  35308. - /* error or good, tell the card to get rid of this packet */
  35309. - _outw(MC_RELEASE, smc9000_base + MMU_CMD);
  35310. - return 0;
  35311. -}
  35312. -
  35313. -static void smc9000_disable(struct nic *nic)
  35314. -{
  35315. - if(!smc9000_base)
  35316. - return;
  35317. -
  35318. - /* no more interrupts for me */
  35319. - SMC_SELECT_BANK(smc9000_base, 2);
  35320. - _outb( 0, smc9000_base + INT_MASK);
  35321. -
  35322. - /* and tell the card to stay away from that nasty outside world */
  35323. - SMC_SELECT_BANK(smc9000_base, 0);
  35324. - _outb( RCR_CLEAR, smc9000_base + RCR );
  35325. - _outb( TCR_CLEAR, smc9000_base + TCR );
  35326. -}
  35327. -
  35328. -/**************************************************************************
  35329. - * ETH_PROBE - Look for an adapter
  35330. - ***************************************************************************/
  35331. -
  35332. -struct nic *smc9000_probe(struct nic *nic, unsigned short *probe_addrs)
  35333. -{
  35334. - unsigned short revision;
  35335. - int memory;
  35336. - int media;
  35337. - const char * version_string;
  35338. - const char * if_string;
  35339. - int i;
  35340. -
  35341. - /*
  35342. - * the SMC9000 can be at any of the following port addresses. To change,
  35343. - * for a slightly different card, you can add it to the array. Keep in
  35344. - * mind that the array must end in zero.
  35345. - */
  35346. - static unsigned short portlist[] = {
  35347. -#ifdef SMC9000_SCAN
  35348. - SMC9000_SCAN,
  35349. -#else
  35350. - 0x200, 0x220, 0x240, 0x260, 0x280, 0x2A0, 0x2C0, 0x2E0,
  35351. - 0x300, 0x320, 0x340, 0x360, 0x380, 0x3A0, 0x3C0, 0x3E0,
  35352. -#endif
  35353. - 0 };
  35354. -
  35355. - printf("\nSMC9000 %s\n", smc9000_version);
  35356. -#ifdef SMC9000_VERBOSE
  35357. - printf("Copyright (C) 1998 Daniel Engstr\x94m\n");
  35358. - printf("Copyright (C) 1996 Eric Stahlman\n");
  35359. -#endif
  35360. - /* if no addresses supplied, fall back on defaults */
  35361. - if (probe_addrs == 0 || probe_addrs[0] == 0)
  35362. - probe_addrs = portlist;
  35363. -
  35364. - /* check every ethernet address */
  35365. - for (i = 0; probe_addrs[i]; i++) {
  35366. - /* check this specific address */
  35367. - if (smc_probe(probe_addrs[i]) == 0)
  35368. - smc9000_base = probe_addrs[i];
  35369. - }
  35370. -
  35371. - /* couldn't find anything */
  35372. - if(0 == smc9000_base)
  35373. - goto out;
  35374. -
  35375. - /*
  35376. - * Get the MAC address ( bank 1, regs 4 - 9 )
  35377. - */
  35378. - SMC_SELECT_BANK(smc9000_base, 1);
  35379. - for ( i = 0; i < 6; i += 2 ) {
  35380. - word address;
  35381. -
  35382. - address = inw(smc9000_base + ADDR0 + i);
  35383. - nic->node_addr[i+1] = address >> 8;
  35384. - nic->node_addr[i] = address & 0xFF;
  35385. - }
  35386. -
  35387. -
  35388. - /* get the memory information */
  35389. - SMC_SELECT_BANK(smc9000_base, 0);
  35390. - memory = ( inw(smc9000_base + MCR) >> 9 ) & 0x7; /* multiplier */
  35391. - memory *= 256 * (inw(smc9000_base + MIR) & 0xFF);
  35392. -
  35393. - /*
  35394. - * Now, I want to find out more about the chip. This is sort of
  35395. - * redundant, but it's cleaner to have it in both, rather than having
  35396. - * one VERY long probe procedure.
  35397. - */
  35398. - SMC_SELECT_BANK(smc9000_base, 3);
  35399. - revision = inw(smc9000_base + REVISION);
  35400. - version_string = chip_ids[(revision >> 4) & 0xF];
  35401. -
  35402. - if (((revision & 0xF0) >> 4 == CHIP_9196) &&
  35403. - ((revision & 0x0F) >= REV_9196)) {
  35404. - /* This is a 91c96. 'c96 has the same chip id as 'c94 (4) but
  35405. - * a revision starting at 6 */
  35406. - version_string = smc91c96_id;
  35407. - }
  35408. -
  35409. - if ( !version_string ) {
  35410. - /* I shouldn't get here because this call was done before.... */
  35411. - goto out;
  35412. - }
  35413. -
  35414. - /* is it using AUI or 10BaseT ? */
  35415. - SMC_SELECT_BANK(smc9000_base, 1);
  35416. - if (inw(smc9000_base + CONFIG) & CFG_AUI_SELECT)
  35417. - media = 2;
  35418. - else
  35419. - media = 1;
  35420. -
  35421. - if_string = interfaces[media - 1];
  35422. -
  35423. - /* now, reset the chip, and put it into a known state */
  35424. - smc_reset(smc9000_base);
  35425. -
  35426. - printf("%s rev:%d I/O port:%hX Interface:%s RAM:%d bytes \n",
  35427. - version_string, revision & 0xF,
  35428. - smc9000_base, if_string, memory );
  35429. - /*
  35430. - * Print the Ethernet address
  35431. - */
  35432. - printf("Ethernet MAC address: %!\n", nic->node_addr);
  35433. -
  35434. - SMC_SELECT_BANK(smc9000_base, 0);
  35435. -
  35436. - /* see the header file for options in TCR/RCR NORMAL*/
  35437. - _outw(TCR_NORMAL, smc9000_base + TCR);
  35438. - _outw(RCR_NORMAL, smc9000_base + RCR);
  35439. -
  35440. - /* Select which interface to use */
  35441. - SMC_SELECT_BANK(smc9000_base, 1);
  35442. - if ( media == 1 ) {
  35443. - _outw( inw( smc9000_base + CONFIG ) & ~CFG_AUI_SELECT,
  35444. - smc9000_base + CONFIG );
  35445. - }
  35446. - else if ( media == 2 ) {
  35447. - _outw( inw( smc9000_base + CONFIG ) | CFG_AUI_SELECT,
  35448. - smc9000_base + CONFIG );
  35449. - }
  35450. -
  35451. - nic->reset = smc9000_reset;
  35452. - nic->poll = smc9000_poll;
  35453. - nic->transmit = smc9000_transmit;
  35454. - nic->disable = smc9000_disable;
  35455. -
  35456. -
  35457. - return nic;
  35458. -
  35459. -out:
  35460. -#ifdef SMC9000_VERBOSE
  35461. - printf("No SMC9000 adapters found\n");
  35462. -#endif
  35463. - smc9000_base = 0;
  35464. -
  35465. - return (0);
  35466. -}
  35467. -
  35468. -
  35469. -
  35470. diff -Naur grub-0.97.orig/netboot/smc9000.h grub-0.97/netboot/smc9000.h
  35471. --- grub-0.97.orig/netboot/smc9000.h 2003-07-09 11:45:38.000000000 +0000
  35472. +++ grub-0.97/netboot/smc9000.h 1970-01-01 00:00:00.000000000 +0000
  35473. @@ -1,205 +0,0 @@
  35474. -/*------------------------------------------------------------------------
  35475. - * smc9000.h
  35476. - *
  35477. - * Copyright (C) 1998 by Daniel Engström
  35478. - * Copyright (C) 1996 by Erik Stahlman
  35479. - *
  35480. - * This software may be used and distributed according to the terms
  35481. - * of the GNU Public License, incorporated herein by reference.
  35482. - *
  35483. - * This file contains register information and access macros for
  35484. - * the SMC91xxx chipset.
  35485. - *
  35486. - * Information contained in this file was obtained from the SMC91C94
  35487. - * manual from SMC. To get a copy, if you really want one, you can find
  35488. - * information under www.smsc.com in the components division.
  35489. - * ( this thanks to advice from Donald Becker ).
  35490. - *
  35491. - * Authors
  35492. - * Daniel Engström <daniel.engstrom@riksnett.no>
  35493. - * Erik Stahlman <erik@vt.edu>
  35494. - *
  35495. - * History
  35496. - * 96-01-06 Erik Stahlman moved definitions here from main .c
  35497. - * file
  35498. - * 96-01-19 Erik Stahlman polished this up some, and added
  35499. - * better error handling
  35500. - * 98-09-25 Daniel Engström adjusted for Etherboot
  35501. - * 98-09-27 Daniel Engström moved some static strings back to the
  35502. - * main .c file
  35503. - * --------------------------------------------------------------------------*/
  35504. -#ifndef _SMC9000_H_
  35505. -# define _SMC9000_H_
  35506. -
  35507. -/* I want some simple types */
  35508. -typedef unsigned char byte;
  35509. -typedef unsigned short word;
  35510. -typedef unsigned long int dword;
  35511. -
  35512. -/*---------------------------------------------------------------
  35513. - *
  35514. - * A description of the SMC registers is probably in order here,
  35515. - * although for details, the SMC datasheet is invaluable.
  35516. - *
  35517. - * Basically, the chip has 4 banks of registers ( 0 to 3 ), which
  35518. - * are accessed by writing a number into the BANK_SELECT register
  35519. - * ( I also use a SMC_SELECT_BANK macro for this ).
  35520. - *
  35521. - * The banks are configured so that for most purposes, bank 2 is all
  35522. - * that is needed for simple run time tasks.
  35523. - * ----------------------------------------------------------------------*/
  35524. -
  35525. -/*
  35526. - * Bank Select Register:
  35527. - *
  35528. - * yyyy yyyy 0000 00xx
  35529. - * xx = bank number
  35530. - * yyyy yyyy = 0x33, for identification purposes.
  35531. - */
  35532. -#define BANK_SELECT 14
  35533. -
  35534. -/* BANK 0 */
  35535. -
  35536. -#define TCR 0 /* transmit control register */
  35537. -#define TCR_ENABLE 0x0001 /* if this is 1, we can transmit */
  35538. -#define TCR_FDUPLX 0x0800 /* receive packets sent out */
  35539. -#define TCR_STP_SQET 0x1000 /* stop transmitting if Signal quality error */
  35540. -#define TCR_MON_CNS 0x0400 /* monitors the carrier status */
  35541. -#define TCR_PAD_ENABLE 0x0080 /* pads short packets to 64 bytes */
  35542. -
  35543. -#define TCR_CLEAR 0 /* do NOTHING */
  35544. -/* the normal settings for the TCR register : */
  35545. -#define TCR_NORMAL (TCR_ENABLE | TCR_PAD_ENABLE)
  35546. -
  35547. -
  35548. -#define EPH_STATUS 2
  35549. -#define ES_LINK_OK 0x4000 /* is the link integrity ok ? */
  35550. -
  35551. -#define RCR 4
  35552. -#define RCR_SOFTRESET 0x8000 /* resets the chip */
  35553. -#define RCR_STRIP_CRC 0x200 /* strips CRC */
  35554. -#define RCR_ENABLE 0x100 /* IFF this is set, we can receive packets */
  35555. -#define RCR_ALMUL 0x4 /* receive all multicast packets */
  35556. -#define RCR_PROMISC 0x2 /* enable promiscuous mode */
  35557. -
  35558. -/* the normal settings for the RCR register : */
  35559. -#define RCR_NORMAL (RCR_STRIP_CRC | RCR_ENABLE)
  35560. -#define RCR_CLEAR 0x0 /* set it to a base state */
  35561. -
  35562. -#define COUNTER 6
  35563. -#define MIR 8
  35564. -#define MCR 10
  35565. -/* 12 is reserved */
  35566. -
  35567. -/* BANK 1 */
  35568. -#define CONFIG 0
  35569. -#define CFG_AUI_SELECT 0x100
  35570. -#define BASE 2
  35571. -#define ADDR0 4
  35572. -#define ADDR1 6
  35573. -#define ADDR2 8
  35574. -#define GENERAL 10
  35575. -#define CONTROL 12
  35576. -#define CTL_POWERDOWN 0x2000
  35577. -#define CTL_LE_ENABLE 0x80
  35578. -#define CTL_CR_ENABLE 0x40
  35579. -#define CTL_TE_ENABLE 0x0020
  35580. -#define CTL_AUTO_RELEASE 0x0800
  35581. -#define CTL_EPROM_ACCESS 0x0003 /* high if Eprom is being read */
  35582. -
  35583. -/* BANK 2 */
  35584. -#define MMU_CMD 0
  35585. -#define MC_BUSY 1 /* only readable bit in the register */
  35586. -#define MC_NOP 0
  35587. -#define MC_ALLOC 0x20 /* or with number of 256 byte packets */
  35588. -#define MC_RESET 0x40
  35589. -#define MC_REMOVE 0x60 /* remove the current rx packet */
  35590. -#define MC_RELEASE 0x80 /* remove and release the current rx packet */
  35591. -#define MC_FREEPKT 0xA0 /* Release packet in PNR register */
  35592. -#define MC_ENQUEUE 0xC0 /* Enqueue the packet for transmit */
  35593. -
  35594. -#define PNR_ARR 2
  35595. -#define FIFO_PORTS 4
  35596. -
  35597. -#define FP_RXEMPTY 0x8000
  35598. -#define FP_TXEMPTY 0x80
  35599. -
  35600. -#define POINTER 6
  35601. -#define PTR_READ 0x2000
  35602. -#define PTR_RCV 0x8000
  35603. -#define PTR_AUTOINC 0x4000
  35604. -#define PTR_AUTO_INC 0x0040
  35605. -
  35606. -#define DATA_1 8
  35607. -#define DATA_2 10
  35608. -#define INTERRUPT 12
  35609. -
  35610. -#define INT_MASK 13
  35611. -#define IM_RCV_INT 0x1
  35612. -#define IM_TX_INT 0x2
  35613. -#define IM_TX_EMPTY_INT 0x4
  35614. -#define IM_ALLOC_INT 0x8
  35615. -#define IM_RX_OVRN_INT 0x10
  35616. -#define IM_EPH_INT 0x20
  35617. -#define IM_ERCV_INT 0x40 /* not on SMC9192 */
  35618. -
  35619. -/* BANK 3 */
  35620. -#define MULTICAST1 0
  35621. -#define MULTICAST2 2
  35622. -#define MULTICAST3 4
  35623. -#define MULTICAST4 6
  35624. -#define MGMT 8
  35625. -#define REVISION 10 /* ( hi: chip id low: rev # ) */
  35626. -
  35627. -
  35628. -/* this is NOT on SMC9192 */
  35629. -#define ERCV 12
  35630. -
  35631. -/* Note that 9194 and 9196 have the smame chip id,
  35632. - * the 9196 will have revisions starting at 6 */
  35633. -#define CHIP_9190 3
  35634. -#define CHIP_9194 4
  35635. -#define CHIP_9195 5
  35636. -#define CHIP_9196 4
  35637. -#define CHIP_91100 7
  35638. -#define CHIP_91100FD 8
  35639. -
  35640. -#define REV_9196 6
  35641. -
  35642. -/*
  35643. - * Transmit status bits
  35644. - */
  35645. -#define TS_SUCCESS 0x0001
  35646. -#define TS_LOSTCAR 0x0400
  35647. -#define TS_LATCOL 0x0200
  35648. -#define TS_16COL 0x0010
  35649. -
  35650. -/*
  35651. - * Receive status bits
  35652. - */
  35653. -#define RS_ALGNERR 0x8000
  35654. -#define RS_BADCRC 0x2000
  35655. -#define RS_ODDFRAME 0x1000
  35656. -#define RS_TOOLONG 0x0800
  35657. -#define RS_TOOSHORT 0x0400
  35658. -#define RS_MULTICAST 0x0001
  35659. -#define RS_ERRORS (RS_ALGNERR | RS_BADCRC | RS_TOOLONG | RS_TOOSHORT)
  35660. -
  35661. -
  35662. -/*-------------------------------------------------------------------------
  35663. - * I define some macros to make it easier to do somewhat common
  35664. - * or slightly complicated, repeated tasks.
  35665. - --------------------------------------------------------------------------*/
  35666. -
  35667. -/* select a register bank, 0 to 3 */
  35668. -
  35669. -#define SMC_SELECT_BANK(x, y) { _outw( y, x + BANK_SELECT ); }
  35670. -
  35671. -/* define a small delay for the reset */
  35672. -#define SMC_DELAY(x) { inw( x + RCR );\
  35673. - inw( x + RCR );\
  35674. - inw( x + RCR ); }
  35675. -
  35676. -
  35677. -#endif /* _SMC_9000_H_ */
  35678. -
  35679. diff -Naur grub-0.97.orig/netboot/stdint.h grub-0.97/netboot/stdint.h
  35680. --- grub-0.97.orig/netboot/stdint.h 1970-01-01 00:00:00.000000000 +0000
  35681. +++ grub-0.97/netboot/stdint.h 2005-08-31 19:03:35.000000000 +0000
  35682. @@ -0,0 +1,18 @@
  35683. +#ifndef STDINT_H
  35684. +#define STDINT_H
  35685. +/*
  35686. + * I'm architecture depended. Check me before port GRUB
  35687. + */
  35688. +typedef unsigned size_t;
  35689. +
  35690. +typedef unsigned char uint8_t;
  35691. +typedef unsigned short uint16_t;
  35692. +typedef unsigned long uint32_t;
  35693. +typedef unsigned long long uint64_t;
  35694. +
  35695. +typedef signed char int8_t;
  35696. +typedef signed short int16_t;
  35697. +typedef signed long int32_t;
  35698. +typedef signed long long int64_t;
  35699. +
  35700. +#endif /* STDINT_H */
  35701. diff -Naur grub-0.97.orig/netboot/tftp.h grub-0.97/netboot/tftp.h
  35702. --- grub-0.97.orig/netboot/tftp.h 1970-01-01 00:00:00.000000000 +0000
  35703. +++ grub-0.97/netboot/tftp.h 2005-08-31 19:03:35.000000000 +0000
  35704. @@ -0,0 +1,82 @@
  35705. +#ifndef _TFTP_H
  35706. +#define _TFTP_H
  35707. +
  35708. +#include "if_ether.h"
  35709. +#include "ip.h"
  35710. +#include "udp.h"
  35711. +
  35712. +#ifndef MAX_TFTP_RETRIES
  35713. +#define MAX_TFTP_RETRIES 20
  35714. +#endif
  35715. +
  35716. +/* These settings have sense only if compiled with -DCONGESTED */
  35717. +/* total retransmission timeout in ticks */
  35718. +#define TFTP_TIMEOUT (30*TICKS_PER_SEC)
  35719. +/* packet retransmission timeout in ticks */
  35720. +#define TFTP_REXMT (3*TICKS_PER_SEC)
  35721. +
  35722. +#define TFTP_PORT 69
  35723. +#define TFTP_DEFAULTSIZE_PACKET 512
  35724. +#define TFTP_MAX_PACKET 1432 /* 512 */
  35725. +
  35726. +#define TFTP_RRQ 1
  35727. +#define TFTP_WRQ 2
  35728. +#define TFTP_DATA 3
  35729. +#define TFTP_ACK 4
  35730. +#define TFTP_ERROR 5
  35731. +#define TFTP_OACK 6
  35732. +
  35733. +#define TFTP_CODE_EOF 1
  35734. +#define TFTP_CODE_MORE 2
  35735. +#define TFTP_CODE_ERROR 3
  35736. +#define TFTP_CODE_BOOT 4
  35737. +#define TFTP_CODE_CFG 5
  35738. +
  35739. +struct tftp_t {
  35740. + struct iphdr ip;
  35741. + struct udphdr udp;
  35742. + uint16_t opcode;
  35743. + union {
  35744. + uint8_t rrq[TFTP_DEFAULTSIZE_PACKET];
  35745. + struct {
  35746. + uint16_t block;
  35747. + uint8_t download[TFTP_MAX_PACKET];
  35748. + } data;
  35749. + struct {
  35750. + uint16_t block;
  35751. + } ack;
  35752. + struct {
  35753. + uint16_t errcode;
  35754. + uint8_t errmsg[TFTP_DEFAULTSIZE_PACKET];
  35755. + } err;
  35756. + struct {
  35757. + uint8_t data[TFTP_DEFAULTSIZE_PACKET+2];
  35758. + } oack;
  35759. + } u;
  35760. +};
  35761. +
  35762. +/* define a smaller tftp packet solely for making requests to conserve stack
  35763. + 512 bytes should be enough */
  35764. +struct tftpreq_t {
  35765. + struct iphdr ip;
  35766. + struct udphdr udp;
  35767. + uint16_t opcode;
  35768. + union {
  35769. + uint8_t rrq[512];
  35770. + struct {
  35771. + uint16_t block;
  35772. + } ack;
  35773. + struct {
  35774. + uint16_t errcode;
  35775. + uint8_t errmsg[512-2];
  35776. + } err;
  35777. + } u;
  35778. +};
  35779. +
  35780. +#define TFTP_MIN_PACKET (sizeof(struct iphdr) + sizeof(struct udphdr) + 4)
  35781. +
  35782. +typedef int (*read_actor_t)(unsigned char *, unsigned int, unsigned int, int);
  35783. +
  35784. +int tftp_file_read(const char *name, read_actor_t);
  35785. +
  35786. +#endif /* _TFTP_H */
  35787. diff -Naur grub-0.97.orig/netboot/tg3.c grub-0.97/netboot/tg3.c
  35788. --- grub-0.97.orig/netboot/tg3.c 1970-01-01 00:00:00.000000000 +0000
  35789. +++ grub-0.97/netboot/tg3.c 2005-08-31 19:03:35.000000000 +0000
  35790. @@ -0,0 +1,3322 @@
  35791. +/* $Id: grub-0.95-diskless-patch-2.patch,v 1.1.1.1 2005/06/14 08:18:50 wesolows Exp $
  35792. + * tg3.c: Broadcom Tigon3 ethernet driver.
  35793. + *
  35794. + * Copyright (C) 2001, 2002 David S. Miller (davem@redhat.com)
  35795. + * Copyright (C) 2001, 2002 Jeff Garzik (jgarzik@mandrakesoft.com)
  35796. + * Copyright (C) 2003 Eric Biederman (ebiederman@lnxi.com) [etherboot port]
  35797. + */
  35798. +
  35799. +/* 11-13-2003 timlegge Fix Issue with NetGear GA302T
  35800. + * 11-18-2003 ebiederm Generalize NetGear Fix to what the code was supposed to be.
  35801. + */
  35802. +
  35803. +#include "etherboot.h"
  35804. +#include "nic.h"
  35805. +#include "pci.h"
  35806. +#include "timer.h"
  35807. +/*#include "string.h"*/
  35808. +#include "tg3.h"
  35809. +
  35810. +#define SUPPORT_COPPER_PHY 1
  35811. +#define SUPPORT_FIBER_PHY 1
  35812. +#define SUPPORT_LINK_REPORT 1
  35813. +#define SUPPORT_PARTNO_STR 1
  35814. +#define SUPPORT_PHY_STR 1
  35815. +
  35816. +struct tg3 tg3;
  35817. +
  35818. +/* Dummy defines for error handling */
  35819. +#define EBUSY 1
  35820. +#define ENODEV 2
  35821. +#define EINVAL 3
  35822. +#define ENOMEM 4
  35823. +
  35824. +
  35825. +/* These numbers seem to be hard coded in the NIC firmware somehow.
  35826. + * You can't change the ring sizes, but you can change where you place
  35827. + * them in the NIC onboard memory.
  35828. + */
  35829. +#define TG3_RX_RING_SIZE 512
  35830. +#define TG3_DEF_RX_RING_PENDING 20 /* RX_RING_PENDING seems to be o.k. at 20 and 200 */
  35831. +#define TG3_RX_RCB_RING_SIZE 1024
  35832. +
  35833. +/* (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 ? \
  35834. + 512 : 1024) */
  35835. + #define TG3_TX_RING_SIZE 512
  35836. +#define TG3_DEF_TX_RING_PENDING (TG3_TX_RING_SIZE - 1)
  35837. +
  35838. +#define TG3_RX_RING_BYTES (sizeof(struct tg3_rx_buffer_desc) * TG3_RX_RING_SIZE)
  35839. +#define TG3_RX_RCB_RING_BYTES (sizeof(struct tg3_rx_buffer_desc) * TG3_RX_RCB_RING_SIZE)
  35840. +
  35841. +#define TG3_TX_RING_BYTES (sizeof(struct tg3_tx_buffer_desc) * TG3_TX_RING_SIZE)
  35842. +#define NEXT_TX(N) (((N) + 1) & (TG3_TX_RING_SIZE - 1))
  35843. +#define PREV_TX(N) (((N) - 1) & (TG3_TX_RING_SIZE - 1))
  35844. +
  35845. +#define RX_PKT_BUF_SZ (1536 + 2 + 64)
  35846. +
  35847. +
  35848. +static struct bss {
  35849. + struct tg3_rx_buffer_desc rx_std[TG3_RX_RING_SIZE];
  35850. + struct tg3_rx_buffer_desc rx_rcb[TG3_RX_RCB_RING_SIZE];
  35851. + struct tg3_tx_buffer_desc tx_ring[TG3_TX_RING_SIZE];
  35852. + struct tg3_hw_status hw_status;
  35853. + struct tg3_hw_stats hw_stats;
  35854. + unsigned char rx_bufs[TG3_DEF_RX_RING_PENDING][RX_PKT_BUF_SZ];
  35855. +} tg3_bss;
  35856. +
  35857. +/**
  35858. + * pci_save_state - save the PCI configuration space of a device before suspending
  35859. + * @dev: - PCI device that we're dealing with
  35860. + * @buffer: - buffer to hold config space context
  35861. + *
  35862. + * @buffer must be large enough to hold the entire PCI 2.2 config space
  35863. + * (>= 64 bytes).
  35864. + */
  35865. +static int pci_save_state(struct pci_device *dev, uint32_t *buffer)
  35866. +{
  35867. + int i;
  35868. + for (i = 0; i < 16; i++)
  35869. + pci_read_config_dword(dev, i * 4,&buffer[i]);
  35870. + return 0;
  35871. +}
  35872. +
  35873. +/**
  35874. + * pci_restore_state - Restore the saved state of a PCI device
  35875. + * @dev: - PCI device that we're dealing with
  35876. + * @buffer: - saved PCI config space
  35877. + *
  35878. + */
  35879. +static int pci_restore_state(struct pci_device *dev, uint32_t *buffer)
  35880. +{
  35881. + int i;
  35882. +
  35883. + for (i = 0; i < 16; i++)
  35884. + pci_write_config_dword(dev,i * 4, buffer[i]);
  35885. + return 0;
  35886. +}
  35887. +
  35888. +static void tg3_write_indirect_reg32(uint32_t off, uint32_t val)
  35889. +{
  35890. + pci_write_config_dword(tg3.pdev, TG3PCI_REG_BASE_ADDR, off);
  35891. + pci_write_config_dword(tg3.pdev, TG3PCI_REG_DATA, val);
  35892. +}
  35893. +
  35894. +#define tw32(reg,val) tg3_write_indirect_reg32((reg),(val))
  35895. +#define tw32_mailbox(reg, val) writel(((val) & 0xffffffff), tg3.regs + (reg))
  35896. +#define tw16(reg,val) writew(((val) & 0xffff), tg3.regs + (reg))
  35897. +#define tw8(reg,val) writeb(((val) & 0xff), tg3.regs + (reg))
  35898. +#define tr32(reg) readl(tg3.regs + (reg))
  35899. +#define tr16(reg) readw(tg3.regs + (reg))
  35900. +#define tr8(reg) readb(tg3.regs + (reg))
  35901. +
  35902. +static void tw32_carefully(uint32_t reg, uint32_t val)
  35903. +{
  35904. + tw32(reg, val);
  35905. + tr32(reg);
  35906. + udelay(100);
  35907. +}
  35908. +
  35909. +static void tw32_mailbox2(uint32_t reg, uint32_t val)
  35910. +{
  35911. + tw32_mailbox(reg, val);
  35912. + tr32(reg);
  35913. +}
  35914. +
  35915. +static void tg3_write_mem(uint32_t off, uint32_t val)
  35916. +{
  35917. + pci_write_config_dword(tg3.pdev, TG3PCI_MEM_WIN_BASE_ADDR, off);
  35918. + pci_write_config_dword(tg3.pdev, TG3PCI_MEM_WIN_DATA, val);
  35919. +
  35920. + /* Always leave this as zero. */
  35921. + pci_write_config_dword(tg3.pdev, TG3PCI_MEM_WIN_BASE_ADDR, 0);
  35922. +}
  35923. +
  35924. +static void tg3_read_mem(uint32_t off, uint32_t *val)
  35925. +{
  35926. + pci_write_config_dword(tg3.pdev, TG3PCI_MEM_WIN_BASE_ADDR, off);
  35927. + pci_read_config_dword(tg3.pdev, TG3PCI_MEM_WIN_DATA, val);
  35928. +
  35929. + /* Always leave this as zero. */
  35930. + pci_write_config_dword(tg3.pdev, TG3PCI_MEM_WIN_BASE_ADDR, 0);
  35931. +}
  35932. +
  35933. +static void tg3_disable_ints(struct tg3 *tp)
  35934. +{
  35935. + tw32(TG3PCI_MISC_HOST_CTRL,
  35936. + (tp->misc_host_ctrl | MISC_HOST_CTRL_MASK_PCI_INT));
  35937. + tw32_mailbox2(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000001);
  35938. +}
  35939. +
  35940. +static void tg3_switch_clocks(struct tg3 *tp)
  35941. +{
  35942. + uint32_t orig_clock_ctrl, clock_ctrl;
  35943. +
  35944. + clock_ctrl = tr32(TG3PCI_CLOCK_CTRL);
  35945. +
  35946. + orig_clock_ctrl = clock_ctrl;
  35947. + clock_ctrl &= (CLOCK_CTRL_FORCE_CLKRUN | CLOCK_CTRL_CLKRUN_OENABLE | 0x1f);
  35948. + tp->pci_clock_ctrl = clock_ctrl;
  35949. +
  35950. + if ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) &&
  35951. + (orig_clock_ctrl & CLOCK_CTRL_44MHZ_CORE)!=0) {
  35952. + tw32_carefully(TG3PCI_CLOCK_CTRL,
  35953. + clock_ctrl | (CLOCK_CTRL_44MHZ_CORE | CLOCK_CTRL_ALTCLK));
  35954. + tw32_carefully(TG3PCI_CLOCK_CTRL,
  35955. + clock_ctrl | (CLOCK_CTRL_ALTCLK));
  35956. + }
  35957. + tw32_carefully(TG3PCI_CLOCK_CTRL, clock_ctrl);
  35958. +}
  35959. +
  35960. +#define PHY_BUSY_LOOPS 5000
  35961. +
  35962. +static int tg3_readphy(struct tg3 *tp, int reg, uint32_t *val)
  35963. +{
  35964. + uint32_t frame_val;
  35965. + int loops, ret;
  35966. +
  35967. + tw32_carefully(MAC_MI_MODE, tp->mi_mode & ~MAC_MI_MODE_AUTO_POLL);
  35968. +
  35969. + *val = 0xffffffff;
  35970. +
  35971. + frame_val = ((PHY_ADDR << MI_COM_PHY_ADDR_SHIFT) &
  35972. + MI_COM_PHY_ADDR_MASK);
  35973. + frame_val |= ((reg << MI_COM_REG_ADDR_SHIFT) &
  35974. + MI_COM_REG_ADDR_MASK);
  35975. + frame_val |= (MI_COM_CMD_READ | MI_COM_START);
  35976. +
  35977. + tw32_carefully(MAC_MI_COM, frame_val);
  35978. +
  35979. + loops = PHY_BUSY_LOOPS;
  35980. + while (loops-- > 0) {
  35981. + udelay(10);
  35982. + frame_val = tr32(MAC_MI_COM);
  35983. +
  35984. + if ((frame_val & MI_COM_BUSY) == 0) {
  35985. + udelay(5);
  35986. + frame_val = tr32(MAC_MI_COM);
  35987. + break;
  35988. + }
  35989. + }
  35990. +
  35991. + ret = -EBUSY;
  35992. + if (loops > 0) {
  35993. + *val = frame_val & MI_COM_DATA_MASK;
  35994. + ret = 0;
  35995. + }
  35996. +
  35997. + tw32_carefully(MAC_MI_MODE, tp->mi_mode);
  35998. +
  35999. + return ret;
  36000. +}
  36001. +
  36002. +static int tg3_writephy(struct tg3 *tp, int reg, uint32_t val)
  36003. +{
  36004. + uint32_t frame_val;
  36005. + int loops, ret;
  36006. +
  36007. + tw32_carefully(MAC_MI_MODE, tp->mi_mode & ~MAC_MI_MODE_AUTO_POLL);
  36008. +
  36009. + frame_val = ((PHY_ADDR << MI_COM_PHY_ADDR_SHIFT) &
  36010. + MI_COM_PHY_ADDR_MASK);
  36011. + frame_val |= ((reg << MI_COM_REG_ADDR_SHIFT) &
  36012. + MI_COM_REG_ADDR_MASK);
  36013. + frame_val |= (val & MI_COM_DATA_MASK);
  36014. + frame_val |= (MI_COM_CMD_WRITE | MI_COM_START);
  36015. +
  36016. + tw32_carefully(MAC_MI_COM, frame_val);
  36017. +
  36018. + loops = PHY_BUSY_LOOPS;
  36019. + while (loops-- > 0) {
  36020. + udelay(10);
  36021. + frame_val = tr32(MAC_MI_COM);
  36022. + if ((frame_val & MI_COM_BUSY) == 0) {
  36023. + udelay(5);
  36024. + frame_val = tr32(MAC_MI_COM);
  36025. + break;
  36026. + }
  36027. + }
  36028. +
  36029. + ret = -EBUSY;
  36030. + if (loops > 0)
  36031. + ret = 0;
  36032. +
  36033. + tw32_carefully(MAC_MI_MODE, tp->mi_mode);
  36034. +
  36035. + return ret;
  36036. +}
  36037. +
  36038. +static int tg3_writedsp(struct tg3 *tp, uint16_t addr, uint16_t val)
  36039. +{
  36040. + int err;
  36041. + err = tg3_writephy(tp, MII_TG3_DSP_ADDRESS, addr);
  36042. + err |= tg3_writephy(tp, MII_TG3_DSP_RW_PORT, val);
  36043. + return err;
  36044. +}
  36045. +
  36046. +
  36047. +static void tg3_phy_set_wirespeed(struct tg3 *tp)
  36048. +{
  36049. + uint32_t val;
  36050. +
  36051. + if (tp->tg3_flags2 & TG3_FLG2_NO_ETH_WIRE_SPEED)
  36052. + return;
  36053. +
  36054. + tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x7007);
  36055. + tg3_readphy(tp, MII_TG3_AUX_CTRL, &val);
  36056. + tg3_writephy(tp, MII_TG3_AUX_CTRL, (val | (1 << 15) | (1 << 4)));
  36057. +}
  36058. +
  36059. +static int tg3_bmcr_reset(struct tg3 *tp)
  36060. +{
  36061. + uint32_t phy_control;
  36062. + int limit, err;
  36063. +
  36064. + /* OK, reset it, and poll the BMCR_RESET bit until it
  36065. + * clears or we time out.
  36066. + */
  36067. + phy_control = BMCR_RESET;
  36068. + err = tg3_writephy(tp, MII_BMCR, phy_control);
  36069. + if (err != 0)
  36070. + return -EBUSY;
  36071. +
  36072. + limit = 5000;
  36073. + while (limit--) {
  36074. + err = tg3_readphy(tp, MII_BMCR, &phy_control);
  36075. + if (err != 0)
  36076. + return -EBUSY;
  36077. +
  36078. + if ((phy_control & BMCR_RESET) == 0) {
  36079. + udelay(40);
  36080. + break;
  36081. + }
  36082. + udelay(10);
  36083. + }
  36084. + if (limit <= 0)
  36085. + return -EBUSY;
  36086. +
  36087. + return 0;
  36088. +}
  36089. +
  36090. +static int tg3_wait_macro_done(struct tg3 *tp)
  36091. +{
  36092. + int limit = 100;
  36093. +
  36094. + while (limit--) {
  36095. + uint32_t tmp32;
  36096. +
  36097. + tg3_readphy(tp, 0x16, &tmp32);
  36098. + if ((tmp32 & 0x1000) == 0)
  36099. + break;
  36100. + }
  36101. + if (limit <= 0)
  36102. + return -EBUSY;
  36103. +
  36104. + return 0;
  36105. +}
  36106. +
  36107. +static int tg3_phy_write_and_check_testpat(struct tg3 *tp, int *resetp)
  36108. +{
  36109. + static const uint32_t test_pat[4][6] = {
  36110. + { 0x00005555, 0x00000005, 0x00002aaa, 0x0000000a, 0x00003456, 0x00000003 },
  36111. + { 0x00002aaa, 0x0000000a, 0x00003333, 0x00000003, 0x0000789a, 0x00000005 },
  36112. + { 0x00005a5a, 0x00000005, 0x00002a6a, 0x0000000a, 0x00001bcd, 0x00000003 },
  36113. + { 0x00002a5a, 0x0000000a, 0x000033c3, 0x00000003, 0x00002ef1, 0x00000005 }
  36114. + };
  36115. + int chan;
  36116. +
  36117. + for (chan = 0; chan < 4; chan++) {
  36118. + int i;
  36119. +
  36120. + tg3_writephy(tp, MII_TG3_DSP_ADDRESS,
  36121. + (chan * 0x2000) | 0x0200);
  36122. + tg3_writephy(tp, 0x16, 0x0002);
  36123. +
  36124. + for (i = 0; i < 6; i++)
  36125. + tg3_writephy(tp, MII_TG3_DSP_RW_PORT,
  36126. + test_pat[chan][i]);
  36127. +
  36128. + tg3_writephy(tp, 0x16, 0x0202);
  36129. + if (tg3_wait_macro_done(tp)) {
  36130. + *resetp = 1;
  36131. + return -EBUSY;
  36132. + }
  36133. +
  36134. + tg3_writephy(tp, MII_TG3_DSP_ADDRESS,
  36135. + (chan * 0x2000) | 0x0200);
  36136. + tg3_writephy(tp, 0x16, 0x0082);
  36137. + if (tg3_wait_macro_done(tp)) {
  36138. + *resetp = 1;
  36139. + return -EBUSY;
  36140. + }
  36141. +
  36142. + tg3_writephy(tp, 0x16, 0x0802);
  36143. + if (tg3_wait_macro_done(tp)) {
  36144. + *resetp = 1;
  36145. + return -EBUSY;
  36146. + }
  36147. +
  36148. + for (i = 0; i < 6; i += 2) {
  36149. + uint32_t low, high;
  36150. +
  36151. + tg3_readphy(tp, MII_TG3_DSP_RW_PORT, &low);
  36152. + tg3_readphy(tp, MII_TG3_DSP_RW_PORT, &high);
  36153. + if (tg3_wait_macro_done(tp)) {
  36154. + *resetp = 1;
  36155. + return -EBUSY;
  36156. + }
  36157. + low &= 0x7fff;
  36158. + high &= 0x000f;
  36159. + if (low != test_pat[chan][i] ||
  36160. + high != test_pat[chan][i+1]) {
  36161. + tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x000b);
  36162. + tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x4001);
  36163. + tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x4005);
  36164. +
  36165. + return -EBUSY;
  36166. + }
  36167. + }
  36168. + }
  36169. +
  36170. + return 0;
  36171. +}
  36172. +
  36173. +static int tg3_phy_reset_chanpat(struct tg3 *tp)
  36174. +{
  36175. + int chan;
  36176. +
  36177. + for (chan = 0; chan < 4; chan++) {
  36178. + int i;
  36179. +
  36180. + tg3_writephy(tp, MII_TG3_DSP_ADDRESS,
  36181. + (chan * 0x2000) | 0x0200);
  36182. + tg3_writephy(tp, 0x16, 0x0002);
  36183. + for (i = 0; i < 6; i++)
  36184. + tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x000);
  36185. + tg3_writephy(tp, 0x16, 0x0202);
  36186. + if (tg3_wait_macro_done(tp))
  36187. + return -EBUSY;
  36188. + }
  36189. +
  36190. + return 0;
  36191. +}
  36192. +
  36193. +static int tg3_phy_reset_5703_4_5(struct tg3 *tp)
  36194. +{
  36195. + uint32_t reg32, phy9_orig;
  36196. + int retries, do_phy_reset, err;
  36197. +
  36198. + retries = 10;
  36199. + do_phy_reset = 1;
  36200. + do {
  36201. + if (do_phy_reset) {
  36202. + err = tg3_bmcr_reset(tp);
  36203. + if (err)
  36204. + return err;
  36205. + do_phy_reset = 0;
  36206. + }
  36207. +
  36208. + /* Disable transmitter and interrupt. */
  36209. + tg3_readphy(tp, MII_TG3_EXT_CTRL, &reg32);
  36210. + reg32 |= 0x3000;
  36211. + tg3_writephy(tp, MII_TG3_EXT_CTRL, reg32);
  36212. +
  36213. + /* Set full-duplex, 1000 mbps. */
  36214. + tg3_writephy(tp, MII_BMCR,
  36215. + BMCR_FULLDPLX | TG3_BMCR_SPEED1000);
  36216. +
  36217. + /* Set to master mode. */
  36218. + tg3_readphy(tp, MII_TG3_CTRL, &phy9_orig);
  36219. + tg3_writephy(tp, MII_TG3_CTRL,
  36220. + (MII_TG3_CTRL_AS_MASTER |
  36221. + MII_TG3_CTRL_ENABLE_AS_MASTER));
  36222. +
  36223. + /* Enable SM_DSP_CLOCK and 6dB. */
  36224. + tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00);
  36225. +
  36226. + /* Block the PHY control access. */
  36227. + tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x8005);
  36228. + tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x0800);
  36229. +
  36230. + err = tg3_phy_write_and_check_testpat(tp, &do_phy_reset);
  36231. + if (!err)
  36232. + break;
  36233. + } while (--retries);
  36234. +
  36235. + err = tg3_phy_reset_chanpat(tp);
  36236. + if (err)
  36237. + return err;
  36238. +
  36239. + tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x8005);
  36240. + tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x0000);
  36241. +
  36242. + tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x8200);
  36243. + tg3_writephy(tp, 0x16, 0x0000);
  36244. +
  36245. + tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0400);
  36246. +
  36247. + tg3_writephy(tp, MII_TG3_CTRL, phy9_orig);
  36248. +
  36249. + tg3_readphy(tp, MII_TG3_EXT_CTRL, &reg32);
  36250. + reg32 &= ~0x3000;
  36251. + tg3_writephy(tp, MII_TG3_EXT_CTRL, reg32);
  36252. +
  36253. + return err;
  36254. +}
  36255. +
  36256. +/* This will reset the tigon3 PHY if there is no valid
  36257. + * link.
  36258. + */
  36259. +static int tg3_phy_reset(struct tg3 *tp)
  36260. +{
  36261. + uint32_t phy_status;
  36262. + int err;
  36263. +
  36264. + err = tg3_readphy(tp, MII_BMSR, &phy_status);
  36265. + err |= tg3_readphy(tp, MII_BMSR, &phy_status);
  36266. + if (err != 0)
  36267. + return -EBUSY;
  36268. +
  36269. + if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703) ||
  36270. + (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
  36271. + (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)) {
  36272. + err = tg3_phy_reset_5703_4_5(tp);
  36273. + if (err)
  36274. + return err;
  36275. + goto out;
  36276. + }
  36277. + err = tg3_bmcr_reset(tp);
  36278. + if (err)
  36279. + return err;
  36280. + out:
  36281. + tg3_phy_set_wirespeed(tp);
  36282. + return 0;
  36283. +}
  36284. +
  36285. +static void tg3_set_power_state_0(struct tg3 *tp)
  36286. +{
  36287. + uint16_t power_control;
  36288. + int pm = tp->pm_cap;
  36289. +
  36290. + /* Make sure register accesses (indirect or otherwise)
  36291. + * will function correctly.
  36292. + */
  36293. + pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL, tp->misc_host_ctrl);
  36294. +
  36295. + pci_read_config_word(tp->pdev, pm + PCI_PM_CTRL, &power_control);
  36296. +
  36297. + power_control |= PCI_PM_CTRL_PME_STATUS;
  36298. + power_control &= ~(PCI_PM_CTRL_STATE_MASK);
  36299. + power_control |= 0;
  36300. + pci_write_config_word(tp->pdev, pm + PCI_PM_CTRL, power_control);
  36301. +
  36302. + tw32_carefully(GRC_LOCAL_CTRL, tp->grc_local_ctrl);
  36303. +
  36304. + return;
  36305. +}
  36306. +
  36307. +
  36308. +#if SUPPORT_LINK_REPORT
  36309. +static void tg3_link_report(struct tg3 *tp)
  36310. +{
  36311. + if (!tp->carrier_ok) {
  36312. + printf("Link is down.\n");
  36313. + } else {
  36314. + printf("Link is up at %d Mbps, %s duplex. %s %s %s\n",
  36315. + (tp->link_config.active_speed == SPEED_1000 ?
  36316. + 1000 :
  36317. + (tp->link_config.active_speed == SPEED_100 ?
  36318. + 100 : 10)),
  36319. + (tp->link_config.active_duplex == DUPLEX_FULL ?
  36320. + "full" : "half"),
  36321. + (tp->tg3_flags & TG3_FLAG_TX_PAUSE) ? "TX" : "",
  36322. + (tp->tg3_flags & TG3_FLAG_RX_PAUSE) ? "RX" : "",
  36323. + (tp->tg3_flags & (TG3_FLAG_TX_PAUSE |TG3_FLAG_RX_PAUSE)) ? "flow control" : "");
  36324. + }
  36325. +}
  36326. +#else
  36327. +#define tg3_link_report(tp)
  36328. +#endif
  36329. +
  36330. +static void tg3_setup_flow_control(struct tg3 *tp, uint32_t local_adv, uint32_t remote_adv)
  36331. +{
  36332. + uint32_t new_tg3_flags = 0;
  36333. +
  36334. + if (local_adv & ADVERTISE_PAUSE_CAP) {
  36335. + if (local_adv & ADVERTISE_PAUSE_ASYM) {
  36336. + if (remote_adv & LPA_PAUSE_CAP)
  36337. + new_tg3_flags |=
  36338. + (TG3_FLAG_RX_PAUSE |
  36339. + TG3_FLAG_TX_PAUSE);
  36340. + else if (remote_adv & LPA_PAUSE_ASYM)
  36341. + new_tg3_flags |=
  36342. + (TG3_FLAG_RX_PAUSE);
  36343. + } else {
  36344. + if (remote_adv & LPA_PAUSE_CAP)
  36345. + new_tg3_flags |=
  36346. + (TG3_FLAG_RX_PAUSE |
  36347. + TG3_FLAG_TX_PAUSE);
  36348. + }
  36349. + } else if (local_adv & ADVERTISE_PAUSE_ASYM) {
  36350. + if ((remote_adv & LPA_PAUSE_CAP) &&
  36351. + (remote_adv & LPA_PAUSE_ASYM))
  36352. + new_tg3_flags |= TG3_FLAG_TX_PAUSE;
  36353. + }
  36354. +
  36355. + tp->tg3_flags &= ~(TG3_FLAG_RX_PAUSE | TG3_FLAG_TX_PAUSE);
  36356. + tp->tg3_flags |= new_tg3_flags;
  36357. +
  36358. + if (new_tg3_flags & TG3_FLAG_RX_PAUSE)
  36359. + tp->rx_mode |= RX_MODE_FLOW_CTRL_ENABLE;
  36360. + else
  36361. + tp->rx_mode &= ~RX_MODE_FLOW_CTRL_ENABLE;
  36362. +
  36363. + if (new_tg3_flags & TG3_FLAG_TX_PAUSE)
  36364. + tp->tx_mode |= TX_MODE_FLOW_CTRL_ENABLE;
  36365. + else
  36366. + tp->tx_mode &= ~TX_MODE_FLOW_CTRL_ENABLE;
  36367. +}
  36368. +
  36369. +#if SUPPORT_COPPER_PHY
  36370. +static void tg3_aux_stat_to_speed_duplex(
  36371. + struct tg3 *tp __unused, uint32_t val, uint8_t *speed, uint8_t *duplex)
  36372. +{
  36373. + static const uint8_t map[] = {
  36374. + [0] = (SPEED_INVALID << 2) | DUPLEX_INVALID,
  36375. + [MII_TG3_AUX_STAT_10HALF >> 8] = (SPEED_10 << 2) | DUPLEX_HALF,
  36376. + [MII_TG3_AUX_STAT_10FULL >> 8] = (SPEED_10 << 2) | DUPLEX_FULL,
  36377. + [MII_TG3_AUX_STAT_100HALF >> 8] = (SPEED_100 << 2) | DUPLEX_HALF,
  36378. + [MII_TG3_AUX_STAT_100_4 >> 8] = (SPEED_INVALID << 2) | DUPLEX_INVALID,
  36379. + [MII_TG3_AUX_STAT_100FULL >> 8] = (SPEED_100 << 2) | DUPLEX_FULL,
  36380. + [MII_TG3_AUX_STAT_1000HALF >> 8] = (SPEED_1000 << 2) | DUPLEX_HALF,
  36381. + [MII_TG3_AUX_STAT_1000FULL >> 8] = (SPEED_1000 << 2) | DUPLEX_FULL,
  36382. + };
  36383. + uint8_t result;
  36384. + result = map[(val & MII_TG3_AUX_STAT_SPDMASK) >> 8];
  36385. + *speed = result >> 2;
  36386. + *duplex = result & 3;
  36387. +}
  36388. +
  36389. +static int tg3_phy_copper_begin(struct tg3 *tp)
  36390. +{
  36391. + uint32_t new_adv;
  36392. +
  36393. + tp->link_config.advertising =
  36394. + (ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
  36395. + ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full |
  36396. + ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full |
  36397. + ADVERTISED_Autoneg | ADVERTISED_MII);
  36398. +
  36399. + if (tp->tg3_flags & TG3_FLAG_10_100_ONLY) {
  36400. + tp->link_config.advertising &=
  36401. + ~(ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full);
  36402. + }
  36403. +
  36404. + new_adv = (ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
  36405. + if (tp->link_config.advertising & ADVERTISED_10baseT_Half) {
  36406. + new_adv |= ADVERTISE_10HALF;
  36407. + }
  36408. + if (tp->link_config.advertising & ADVERTISED_10baseT_Full) {
  36409. + new_adv |= ADVERTISE_10FULL;
  36410. + }
  36411. + if (tp->link_config.advertising & ADVERTISED_100baseT_Half) {
  36412. + new_adv |= ADVERTISE_100HALF;
  36413. + }
  36414. + if (tp->link_config.advertising & ADVERTISED_100baseT_Full) {
  36415. + new_adv |= ADVERTISE_100FULL;
  36416. + }
  36417. + tg3_writephy(tp, MII_ADVERTISE, new_adv);
  36418. +
  36419. + if (tp->link_config.advertising &
  36420. + (ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full)) {
  36421. + new_adv = 0;
  36422. + if (tp->link_config.advertising & ADVERTISED_1000baseT_Half) {
  36423. + new_adv |= MII_TG3_CTRL_ADV_1000_HALF;
  36424. + }
  36425. + if (tp->link_config.advertising & ADVERTISED_1000baseT_Full) {
  36426. + new_adv |= MII_TG3_CTRL_ADV_1000_FULL;
  36427. + }
  36428. + if (!(tp->tg3_flags & TG3_FLAG_10_100_ONLY) &&
  36429. + (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0 ||
  36430. + tp->pci_chip_rev_id == CHIPREV_ID_5701_B0)) {
  36431. + new_adv |= (MII_TG3_CTRL_AS_MASTER |
  36432. + MII_TG3_CTRL_ENABLE_AS_MASTER);
  36433. + }
  36434. + tg3_writephy(tp, MII_TG3_CTRL, new_adv);
  36435. + } else {
  36436. + tg3_writephy(tp, MII_TG3_CTRL, 0);
  36437. + }
  36438. +
  36439. + tg3_writephy(tp, MII_BMCR, BMCR_ANENABLE | BMCR_ANRESTART);
  36440. +
  36441. + return 0;
  36442. +}
  36443. +
  36444. +static int tg3_init_5401phy_dsp(struct tg3 *tp)
  36445. +{
  36446. + int err;
  36447. +
  36448. + /* Turn off tap power management. */
  36449. + err = tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c20);
  36450. +
  36451. + err |= tg3_writedsp(tp, 0x0012, 0x1804);
  36452. + err |= tg3_writedsp(tp, 0x0013, 0x1204);
  36453. + err |= tg3_writedsp(tp, 0x8006, 0x0132);
  36454. + err |= tg3_writedsp(tp, 0x8006, 0x0232);
  36455. + err |= tg3_writedsp(tp, 0x201f, 0x0a20);
  36456. +
  36457. + udelay(40);
  36458. +
  36459. + return err;
  36460. +}
  36461. +
  36462. +static int tg3_setup_copper_phy(struct tg3 *tp)
  36463. +{
  36464. + int current_link_up;
  36465. + uint32_t bmsr, dummy;
  36466. + int i, err;
  36467. +
  36468. + tw32_carefully(MAC_STATUS,
  36469. + (MAC_STATUS_SYNC_CHANGED | MAC_STATUS_CFG_CHANGED));
  36470. +
  36471. + tp->mi_mode = MAC_MI_MODE_BASE;
  36472. + tw32_carefully(MAC_MI_MODE, tp->mi_mode);
  36473. +
  36474. + tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x02);
  36475. +
  36476. + /* Some third-party PHYs need to be reset on link going
  36477. + * down.
  36478. + */
  36479. + if ( ( (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703) ||
  36480. + (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
  36481. + (tp->pci_chip_rev_id == CHIPREV_ID_5705_A0)) &&
  36482. + (tp->carrier_ok)) {
  36483. + tg3_readphy(tp, MII_BMSR, &bmsr);
  36484. + tg3_readphy(tp, MII_BMSR, &bmsr);
  36485. + if (!(bmsr & BMSR_LSTATUS))
  36486. + tg3_phy_reset(tp);
  36487. + }
  36488. +
  36489. + if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401) {
  36490. + tg3_readphy(tp, MII_BMSR, &bmsr);
  36491. + tg3_readphy(tp, MII_BMSR, &bmsr);
  36492. +
  36493. + if (!(tp->tg3_flags & TG3_FLAG_INIT_COMPLETE))
  36494. + bmsr = 0;
  36495. +
  36496. + if (!(bmsr & BMSR_LSTATUS)) {
  36497. + err = tg3_init_5401phy_dsp(tp);
  36498. + if (err)
  36499. + return err;
  36500. +
  36501. + tg3_readphy(tp, MII_BMSR, &bmsr);
  36502. + for (i = 0; i < 1000; i++) {
  36503. + udelay(10);
  36504. + tg3_readphy(tp, MII_BMSR, &bmsr);
  36505. + if (bmsr & BMSR_LSTATUS) {
  36506. + udelay(40);
  36507. + break;
  36508. + }
  36509. + }
  36510. +
  36511. + if ((tp->phy_id & PHY_ID_REV_MASK) == PHY_REV_BCM5401_B0 &&
  36512. + !(bmsr & BMSR_LSTATUS) &&
  36513. + tp->link_config.active_speed == SPEED_1000) {
  36514. + err = tg3_phy_reset(tp);
  36515. + if (!err)
  36516. + err = tg3_init_5401phy_dsp(tp);
  36517. + if (err)
  36518. + return err;
  36519. + }
  36520. + }
  36521. + } else if (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0 ||
  36522. + tp->pci_chip_rev_id == CHIPREV_ID_5701_B0) {
  36523. + /* 5701 {A0,B0} CRC bug workaround */
  36524. + tg3_writephy(tp, 0x15, 0x0a75);
  36525. + tg3_writephy(tp, 0x1c, 0x8c68);
  36526. + tg3_writephy(tp, 0x1c, 0x8d68);
  36527. + tg3_writephy(tp, 0x1c, 0x8c68);
  36528. + }
  36529. +
  36530. + /* Clear pending interrupts... */
  36531. + tg3_readphy(tp, MII_TG3_ISTAT, &dummy);
  36532. + tg3_readphy(tp, MII_TG3_ISTAT, &dummy);
  36533. +
  36534. + tg3_writephy(tp, MII_TG3_IMASK, ~0);
  36535. +
  36536. + if (tp->led_mode == led_mode_three_link)
  36537. + tg3_writephy(tp, MII_TG3_EXT_CTRL,
  36538. + MII_TG3_EXT_CTRL_LNK3_LED_MODE);
  36539. + else
  36540. + tg3_writephy(tp, MII_TG3_EXT_CTRL, 0);
  36541. +
  36542. + current_link_up = 0;
  36543. +
  36544. + tg3_readphy(tp, MII_BMSR, &bmsr);
  36545. + tg3_readphy(tp, MII_BMSR, &bmsr);
  36546. +
  36547. + if (bmsr & BMSR_LSTATUS) {
  36548. + uint32_t aux_stat, bmcr;
  36549. +
  36550. + tg3_readphy(tp, MII_TG3_AUX_STAT, &aux_stat);
  36551. + for (i = 0; i < 2000; i++) {
  36552. + udelay(10);
  36553. + tg3_readphy(tp, MII_TG3_AUX_STAT, &aux_stat);
  36554. + if (aux_stat)
  36555. + break;
  36556. + }
  36557. +
  36558. + tg3_aux_stat_to_speed_duplex(tp, aux_stat,
  36559. + &tp->link_config.active_speed,
  36560. + &tp->link_config.active_duplex);
  36561. + tg3_readphy(tp, MII_BMCR, &bmcr);
  36562. + tg3_readphy(tp, MII_BMCR, &bmcr);
  36563. + if (bmcr & BMCR_ANENABLE) {
  36564. + uint32_t gig_ctrl;
  36565. +
  36566. + current_link_up = 1;
  36567. +
  36568. + /* Force autoneg restart if we are exiting
  36569. + * low power mode.
  36570. + */
  36571. + tg3_readphy(tp, MII_TG3_CTRL, &gig_ctrl);
  36572. + if (!(gig_ctrl & (MII_TG3_CTRL_ADV_1000_HALF |
  36573. + MII_TG3_CTRL_ADV_1000_FULL))) {
  36574. + current_link_up = 0;
  36575. + }
  36576. + } else {
  36577. + current_link_up = 0;
  36578. + }
  36579. + }
  36580. +
  36581. + if (current_link_up == 1 &&
  36582. + (tp->link_config.active_duplex == DUPLEX_FULL)) {
  36583. + uint32_t local_adv, remote_adv;
  36584. +
  36585. + tg3_readphy(tp, MII_ADVERTISE, &local_adv);
  36586. + local_adv &= (ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM);
  36587. +
  36588. + tg3_readphy(tp, MII_LPA, &remote_adv);
  36589. + remote_adv &= (LPA_PAUSE_CAP | LPA_PAUSE_ASYM);
  36590. +
  36591. + /* If we are not advertising full pause capability,
  36592. + * something is wrong. Bring the link down and reconfigure.
  36593. + */
  36594. + if (local_adv != ADVERTISE_PAUSE_CAP) {
  36595. + current_link_up = 0;
  36596. + } else {
  36597. + tg3_setup_flow_control(tp, local_adv, remote_adv);
  36598. + }
  36599. + }
  36600. +
  36601. + if (current_link_up == 0) {
  36602. + uint32_t tmp;
  36603. +
  36604. + tg3_phy_copper_begin(tp);
  36605. +
  36606. + tg3_readphy(tp, MII_BMSR, &tmp);
  36607. + tg3_readphy(tp, MII_BMSR, &tmp);
  36608. + if (tmp & BMSR_LSTATUS)
  36609. + current_link_up = 1;
  36610. + }
  36611. +
  36612. + tp->mac_mode &= ~MAC_MODE_PORT_MODE_MASK;
  36613. + if (current_link_up == 1) {
  36614. + if (tp->link_config.active_speed == SPEED_100 ||
  36615. + tp->link_config.active_speed == SPEED_10)
  36616. + tp->mac_mode |= MAC_MODE_PORT_MODE_MII;
  36617. + else
  36618. + tp->mac_mode |= MAC_MODE_PORT_MODE_GMII;
  36619. + } else
  36620. + tp->mac_mode |= MAC_MODE_PORT_MODE_GMII;
  36621. +
  36622. + tp->mac_mode &= ~MAC_MODE_HALF_DUPLEX;
  36623. + if (tp->link_config.active_duplex == DUPLEX_HALF)
  36624. + tp->mac_mode |= MAC_MODE_HALF_DUPLEX;
  36625. +
  36626. + tp->mac_mode &= ~MAC_MODE_LINK_POLARITY;
  36627. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700) {
  36628. + if ((tp->led_mode == led_mode_link10) ||
  36629. + (current_link_up == 1 &&
  36630. + tp->link_config.active_speed == SPEED_10))
  36631. + tp->mac_mode |= MAC_MODE_LINK_POLARITY;
  36632. + } else {
  36633. + if (current_link_up == 1)
  36634. + tp->mac_mode |= MAC_MODE_LINK_POLARITY;
  36635. + tw32(MAC_LED_CTRL, LED_CTRL_PHY_MODE_1);
  36636. + }
  36637. +
  36638. + /* ??? Without this setting Netgear GA302T PHY does not
  36639. + * ??? send/receive packets...
  36640. + * With this other PHYs cannot bring up the link
  36641. + */
  36642. + if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5411 &&
  36643. + tp->pci_chip_rev_id == CHIPREV_ID_5700_ALTIMA) {
  36644. + tp->mi_mode |= MAC_MI_MODE_AUTO_POLL;
  36645. + tw32_carefully(MAC_MI_MODE, tp->mi_mode);
  36646. + }
  36647. +
  36648. + tw32_carefully(MAC_MODE, tp->mac_mode);
  36649. +
  36650. + /* Link change polled. */
  36651. + tw32_carefully(MAC_EVENT, 0);
  36652. +
  36653. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 &&
  36654. + current_link_up == 1 &&
  36655. + tp->link_config.active_speed == SPEED_1000 &&
  36656. + ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) ||
  36657. + (tp->tg3_flags & TG3_FLAG_PCI_HIGH_SPEED))) {
  36658. + udelay(120);
  36659. + tw32_carefully(MAC_STATUS,
  36660. + (MAC_STATUS_SYNC_CHANGED | MAC_STATUS_CFG_CHANGED));
  36661. + tg3_write_mem(
  36662. + NIC_SRAM_FIRMWARE_MBOX,
  36663. + NIC_SRAM_FIRMWARE_MBOX_MAGIC2);
  36664. + }
  36665. +
  36666. + if (current_link_up != tp->carrier_ok) {
  36667. + tp->carrier_ok = current_link_up;
  36668. + tg3_link_report(tp);
  36669. + }
  36670. +
  36671. + return 0;
  36672. +}
  36673. +#else
  36674. +#define tg3_setup_copper_phy(TP) (-EINVAL)
  36675. +#endif /* SUPPORT_COPPER_PHY */
  36676. +
  36677. +#if SUPPORT_FIBER_PHY
  36678. +struct tg3_fiber_aneginfo {
  36679. + int state;
  36680. +#define ANEG_STATE_UNKNOWN 0
  36681. +#define ANEG_STATE_AN_ENABLE 1
  36682. +#define ANEG_STATE_RESTART_INIT 2
  36683. +#define ANEG_STATE_RESTART 3
  36684. +#define ANEG_STATE_DISABLE_LINK_OK 4
  36685. +#define ANEG_STATE_ABILITY_DETECT_INIT 5
  36686. +#define ANEG_STATE_ABILITY_DETECT 6
  36687. +#define ANEG_STATE_ACK_DETECT_INIT 7
  36688. +#define ANEG_STATE_ACK_DETECT 8
  36689. +#define ANEG_STATE_COMPLETE_ACK_INIT 9
  36690. +#define ANEG_STATE_COMPLETE_ACK 10
  36691. +#define ANEG_STATE_IDLE_DETECT_INIT 11
  36692. +#define ANEG_STATE_IDLE_DETECT 12
  36693. +#define ANEG_STATE_LINK_OK 13
  36694. +#define ANEG_STATE_NEXT_PAGE_WAIT_INIT 14
  36695. +#define ANEG_STATE_NEXT_PAGE_WAIT 15
  36696. +
  36697. + uint32_t flags;
  36698. +#define MR_AN_ENABLE 0x00000001
  36699. +#define MR_RESTART_AN 0x00000002
  36700. +#define MR_AN_COMPLETE 0x00000004
  36701. +#define MR_PAGE_RX 0x00000008
  36702. +#define MR_NP_LOADED 0x00000010
  36703. +#define MR_TOGGLE_TX 0x00000020
  36704. +#define MR_LP_ADV_FULL_DUPLEX 0x00000040
  36705. +#define MR_LP_ADV_HALF_DUPLEX 0x00000080
  36706. +#define MR_LP_ADV_SYM_PAUSE 0x00000100
  36707. +#define MR_LP_ADV_ASYM_PAUSE 0x00000200
  36708. +#define MR_LP_ADV_REMOTE_FAULT1 0x00000400
  36709. +#define MR_LP_ADV_REMOTE_FAULT2 0x00000800
  36710. +#define MR_LP_ADV_NEXT_PAGE 0x00001000
  36711. +#define MR_TOGGLE_RX 0x00002000
  36712. +#define MR_NP_RX 0x00004000
  36713. +
  36714. +#define MR_LINK_OK 0x80000000
  36715. +
  36716. + unsigned long link_time, cur_time;
  36717. +
  36718. + uint32_t ability_match_cfg;
  36719. + int ability_match_count;
  36720. +
  36721. + char ability_match, idle_match, ack_match;
  36722. +
  36723. + uint32_t txconfig, rxconfig;
  36724. +#define ANEG_CFG_NP 0x00000080
  36725. +#define ANEG_CFG_ACK 0x00000040
  36726. +#define ANEG_CFG_RF2 0x00000020
  36727. +#define ANEG_CFG_RF1 0x00000010
  36728. +#define ANEG_CFG_PS2 0x00000001
  36729. +#define ANEG_CFG_PS1 0x00008000
  36730. +#define ANEG_CFG_HD 0x00004000
  36731. +#define ANEG_CFG_FD 0x00002000
  36732. +#define ANEG_CFG_INVAL 0x00001f06
  36733. +
  36734. +};
  36735. +#define ANEG_OK 0
  36736. +#define ANEG_DONE 1
  36737. +#define ANEG_TIMER_ENAB 2
  36738. +#define ANEG_FAILED -1
  36739. +
  36740. +#define ANEG_STATE_SETTLE_TIME 10000
  36741. +
  36742. +static int tg3_fiber_aneg_smachine(struct tg3 *tp,
  36743. + struct tg3_fiber_aneginfo *ap)
  36744. +{
  36745. + unsigned long delta;
  36746. + uint32_t rx_cfg_reg;
  36747. + int ret;
  36748. +
  36749. + if (ap->state == ANEG_STATE_UNKNOWN) {
  36750. + ap->rxconfig = 0;
  36751. + ap->link_time = 0;
  36752. + ap->cur_time = 0;
  36753. + ap->ability_match_cfg = 0;
  36754. + ap->ability_match_count = 0;
  36755. + ap->ability_match = 0;
  36756. + ap->idle_match = 0;
  36757. + ap->ack_match = 0;
  36758. + }
  36759. + ap->cur_time++;
  36760. +
  36761. + if (tr32(MAC_STATUS) & MAC_STATUS_RCVD_CFG) {
  36762. + rx_cfg_reg = tr32(MAC_RX_AUTO_NEG);
  36763. +
  36764. + if (rx_cfg_reg != ap->ability_match_cfg) {
  36765. + ap->ability_match_cfg = rx_cfg_reg;
  36766. + ap->ability_match = 0;
  36767. + ap->ability_match_count = 0;
  36768. + } else {
  36769. + if (++ap->ability_match_count > 1) {
  36770. + ap->ability_match = 1;
  36771. + ap->ability_match_cfg = rx_cfg_reg;
  36772. + }
  36773. + }
  36774. + if (rx_cfg_reg & ANEG_CFG_ACK)
  36775. + ap->ack_match = 1;
  36776. + else
  36777. + ap->ack_match = 0;
  36778. +
  36779. + ap->idle_match = 0;
  36780. + } else {
  36781. + ap->idle_match = 1;
  36782. + ap->ability_match_cfg = 0;
  36783. + ap->ability_match_count = 0;
  36784. + ap->ability_match = 0;
  36785. + ap->ack_match = 0;
  36786. +
  36787. + rx_cfg_reg = 0;
  36788. + }
  36789. +
  36790. + ap->rxconfig = rx_cfg_reg;
  36791. + ret = ANEG_OK;
  36792. +
  36793. + switch(ap->state) {
  36794. + case ANEG_STATE_UNKNOWN:
  36795. + if (ap->flags & (MR_AN_ENABLE | MR_RESTART_AN))
  36796. + ap->state = ANEG_STATE_AN_ENABLE;
  36797. +
  36798. + /* fallthru */
  36799. + case ANEG_STATE_AN_ENABLE:
  36800. + ap->flags &= ~(MR_AN_COMPLETE | MR_PAGE_RX);
  36801. + if (ap->flags & MR_AN_ENABLE) {
  36802. + ap->link_time = 0;
  36803. + ap->cur_time = 0;
  36804. + ap->ability_match_cfg = 0;
  36805. + ap->ability_match_count = 0;
  36806. + ap->ability_match = 0;
  36807. + ap->idle_match = 0;
  36808. + ap->ack_match = 0;
  36809. +
  36810. + ap->state = ANEG_STATE_RESTART_INIT;
  36811. + } else {
  36812. + ap->state = ANEG_STATE_DISABLE_LINK_OK;
  36813. + }
  36814. + break;
  36815. +
  36816. + case ANEG_STATE_RESTART_INIT:
  36817. + ap->link_time = ap->cur_time;
  36818. + ap->flags &= ~(MR_NP_LOADED);
  36819. + ap->txconfig = 0;
  36820. + tw32(MAC_TX_AUTO_NEG, 0);
  36821. + tp->mac_mode |= MAC_MODE_SEND_CONFIGS;
  36822. + tw32_carefully(MAC_MODE, tp->mac_mode);
  36823. +
  36824. + ret = ANEG_TIMER_ENAB;
  36825. + ap->state = ANEG_STATE_RESTART;
  36826. +
  36827. + /* fallthru */
  36828. + case ANEG_STATE_RESTART:
  36829. + delta = ap->cur_time - ap->link_time;
  36830. + if (delta > ANEG_STATE_SETTLE_TIME) {
  36831. + ap->state = ANEG_STATE_ABILITY_DETECT_INIT;
  36832. + } else {
  36833. + ret = ANEG_TIMER_ENAB;
  36834. + }
  36835. + break;
  36836. +
  36837. + case ANEG_STATE_DISABLE_LINK_OK:
  36838. + ret = ANEG_DONE;
  36839. + break;
  36840. +
  36841. + case ANEG_STATE_ABILITY_DETECT_INIT:
  36842. + ap->flags &= ~(MR_TOGGLE_TX);
  36843. + ap->txconfig = (ANEG_CFG_FD | ANEG_CFG_PS1);
  36844. + tw32(MAC_TX_AUTO_NEG, ap->txconfig);
  36845. + tp->mac_mode |= MAC_MODE_SEND_CONFIGS;
  36846. + tw32_carefully(MAC_MODE, tp->mac_mode);
  36847. +
  36848. + ap->state = ANEG_STATE_ABILITY_DETECT;
  36849. + break;
  36850. +
  36851. + case ANEG_STATE_ABILITY_DETECT:
  36852. + if (ap->ability_match != 0 && ap->rxconfig != 0) {
  36853. + ap->state = ANEG_STATE_ACK_DETECT_INIT;
  36854. + }
  36855. + break;
  36856. +
  36857. + case ANEG_STATE_ACK_DETECT_INIT:
  36858. + ap->txconfig |= ANEG_CFG_ACK;
  36859. + tw32(MAC_TX_AUTO_NEG, ap->txconfig);
  36860. + tp->mac_mode |= MAC_MODE_SEND_CONFIGS;
  36861. + tw32_carefully(MAC_MODE, tp->mac_mode);
  36862. +
  36863. + ap->state = ANEG_STATE_ACK_DETECT;
  36864. +
  36865. + /* fallthru */
  36866. + case ANEG_STATE_ACK_DETECT:
  36867. + if (ap->ack_match != 0) {
  36868. + if ((ap->rxconfig & ~ANEG_CFG_ACK) ==
  36869. + (ap->ability_match_cfg & ~ANEG_CFG_ACK)) {
  36870. + ap->state = ANEG_STATE_COMPLETE_ACK_INIT;
  36871. + } else {
  36872. + ap->state = ANEG_STATE_AN_ENABLE;
  36873. + }
  36874. + } else if (ap->ability_match != 0 &&
  36875. + ap->rxconfig == 0) {
  36876. + ap->state = ANEG_STATE_AN_ENABLE;
  36877. + }
  36878. + break;
  36879. +
  36880. + case ANEG_STATE_COMPLETE_ACK_INIT:
  36881. + if (ap->rxconfig & ANEG_CFG_INVAL) {
  36882. + ret = ANEG_FAILED;
  36883. + break;
  36884. + }
  36885. + ap->flags &= ~(MR_LP_ADV_FULL_DUPLEX |
  36886. + MR_LP_ADV_HALF_DUPLEX |
  36887. + MR_LP_ADV_SYM_PAUSE |
  36888. + MR_LP_ADV_ASYM_PAUSE |
  36889. + MR_LP_ADV_REMOTE_FAULT1 |
  36890. + MR_LP_ADV_REMOTE_FAULT2 |
  36891. + MR_LP_ADV_NEXT_PAGE |
  36892. + MR_TOGGLE_RX |
  36893. + MR_NP_RX);
  36894. + if (ap->rxconfig & ANEG_CFG_FD)
  36895. + ap->flags |= MR_LP_ADV_FULL_DUPLEX;
  36896. + if (ap->rxconfig & ANEG_CFG_HD)
  36897. + ap->flags |= MR_LP_ADV_HALF_DUPLEX;
  36898. + if (ap->rxconfig & ANEG_CFG_PS1)
  36899. + ap->flags |= MR_LP_ADV_SYM_PAUSE;
  36900. + if (ap->rxconfig & ANEG_CFG_PS2)
  36901. + ap->flags |= MR_LP_ADV_ASYM_PAUSE;
  36902. + if (ap->rxconfig & ANEG_CFG_RF1)
  36903. + ap->flags |= MR_LP_ADV_REMOTE_FAULT1;
  36904. + if (ap->rxconfig & ANEG_CFG_RF2)
  36905. + ap->flags |= MR_LP_ADV_REMOTE_FAULT2;
  36906. + if (ap->rxconfig & ANEG_CFG_NP)
  36907. + ap->flags |= MR_LP_ADV_NEXT_PAGE;
  36908. +
  36909. + ap->link_time = ap->cur_time;
  36910. +
  36911. + ap->flags ^= (MR_TOGGLE_TX);
  36912. + if (ap->rxconfig & 0x0008)
  36913. + ap->flags |= MR_TOGGLE_RX;
  36914. + if (ap->rxconfig & ANEG_CFG_NP)
  36915. + ap->flags |= MR_NP_RX;
  36916. + ap->flags |= MR_PAGE_RX;
  36917. +
  36918. + ap->state = ANEG_STATE_COMPLETE_ACK;
  36919. + ret = ANEG_TIMER_ENAB;
  36920. + break;
  36921. +
  36922. + case ANEG_STATE_COMPLETE_ACK:
  36923. + if (ap->ability_match != 0 &&
  36924. + ap->rxconfig == 0) {
  36925. + ap->state = ANEG_STATE_AN_ENABLE;
  36926. + break;
  36927. + }
  36928. + delta = ap->cur_time - ap->link_time;
  36929. + if (delta > ANEG_STATE_SETTLE_TIME) {
  36930. + if (!(ap->flags & (MR_LP_ADV_NEXT_PAGE))) {
  36931. + ap->state = ANEG_STATE_IDLE_DETECT_INIT;
  36932. + } else {
  36933. + if ((ap->txconfig & ANEG_CFG_NP) == 0 &&
  36934. + !(ap->flags & MR_NP_RX)) {
  36935. + ap->state = ANEG_STATE_IDLE_DETECT_INIT;
  36936. + } else {
  36937. + ret = ANEG_FAILED;
  36938. + }
  36939. + }
  36940. + }
  36941. + break;
  36942. +
  36943. + case ANEG_STATE_IDLE_DETECT_INIT:
  36944. + ap->link_time = ap->cur_time;
  36945. + tp->mac_mode &= ~MAC_MODE_SEND_CONFIGS;
  36946. + tw32_carefully(MAC_MODE, tp->mac_mode);
  36947. +
  36948. + ap->state = ANEG_STATE_IDLE_DETECT;
  36949. + ret = ANEG_TIMER_ENAB;
  36950. + break;
  36951. +
  36952. + case ANEG_STATE_IDLE_DETECT:
  36953. + if (ap->ability_match != 0 &&
  36954. + ap->rxconfig == 0) {
  36955. + ap->state = ANEG_STATE_AN_ENABLE;
  36956. + break;
  36957. + }
  36958. + delta = ap->cur_time - ap->link_time;
  36959. + if (delta > ANEG_STATE_SETTLE_TIME) {
  36960. + /* XXX another gem from the Broadcom driver :( */
  36961. + ap->state = ANEG_STATE_LINK_OK;
  36962. + }
  36963. + break;
  36964. +
  36965. + case ANEG_STATE_LINK_OK:
  36966. + ap->flags |= (MR_AN_COMPLETE | MR_LINK_OK);
  36967. + ret = ANEG_DONE;
  36968. + break;
  36969. +
  36970. + case ANEG_STATE_NEXT_PAGE_WAIT_INIT:
  36971. + /* ??? unimplemented */
  36972. + break;
  36973. +
  36974. + case ANEG_STATE_NEXT_PAGE_WAIT:
  36975. + /* ??? unimplemented */
  36976. + break;
  36977. +
  36978. + default:
  36979. + ret = ANEG_FAILED;
  36980. + break;
  36981. + };
  36982. +
  36983. + return ret;
  36984. +}
  36985. +
  36986. +static int tg3_setup_fiber_phy(struct tg3 *tp)
  36987. +{
  36988. + uint32_t orig_pause_cfg;
  36989. + uint16_t orig_active_speed;
  36990. + uint8_t orig_active_duplex;
  36991. + int current_link_up;
  36992. + int i;
  36993. +
  36994. + orig_pause_cfg =
  36995. + (tp->tg3_flags & (TG3_FLAG_RX_PAUSE |
  36996. + TG3_FLAG_TX_PAUSE));
  36997. + orig_active_speed = tp->link_config.active_speed;
  36998. + orig_active_duplex = tp->link_config.active_duplex;
  36999. +
  37000. + tp->mac_mode &= ~(MAC_MODE_PORT_MODE_MASK | MAC_MODE_HALF_DUPLEX);
  37001. + tp->mac_mode |= MAC_MODE_PORT_MODE_TBI;
  37002. + tw32_carefully(MAC_MODE, tp->mac_mode);
  37003. +
  37004. + /* Reset when initting first time or we have a link. */
  37005. + if (!(tp->tg3_flags & TG3_FLAG_INIT_COMPLETE) ||
  37006. + (tr32(MAC_STATUS) & MAC_STATUS_PCS_SYNCED)) {
  37007. + /* Set PLL lock range. */
  37008. + tg3_writephy(tp, 0x16, 0x8007);
  37009. +
  37010. + /* SW reset */
  37011. + tg3_writephy(tp, MII_BMCR, BMCR_RESET);
  37012. +
  37013. + /* Wait for reset to complete. */
  37014. + mdelay(5);
  37015. +
  37016. + /* Config mode; select PMA/Ch 1 regs. */
  37017. + tg3_writephy(tp, 0x10, 0x8411);
  37018. +
  37019. + /* Enable auto-lock and comdet, select txclk for tx. */
  37020. + tg3_writephy(tp, 0x11, 0x0a10);
  37021. +
  37022. + tg3_writephy(tp, 0x18, 0x00a0);
  37023. + tg3_writephy(tp, 0x16, 0x41ff);
  37024. +
  37025. + /* Assert and deassert POR. */
  37026. + tg3_writephy(tp, 0x13, 0x0400);
  37027. + udelay(40);
  37028. + tg3_writephy(tp, 0x13, 0x0000);
  37029. +
  37030. + tg3_writephy(tp, 0x11, 0x0a50);
  37031. + udelay(40);
  37032. + tg3_writephy(tp, 0x11, 0x0a10);
  37033. +
  37034. + /* Wait for signal to stabilize */
  37035. + mdelay(150);
  37036. +
  37037. + /* Deselect the channel register so we can read the PHYID
  37038. + * later.
  37039. + */
  37040. + tg3_writephy(tp, 0x10, 0x8011);
  37041. + }
  37042. +
  37043. + /* Disable link change interrupt. */
  37044. + tw32_carefully(MAC_EVENT, 0);
  37045. +
  37046. + current_link_up = 0;
  37047. + if (tr32(MAC_STATUS) & MAC_STATUS_PCS_SYNCED) {
  37048. + if (!(tp->tg3_flags & TG3_FLAG_GOT_SERDES_FLOWCTL)) {
  37049. + struct tg3_fiber_aneginfo aninfo;
  37050. + int status = ANEG_FAILED;
  37051. + unsigned int tick;
  37052. + uint32_t tmp;
  37053. +
  37054. + memset(&aninfo, 0, sizeof(aninfo));
  37055. + aninfo.flags |= (MR_AN_ENABLE);
  37056. +
  37057. + tw32(MAC_TX_AUTO_NEG, 0);
  37058. +
  37059. + tmp = tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK;
  37060. + tw32_carefully(MAC_MODE, tmp | MAC_MODE_PORT_MODE_GMII);
  37061. +
  37062. + tw32_carefully(MAC_MODE, tp->mac_mode | MAC_MODE_SEND_CONFIGS);
  37063. +
  37064. + aninfo.state = ANEG_STATE_UNKNOWN;
  37065. + aninfo.cur_time = 0;
  37066. + tick = 0;
  37067. + while (++tick < 195000) {
  37068. + status = tg3_fiber_aneg_smachine(tp, &aninfo);
  37069. + if (status == ANEG_DONE ||
  37070. + status == ANEG_FAILED)
  37071. + break;
  37072. +
  37073. + udelay(1);
  37074. + }
  37075. +
  37076. + tp->mac_mode &= ~MAC_MODE_SEND_CONFIGS;
  37077. + tw32_carefully(MAC_MODE, tp->mac_mode);
  37078. +
  37079. + if (status == ANEG_DONE &&
  37080. + (aninfo.flags &
  37081. + (MR_AN_COMPLETE | MR_LINK_OK |
  37082. + MR_LP_ADV_FULL_DUPLEX))) {
  37083. + uint32_t local_adv, remote_adv;
  37084. +
  37085. + local_adv = ADVERTISE_PAUSE_CAP;
  37086. + remote_adv = 0;
  37087. + if (aninfo.flags & MR_LP_ADV_SYM_PAUSE)
  37088. + remote_adv |= LPA_PAUSE_CAP;
  37089. + if (aninfo.flags & MR_LP_ADV_ASYM_PAUSE)
  37090. + remote_adv |= LPA_PAUSE_ASYM;
  37091. +
  37092. + tg3_setup_flow_control(tp, local_adv, remote_adv);
  37093. +
  37094. + tp->tg3_flags |=
  37095. + TG3_FLAG_GOT_SERDES_FLOWCTL;
  37096. + current_link_up = 1;
  37097. + }
  37098. + for (i = 0; i < 60; i++) {
  37099. + udelay(20);
  37100. + tw32_carefully(MAC_STATUS,
  37101. + (MAC_STATUS_SYNC_CHANGED | MAC_STATUS_CFG_CHANGED));
  37102. + if ((tr32(MAC_STATUS) &
  37103. + (MAC_STATUS_SYNC_CHANGED |
  37104. + MAC_STATUS_CFG_CHANGED)) == 0)
  37105. + break;
  37106. + }
  37107. + if (current_link_up == 0 &&
  37108. + (tr32(MAC_STATUS) & MAC_STATUS_PCS_SYNCED)) {
  37109. + current_link_up = 1;
  37110. + }
  37111. + } else {
  37112. + /* Forcing 1000FD link up. */
  37113. + current_link_up = 1;
  37114. + }
  37115. + }
  37116. +
  37117. + tp->mac_mode &= ~MAC_MODE_LINK_POLARITY;
  37118. + tw32_carefully(MAC_MODE, tp->mac_mode);
  37119. +
  37120. + tp->hw_status->status =
  37121. + (SD_STATUS_UPDATED |
  37122. + (tp->hw_status->status & ~SD_STATUS_LINK_CHG));
  37123. +
  37124. + for (i = 0; i < 100; i++) {
  37125. + udelay(20);
  37126. + tw32_carefully(MAC_STATUS,
  37127. + (MAC_STATUS_SYNC_CHANGED | MAC_STATUS_CFG_CHANGED));
  37128. + if ((tr32(MAC_STATUS) &
  37129. + (MAC_STATUS_SYNC_CHANGED |
  37130. + MAC_STATUS_CFG_CHANGED)) == 0)
  37131. + break;
  37132. + }
  37133. +
  37134. + if ((tr32(MAC_STATUS) & MAC_STATUS_PCS_SYNCED) == 0)
  37135. + current_link_up = 0;
  37136. +
  37137. + if (current_link_up == 1) {
  37138. + tp->link_config.active_speed = SPEED_1000;
  37139. + tp->link_config.active_duplex = DUPLEX_FULL;
  37140. + } else {
  37141. + tp->link_config.active_speed = SPEED_INVALID;
  37142. + tp->link_config.active_duplex = DUPLEX_INVALID;
  37143. + }
  37144. +
  37145. + if (current_link_up != tp->carrier_ok) {
  37146. + tp->carrier_ok = current_link_up;
  37147. + tg3_link_report(tp);
  37148. + } else {
  37149. + uint32_t now_pause_cfg =
  37150. + tp->tg3_flags & (TG3_FLAG_RX_PAUSE |
  37151. + TG3_FLAG_TX_PAUSE);
  37152. + if (orig_pause_cfg != now_pause_cfg ||
  37153. + orig_active_speed != tp->link_config.active_speed ||
  37154. + orig_active_duplex != tp->link_config.active_duplex)
  37155. + tg3_link_report(tp);
  37156. + }
  37157. +
  37158. + if ((tr32(MAC_STATUS) & MAC_STATUS_PCS_SYNCED) == 0) {
  37159. + tw32_carefully(MAC_MODE, tp->mac_mode | MAC_MODE_LINK_POLARITY);
  37160. + if (tp->tg3_flags & TG3_FLAG_INIT_COMPLETE) {
  37161. + tw32_carefully(MAC_MODE, tp->mac_mode);
  37162. + }
  37163. + }
  37164. +
  37165. + return 0;
  37166. +}
  37167. +#else
  37168. +#define tg3_setup_fiber_phy(TP) (-EINVAL)
  37169. +#endif /* SUPPORT_FIBER_PHY */
  37170. +
  37171. +static int tg3_setup_phy(struct tg3 *tp)
  37172. +{
  37173. + int err;
  37174. +
  37175. + if (tp->phy_id == PHY_ID_SERDES) {
  37176. + err = tg3_setup_fiber_phy(tp);
  37177. + } else {
  37178. + err = tg3_setup_copper_phy(tp);
  37179. + }
  37180. +
  37181. + if (tp->link_config.active_speed == SPEED_1000 &&
  37182. + tp->link_config.active_duplex == DUPLEX_HALF)
  37183. + tw32(MAC_TX_LENGTHS,
  37184. + ((2 << TX_LENGTHS_IPG_CRS_SHIFT) |
  37185. + (6 << TX_LENGTHS_IPG_SHIFT) |
  37186. + (0xff << TX_LENGTHS_SLOT_TIME_SHIFT)));
  37187. + else
  37188. + tw32(MAC_TX_LENGTHS,
  37189. + ((2 << TX_LENGTHS_IPG_CRS_SHIFT) |
  37190. + (6 << TX_LENGTHS_IPG_SHIFT) |
  37191. + (32 << TX_LENGTHS_SLOT_TIME_SHIFT)));
  37192. +
  37193. + return err;
  37194. +}
  37195. +
  37196. +
  37197. +#define MAX_WAIT_CNT 1000
  37198. +
  37199. +/* To stop a block, clear the enable bit and poll till it
  37200. + * clears.
  37201. + */
  37202. +static int tg3_stop_block(struct tg3 *tp, unsigned long ofs, uint32_t enable_bit)
  37203. +{
  37204. + unsigned int i;
  37205. + uint32_t val;
  37206. +
  37207. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
  37208. + switch(ofs) {
  37209. + case RCVLSC_MODE:
  37210. + case DMAC_MODE:
  37211. + case MBFREE_MODE:
  37212. + case BUFMGR_MODE:
  37213. + case MEMARB_MODE:
  37214. + /* We can't enable/disable these bits of the
  37215. + * 5705, just say success.
  37216. + */
  37217. + return 0;
  37218. + default:
  37219. + break;
  37220. + }
  37221. + }
  37222. + val = tr32(ofs);
  37223. + val &= ~enable_bit;
  37224. + tw32(ofs, val);
  37225. + tr32(ofs);
  37226. +
  37227. + for (i = 0; i < MAX_WAIT_CNT; i++) {
  37228. + udelay(100);
  37229. + val = tr32(ofs);
  37230. + if ((val & enable_bit) == 0)
  37231. + break;
  37232. + }
  37233. +
  37234. + if (i == MAX_WAIT_CNT) {
  37235. + printf("tg3_stop_block timed out, ofs=%lx enable_bit=%x\n",
  37236. + ofs, enable_bit);
  37237. + return -ENODEV;
  37238. + }
  37239. +
  37240. + return 0;
  37241. +}
  37242. +
  37243. +static int tg3_abort_hw(struct tg3 *tp)
  37244. +{
  37245. + int i, err;
  37246. +
  37247. + tg3_disable_ints(tp);
  37248. +
  37249. + tp->rx_mode &= ~RX_MODE_ENABLE;
  37250. + tw32_carefully(MAC_RX_MODE, tp->rx_mode);
  37251. +
  37252. + err = tg3_stop_block(tp, RCVBDI_MODE, RCVBDI_MODE_ENABLE);
  37253. + err |= tg3_stop_block(tp, RCVLPC_MODE, RCVLPC_MODE_ENABLE);
  37254. + err |= tg3_stop_block(tp, RCVLSC_MODE, RCVLSC_MODE_ENABLE);
  37255. + err |= tg3_stop_block(tp, RCVDBDI_MODE, RCVDBDI_MODE_ENABLE);
  37256. + err |= tg3_stop_block(tp, RCVDCC_MODE, RCVDCC_MODE_ENABLE);
  37257. + err |= tg3_stop_block(tp, RCVCC_MODE, RCVCC_MODE_ENABLE);
  37258. +
  37259. + err |= tg3_stop_block(tp, SNDBDS_MODE, SNDBDS_MODE_ENABLE);
  37260. + err |= tg3_stop_block(tp, SNDBDI_MODE, SNDBDI_MODE_ENABLE);
  37261. + err |= tg3_stop_block(tp, SNDDATAI_MODE, SNDDATAI_MODE_ENABLE);
  37262. + err |= tg3_stop_block(tp, RDMAC_MODE, RDMAC_MODE_ENABLE);
  37263. + err |= tg3_stop_block(tp, SNDDATAC_MODE, SNDDATAC_MODE_ENABLE);
  37264. + err |= tg3_stop_block(tp, SNDBDC_MODE, SNDBDC_MODE_ENABLE);
  37265. + if (err)
  37266. + goto out;
  37267. +
  37268. + tp->mac_mode &= ~MAC_MODE_TDE_ENABLE;
  37269. + tw32_carefully(MAC_MODE, tp->mac_mode);
  37270. +
  37271. + tp->tx_mode &= ~TX_MODE_ENABLE;
  37272. + tw32_carefully(MAC_TX_MODE, tp->tx_mode);
  37273. +
  37274. + for (i = 0; i < MAX_WAIT_CNT; i++) {
  37275. + udelay(100);
  37276. + if (!(tr32(MAC_TX_MODE) & TX_MODE_ENABLE))
  37277. + break;
  37278. + }
  37279. + if (i >= MAX_WAIT_CNT) {
  37280. + printf("tg3_abort_hw timed out TX_MODE_ENABLE will not clear MAC_TX_MODE=%x\n",
  37281. + tr32(MAC_TX_MODE));
  37282. + return -ENODEV;
  37283. + }
  37284. +
  37285. + err = tg3_stop_block(tp, HOSTCC_MODE, HOSTCC_MODE_ENABLE);
  37286. + err |= tg3_stop_block(tp, WDMAC_MODE, WDMAC_MODE_ENABLE);
  37287. + err |= tg3_stop_block(tp, MBFREE_MODE, MBFREE_MODE_ENABLE);
  37288. +
  37289. + tw32(FTQ_RESET, 0xffffffff);
  37290. + tw32(FTQ_RESET, 0x00000000);
  37291. +
  37292. + err |= tg3_stop_block(tp, BUFMGR_MODE, BUFMGR_MODE_ENABLE);
  37293. + err |= tg3_stop_block(tp, MEMARB_MODE, MEMARB_MODE_ENABLE);
  37294. + if (err)
  37295. + goto out;
  37296. +
  37297. + memset(tp->hw_status, 0, TG3_HW_STATUS_SIZE);
  37298. +
  37299. +out:
  37300. + return err;
  37301. +}
  37302. +
  37303. +static void tg3_chip_reset(struct tg3 *tp)
  37304. +{
  37305. + uint32_t val;
  37306. +
  37307. + if (!(tp->tg3_flags2 & TG3_FLG2_SUN_5704)) {
  37308. + /* Force NVRAM to settle.
  37309. + * This deals with a chip bug which can result in EEPROM
  37310. + * corruption.
  37311. + */
  37312. + if (tp->tg3_flags & TG3_FLAG_NVRAM) {
  37313. + int i;
  37314. +
  37315. + tw32(NVRAM_SWARB, SWARB_REQ_SET1);
  37316. + for (i = 0; i < 100000; i++) {
  37317. + if (tr32(NVRAM_SWARB) & SWARB_GNT1)
  37318. + break;
  37319. + udelay(10);
  37320. + }
  37321. + }
  37322. + }
  37323. + /* In Etherboot we don't need to worry about the 5701
  37324. + * REG_WRITE_BUG because we do all register writes indirectly.
  37325. + */
  37326. +
  37327. + /* do the reset */
  37328. + val = GRC_MISC_CFG_CORECLK_RESET;
  37329. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
  37330. + val |= GRC_MISC_CFG_KEEP_GPHY_POWER;
  37331. + tw32(GRC_MISC_CFG, val);
  37332. +
  37333. + /* Flush PCI posted writes. The normal MMIO registers
  37334. + * are inaccessible at this time so this is the only
  37335. + * way to make this reliably. I tried to use indirect
  37336. + * register read/write but this upset some 5701 variants.
  37337. + */
  37338. + pci_read_config_dword(tp->pdev, PCI_COMMAND, &val);
  37339. +
  37340. + udelay(120);
  37341. +
  37342. + /* Re-enable indirect register accesses. */
  37343. + pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL,
  37344. + tp->misc_host_ctrl);
  37345. +
  37346. + /* Set MAX PCI retry to zero. */
  37347. + val = (PCISTATE_ROM_ENABLE | PCISTATE_ROM_RETRY_ENABLE);
  37348. + if (tp->pci_chip_rev_id == CHIPREV_ID_5704_A0 &&
  37349. + (tp->tg3_flags & TG3_FLAG_PCIX_MODE))
  37350. + val |= PCISTATE_RETRY_SAME_DMA;
  37351. + pci_write_config_dword(tp->pdev, TG3PCI_PCISTATE, val);
  37352. +
  37353. + pci_restore_state(tp->pdev, tp->pci_cfg_state);
  37354. +
  37355. + /* Make sure PCI-X relaxed ordering bit is clear. */
  37356. + pci_read_config_dword(tp->pdev, TG3PCI_X_CAPS, &val);
  37357. + val &= ~PCIX_CAPS_RELAXED_ORDERING;
  37358. + pci_write_config_dword(tp->pdev, TG3PCI_X_CAPS, val);
  37359. +
  37360. + tw32(MEMARB_MODE, MEMARB_MODE_ENABLE);
  37361. +
  37362. + if (((tp->nic_sram_data_cfg & NIC_SRAM_DATA_CFG_MINI_PCI) != 0) &&
  37363. + (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)) {
  37364. + tp->pci_clock_ctrl |=
  37365. + (CLOCK_CTRL_FORCE_CLKRUN | CLOCK_CTRL_CLKRUN_OENABLE);
  37366. + tw32(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl);
  37367. + }
  37368. +
  37369. + tw32(TG3PCI_MISC_HOST_CTRL, tp->misc_host_ctrl);
  37370. +}
  37371. +
  37372. +static void tg3_stop_fw(struct tg3 *tp)
  37373. +{
  37374. + if (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) {
  37375. + uint32_t val;
  37376. + int i;
  37377. +
  37378. + tg3_write_mem(NIC_SRAM_FW_CMD_MBOX, FWCMD_NICDRV_PAUSE_FW);
  37379. + val = tr32(GRC_RX_CPU_EVENT);
  37380. + val |= (1 << 14);
  37381. + tw32(GRC_RX_CPU_EVENT, val);
  37382. +
  37383. + /* Wait for RX cpu to ACK the event. */
  37384. + for (i = 0; i < 100; i++) {
  37385. + if (!(tr32(GRC_RX_CPU_EVENT) & (1 << 14)))
  37386. + break;
  37387. + udelay(1);
  37388. + }
  37389. + }
  37390. +}
  37391. +
  37392. +static int tg3_restart_fw(struct tg3 *tp, uint32_t state)
  37393. +{
  37394. + uint32_t val;
  37395. + int i;
  37396. +
  37397. + tg3_write_mem(NIC_SRAM_FIRMWARE_MBOX,
  37398. + NIC_SRAM_FIRMWARE_MBOX_MAGIC1);
  37399. + /* Wait for firmware initialization to complete. */
  37400. + for (i = 0; i < 100000; i++) {
  37401. + tg3_read_mem(NIC_SRAM_FIRMWARE_MBOX, &val);
  37402. + if (val == (uint32_t) ~NIC_SRAM_FIRMWARE_MBOX_MAGIC1)
  37403. + break;
  37404. + udelay(10);
  37405. + }
  37406. + if (i >= 100000 &&
  37407. + !(tp->tg3_flags2 & TG3_FLG2_SUN_5704)) {
  37408. + printf("Firmware will not restart magic=%x\n",
  37409. + val);
  37410. + return -ENODEV;
  37411. + }
  37412. + if (!(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) {
  37413. + state = DRV_STATE_SUSPEND;
  37414. + }
  37415. + tg3_write_mem(NIC_SRAM_FW_DRV_STATE_MBOX, state);
  37416. + return 0;
  37417. +}
  37418. +
  37419. +static int tg3_halt(struct tg3 *tp)
  37420. +{
  37421. + tg3_stop_fw(tp);
  37422. + tg3_abort_hw(tp);
  37423. + tg3_chip_reset(tp);
  37424. + return tg3_restart_fw(tp, DRV_STATE_UNLOAD);
  37425. +}
  37426. +
  37427. +static void __tg3_set_mac_addr(struct tg3 *tp)
  37428. +{
  37429. + uint32_t addr_high, addr_low;
  37430. + int i;
  37431. +
  37432. + addr_high = ((tp->nic->node_addr[0] << 8) |
  37433. + tp->nic->node_addr[1]);
  37434. + addr_low = ((tp->nic->node_addr[2] << 24) |
  37435. + (tp->nic->node_addr[3] << 16) |
  37436. + (tp->nic->node_addr[4] << 8) |
  37437. + (tp->nic->node_addr[5] << 0));
  37438. + for (i = 0; i < 4; i++) {
  37439. + tw32(MAC_ADDR_0_HIGH + (i * 8), addr_high);
  37440. + tw32(MAC_ADDR_0_LOW + (i * 8), addr_low);
  37441. + }
  37442. +
  37443. + if ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700) &&
  37444. + (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) &&
  37445. + (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705)) {
  37446. + for(i = 0; i < 12; i++) {
  37447. + tw32(MAC_EXTADDR_0_HIGH + (i * 8), addr_high);
  37448. + tw32(MAC_EXTADDR_0_LOW + (i * 8), addr_low);
  37449. + }
  37450. + }
  37451. + addr_high = (tp->nic->node_addr[0] +
  37452. + tp->nic->node_addr[1] +
  37453. + tp->nic->node_addr[2] +
  37454. + tp->nic->node_addr[3] +
  37455. + tp->nic->node_addr[4] +
  37456. + tp->nic->node_addr[5]) &
  37457. + TX_BACKOFF_SEED_MASK;
  37458. + tw32(MAC_TX_BACKOFF_SEED, addr_high);
  37459. +}
  37460. +
  37461. +static void tg3_set_bdinfo(struct tg3 *tp, uint32_t bdinfo_addr,
  37462. + dma_addr_t mapping, uint32_t maxlen_flags,
  37463. + uint32_t nic_addr)
  37464. +{
  37465. + tg3_write_mem((bdinfo_addr +
  37466. + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_HIGH),
  37467. + ((uint64_t) mapping >> 32));
  37468. + tg3_write_mem((bdinfo_addr +
  37469. + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_LOW),
  37470. + ((uint64_t) mapping & 0xffffffff));
  37471. + tg3_write_mem((bdinfo_addr +
  37472. + TG3_BDINFO_MAXLEN_FLAGS),
  37473. + maxlen_flags);
  37474. + if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
  37475. + tg3_write_mem((bdinfo_addr + TG3_BDINFO_NIC_ADDR), nic_addr);
  37476. + }
  37477. +}
  37478. +
  37479. +
  37480. +static void tg3_init_rings(struct tg3 *tp)
  37481. +{
  37482. + unsigned i;
  37483. +
  37484. + /* Zero out the tg3 variables */
  37485. + memset(&tg3_bss, 0, sizeof(tg3_bss));
  37486. + tp->rx_std = &tg3_bss.rx_std[0];
  37487. + tp->rx_rcb = &tg3_bss.rx_rcb[0];
  37488. + tp->tx_ring = &tg3_bss.tx_ring[0];
  37489. + tp->hw_status = &tg3_bss.hw_status;
  37490. + tp->hw_stats = &tg3_bss.hw_stats;
  37491. + tp->mac_mode = 0;
  37492. +
  37493. +
  37494. + /* Initialize tx/rx rings for packet processing.
  37495. + *
  37496. + * The chip has been shut down and the driver detached from
  37497. + * the networking, so no interrupts or new tx packets will
  37498. + * end up in the driver.
  37499. + */
  37500. +
  37501. + /* Initialize invariants of the rings, we only set this
  37502. + * stuff once. This works because the card does not
  37503. + * write into the rx buffer posting rings.
  37504. + */
  37505. + for (i = 0; i < TG3_RX_RING_SIZE; i++) {
  37506. + struct tg3_rx_buffer_desc *rxd;
  37507. +
  37508. + rxd = &tp->rx_std[i];
  37509. + rxd->idx_len = (RX_PKT_BUF_SZ - 2 - 64) << RXD_LEN_SHIFT;
  37510. + rxd->type_flags = (RXD_FLAG_END << RXD_FLAGS_SHIFT);
  37511. + rxd->opaque = (RXD_OPAQUE_RING_STD | (i << RXD_OPAQUE_INDEX_SHIFT));
  37512. +
  37513. + /* Note where the receive buffer for the ring is placed */
  37514. + rxd->addr_hi = 0;
  37515. + rxd->addr_lo = virt_to_bus(
  37516. + &tg3_bss.rx_bufs[i%TG3_DEF_RX_RING_PENDING][2]);
  37517. + }
  37518. +}
  37519. +
  37520. +#define TG3_WRITE_SETTINGS(TABLE) \
  37521. +do { \
  37522. + const uint32_t *_table, *_end; \
  37523. + _table = TABLE; \
  37524. + _end = _table + sizeof(TABLE)/sizeof(TABLE[0]); \
  37525. + for(; _table < _end; _table += 2) { \
  37526. + tw32(_table[0], _table[1]); \
  37527. + } \
  37528. +} while(0)
  37529. +
  37530. +
  37531. +/* initialize/reset the tg3 */
  37532. +static int tg3_setup_hw(struct tg3 *tp)
  37533. +{
  37534. + uint32_t val, rdmac_mode;
  37535. + int i, err, limit;
  37536. +
  37537. + /* Simply don't support setups with extremly buggy firmware in etherboot */
  37538. + if (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0) {
  37539. + printf("Error 5701_A0 firmware bug detected\n");
  37540. + return -EINVAL;
  37541. + }
  37542. +
  37543. + tg3_disable_ints(tp);
  37544. +
  37545. + /* Originally this was all in tg3_init_hw */
  37546. +
  37547. + /* Force the chip into D0. */
  37548. + tg3_set_power_state_0(tp);
  37549. +
  37550. + tg3_switch_clocks(tp);
  37551. +
  37552. + tw32(TG3PCI_MEM_WIN_BASE_ADDR, 0);
  37553. +
  37554. +
  37555. + /* Originally this was all in tg3_reset_hw */
  37556. +
  37557. + tg3_stop_fw(tp);
  37558. +
  37559. + /* No need to call tg3_abort_hw here, it is called before tg3_setup_hw. */
  37560. +
  37561. + tg3_chip_reset(tp);
  37562. +
  37563. + tw32(GRC_MODE, tp->grc_mode); /* Redundant? */
  37564. +
  37565. + err = tg3_restart_fw(tp, DRV_STATE_START);
  37566. + if (err)
  37567. + return err;
  37568. +
  37569. + if (tp->phy_id == PHY_ID_SERDES) {
  37570. + tp->mac_mode = MAC_MODE_PORT_MODE_TBI;
  37571. + }
  37572. + tw32_carefully(MAC_MODE, tp->mac_mode);
  37573. +
  37574. +
  37575. + /* This works around an issue with Athlon chipsets on
  37576. + * B3 tigon3 silicon. This bit has no effect on any
  37577. + * other revision.
  37578. + */
  37579. + tp->pci_clock_ctrl |= CLOCK_CTRL_DELAY_PCI_GRANT;
  37580. + tw32_carefully(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl);
  37581. +
  37582. + if (tp->pci_chip_rev_id == CHIPREV_ID_5704_A0 &&
  37583. + (tp->tg3_flags & TG3_FLAG_PCIX_MODE)) {
  37584. + val = tr32(TG3PCI_PCISTATE);
  37585. + val |= PCISTATE_RETRY_SAME_DMA;
  37586. + tw32(TG3PCI_PCISTATE, val);
  37587. + }
  37588. +
  37589. + /* Descriptor ring init may make accesses to the
  37590. + * NIC SRAM area to setup the TX descriptors, so we
  37591. + * can only do this after the hardware has been
  37592. + * successfully reset.
  37593. + */
  37594. + tg3_init_rings(tp);
  37595. +
  37596. + /* Clear statistics/status block in chip */
  37597. + if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
  37598. + for (i = NIC_SRAM_STATS_BLK;
  37599. + i < NIC_SRAM_STATUS_BLK + TG3_HW_STATUS_SIZE;
  37600. + i += sizeof(uint32_t)) {
  37601. + tg3_write_mem(i, 0);
  37602. + udelay(40);
  37603. + }
  37604. + }
  37605. +
  37606. + /* This value is determined during the probe time DMA
  37607. + * engine test, tg3_setup_dma.
  37608. + */
  37609. + tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl);
  37610. +
  37611. + tp->grc_mode &= ~(GRC_MODE_HOST_SENDBDS |
  37612. + GRC_MODE_4X_NIC_SEND_RINGS |
  37613. + GRC_MODE_NO_TX_PHDR_CSUM |
  37614. + GRC_MODE_NO_RX_PHDR_CSUM);
  37615. + tp->grc_mode |= GRC_MODE_HOST_SENDBDS;
  37616. + tp->grc_mode |= GRC_MODE_NO_TX_PHDR_CSUM;
  37617. + tp->grc_mode |= GRC_MODE_NO_RX_PHDR_CSUM;
  37618. +
  37619. + tw32(GRC_MODE,
  37620. + tp->grc_mode |
  37621. + (GRC_MODE_IRQ_ON_MAC_ATTN | GRC_MODE_HOST_STACKUP));
  37622. +
  37623. + /* Setup the timer prescalar register. Clock is always 66Mhz. */
  37624. + tw32(GRC_MISC_CFG,
  37625. + (65 << GRC_MISC_CFG_PRESCALAR_SHIFT));
  37626. +
  37627. + /* Initialize MBUF/DESC pool. */
  37628. + if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
  37629. + tw32(BUFMGR_MB_POOL_ADDR, NIC_SRAM_MBUF_POOL_BASE);
  37630. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704)
  37631. + tw32(BUFMGR_MB_POOL_SIZE, NIC_SRAM_MBUF_POOL_SIZE64);
  37632. + else
  37633. + tw32(BUFMGR_MB_POOL_SIZE, NIC_SRAM_MBUF_POOL_SIZE96);
  37634. + tw32(BUFMGR_DMA_DESC_POOL_ADDR, NIC_SRAM_DMA_DESC_POOL_BASE);
  37635. + tw32(BUFMGR_DMA_DESC_POOL_SIZE, NIC_SRAM_DMA_DESC_POOL_SIZE);
  37636. + }
  37637. + if (!(tp->tg3_flags & TG3_FLAG_JUMBO_ENABLE)) {
  37638. + tw32(BUFMGR_MB_RDMA_LOW_WATER,
  37639. + tp->bufmgr_config.mbuf_read_dma_low_water);
  37640. + tw32(BUFMGR_MB_MACRX_LOW_WATER,
  37641. + tp->bufmgr_config.mbuf_mac_rx_low_water);
  37642. + tw32(BUFMGR_MB_HIGH_WATER,
  37643. + tp->bufmgr_config.mbuf_high_water);
  37644. + } else {
  37645. + tw32(BUFMGR_MB_RDMA_LOW_WATER,
  37646. + tp->bufmgr_config.mbuf_read_dma_low_water_jumbo);
  37647. + tw32(BUFMGR_MB_MACRX_LOW_WATER,
  37648. + tp->bufmgr_config.mbuf_mac_rx_low_water_jumbo);
  37649. + tw32(BUFMGR_MB_HIGH_WATER,
  37650. + tp->bufmgr_config.mbuf_high_water_jumbo);
  37651. + }
  37652. + tw32(BUFMGR_DMA_LOW_WATER,
  37653. + tp->bufmgr_config.dma_low_water);
  37654. + tw32(BUFMGR_DMA_HIGH_WATER,
  37655. + tp->bufmgr_config.dma_high_water);
  37656. +
  37657. + tw32(BUFMGR_MODE, BUFMGR_MODE_ENABLE | BUFMGR_MODE_ATTN_ENABLE);
  37658. + for (i = 0; i < 2000; i++) {
  37659. + if (tr32(BUFMGR_MODE) & BUFMGR_MODE_ENABLE)
  37660. + break;
  37661. + udelay(10);
  37662. + }
  37663. + if (i >= 2000) {
  37664. + printf("tg3_setup_hw cannot enable BUFMGR\n");
  37665. + return -ENODEV;
  37666. + }
  37667. +
  37668. + tw32(FTQ_RESET, 0xffffffff);
  37669. + tw32(FTQ_RESET, 0x00000000);
  37670. + for (i = 0; i < 2000; i++) {
  37671. + if (tr32(FTQ_RESET) == 0x00000000)
  37672. + break;
  37673. + udelay(10);
  37674. + }
  37675. + if (i >= 2000) {
  37676. + printf("tg3_setup_hw cannot reset FTQ\n");
  37677. + return -ENODEV;
  37678. + }
  37679. +
  37680. + /* Initialize TG3_BDINFO's at:
  37681. + * RCVDBDI_STD_BD: standard eth size rx ring
  37682. + * RCVDBDI_JUMBO_BD: jumbo frame rx ring
  37683. + * RCVDBDI_MINI_BD: small frame rx ring (??? does not work)
  37684. + *
  37685. + * like so:
  37686. + * TG3_BDINFO_HOST_ADDR: high/low parts of DMA address of ring
  37687. + * TG3_BDINFO_MAXLEN_FLAGS: (rx max buffer size << 16) |
  37688. + * ring attribute flags
  37689. + * TG3_BDINFO_NIC_ADDR: location of descriptors in nic SRAM
  37690. + *
  37691. + * Standard receive ring @ NIC_SRAM_RX_BUFFER_DESC, 512 entries.
  37692. + * Jumbo receive ring @ NIC_SRAM_RX_JUMBO_BUFFER_DESC, 256 entries.
  37693. + *
  37694. + * ??? No space allocated for mini receive ring? :(
  37695. + *
  37696. + * The size of each ring is fixed in the firmware, but the location is
  37697. + * configurable.
  37698. + */
  37699. + {
  37700. + static const uint32_t table_all[] = {
  37701. + /* Setup replenish thresholds. */
  37702. + RCVBDI_STD_THRESH, TG3_DEF_RX_RING_PENDING / 8,
  37703. +
  37704. + /* Etherboot lives below 4GB */
  37705. + RCVDBDI_STD_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_HIGH, 0,
  37706. + RCVDBDI_STD_BD + TG3_BDINFO_NIC_ADDR, NIC_SRAM_RX_BUFFER_DESC,
  37707. + };
  37708. + static const uint32_t table_not_5705[] = {
  37709. + /* Buffer maximum length */
  37710. + RCVDBDI_STD_BD + TG3_BDINFO_MAXLEN_FLAGS, RX_STD_MAX_SIZE << BDINFO_FLAGS_MAXLEN_SHIFT,
  37711. +
  37712. + /* Disable the mini frame rx ring */
  37713. + RCVDBDI_MINI_BD + TG3_BDINFO_MAXLEN_FLAGS, BDINFO_FLAGS_DISABLED,
  37714. +
  37715. + /* Disable the jumbo frame rx ring */
  37716. + RCVBDI_JUMBO_THRESH, 0,
  37717. + RCVDBDI_JUMBO_BD + TG3_BDINFO_MAXLEN_FLAGS, BDINFO_FLAGS_DISABLED,
  37718. +
  37719. +
  37720. + };
  37721. + TG3_WRITE_SETTINGS(table_all);
  37722. + tw32(RCVDBDI_STD_BD + TG3_BDINFO_HOST_ADDR + TG3_64BIT_REG_LOW,
  37723. + virt_to_bus(tp->rx_std));
  37724. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
  37725. + tw32(RCVDBDI_STD_BD + TG3_BDINFO_MAXLEN_FLAGS,
  37726. + RX_STD_MAX_SIZE_5705 << BDINFO_FLAGS_MAXLEN_SHIFT);
  37727. + } else {
  37728. + TG3_WRITE_SETTINGS(table_not_5705);
  37729. + }
  37730. + }
  37731. +
  37732. +
  37733. + /* There is only one send ring on 5705, no need to explicitly
  37734. + * disable the others.
  37735. + */
  37736. + if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
  37737. + /* Clear out send RCB ring in SRAM. */
  37738. + for (i = NIC_SRAM_SEND_RCB; i < NIC_SRAM_RCV_RET_RCB; i += TG3_BDINFO_SIZE)
  37739. + tg3_write_mem(i + TG3_BDINFO_MAXLEN_FLAGS, BDINFO_FLAGS_DISABLED);
  37740. + }
  37741. +
  37742. + tp->tx_prod = 0;
  37743. + tw32_mailbox(MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW, 0);
  37744. + tw32_mailbox2(MAILBOX_SNDNIC_PROD_IDX_0 + TG3_64BIT_REG_LOW, 0);
  37745. +
  37746. + tg3_set_bdinfo(tp,
  37747. + NIC_SRAM_SEND_RCB,
  37748. + virt_to_bus(tp->tx_ring),
  37749. + (TG3_TX_RING_SIZE << BDINFO_FLAGS_MAXLEN_SHIFT),
  37750. + NIC_SRAM_TX_BUFFER_DESC);
  37751. +
  37752. + /* There is only one receive return ring on 5705, no need to explicitly
  37753. + * disable the others.
  37754. + */
  37755. + if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
  37756. + for (i = NIC_SRAM_RCV_RET_RCB; i < NIC_SRAM_STATS_BLK; i += TG3_BDINFO_SIZE) {
  37757. + tg3_write_mem(i + TG3_BDINFO_MAXLEN_FLAGS,
  37758. + BDINFO_FLAGS_DISABLED);
  37759. + }
  37760. + }
  37761. +
  37762. + tp->rx_rcb_ptr = 0;
  37763. + tw32_mailbox2(MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW, 0);
  37764. +
  37765. + tg3_set_bdinfo(tp,
  37766. + NIC_SRAM_RCV_RET_RCB,
  37767. + virt_to_bus(tp->rx_rcb),
  37768. + (TG3_RX_RCB_RING_SIZE << BDINFO_FLAGS_MAXLEN_SHIFT),
  37769. + 0);
  37770. +
  37771. + tp->rx_std_ptr = TG3_DEF_RX_RING_PENDING;
  37772. + tw32_mailbox2(MAILBOX_RCV_STD_PROD_IDX + TG3_64BIT_REG_LOW,
  37773. + tp->rx_std_ptr);
  37774. +
  37775. + tw32_mailbox2(MAILBOX_RCV_JUMBO_PROD_IDX + TG3_64BIT_REG_LOW, 0);
  37776. +
  37777. + /* Initialize MAC address and backoff seed. */
  37778. + __tg3_set_mac_addr(tp);
  37779. +
  37780. + /* Calculate RDMAC_MODE setting early, we need it to determine
  37781. + * the RCVLPC_STATE_ENABLE mask.
  37782. + */
  37783. + rdmac_mode = (RDMAC_MODE_ENABLE | RDMAC_MODE_TGTABORT_ENAB |
  37784. + RDMAC_MODE_MSTABORT_ENAB | RDMAC_MODE_PARITYERR_ENAB |
  37785. + RDMAC_MODE_ADDROFLOW_ENAB | RDMAC_MODE_FIFOOFLOW_ENAB |
  37786. + RDMAC_MODE_FIFOURUN_ENAB | RDMAC_MODE_FIFOOREAD_ENAB |
  37787. + RDMAC_MODE_LNGREAD_ENAB);
  37788. + if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE)
  37789. + rdmac_mode |= RDMAC_MODE_SPLIT_ENABLE;
  37790. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
  37791. + if (tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) {
  37792. + if (!(tr32(TG3PCI_PCISTATE) & PCISTATE_BUS_SPEED_HIGH) &&
  37793. + !(tp->tg3_flags2 & TG3_FLG2_IS_5788)) {
  37794. + rdmac_mode |= RDMAC_MODE_FIFO_LONG_BURST;
  37795. + }
  37796. + }
  37797. + }
  37798. +
  37799. + /* Setup host coalescing engine. */
  37800. + tw32(HOSTCC_MODE, 0);
  37801. + for (i = 0; i < 2000; i++) {
  37802. + if (!(tr32(HOSTCC_MODE) & HOSTCC_MODE_ENABLE))
  37803. + break;
  37804. + udelay(10);
  37805. + }
  37806. +
  37807. + tp->mac_mode = MAC_MODE_TXSTAT_ENABLE | MAC_MODE_RXSTAT_ENABLE |
  37808. + MAC_MODE_TDE_ENABLE | MAC_MODE_RDE_ENABLE | MAC_MODE_FHDE_ENABLE;
  37809. + tw32_carefully(MAC_MODE, tp->mac_mode | MAC_MODE_RXSTAT_CLEAR | MAC_MODE_TXSTAT_CLEAR);
  37810. +
  37811. + tp->grc_local_ctrl = GRC_LCLCTRL_INT_ON_ATTN | GRC_LCLCTRL_AUTO_SEEPROM;
  37812. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700)
  37813. + tp->grc_local_ctrl |= (GRC_LCLCTRL_GPIO_OE1 |
  37814. + GRC_LCLCTRL_GPIO_OUTPUT1);
  37815. + tw32_carefully(GRC_LOCAL_CTRL, tp->grc_local_ctrl);
  37816. +
  37817. + tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0);
  37818. + tr32(MAILBOX_INTERRUPT_0);
  37819. +
  37820. + if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
  37821. + tw32_carefully(DMAC_MODE, DMAC_MODE_ENABLE);
  37822. + }
  37823. +
  37824. + val = ( WDMAC_MODE_ENABLE | WDMAC_MODE_TGTABORT_ENAB |
  37825. + WDMAC_MODE_MSTABORT_ENAB | WDMAC_MODE_PARITYERR_ENAB |
  37826. + WDMAC_MODE_ADDROFLOW_ENAB | WDMAC_MODE_FIFOOFLOW_ENAB |
  37827. + WDMAC_MODE_FIFOURUN_ENAB | WDMAC_MODE_FIFOOREAD_ENAB |
  37828. + WDMAC_MODE_LNGREAD_ENAB);
  37829. + if ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) &&
  37830. + ((tr32(TG3PCI_PCISTATE) & PCISTATE_BUS_SPEED_HIGH) != 0) &&
  37831. + !(tp->tg3_flags2 & TG3_FLG2_IS_5788)) {
  37832. + val |= WDMAC_MODE_RX_ACCEL;
  37833. + }
  37834. + tw32_carefully(WDMAC_MODE, val);
  37835. +
  37836. + if ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) != 0) {
  37837. + val = tr32(TG3PCI_X_CAPS);
  37838. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703) {
  37839. + val &= PCIX_CAPS_BURST_MASK;
  37840. + val |= (PCIX_CAPS_MAX_BURST_CPIOB << PCIX_CAPS_BURST_SHIFT);
  37841. + } else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) {
  37842. + val &= ~(PCIX_CAPS_SPLIT_MASK | PCIX_CAPS_BURST_MASK);
  37843. + val |= (PCIX_CAPS_MAX_BURST_CPIOB << PCIX_CAPS_BURST_SHIFT);
  37844. + if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE)
  37845. + val |= (tp->split_mode_max_reqs <<
  37846. + PCIX_CAPS_SPLIT_SHIFT);
  37847. + }
  37848. + tw32(TG3PCI_X_CAPS, val);
  37849. + }
  37850. +
  37851. + tw32_carefully(RDMAC_MODE, rdmac_mode);
  37852. + {
  37853. + static const uint32_t table_all[] = {
  37854. + /* MTU + ethernet header + FCS + optional VLAN tag */
  37855. + MAC_RX_MTU_SIZE, ETH_MAX_MTU + ETH_HLEN + 8,
  37856. +
  37857. + /* The slot time is changed by tg3_setup_phy if we
  37858. + * run at gigabit with half duplex.
  37859. + */
  37860. + MAC_TX_LENGTHS,
  37861. + (2 << TX_LENGTHS_IPG_CRS_SHIFT) |
  37862. + (6 << TX_LENGTHS_IPG_SHIFT) |
  37863. + (32 << TX_LENGTHS_SLOT_TIME_SHIFT),
  37864. +
  37865. + /* Receive rules. */
  37866. + MAC_RCV_RULE_CFG, RCV_RULE_CFG_DEFAULT_CLASS,
  37867. + RCVLPC_CONFIG, 0x0181,
  37868. +
  37869. + /* Receive/send statistics. */
  37870. + RCVLPC_STATS_ENABLE, 0xffffff,
  37871. + RCVLPC_STATSCTRL, RCVLPC_STATSCTRL_ENABLE,
  37872. + SNDDATAI_STATSENAB, 0xffffff,
  37873. + SNDDATAI_STATSCTRL, (SNDDATAI_SCTRL_ENABLE |SNDDATAI_SCTRL_FASTUPD),
  37874. +
  37875. + /* Host coalescing engine */
  37876. + HOSTCC_RXCOL_TICKS, 0,
  37877. + HOSTCC_TXCOL_TICKS, LOW_TXCOL_TICKS,
  37878. + HOSTCC_RXMAX_FRAMES, 1,
  37879. + HOSTCC_TXMAX_FRAMES, LOW_RXMAX_FRAMES,
  37880. + HOSTCC_RXCOAL_MAXF_INT, 1,
  37881. + HOSTCC_TXCOAL_MAXF_INT, 0,
  37882. +
  37883. + /* Status/statistics block address. */
  37884. + /* Etherboot lives below 4GB, so HIGH == 0 */
  37885. + HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH, 0,
  37886. +
  37887. + /* No need to enable 32byte coalesce mode. */
  37888. + HOSTCC_MODE, HOSTCC_MODE_ENABLE | 0,
  37889. +
  37890. + RCVCC_MODE, RCVCC_MODE_ENABLE | RCVCC_MODE_ATTN_ENABLE,
  37891. + RCVLPC_MODE, RCVLPC_MODE_ENABLE,
  37892. +
  37893. + RCVDCC_MODE, RCVDCC_MODE_ENABLE | RCVDCC_MODE_ATTN_ENABLE,
  37894. +
  37895. + SNDDATAC_MODE, SNDDATAC_MODE_ENABLE,
  37896. + SNDBDC_MODE, SNDBDC_MODE_ENABLE | SNDBDC_MODE_ATTN_ENABLE,
  37897. + RCVBDI_MODE, RCVBDI_MODE_ENABLE | RCVBDI_MODE_RCB_ATTN_ENAB,
  37898. + RCVDBDI_MODE, RCVDBDI_MODE_ENABLE | RCVDBDI_MODE_INV_RING_SZ,
  37899. + SNDDATAI_MODE, SNDDATAI_MODE_ENABLE,
  37900. + SNDBDI_MODE, SNDBDI_MODE_ENABLE | SNDBDI_MODE_ATTN_ENABLE,
  37901. + SNDBDS_MODE, SNDBDS_MODE_ENABLE | SNDBDS_MODE_ATTN_ENABLE,
  37902. +
  37903. + /* Accept all multicast frames. */
  37904. + MAC_HASH_REG_0, 0xffffffff,
  37905. + MAC_HASH_REG_1, 0xffffffff,
  37906. + MAC_HASH_REG_2, 0xffffffff,
  37907. + MAC_HASH_REG_3, 0xffffffff,
  37908. + };
  37909. + static const uint32_t table_not_5705[] = {
  37910. + /* Host coalescing engine */
  37911. + HOSTCC_RXCOAL_TICK_INT, 0,
  37912. + HOSTCC_TXCOAL_TICK_INT, 0,
  37913. +
  37914. + /* Status/statistics block address. */
  37915. + /* Etherboot lives below 4GB, so HIGH == 0 */
  37916. + HOSTCC_STAT_COAL_TICKS, DEFAULT_STAT_COAL_TICKS,
  37917. + HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH, 0,
  37918. + HOSTCC_STATS_BLK_NIC_ADDR, NIC_SRAM_STATS_BLK,
  37919. + HOSTCC_STATUS_BLK_NIC_ADDR, NIC_SRAM_STATUS_BLK,
  37920. +
  37921. + RCVLSC_MODE, RCVLSC_MODE_ENABLE | RCVLSC_MODE_ATTN_ENABLE,
  37922. +
  37923. + MBFREE_MODE, MBFREE_MODE_ENABLE,
  37924. + };
  37925. + TG3_WRITE_SETTINGS(table_all);
  37926. + tw32(HOSTCC_STATS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW,
  37927. + virt_to_bus(tp->hw_stats));
  37928. + tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW,
  37929. + virt_to_bus(tp->hw_status));
  37930. + if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
  37931. + TG3_WRITE_SETTINGS(table_not_5705);
  37932. + }
  37933. + }
  37934. +
  37935. + tp->tx_mode = TX_MODE_ENABLE;
  37936. + tw32_carefully(MAC_TX_MODE, tp->tx_mode);
  37937. +
  37938. + tp->rx_mode = RX_MODE_ENABLE;
  37939. + tw32_carefully(MAC_RX_MODE, tp->rx_mode);
  37940. +
  37941. + tp->mi_mode = MAC_MI_MODE_BASE;
  37942. + tw32_carefully(MAC_MI_MODE, tp->mi_mode);
  37943. +
  37944. + tw32(MAC_LED_CTRL, 0);
  37945. + tw32(MAC_MI_STAT, MAC_MI_STAT_LNKSTAT_ATTN_ENAB);
  37946. + if (tp->phy_id == PHY_ID_SERDES) {
  37947. + tw32_carefully(MAC_RX_MODE, RX_MODE_RESET);
  37948. + }
  37949. + tp->rx_mode |= RX_MODE_KEEP_VLAN_TAG; /* drop tagged vlan packets */
  37950. + tw32_carefully(MAC_RX_MODE, tp->rx_mode);
  37951. +
  37952. + if (tp->pci_chip_rev_id == CHIPREV_ID_5703_A1)
  37953. + tw32(MAC_SERDES_CFG, 0x616000);
  37954. +
  37955. + /* Prevent chip from dropping frames when flow control
  37956. + * is enabled.
  37957. + */
  37958. + tw32(MAC_LOW_WMARK_MAX_RX_FRAME, 2);
  37959. + tr32(MAC_LOW_WMARK_MAX_RX_FRAME);
  37960. +
  37961. + err = tg3_setup_phy(tp);
  37962. +
  37963. + /* Ignore CRC stats */
  37964. +
  37965. + /* Initialize receive rules. */
  37966. + tw32(MAC_RCV_RULE_0, 0xc2000000 & RCV_RULE_DISABLE_MASK);
  37967. + tw32(MAC_RCV_VALUE_0, 0xffffffff & RCV_RULE_DISABLE_MASK);
  37968. + tw32(MAC_RCV_RULE_1, 0x86000004 & RCV_RULE_DISABLE_MASK);
  37969. + tw32(MAC_RCV_VALUE_1, 0xffffffff & RCV_RULE_DISABLE_MASK);
  37970. +
  37971. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)
  37972. + limit = 8;
  37973. + else
  37974. + limit = 16;
  37975. + if (tp->tg3_flags & TG3_FLAG_ENABLE_ASF)
  37976. + limit -= 4;
  37977. + switch (limit) {
  37978. + case 16: tw32(MAC_RCV_RULE_15, 0); tw32(MAC_RCV_VALUE_15, 0);
  37979. + case 15: tw32(MAC_RCV_RULE_14, 0); tw32(MAC_RCV_VALUE_14, 0);
  37980. + case 14: tw32(MAC_RCV_RULE_13, 0); tw32(MAC_RCV_VALUE_13, 0);
  37981. + case 13: tw32(MAC_RCV_RULE_12, 0); tw32(MAC_RCV_VALUE_12, 0);
  37982. + case 12: tw32(MAC_RCV_RULE_11, 0); tw32(MAC_RCV_VALUE_11, 0);
  37983. + case 11: tw32(MAC_RCV_RULE_10, 0); tw32(MAC_RCV_VALUE_10, 0);
  37984. + case 10: tw32(MAC_RCV_RULE_9, 0); tw32(MAC_RCV_VALUE_9, 0);
  37985. + case 9: tw32(MAC_RCV_RULE_8, 0); tw32(MAC_RCV_VALUE_8, 0);
  37986. + case 8: tw32(MAC_RCV_RULE_7, 0); tw32(MAC_RCV_VALUE_7, 0);
  37987. + case 7: tw32(MAC_RCV_RULE_6, 0); tw32(MAC_RCV_VALUE_6, 0);
  37988. + case 6: tw32(MAC_RCV_RULE_5, 0); tw32(MAC_RCV_VALUE_5, 0);
  37989. + case 5: tw32(MAC_RCV_RULE_4, 0); tw32(MAC_RCV_VALUE_4, 0);
  37990. + case 4: /* tw32(MAC_RCV_RULE_3, 0); tw32(MAC_RCV_VALUE_3, 0); */
  37991. + case 3: /* tw32(MAC_RCV_RULE_2, 0); tw32(MAC_RCV_VALUE_2, 0); */
  37992. + case 2:
  37993. + case 1:
  37994. + default:
  37995. + break;
  37996. + };
  37997. +
  37998. + return err;
  37999. +}
  38000. +
  38001. +
  38002. +
  38003. +/* Chips other than 5700/5701 use the NVRAM for fetching info. */
  38004. +static void tg3_nvram_init(struct tg3 *tp)
  38005. +{
  38006. + tw32(GRC_EEPROM_ADDR,
  38007. + (EEPROM_ADDR_FSM_RESET |
  38008. + (EEPROM_DEFAULT_CLOCK_PERIOD <<
  38009. + EEPROM_ADDR_CLKPERD_SHIFT)));
  38010. +
  38011. + mdelay(1);
  38012. +
  38013. + /* Enable seeprom accesses. */
  38014. + tw32_carefully(GRC_LOCAL_CTRL,
  38015. + tr32(GRC_LOCAL_CTRL) | GRC_LCLCTRL_AUTO_SEEPROM);
  38016. +
  38017. + if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700 &&
  38018. + GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) {
  38019. + uint32_t nvcfg1 = tr32(NVRAM_CFG1);
  38020. +
  38021. + tp->tg3_flags |= TG3_FLAG_NVRAM;
  38022. + if (nvcfg1 & NVRAM_CFG1_FLASHIF_ENAB) {
  38023. + if (nvcfg1 & NVRAM_CFG1_BUFFERED_MODE)
  38024. + tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
  38025. + } else {
  38026. + nvcfg1 &= ~NVRAM_CFG1_COMPAT_BYPASS;
  38027. + tw32(NVRAM_CFG1, nvcfg1);
  38028. + }
  38029. +
  38030. + } else {
  38031. + tp->tg3_flags &= ~(TG3_FLAG_NVRAM | TG3_FLAG_NVRAM_BUFFERED);
  38032. + }
  38033. +}
  38034. +
  38035. +
  38036. +static int tg3_nvram_read_using_eeprom(
  38037. + struct tg3 *tp __unused, uint32_t offset, uint32_t *val)
  38038. +{
  38039. + uint32_t tmp;
  38040. + int i;
  38041. +
  38042. + if (offset > EEPROM_ADDR_ADDR_MASK ||
  38043. + (offset % 4) != 0) {
  38044. + return -EINVAL;
  38045. + }
  38046. +
  38047. + tmp = tr32(GRC_EEPROM_ADDR) & ~(EEPROM_ADDR_ADDR_MASK |
  38048. + EEPROM_ADDR_DEVID_MASK |
  38049. + EEPROM_ADDR_READ);
  38050. + tw32(GRC_EEPROM_ADDR,
  38051. + tmp |
  38052. + (0 << EEPROM_ADDR_DEVID_SHIFT) |
  38053. + ((offset << EEPROM_ADDR_ADDR_SHIFT) &
  38054. + EEPROM_ADDR_ADDR_MASK) |
  38055. + EEPROM_ADDR_READ | EEPROM_ADDR_START);
  38056. +
  38057. + for (i = 0; i < 10000; i++) {
  38058. + tmp = tr32(GRC_EEPROM_ADDR);
  38059. +
  38060. + if (tmp & EEPROM_ADDR_COMPLETE)
  38061. + break;
  38062. + udelay(100);
  38063. + }
  38064. + if (!(tmp & EEPROM_ADDR_COMPLETE)) {
  38065. + return -EBUSY;
  38066. + }
  38067. +
  38068. + *val = tr32(GRC_EEPROM_DATA);
  38069. + return 0;
  38070. +}
  38071. +
  38072. +static int tg3_nvram_read(struct tg3 *tp, uint32_t offset, uint32_t *val)
  38073. +{
  38074. + int i, saw_done_clear;
  38075. +
  38076. + if (!(tp->tg3_flags & TG3_FLAG_NVRAM))
  38077. + return tg3_nvram_read_using_eeprom(tp, offset, val);
  38078. +
  38079. + if (tp->tg3_flags & TG3_FLAG_NVRAM_BUFFERED)
  38080. + offset = ((offset / NVRAM_BUFFERED_PAGE_SIZE) <<
  38081. + NVRAM_BUFFERED_PAGE_POS) +
  38082. + (offset % NVRAM_BUFFERED_PAGE_SIZE);
  38083. +
  38084. + if (offset > NVRAM_ADDR_MSK)
  38085. + return -EINVAL;
  38086. +
  38087. + tw32(NVRAM_SWARB, SWARB_REQ_SET1);
  38088. + for (i = 0; i < 1000; i++) {
  38089. + if (tr32(NVRAM_SWARB) & SWARB_GNT1)
  38090. + break;
  38091. + udelay(20);
  38092. + }
  38093. +
  38094. + tw32(NVRAM_ADDR, offset);
  38095. + tw32(NVRAM_CMD,
  38096. + NVRAM_CMD_RD | NVRAM_CMD_GO |
  38097. + NVRAM_CMD_FIRST | NVRAM_CMD_LAST | NVRAM_CMD_DONE);
  38098. +
  38099. + /* Wait for done bit to clear then set again. */
  38100. + saw_done_clear = 0;
  38101. + for (i = 0; i < 1000; i++) {
  38102. + udelay(10);
  38103. + if (!saw_done_clear &&
  38104. + !(tr32(NVRAM_CMD) & NVRAM_CMD_DONE))
  38105. + saw_done_clear = 1;
  38106. + else if (saw_done_clear &&
  38107. + (tr32(NVRAM_CMD) & NVRAM_CMD_DONE))
  38108. + break;
  38109. + }
  38110. + if (i >= 1000) {
  38111. + tw32(NVRAM_SWARB, SWARB_REQ_CLR1);
  38112. + return -EBUSY;
  38113. + }
  38114. +
  38115. + *val = bswap_32(tr32(NVRAM_RDDATA));
  38116. + tw32(NVRAM_SWARB, 0x20);
  38117. +
  38118. + return 0;
  38119. +}
  38120. +
  38121. +struct subsys_tbl_ent {
  38122. + uint16_t subsys_vendor, subsys_devid;
  38123. + uint32_t phy_id;
  38124. +};
  38125. +
  38126. +static struct subsys_tbl_ent subsys_id_to_phy_id[] = {
  38127. + /* Broadcom boards. */
  38128. + { 0x14e4, 0x1644, PHY_ID_BCM5401 }, /* BCM95700A6 */
  38129. + { 0x14e4, 0x0001, PHY_ID_BCM5701 }, /* BCM95701A5 */
  38130. + { 0x14e4, 0x0002, PHY_ID_BCM8002 }, /* BCM95700T6 */
  38131. + { 0x14e4, 0x0003, PHY_ID_SERDES }, /* BCM95700A9 */
  38132. + { 0x14e4, 0x0005, PHY_ID_BCM5701 }, /* BCM95701T1 */
  38133. + { 0x14e4, 0x0006, PHY_ID_BCM5701 }, /* BCM95701T8 */
  38134. + { 0x14e4, 0x0007, PHY_ID_SERDES }, /* BCM95701A7 */
  38135. + { 0x14e4, 0x0008, PHY_ID_BCM5701 }, /* BCM95701A10 */
  38136. + { 0x14e4, 0x8008, PHY_ID_BCM5701 }, /* BCM95701A12 */
  38137. + { 0x14e4, 0x0009, PHY_ID_BCM5701 }, /* BCM95703Ax1 */
  38138. + { 0x14e4, 0x8009, PHY_ID_BCM5701 }, /* BCM95703Ax2 */
  38139. +
  38140. + /* 3com boards. */
  38141. + { PCI_VENDOR_ID_3COM, 0x1000, PHY_ID_BCM5401 }, /* 3C996T */
  38142. + { PCI_VENDOR_ID_3COM, 0x1006, PHY_ID_BCM5701 }, /* 3C996BT */
  38143. + /* { PCI_VENDOR_ID_3COM, 0x1002, PHY_ID_XXX }, 3C996CT */
  38144. + /* { PCI_VENDOR_ID_3COM, 0x1003, PHY_ID_XXX }, 3C997T */
  38145. + { PCI_VENDOR_ID_3COM, 0x1004, PHY_ID_SERDES }, /* 3C996SX */
  38146. + /* { PCI_VENDOR_ID_3COM, 0x1005, PHY_ID_XXX }, 3C997SZ */
  38147. + { PCI_VENDOR_ID_3COM, 0x1007, PHY_ID_BCM5701 }, /* 3C1000T */
  38148. + { PCI_VENDOR_ID_3COM, 0x1008, PHY_ID_BCM5701 }, /* 3C940BR01 */
  38149. +
  38150. + /* DELL boards. */
  38151. + { PCI_VENDOR_ID_DELL, 0x00d1, PHY_ID_BCM5401 }, /* VIPER */
  38152. + { PCI_VENDOR_ID_DELL, 0x0106, PHY_ID_BCM5401 }, /* JAGUAR */
  38153. + { PCI_VENDOR_ID_DELL, 0x0109, PHY_ID_BCM5411 }, /* MERLOT */
  38154. + { PCI_VENDOR_ID_DELL, 0x010a, PHY_ID_BCM5411 }, /* SLIM_MERLOT */
  38155. +
  38156. + /* Compaq boards. */
  38157. + { PCI_VENDOR_ID_COMPAQ, 0x007c, PHY_ID_BCM5701 }, /* BANSHEE */
  38158. + { PCI_VENDOR_ID_COMPAQ, 0x009a, PHY_ID_BCM5701 }, /* BANSHEE_2 */
  38159. + { PCI_VENDOR_ID_COMPAQ, 0x007d, PHY_ID_SERDES }, /* CHANGELING */
  38160. + { PCI_VENDOR_ID_COMPAQ, 0x0085, PHY_ID_BCM5701 }, /* NC7780 */
  38161. + { PCI_VENDOR_ID_COMPAQ, 0x0099, PHY_ID_BCM5701 } /* NC7780_2 */
  38162. +};
  38163. +
  38164. +static int tg3_phy_probe(struct tg3 *tp)
  38165. +{
  38166. + uint32_t eeprom_phy_id, hw_phy_id_1, hw_phy_id_2;
  38167. + uint32_t hw_phy_id, hw_phy_id_masked;
  38168. + enum phy_led_mode eeprom_led_mode;
  38169. + uint32_t val;
  38170. + unsigned i;
  38171. + int eeprom_signature_found, err;
  38172. +
  38173. + tp->phy_id = PHY_ID_INVALID;
  38174. +
  38175. + for (i = 0; i < sizeof(subsys_id_to_phy_id)/sizeof(subsys_id_to_phy_id[0]); i++) {
  38176. + if ((subsys_id_to_phy_id[i].subsys_vendor == tp->subsystem_vendor) &&
  38177. + (subsys_id_to_phy_id[i].subsys_devid == tp->subsystem_device)) {
  38178. + tp->phy_id = subsys_id_to_phy_id[i].phy_id;
  38179. + break;
  38180. + }
  38181. + }
  38182. +
  38183. + eeprom_phy_id = PHY_ID_INVALID;
  38184. + eeprom_led_mode = led_mode_auto;
  38185. + eeprom_signature_found = 0;
  38186. + tg3_read_mem(NIC_SRAM_DATA_SIG, &val);
  38187. + if (val == NIC_SRAM_DATA_SIG_MAGIC) {
  38188. + uint32_t nic_cfg;
  38189. +
  38190. + tg3_read_mem(NIC_SRAM_DATA_CFG, &nic_cfg);
  38191. + tp->nic_sram_data_cfg = nic_cfg;
  38192. +
  38193. + eeprom_signature_found = 1;
  38194. +
  38195. + if ((nic_cfg & NIC_SRAM_DATA_CFG_PHY_TYPE_MASK) ==
  38196. + NIC_SRAM_DATA_CFG_PHY_TYPE_FIBER) {
  38197. + eeprom_phy_id = PHY_ID_SERDES;
  38198. + } else {
  38199. + uint32_t nic_phy_id;
  38200. +
  38201. + tg3_read_mem(NIC_SRAM_DATA_PHY_ID, &nic_phy_id);
  38202. + if (nic_phy_id != 0) {
  38203. + uint32_t id1 = nic_phy_id & NIC_SRAM_DATA_PHY_ID1_MASK;
  38204. + uint32_t id2 = nic_phy_id & NIC_SRAM_DATA_PHY_ID2_MASK;
  38205. +
  38206. + eeprom_phy_id = (id1 >> 16) << 10;
  38207. + eeprom_phy_id |= (id2 & 0xfc00) << 16;
  38208. + eeprom_phy_id |= (id2 & 0x03ff) << 0;
  38209. + }
  38210. + }
  38211. +
  38212. + switch (nic_cfg & NIC_SRAM_DATA_CFG_LED_MODE_MASK) {
  38213. + case NIC_SRAM_DATA_CFG_LED_TRIPLE_SPD:
  38214. + eeprom_led_mode = led_mode_three_link;
  38215. + break;
  38216. +
  38217. + case NIC_SRAM_DATA_CFG_LED_LINK_SPD:
  38218. + eeprom_led_mode = led_mode_link10;
  38219. + break;
  38220. +
  38221. + default:
  38222. + eeprom_led_mode = led_mode_auto;
  38223. + break;
  38224. + };
  38225. + if (((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703) ||
  38226. + (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
  38227. + (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705)) &&
  38228. + (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP)) {
  38229. + tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT;
  38230. + }
  38231. +
  38232. + if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE)
  38233. + tp->tg3_flags |= TG3_FLAG_ENABLE_ASF;
  38234. + if (nic_cfg & NIC_SRAM_DATA_CFG_FIBER_WOL)
  38235. + tp->tg3_flags |= TG3_FLAG_SERDES_WOL_CAP;
  38236. + }
  38237. +
  38238. + /* Now read the physical PHY_ID from the chip and verify
  38239. + * that it is sane. If it doesn't look good, we fall back
  38240. + * to either the hard-coded table based PHY_ID and failing
  38241. + * that the value found in the eeprom area.
  38242. + */
  38243. + err = tg3_readphy(tp, MII_PHYSID1, &hw_phy_id_1);
  38244. + err |= tg3_readphy(tp, MII_PHYSID2, &hw_phy_id_2);
  38245. +
  38246. + hw_phy_id = (hw_phy_id_1 & 0xffff) << 10;
  38247. + hw_phy_id |= (hw_phy_id_2 & 0xfc00) << 16;
  38248. + hw_phy_id |= (hw_phy_id_2 & 0x03ff) << 0;
  38249. +
  38250. + hw_phy_id_masked = hw_phy_id & PHY_ID_MASK;
  38251. +
  38252. + if (!err && KNOWN_PHY_ID(hw_phy_id_masked)) {
  38253. + tp->phy_id = hw_phy_id;
  38254. + } else {
  38255. + /* phy_id currently holds the value found in the
  38256. + * subsys_id_to_phy_id[] table or PHY_ID_INVALID
  38257. + * if a match was not found there.
  38258. + */
  38259. + if (tp->phy_id == PHY_ID_INVALID) {
  38260. + if (!eeprom_signature_found ||
  38261. + !KNOWN_PHY_ID(eeprom_phy_id & PHY_ID_MASK))
  38262. + return -ENODEV;
  38263. + tp->phy_id = eeprom_phy_id;
  38264. + }
  38265. + }
  38266. +
  38267. + err = tg3_phy_reset(tp);
  38268. + if (err)
  38269. + return err;
  38270. +
  38271. + if (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0 ||
  38272. + tp->pci_chip_rev_id == CHIPREV_ID_5701_B0) {
  38273. + uint32_t mii_tg3_ctrl;
  38274. +
  38275. + /* These chips, when reset, only advertise 10Mb
  38276. + * capabilities. Fix that.
  38277. + */
  38278. + err = tg3_writephy(tp, MII_ADVERTISE,
  38279. + (ADVERTISE_CSMA |
  38280. + ADVERTISE_PAUSE_CAP |
  38281. + ADVERTISE_10HALF |
  38282. + ADVERTISE_10FULL |
  38283. + ADVERTISE_100HALF |
  38284. + ADVERTISE_100FULL));
  38285. + mii_tg3_ctrl = (MII_TG3_CTRL_ADV_1000_HALF |
  38286. + MII_TG3_CTRL_ADV_1000_FULL |
  38287. + MII_TG3_CTRL_AS_MASTER |
  38288. + MII_TG3_CTRL_ENABLE_AS_MASTER);
  38289. + if (tp->tg3_flags & TG3_FLAG_10_100_ONLY)
  38290. + mii_tg3_ctrl = 0;
  38291. +
  38292. + err |= tg3_writephy(tp, MII_TG3_CTRL, mii_tg3_ctrl);
  38293. + err |= tg3_writephy(tp, MII_BMCR,
  38294. + (BMCR_ANRESTART | BMCR_ANENABLE));
  38295. + }
  38296. +
  38297. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703) {
  38298. + tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00);
  38299. + tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x201f);
  38300. + tg3_writedsp(tp, MII_TG3_DSP_RW_PORT, 0x2aaa);
  38301. + }
  38302. +
  38303. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) {
  38304. + tg3_writephy(tp, 0x1c, 0x8d68);
  38305. + tg3_writephy(tp, 0x1c, 0x8d68);
  38306. + }
  38307. +
  38308. + /* Enable Ethernet@WireSpeed */
  38309. + tg3_phy_set_wirespeed(tp);
  38310. +
  38311. + if (!err && ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401)) {
  38312. + err = tg3_init_5401phy_dsp(tp);
  38313. + }
  38314. +
  38315. + /* Determine the PHY led mode.
  38316. + * Be careful if this gets set wrong it can result in an inability to
  38317. + * establish a link.
  38318. + */
  38319. + if (tp->phy_id == PHY_ID_SERDES) {
  38320. + tp->led_mode = led_mode_three_link;
  38321. + }
  38322. + else if (tp->subsystem_vendor == PCI_VENDOR_ID_DELL) {
  38323. + tp->led_mode = led_mode_link10;
  38324. + } else {
  38325. + tp->led_mode = led_mode_three_link;
  38326. + if (eeprom_signature_found &&
  38327. + eeprom_led_mode != led_mode_auto)
  38328. + tp->led_mode = eeprom_led_mode;
  38329. + }
  38330. +
  38331. + if (tp->phy_id == PHY_ID_SERDES)
  38332. + tp->link_config.advertising =
  38333. + (ADVERTISED_1000baseT_Half |
  38334. + ADVERTISED_1000baseT_Full |
  38335. + ADVERTISED_Autoneg |
  38336. + ADVERTISED_FIBRE);
  38337. + if (tp->tg3_flags & TG3_FLAG_10_100_ONLY)
  38338. + tp->link_config.advertising &=
  38339. + ~(ADVERTISED_1000baseT_Half |
  38340. + ADVERTISED_1000baseT_Full);
  38341. +
  38342. + return err;
  38343. +}
  38344. +
  38345. +#if SUPPORT_PARTNO_STR
  38346. +static void tg3_read_partno(struct tg3 *tp)
  38347. +{
  38348. + unsigned char vpd_data[256];
  38349. + int i;
  38350. +
  38351. + for (i = 0; i < 256; i += 4) {
  38352. + uint32_t tmp;
  38353. +
  38354. + if (tg3_nvram_read(tp, 0x100 + i, &tmp))
  38355. + goto out_not_found;
  38356. +
  38357. + vpd_data[i + 0] = ((tmp >> 0) & 0xff);
  38358. + vpd_data[i + 1] = ((tmp >> 8) & 0xff);
  38359. + vpd_data[i + 2] = ((tmp >> 16) & 0xff);
  38360. + vpd_data[i + 3] = ((tmp >> 24) & 0xff);
  38361. + }
  38362. +
  38363. + /* Now parse and find the part number. */
  38364. + for (i = 0; i < 256; ) {
  38365. + unsigned char val = vpd_data[i];
  38366. + int block_end;
  38367. +
  38368. + if (val == 0x82 || val == 0x91) {
  38369. + i = (i + 3 +
  38370. + (vpd_data[i + 1] +
  38371. + (vpd_data[i + 2] << 8)));
  38372. + continue;
  38373. + }
  38374. +
  38375. + if (val != 0x90)
  38376. + goto out_not_found;
  38377. +
  38378. + block_end = (i + 3 +
  38379. + (vpd_data[i + 1] +
  38380. + (vpd_data[i + 2] << 8)));
  38381. + i += 3;
  38382. + while (i < block_end) {
  38383. + if (vpd_data[i + 0] == 'P' &&
  38384. + vpd_data[i + 1] == 'N') {
  38385. + int partno_len = vpd_data[i + 2];
  38386. +
  38387. + if (partno_len > 24)
  38388. + goto out_not_found;
  38389. +
  38390. + memcpy(tp->board_part_number,
  38391. + &vpd_data[i + 3],
  38392. + partno_len);
  38393. +
  38394. + /* Success. */
  38395. + return;
  38396. + }
  38397. + }
  38398. +
  38399. + /* Part number not found. */
  38400. + goto out_not_found;
  38401. + }
  38402. +
  38403. +out_not_found:
  38404. + memcpy(tp->board_part_number, "none", sizeof("none"));
  38405. +}
  38406. +#else
  38407. +#define tg3_read_partno(TP) ((TP)->board_part_number[0] = '\0')
  38408. +#endif
  38409. +
  38410. +static int tg3_get_invariants(struct tg3 *tp)
  38411. +{
  38412. + uint32_t misc_ctrl_reg;
  38413. + uint32_t pci_state_reg, grc_misc_cfg;
  38414. + uint16_t pci_cmd;
  38415. + uint8_t pci_latency;
  38416. + int err;
  38417. +
  38418. + /* Read the subsystem vendor and device ids */
  38419. + pci_read_config_word(tp->pdev, PCI_SUBSYSTEM_VENDOR_ID, &tp->subsystem_vendor);
  38420. + pci_read_config_word(tp->pdev, PCI_SUBSYSTEM_ID, &tp->subsystem_device);
  38421. +
  38422. + /* The sun_5704 code needs infrastructure etherboot does have
  38423. + * ignore it for now.
  38424. + */
  38425. +
  38426. + /* If we have an AMD 762 or Intel ICH/ICH0 chipset, write
  38427. + * reordering to the mailbox registers done by the host
  38428. + * controller can cause major troubles. We read back from
  38429. + * every mailbox register write to force the writes to be
  38430. + * posted to the chip in order.
  38431. + *
  38432. + * TG3_FLAG_MBOX_WRITE_REORDER has been forced on.
  38433. + */
  38434. +
  38435. + /* Force memory write invalidate off. If we leave it on,
  38436. + * then on 5700_BX chips we have to enable a workaround.
  38437. + * The workaround is to set the TG3PCI_DMA_RW_CTRL boundry
  38438. + * to match the cacheline size. The Broadcom driver have this
  38439. + * workaround but turns MWI off all the times so never uses
  38440. + * it. This seems to suggest that the workaround is insufficient.
  38441. + */
  38442. + pci_read_config_word(tp->pdev, PCI_COMMAND, &pci_cmd);
  38443. + pci_cmd &= ~PCI_COMMAND_INVALIDATE;
  38444. + /* Also, force SERR#/PERR# in PCI command. */
  38445. + pci_cmd |= PCI_COMMAND_PARITY | PCI_COMMAND_SERR;
  38446. + pci_write_config_word(tp->pdev, PCI_COMMAND, pci_cmd);
  38447. +
  38448. + /* It is absolutely critical that TG3PCI_MISC_HOST_CTRL
  38449. + * has the register indirect write enable bit set before
  38450. + * we try to access any of the MMIO registers. It is also
  38451. + * critical that the PCI-X hw workaround situation is decided
  38452. + * before that as well.
  38453. + */
  38454. + pci_read_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL, &misc_ctrl_reg);
  38455. +
  38456. + tp->pci_chip_rev_id = (misc_ctrl_reg >> MISC_HOST_CTRL_CHIPREV_SHIFT);
  38457. +
  38458. + /* Initialize misc host control in PCI block. */
  38459. + tp->misc_host_ctrl |= (misc_ctrl_reg &
  38460. + MISC_HOST_CTRL_CHIPREV);
  38461. + pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL,
  38462. + tp->misc_host_ctrl);
  38463. +
  38464. + pci_read_config_byte(tp->pdev, PCI_LATENCY_TIMER, &pci_latency);
  38465. + if (pci_latency < 64) {
  38466. + pci_write_config_byte(tp->pdev, PCI_LATENCY_TIMER, 64);
  38467. + }
  38468. +
  38469. + pci_read_config_dword(tp->pdev, TG3PCI_PCISTATE, &pci_state_reg);
  38470. +
  38471. + /* If this is a 5700 BX chipset, and we are in PCI-X
  38472. + * mode, enable register write workaround.
  38473. + *
  38474. + * The workaround is to use indirect register accesses
  38475. + * for all chip writes not to mailbox registers.
  38476. + *
  38477. + * In etherboot to simplify things we just always use this work around.
  38478. + */
  38479. + if ((pci_state_reg & PCISTATE_CONV_PCI_MODE) == 0) {
  38480. + tp->tg3_flags |= TG3_FLAG_PCIX_MODE;
  38481. + }
  38482. + /* Back to back register writes can cause problems on the 5701,
  38483. + * the workaround is to read back all reg writes except those to
  38484. + * mailbox regs.
  38485. + * In etherboot we always use indirect register accesses so
  38486. + * we don't see this.
  38487. + */
  38488. +
  38489. + if ((pci_state_reg & PCISTATE_BUS_SPEED_HIGH) != 0)
  38490. + tp->tg3_flags |= TG3_FLAG_PCI_HIGH_SPEED;
  38491. + if ((pci_state_reg & PCISTATE_BUS_32BIT) != 0)
  38492. + tp->tg3_flags |= TG3_FLAG_PCI_32BIT;
  38493. +
  38494. + /* Chip-specific fixup from Broadcom driver */
  38495. + if ((tp->pci_chip_rev_id == CHIPREV_ID_5704_A0) &&
  38496. + (!(pci_state_reg & PCISTATE_RETRY_SAME_DMA))) {
  38497. + pci_state_reg |= PCISTATE_RETRY_SAME_DMA;
  38498. + pci_write_config_dword(tp->pdev, TG3PCI_PCISTATE, pci_state_reg);
  38499. + }
  38500. +
  38501. + /* Force the chip into D0. */
  38502. + tg3_set_power_state_0(tp);
  38503. +
  38504. + /* Etherboot does not ask the tg3 to do checksums */
  38505. + /* Etherboot does not ask the tg3 to do jumbo frames */
  38506. + /* Ehterboot does not ask the tg3 to use WakeOnLan. */
  38507. +
  38508. + /* A few boards don't want Ethernet@WireSpeed phy feature */
  38509. + if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700) ||
  38510. + ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) &&
  38511. + (tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) &&
  38512. + (tp->pci_chip_rev_id != CHIPREV_ID_5705_A1))) {
  38513. + tp->tg3_flags2 |= TG3_FLG2_NO_ETH_WIRE_SPEED;
  38514. + }
  38515. +
  38516. + /* Avoid tagged irq status etherboot does not use irqs */
  38517. +
  38518. + /* Only 5701 and later support tagged irq status mode.
  38519. + * Also, 5788 chips cannot use tagged irq status.
  38520. + *
  38521. + * However, since etherboot does not use irqs avoid tagged irqs
  38522. + * status because the interrupt condition is more difficult to
  38523. + * fully clear in that mode.
  38524. + */
  38525. +
  38526. + /* Since some 5700_AX && 5700_BX have problems with 32BYTE
  38527. + * coalesce_mode, and the rest work fine anything set.
  38528. + * Don't enable HOST_CC_MODE_32BYTE in etherboot.
  38529. + */
  38530. +
  38531. + /* Initialize MAC MI mode, polling disabled. */
  38532. + tw32_carefully(MAC_MI_MODE, tp->mi_mode);
  38533. +
  38534. + /* Initialize data/descriptor byte/word swapping. */
  38535. + tw32(GRC_MODE, tp->grc_mode);
  38536. +
  38537. + tg3_switch_clocks(tp);
  38538. +
  38539. + /* Clear this out for sanity. */
  38540. + tw32(TG3PCI_MEM_WIN_BASE_ADDR, 0);
  38541. +
  38542. + /* Etherboot does not need to check if the PCIX_TARGET_HWBUG
  38543. + * is needed. It always uses it.
  38544. + */
  38545. +
  38546. + udelay(50);
  38547. + tg3_nvram_init(tp);
  38548. +
  38549. + /* The TX descriptors will reside in main memory.
  38550. + */
  38551. +
  38552. + /* See which board we are using.
  38553. + */
  38554. + grc_misc_cfg = tr32(GRC_MISC_CFG);
  38555. + grc_misc_cfg &= GRC_MISC_CFG_BOARD_ID_MASK;
  38556. +
  38557. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 &&
  38558. + grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5704CIOBE) {
  38559. + tp->tg3_flags |= TG3_FLAG_SPLIT_MODE;
  38560. + tp->split_mode_max_reqs = SPLIT_MODE_5704_MAX_REQ;
  38561. + }
  38562. +
  38563. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 &&
  38564. + (grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5788 ||
  38565. + grc_misc_cfg == GRC_MISC_CFG_BOARD_ID_5788M))
  38566. + tp->tg3_flags2 |= TG3_FLG2_IS_5788;
  38567. +
  38568. + /* these are limited to 10/100 only */
  38569. + if (((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703) &&
  38570. + ((grc_misc_cfg == 0x8000) || (grc_misc_cfg == 0x4000))) ||
  38571. + ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) &&
  38572. + (tp->pdev->vendor == PCI_VENDOR_ID_BROADCOM) &&
  38573. + ((tp->pdev->dev_id == PCI_DEVICE_ID_TIGON3_5901) ||
  38574. + (tp->pdev->dev_id == PCI_DEVICE_ID_TIGON3_5901_2)))) {
  38575. + tp->tg3_flags |= TG3_FLAG_10_100_ONLY;
  38576. + }
  38577. +
  38578. + err = tg3_phy_probe(tp);
  38579. + if (err) {
  38580. + printf("phy probe failed, err %d\n", err);
  38581. + }
  38582. +
  38583. + tg3_read_partno(tp);
  38584. +
  38585. +
  38586. + /* 5700 BX chips need to have their TX producer index mailboxes
  38587. + * written twice to workaround a bug.
  38588. + * In etherboot we do this unconditionally to simplify things.
  38589. + */
  38590. +
  38591. + /* 5700 chips can get confused if TX buffers straddle the
  38592. + * 4GB address boundary in some cases.
  38593. + *
  38594. + * In etherboot we can ignore the problem as etherboot lives below 4GB.
  38595. + */
  38596. +
  38597. + /* In etherboot wake-on-lan is unconditionally disabled */
  38598. + return err;
  38599. +}
  38600. +
  38601. +static int tg3_get_device_address(struct tg3 *tp)
  38602. +{
  38603. + struct nic *nic = tp->nic;
  38604. + uint32_t hi, lo, mac_offset;
  38605. +
  38606. + if (PCI_FUNC(tp->pdev->devfn) == 0)
  38607. + mac_offset = 0x7c;
  38608. + else
  38609. + mac_offset = 0xcc;
  38610. +
  38611. + /* First try to get it from MAC address mailbox. */
  38612. + tg3_read_mem(NIC_SRAM_MAC_ADDR_HIGH_MBOX, &hi);
  38613. + if ((hi >> 16) == 0x484b) {
  38614. + nic->node_addr[0] = (hi >> 8) & 0xff;
  38615. + nic->node_addr[1] = (hi >> 0) & 0xff;
  38616. +
  38617. + tg3_read_mem(NIC_SRAM_MAC_ADDR_LOW_MBOX, &lo);
  38618. + nic->node_addr[2] = (lo >> 24) & 0xff;
  38619. + nic->node_addr[3] = (lo >> 16) & 0xff;
  38620. + nic->node_addr[4] = (lo >> 8) & 0xff;
  38621. + nic->node_addr[5] = (lo >> 0) & 0xff;
  38622. + }
  38623. + /* Next, try NVRAM. */
  38624. + else if (!tg3_nvram_read(tp, mac_offset + 0, &hi) &&
  38625. + !tg3_nvram_read(tp, mac_offset + 4, &lo)) {
  38626. + nic->node_addr[0] = ((hi >> 16) & 0xff);
  38627. + nic->node_addr[1] = ((hi >> 24) & 0xff);
  38628. + nic->node_addr[2] = ((lo >> 0) & 0xff);
  38629. + nic->node_addr[3] = ((lo >> 8) & 0xff);
  38630. + nic->node_addr[4] = ((lo >> 16) & 0xff);
  38631. + nic->node_addr[5] = ((lo >> 24) & 0xff);
  38632. + }
  38633. + /* Finally just fetch it out of the MAC control regs. */
  38634. + else {
  38635. + hi = tr32(MAC_ADDR_0_HIGH);
  38636. + lo = tr32(MAC_ADDR_0_LOW);
  38637. +
  38638. + nic->node_addr[5] = lo & 0xff;
  38639. + nic->node_addr[4] = (lo >> 8) & 0xff;
  38640. + nic->node_addr[3] = (lo >> 16) & 0xff;
  38641. + nic->node_addr[2] = (lo >> 24) & 0xff;
  38642. + nic->node_addr[1] = hi & 0xff;
  38643. + nic->node_addr[0] = (hi >> 8) & 0xff;
  38644. + }
  38645. +
  38646. + return 0;
  38647. +}
  38648. +
  38649. +
  38650. +static int tg3_setup_dma(struct tg3 *tp)
  38651. +{
  38652. + tw32(TG3PCI_CLOCK_CTRL, 0);
  38653. +
  38654. + if ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) == 0) {
  38655. + tp->dma_rwctrl =
  38656. + (0x7 << DMA_RWCTRL_PCI_WRITE_CMD_SHIFT) |
  38657. + (0x6 << DMA_RWCTRL_PCI_READ_CMD_SHIFT) |
  38658. + (0x7 << DMA_RWCTRL_WRITE_WATER_SHIFT) |
  38659. + (0x7 << DMA_RWCTRL_READ_WATER_SHIFT) |
  38660. + (0x0f << DMA_RWCTRL_MIN_DMA_SHIFT);
  38661. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
  38662. + tp->dma_rwctrl &= ~(DMA_RWCTRL_MIN_DMA << DMA_RWCTRL_MIN_DMA_SHIFT);
  38663. + }
  38664. + } else {
  38665. + if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704)
  38666. + tp->dma_rwctrl =
  38667. + (0x7 << DMA_RWCTRL_PCI_WRITE_CMD_SHIFT) |
  38668. + (0x6 << DMA_RWCTRL_PCI_READ_CMD_SHIFT) |
  38669. + (0x3 << DMA_RWCTRL_WRITE_WATER_SHIFT) |
  38670. + (0x7 << DMA_RWCTRL_READ_WATER_SHIFT) |
  38671. + (0x00 << DMA_RWCTRL_MIN_DMA_SHIFT);
  38672. + else
  38673. + tp->dma_rwctrl =
  38674. + (0x7 << DMA_RWCTRL_PCI_WRITE_CMD_SHIFT) |
  38675. + (0x6 << DMA_RWCTRL_PCI_READ_CMD_SHIFT) |
  38676. + (0x3 << DMA_RWCTRL_WRITE_WATER_SHIFT) |
  38677. + (0x3 << DMA_RWCTRL_READ_WATER_SHIFT) |
  38678. + (0x0f << DMA_RWCTRL_MIN_DMA_SHIFT);
  38679. +
  38680. + /* Wheee, some more chip bugs... */
  38681. + if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703) ||
  38682. + (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704)) {
  38683. + uint32_t ccval = tr32(TG3PCI_CLOCK_CTRL) & 0x1f;
  38684. +
  38685. + if ((ccval == 0x6) || (ccval == 0x7)) {
  38686. + tp->dma_rwctrl |= DMA_RWCTRL_ONE_DMA;
  38687. + }
  38688. + }
  38689. + }
  38690. +
  38691. + if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703) ||
  38692. + (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704)) {
  38693. + tp->dma_rwctrl &= ~(DMA_RWCTRL_MIN_DMA << DMA_RWCTRL_MIN_DMA_SHIFT);
  38694. + }
  38695. +
  38696. + tp->dma_rwctrl |= DMA_RWCTRL_ASSERT_ALL_BE;
  38697. +
  38698. + tw32(TG3PCI_DMA_RW_CTRL, tp->dma_rwctrl);
  38699. +
  38700. + return 0;
  38701. +}
  38702. +
  38703. +static void tg3_init_link_config(struct tg3 *tp)
  38704. +{
  38705. + tp->link_config.advertising =
  38706. + (ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
  38707. + ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full |
  38708. + ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full |
  38709. + ADVERTISED_Autoneg | ADVERTISED_MII);
  38710. + tp->carrier_ok = 0;
  38711. + tp->link_config.active_speed = SPEED_INVALID;
  38712. + tp->link_config.active_duplex = DUPLEX_INVALID;
  38713. +}
  38714. +
  38715. +
  38716. +#if SUPPORT_PHY_STR
  38717. +static const char * tg3_phy_string(struct tg3 *tp)
  38718. +{
  38719. + switch (tp->phy_id & PHY_ID_MASK) {
  38720. + case PHY_ID_BCM5400: return "5400";
  38721. + case PHY_ID_BCM5401: return "5401";
  38722. + case PHY_ID_BCM5411: return "5411";
  38723. + case PHY_ID_BCM5701: return "5701";
  38724. + case PHY_ID_BCM5703: return "5703";
  38725. + case PHY_ID_BCM5704: return "5704";
  38726. + case PHY_ID_BCM8002: return "8002";
  38727. + case PHY_ID_SERDES: return "serdes";
  38728. + default: return "unknown";
  38729. + };
  38730. +}
  38731. +#else
  38732. +#define tg3_phy_string(TP) "?"
  38733. +#endif
  38734. +
  38735. +
  38736. +static void tg3_poll_link(struct tg3 *tp)
  38737. +{
  38738. + uint32_t mac_stat;
  38739. +
  38740. + mac_stat = tr32(MAC_STATUS);
  38741. + if (tp->phy_id == PHY_ID_SERDES) {
  38742. + if (tp->carrier_ok?
  38743. + (mac_stat & MAC_STATUS_LNKSTATE_CHANGED):
  38744. + (mac_stat & MAC_STATUS_PCS_SYNCED)) {
  38745. + tw32_carefully(MAC_MODE, tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK);
  38746. + tw32_carefully(MAC_MODE, tp->mac_mode);
  38747. +
  38748. + tg3_setup_phy(tp);
  38749. + }
  38750. + }
  38751. + else {
  38752. + if (mac_stat & MAC_STATUS_LNKSTATE_CHANGED) {
  38753. + tg3_setup_phy(tp);
  38754. + }
  38755. + }
  38756. +}
  38757. +
  38758. +/**************************************************************************
  38759. +POLL - Wait for a frame
  38760. +***************************************************************************/
  38761. +static void tg3_ack_irqs(struct tg3 *tp)
  38762. +{
  38763. + if (tp->hw_status->status & SD_STATUS_UPDATED) {
  38764. + /*
  38765. + * writing any value to intr-mbox-0 clears PCI INTA# and
  38766. + * chip-internal interrupt pending events.
  38767. + * writing non-zero to intr-mbox-0 additional tells the
  38768. + * NIC to stop sending us irqs, engaging "in-intr-handler"
  38769. + * event coalescing.
  38770. + */
  38771. + tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
  38772. + 0x00000001);
  38773. + /*
  38774. + * Flush PCI write. This also guarantees that our
  38775. + * status block has been flushed to host memory.
  38776. + */
  38777. + tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW);
  38778. + tp->hw_status->status &= ~SD_STATUS_UPDATED;
  38779. + }
  38780. +}
  38781. +
  38782. +static int tg3_poll(struct nic *nic, int retrieve)
  38783. +{
  38784. + /* return true if there's an ethernet packet ready to read */
  38785. + /* nic->packet should contain data on return */
  38786. + /* nic->packetlen should contain length of data */
  38787. +
  38788. + struct tg3 *tp = &tg3;
  38789. + int result;
  38790. +
  38791. + result = 0;
  38792. +
  38793. + if ( (tp->hw_status->idx[0].rx_producer != tp->rx_rcb_ptr) && !retrieve )
  38794. + return 1;
  38795. +
  38796. + tg3_ack_irqs(tp);
  38797. +
  38798. + if (tp->hw_status->idx[0].rx_producer != tp->rx_rcb_ptr) {
  38799. + struct tg3_rx_buffer_desc *desc;
  38800. + unsigned int len;
  38801. + desc = &tp->rx_rcb[tp->rx_rcb_ptr];
  38802. + if ((desc->opaque & RXD_OPAQUE_RING_MASK) == RXD_OPAQUE_RING_STD) {
  38803. + len = ((desc->idx_len & RXD_LEN_MASK) >> RXD_LEN_SHIFT) - 4; /* omit crc */
  38804. +
  38805. + nic->packetlen = len;
  38806. + memcpy(nic->packet, bus_to_virt(desc->addr_lo), len);
  38807. + result = 1;
  38808. + }
  38809. + tp->rx_rcb_ptr = (tp->rx_rcb_ptr + 1) % TG3_RX_RCB_RING_SIZE;
  38810. +
  38811. + /* ACK the status ring */
  38812. + tw32_mailbox2(MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW, tp->rx_rcb_ptr);
  38813. +
  38814. + /* Refill RX ring. */
  38815. + if (result) {
  38816. + tp->rx_std_ptr = (tp->rx_std_ptr + 1) % TG3_RX_RING_SIZE;
  38817. + tw32_mailbox2(MAILBOX_RCV_STD_PROD_IDX + TG3_64BIT_REG_LOW, tp->rx_std_ptr);
  38818. + }
  38819. + }
  38820. + tg3_poll_link(tp);
  38821. + return result;
  38822. +}
  38823. +
  38824. +/**************************************************************************
  38825. +TRANSMIT - Transmit a frame
  38826. +***************************************************************************/
  38827. +#if 0
  38828. +static void tg3_set_txd(struct tg3 *tp, int entry,
  38829. + dma_addr_t mapping, int len, uint32_t flags,
  38830. + uint32_t mss_and_is_end)
  38831. +{
  38832. + struct tg3_tx_buffer_desc *txd = &tp->tx_ring[entry];
  38833. + int is_end = (mss_and_is_end & 0x1);
  38834. + if (is_end) {
  38835. + flags |= TXD_FLAG_END;
  38836. + }
  38837. +
  38838. + txd->addr_hi = 0;
  38839. + txd->addr_lo = mapping & 0xffffffff;
  38840. + txd->len_flags = (len << TXD_LEN_SHIFT) | flags;
  38841. + txd->vlan_tag = 0 << TXD_VLAN_TAG_SHIFT;
  38842. +}
  38843. +#endif
  38844. +
  38845. +static void tg3_transmit(struct nic *nic, const char *dst_addr,
  38846. + unsigned int type, unsigned int size, const char *packet)
  38847. +{
  38848. + static struct eth_frame {
  38849. + uint8_t dst_addr[ETH_ALEN];
  38850. + uint8_t src_addr[ETH_ALEN];
  38851. + uint16_t type;
  38852. + uint8_t data [ETH_FRAME_LEN - ETH_HLEN];
  38853. + } frame[2];
  38854. + static int frame_idx;
  38855. +
  38856. + /* send the packet to destination */
  38857. + struct tg3_tx_buffer_desc *txd;
  38858. + struct tg3 *tp;
  38859. + uint32_t entry;
  38860. + int i;
  38861. +
  38862. + /* Wait until there is a free packet frame */
  38863. + tp = &tg3;
  38864. + i = 0;
  38865. + entry = tp->tx_prod;
  38866. + while((tp->hw_status->idx[0].tx_consumer != entry) &&
  38867. + (tp->hw_status->idx[0].tx_consumer != PREV_TX(entry))) {
  38868. + mdelay(10); /* give the nick a chance */
  38869. + poll_interruptions();
  38870. + if (++i > 500) { /* timeout 5s for transmit */
  38871. + printf("transmit timed out\n");
  38872. + tg3_halt(tp);
  38873. + tg3_setup_hw(tp);
  38874. + return;
  38875. + }
  38876. + }
  38877. + if (i != 0) {
  38878. + printf("#");
  38879. + }
  38880. +
  38881. + /* Copy the packet to the our local buffer */
  38882. + memcpy(&frame[frame_idx].dst_addr, dst_addr, ETH_ALEN);
  38883. + memcpy(&frame[frame_idx].src_addr, nic->node_addr, ETH_ALEN);
  38884. + frame[frame_idx].type = htons(type);
  38885. + memset(&frame[frame_idx].data, 0, sizeof(frame[frame_idx].data));
  38886. + memcpy(&frame[frame_idx].data, packet, size);
  38887. +
  38888. + /* Setup the ring buffer entry to transmit */
  38889. + txd = &tp->tx_ring[entry];
  38890. + txd->addr_hi = 0; /* Etherboot runs under 4GB */
  38891. + txd->addr_lo = virt_to_bus(&frame[frame_idx]);
  38892. + txd->len_flags = ((size + ETH_HLEN) << TXD_LEN_SHIFT) | TXD_FLAG_END;
  38893. + txd->vlan_tag = 0 << TXD_VLAN_TAG_SHIFT;
  38894. +
  38895. + /* Advance to the next entry */
  38896. + entry = NEXT_TX(entry);
  38897. + frame_idx ^= 1;
  38898. +
  38899. + /* Packets are ready, update Tx producer idx local and on card */
  38900. + tw32_mailbox((MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW), entry);
  38901. + tw32_mailbox2((MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW), entry);
  38902. + tp->tx_prod = entry;
  38903. +}
  38904. +
  38905. +/**************************************************************************
  38906. +DISABLE - Turn off ethernet interface
  38907. +***************************************************************************/
  38908. +static void tg3_disable(struct dev *dev __unused)
  38909. +{
  38910. + struct tg3 *tp = &tg3;
  38911. + /* put the card in its initial state */
  38912. + /* This function serves 3 purposes.
  38913. + * This disables DMA and interrupts so we don't receive
  38914. + * unexpected packets or interrupts from the card after
  38915. + * etherboot has finished.
  38916. + * This frees resources so etherboot may use
  38917. + * this driver on another interface
  38918. + * This allows etherboot to reinitialize the interface
  38919. + * if something is something goes wrong.
  38920. + */
  38921. + tg3_halt(tp);
  38922. + tp->tg3_flags &= ~(TG3_FLAG_INIT_COMPLETE|TG3_FLAG_GOT_SERDES_FLOWCTL);
  38923. + tp->carrier_ok = 0;
  38924. + iounmap((void *)tp->regs);
  38925. +}
  38926. +
  38927. +/**************************************************************************
  38928. +IRQ - Enable, Disable, or Force interrupts
  38929. +***************************************************************************/
  38930. +static void tg3_irq(struct nic *nic __unused, irq_action_t action __unused)
  38931. +{
  38932. + switch ( action ) {
  38933. + case DISABLE :
  38934. + break;
  38935. + case ENABLE :
  38936. + break;
  38937. + case FORCE :
  38938. + break;
  38939. + }
  38940. +}
  38941. +
  38942. +/**************************************************************************
  38943. +PROBE - Look for an adapter, this routine's visible to the outside
  38944. +You should omit the last argument struct pci_device * for a non-PCI NIC
  38945. +***************************************************************************/
  38946. +static int tg3_probe(struct dev *dev, struct pci_device *pdev)
  38947. +{
  38948. + struct nic *nic = (struct nic *)dev;
  38949. + struct tg3 *tp = &tg3;
  38950. + unsigned long tg3reg_base, tg3reg_len;
  38951. + int i, err, pm_cap;
  38952. +
  38953. + if (pdev == 0)
  38954. + return 0;
  38955. +
  38956. + memset(tp, 0, sizeof(*tp));
  38957. +
  38958. + adjust_pci_device(pdev);
  38959. +
  38960. + nic->irqno = 0;
  38961. + nic->ioaddr = pdev->ioaddr & ~3;
  38962. +
  38963. + /* Find power-management capability. */
  38964. + pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
  38965. + if (pm_cap == 0) {
  38966. + printf("Cannot find PowerManagement capability, aborting.\n");
  38967. + return 0;
  38968. + }
  38969. + tg3reg_base = pci_bar_start(pdev, PCI_BASE_ADDRESS_0);
  38970. + if (tg3reg_base == -1UL) {
  38971. + printf("Unuseable bar\n");
  38972. + return 0;
  38973. + }
  38974. + tg3reg_len = pci_bar_size(pdev, PCI_BASE_ADDRESS_0);
  38975. +
  38976. + tp->pdev = pdev;
  38977. + tp->nic = nic;
  38978. + tp->pm_cap = pm_cap;
  38979. + tp->rx_mode = 0;
  38980. + tp->tx_mode = 0;
  38981. + tp->mi_mode = MAC_MI_MODE_BASE;
  38982. + tp->tg3_flags = 0 & ~TG3_FLAG_INIT_COMPLETE;
  38983. +
  38984. + /* The word/byte swap controls here control register access byte
  38985. + * swapping. DMA data byte swapping is controlled in the GRC_MODE
  38986. + * setting below.
  38987. + */
  38988. + tp->misc_host_ctrl =
  38989. + MISC_HOST_CTRL_MASK_PCI_INT |
  38990. + MISC_HOST_CTRL_WORD_SWAP |
  38991. + MISC_HOST_CTRL_INDIR_ACCESS |
  38992. + MISC_HOST_CTRL_PCISTATE_RW;
  38993. +
  38994. + /* The NONFRM (non-frame) byte/word swap controls take effect
  38995. + * on descriptor entries, anything which isn't packet data.
  38996. + *
  38997. + * The StrongARM chips on the board (one for tx, one for rx)
  38998. + * are running in big-endian mode.
  38999. + */
  39000. + tp->grc_mode = (GRC_MODE_WSWAP_DATA | GRC_MODE_BSWAP_DATA |
  39001. + GRC_MODE_WSWAP_NONFRM_DATA);
  39002. +#if __BYTE_ORDER == __BIG_ENDIAN
  39003. + tp->grc_mode |= GRC_MODE_BSWAP_NONFRM_DATA;
  39004. +#endif
  39005. + tp->regs = (unsigned long) ioremap(tg3reg_base, tg3reg_len);
  39006. + if (tp->regs == 0UL) {
  39007. + printf("Cannot map device registers, aborting\n");
  39008. + return 0;
  39009. + }
  39010. +
  39011. + tg3_init_link_config(tp);
  39012. +
  39013. + err = tg3_get_invariants(tp);
  39014. + if (err) {
  39015. + printf("Problem fetching invariants of chip, aborting.\n");
  39016. + goto err_out_iounmap;
  39017. + }
  39018. +
  39019. + err = tg3_get_device_address(tp);
  39020. + if (err) {
  39021. + printf("Could not obtain valid ethernet address, aborting.\n");
  39022. + goto err_out_iounmap;
  39023. + }
  39024. + printf("Ethernet addr: %!\n", nic->node_addr);
  39025. +
  39026. + tg3_setup_dma(tp);
  39027. +
  39028. + /* Now that we have fully setup the chip, save away a snapshot
  39029. + * of the PCI config space. We need to restore this after
  39030. + * GRC_MISC_CFG core clock resets and some resume events.
  39031. + */
  39032. + pci_save_state(tp->pdev, tp->pci_cfg_state);
  39033. +
  39034. + printf("Tigon3 [partno(%s) rev %hx PHY(%s)] (PCI%s:%s:%s)\n",
  39035. + tp->board_part_number,
  39036. + tp->pci_chip_rev_id,
  39037. + tg3_phy_string(tp),
  39038. + ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) ? "X" : ""),
  39039. + ((tp->tg3_flags & TG3_FLAG_PCI_HIGH_SPEED) ?
  39040. + ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) ? "133MHz" : "66MHz") :
  39041. + ((tp->tg3_flags & TG3_FLAG_PCIX_MODE) ? "100MHz" : "33MHz")),
  39042. + ((tp->tg3_flags & TG3_FLAG_PCI_32BIT) ? "32-bit" : "64-bit"));
  39043. +
  39044. +
  39045. + err = tg3_setup_hw(tp);
  39046. + if (err) {
  39047. + goto err_out_disable;
  39048. + }
  39049. + tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE;
  39050. +
  39051. + /* Wait for a reasonable time for the link to come up */
  39052. + tg3_poll_link(tp);
  39053. + for(i = 0; !tp->carrier_ok && (i < VALID_LINK_TIMEOUT*100); i++) {
  39054. + mdelay(1);
  39055. + tg3_poll_link(tp);
  39056. + }
  39057. + if (!tp->carrier_ok){
  39058. + printf("Valid link not established\n");
  39059. + goto err_out_disable;
  39060. + }
  39061. +
  39062. + dev->disable = tg3_disable;
  39063. + nic->poll = tg3_poll;
  39064. + nic->transmit = tg3_transmit;
  39065. + nic->irq = tg3_irq;
  39066. +
  39067. + return 1;
  39068. +
  39069. + err_out_iounmap:
  39070. + iounmap((void *)tp->regs);
  39071. + return 0;
  39072. + err_out_disable:
  39073. + tg3_disable(dev);
  39074. + return 0;
  39075. +}
  39076. +
  39077. +static struct pci_id tg3_nics[] = {
  39078. +PCI_ROM(0x14e4, 0x1644, "tg3-5700", "Broadcom Tigon 3 5700"),
  39079. +PCI_ROM(0x14e4, 0x1645, "tg3-5701", "Broadcom Tigon 3 5701"),
  39080. +PCI_ROM(0x14e4, 0x1646, "tg3-5702", "Broadcom Tigon 3 5702"),
  39081. +PCI_ROM(0x14e4, 0x1647, "tg3-5703", "Broadcom Tigon 3 5703"),
  39082. +PCI_ROM(0x14e4, 0x1648, "tg3-5704", "Broadcom Tigon 3 5704"),
  39083. +PCI_ROM(0x14e4, 0x164d, "tg3-5702FE", "Broadcom Tigon 3 5702FE"),
  39084. +PCI_ROM(0x14e4, 0x1653, "tg3-5705", "Broadcom Tigon 3 5705"),
  39085. +PCI_ROM(0x14e4, 0x1654, "tg3-5705_2", "Broadcom Tigon 3 5705_2"),
  39086. +PCI_ROM(0x14e4, 0x165d, "tg3-5705M", "Broadcom Tigon 3 5705M"),
  39087. +PCI_ROM(0x14e4, 0x165e, "tg3-5705M_2", "Broadcom Tigon 3 5705M_2"),
  39088. +PCI_ROM(0x14e4, 0x1696, "tg3-5782", "Broadcom Tigon 3 5782"),
  39089. +PCI_ROM(0x14e4, 0x169c, "tg3-5788", "Broadcom Tigon 3 5788"),
  39090. +PCI_ROM(0x14e4, 0x16a6, "tg3-5702X", "Broadcom Tigon 3 5702X"),
  39091. +PCI_ROM(0x14e4, 0x16a7, "tg3-5703X", "Broadcom Tigon 3 5703X"),
  39092. +PCI_ROM(0x14e4, 0x16a8, "tg3-5704S", "Broadcom Tigon 3 5704S"),
  39093. +PCI_ROM(0x14e4, 0x16c6, "tg3-5702A3", "Broadcom Tigon 3 5702A3"),
  39094. +PCI_ROM(0x14e4, 0x16c7, "tg3-5703A3", "Broadcom Tigon 3 5703A3"),
  39095. +PCI_ROM(0x14e4, 0x170d, "tg3-5901", "Broadcom Tigon 3 5901"),
  39096. +PCI_ROM(0x14e4, 0x170e, "tg3-5901_2", "Broadcom Tigon 3 5901_2"),
  39097. +PCI_ROM(0x1148, 0x4400, "tg3-9DXX", "Syskonnect 9DXX"),
  39098. +PCI_ROM(0x1148, 0x4500, "tg3-9MXX", "Syskonnect 9MXX"),
  39099. +PCI_ROM(0x173b, 0x03e8, "tg3-ac1000", "Altima AC1000"),
  39100. +PCI_ROM(0x173b, 0x03e9, "tg3-ac1001", "Altima AC1001"),
  39101. +PCI_ROM(0x173b, 0x03ea, "tg3-ac9100", "Altima AC9100"),
  39102. +PCI_ROM(0x173b, 0x03eb, "tg3-ac1003", "Altima AC1003"),
  39103. +};
  39104. +
  39105. +struct pci_driver tg3_driver = {
  39106. + .type = NIC_DRIVER,
  39107. + .name = "TG3",
  39108. + .probe = tg3_probe,
  39109. + .ids = tg3_nics,
  39110. + .id_count = sizeof(tg3_nics)/sizeof(tg3_nics[0]),
  39111. + .class = 0,
  39112. +};
  39113. diff -Naur grub-0.97.orig/netboot/tg3.h grub-0.97/netboot/tg3.h
  39114. --- grub-0.97.orig/netboot/tg3.h 1970-01-01 00:00:00.000000000 +0000
  39115. +++ grub-0.97/netboot/tg3.h 2005-08-31 19:03:35.000000000 +0000
  39116. @@ -0,0 +1,2203 @@
  39117. +/* $Id: grub-0.95-diskless-patch-2.patch,v 1.1.1.1 2005/06/14 08:18:50 wesolows Exp $
  39118. + * tg3.h: Definitions for Broadcom Tigon3 ethernet driver.
  39119. + *
  39120. + * Copyright (C) 2001, 2002 David S. Miller (davem@redhat.com)
  39121. + * Copyright (C) 2001 Jeff Garzik (jgarzik@mandrakesoft.com)
  39122. + */
  39123. +
  39124. +#ifndef _T3_H
  39125. +#define _T3_H
  39126. +
  39127. +#include "stdint.h"
  39128. +
  39129. +typedef unsigned long dma_addr_t;
  39130. +
  39131. +/* From mii.h */
  39132. +
  39133. +/* Indicates what features are advertised by the interface. */
  39134. +#define ADVERTISED_10baseT_Half (1 << 0)
  39135. +#define ADVERTISED_10baseT_Full (1 << 1)
  39136. +#define ADVERTISED_100baseT_Half (1 << 2)
  39137. +#define ADVERTISED_100baseT_Full (1 << 3)
  39138. +#define ADVERTISED_1000baseT_Half (1 << 4)
  39139. +#define ADVERTISED_1000baseT_Full (1 << 5)
  39140. +#define ADVERTISED_Autoneg (1 << 6)
  39141. +#define ADVERTISED_TP (1 << 7)
  39142. +#define ADVERTISED_AUI (1 << 8)
  39143. +#define ADVERTISED_MII (1 << 9)
  39144. +#define ADVERTISED_FIBRE (1 << 10)
  39145. +#define ADVERTISED_BNC (1 << 11)
  39146. +
  39147. +/* The following are all involved in forcing a particular link
  39148. + * mode for the device for setting things. When getting the
  39149. + * devices settings, these indicate the current mode and whether
  39150. + * it was foced up into this mode or autonegotiated.
  39151. + */
  39152. +
  39153. +/* The forced speed, 10Mb, 100Mb, gigabit. */
  39154. +#define SPEED_10 0
  39155. +#define SPEED_100 1
  39156. +#define SPEED_1000 2
  39157. +#define SPEED_INVALID 3
  39158. +
  39159. +
  39160. +/* Duplex, half or full. */
  39161. +#define DUPLEX_HALF 0x00
  39162. +#define DUPLEX_FULL 0x01
  39163. +#define DUPLEX_INVALID 0x02
  39164. +
  39165. +/* Which connector port. */
  39166. +#define PORT_TP 0x00
  39167. +#define PORT_AUI 0x01
  39168. +#define PORT_MII 0x02
  39169. +#define PORT_FIBRE 0x03
  39170. +#define PORT_BNC 0x04
  39171. +
  39172. +/* Which tranceiver to use. */
  39173. +#define XCVR_INTERNAL 0x00
  39174. +#define XCVR_EXTERNAL 0x01
  39175. +#define XCVR_DUMMY1 0x02
  39176. +#define XCVR_DUMMY2 0x03
  39177. +#define XCVR_DUMMY3 0x04
  39178. +
  39179. +/* Enable or disable autonegotiation. If this is set to enable,
  39180. + * the forced link modes above are completely ignored.
  39181. + */
  39182. +#define AUTONEG_DISABLE 0x00
  39183. +#define AUTONEG_ENABLE 0x01
  39184. +
  39185. +/* Wake-On-Lan options. */
  39186. +#define WAKE_PHY (1 << 0)
  39187. +#define WAKE_UCAST (1 << 1)
  39188. +#define WAKE_MCAST (1 << 2)
  39189. +#define WAKE_BCAST (1 << 3)
  39190. +#define WAKE_ARP (1 << 4)
  39191. +#define WAKE_MAGIC (1 << 5)
  39192. +#define WAKE_MAGICSECURE (1 << 6) /* only meaningful if WAKE_MAGIC */
  39193. +
  39194. +/* Generic MII registers. */
  39195. +
  39196. +#define MII_BMCR 0x00 /* Basic mode control register */
  39197. +#define MII_BMSR 0x01 /* Basic mode status register */
  39198. +#define MII_PHYSID1 0x02 /* PHYS ID 1 */
  39199. +#define MII_PHYSID2 0x03 /* PHYS ID 2 */
  39200. +#define MII_ADVERTISE 0x04 /* Advertisement control reg */
  39201. +#define MII_LPA 0x05 /* Link partner ability reg */
  39202. +#define MII_EXPANSION 0x06 /* Expansion register */
  39203. +#define MII_DCOUNTER 0x12 /* Disconnect counter */
  39204. +#define MII_FCSCOUNTER 0x13 /* False carrier counter */
  39205. +#define MII_NWAYTEST 0x14 /* N-way auto-neg test reg */
  39206. +#define MII_RERRCOUNTER 0x15 /* Receive error counter */
  39207. +#define MII_SREVISION 0x16 /* Silicon revision */
  39208. +#define MII_RESV1 0x17 /* Reserved... */
  39209. +#define MII_LBRERROR 0x18 /* Lpback, rx, bypass error */
  39210. +#define MII_PHYADDR 0x19 /* PHY address */
  39211. +#define MII_RESV2 0x1a /* Reserved... */
  39212. +#define MII_TPISTATUS 0x1b /* TPI status for 10mbps */
  39213. +#define MII_NCONFIG 0x1c /* Network interface config */
  39214. +
  39215. +/* Basic mode control register. */
  39216. +#define BMCR_RESV 0x007f /* Unused... */
  39217. +#define BMCR_CTST 0x0080 /* Collision test */
  39218. +#define BMCR_FULLDPLX 0x0100 /* Full duplex */
  39219. +#define BMCR_ANRESTART 0x0200 /* Auto negotiation restart */
  39220. +#define BMCR_ISOLATE 0x0400 /* Disconnect DP83840 from MII */
  39221. +#define BMCR_PDOWN 0x0800 /* Powerdown the DP83840 */
  39222. +#define BMCR_ANENABLE 0x1000 /* Enable auto negotiation */
  39223. +#define BMCR_SPEED100 0x2000 /* Select 100Mbps */
  39224. +#define BMCR_LOOPBACK 0x4000 /* TXD loopback bits */
  39225. +#define BMCR_RESET 0x8000 /* Reset the DP83840 */
  39226. +
  39227. +/* Basic mode status register. */
  39228. +#define BMSR_ERCAP 0x0001 /* Ext-reg capability */
  39229. +#define BMSR_JCD 0x0002 /* Jabber detected */
  39230. +#define BMSR_LSTATUS 0x0004 /* Link status */
  39231. +#define BMSR_ANEGCAPABLE 0x0008 /* Able to do auto-negotiation */
  39232. +#define BMSR_RFAULT 0x0010 /* Remote fault detected */
  39233. +#define BMSR_ANEGCOMPLETE 0x0020 /* Auto-negotiation complete */
  39234. +#define BMSR_RESV 0x07c0 /* Unused... */
  39235. +#define BMSR_10HALF 0x0800 /* Can do 10mbps, half-duplex */
  39236. +#define BMSR_10FULL 0x1000 /* Can do 10mbps, full-duplex */
  39237. +#define BMSR_100HALF 0x2000 /* Can do 100mbps, half-duplex */
  39238. +#define BMSR_100FULL 0x4000 /* Can do 100mbps, full-duplex */
  39239. +#define BMSR_100BASE4 0x8000 /* Can do 100mbps, 4k packets */
  39240. +
  39241. +/* Advertisement control register. */
  39242. +#define ADVERTISE_SLCT 0x001f /* Selector bits */
  39243. +#define ADVERTISE_CSMA 0x0001 /* Only selector supported */
  39244. +#define ADVERTISE_10HALF 0x0020 /* Try for 10mbps half-duplex */
  39245. +#define ADVERTISE_10FULL 0x0040 /* Try for 10mbps full-duplex */
  39246. +#define ADVERTISE_100HALF 0x0080 /* Try for 100mbps half-duplex */
  39247. +#define ADVERTISE_100FULL 0x0100 /* Try for 100mbps full-duplex */
  39248. +#define ADVERTISE_100BASE4 0x0200 /* Try for 100mbps 4k packets */
  39249. +#define ADVERTISE_RESV 0x1c00 /* Unused... */
  39250. +#define ADVERTISE_RFAULT 0x2000 /* Say we can detect faults */
  39251. +#define ADVERTISE_LPACK 0x4000 /* Ack link partners response */
  39252. +#define ADVERTISE_NPAGE 0x8000 /* Next page bit */
  39253. +
  39254. +#define ADVERTISE_FULL (ADVERTISE_100FULL | ADVERTISE_10FULL | \
  39255. + ADVERTISE_CSMA)
  39256. +#define ADVERTISE_ALL (ADVERTISE_10HALF | ADVERTISE_10FULL | \
  39257. + ADVERTISE_100HALF | ADVERTISE_100FULL)
  39258. +
  39259. +/* Link partner ability register. */
  39260. +#define LPA_SLCT 0x001f /* Same as advertise selector */
  39261. +#define LPA_10HALF 0x0020 /* Can do 10mbps half-duplex */
  39262. +#define LPA_10FULL 0x0040 /* Can do 10mbps full-duplex */
  39263. +#define LPA_100HALF 0x0080 /* Can do 100mbps half-duplex */
  39264. +#define LPA_100FULL 0x0100 /* Can do 100mbps full-duplex */
  39265. +#define LPA_100BASE4 0x0200 /* Can do 100mbps 4k packets */
  39266. +#define LPA_RESV 0x1c00 /* Unused... */
  39267. +#define LPA_RFAULT 0x2000 /* Link partner faulted */
  39268. +#define LPA_LPACK 0x4000 /* Link partner acked us */
  39269. +#define LPA_NPAGE 0x8000 /* Next page bit */
  39270. +
  39271. +#define LPA_DUPLEX (LPA_10FULL | LPA_100FULL)
  39272. +#define LPA_100 (LPA_100FULL | LPA_100HALF | LPA_100BASE4)
  39273. +
  39274. +/* Expansion register for auto-negotiation. */
  39275. +#define EXPANSION_NWAY 0x0001 /* Can do N-way auto-nego */
  39276. +#define EXPANSION_LCWP 0x0002 /* Got new RX page code word */
  39277. +#define EXPANSION_ENABLENPAGE 0x0004 /* This enables npage words */
  39278. +#define EXPANSION_NPCAPABLE 0x0008 /* Link partner supports npage */
  39279. +#define EXPANSION_MFAULTS 0x0010 /* Multiple faults detected */
  39280. +#define EXPANSION_RESV 0xffe0 /* Unused... */
  39281. +
  39282. +/* N-way test register. */
  39283. +#define NWAYTEST_RESV1 0x00ff /* Unused... */
  39284. +#define NWAYTEST_LOOPBACK 0x0100 /* Enable loopback for N-way */
  39285. +#define NWAYTEST_RESV2 0xfe00 /* Unused... */
  39286. +
  39287. +
  39288. +/* From tg3.h */
  39289. +
  39290. +#define TG3_64BIT_REG_HIGH 0x00UL
  39291. +#define TG3_64BIT_REG_LOW 0x04UL
  39292. +
  39293. +/* Descriptor block info. */
  39294. +#define TG3_BDINFO_HOST_ADDR 0x0UL /* 64-bit */
  39295. +#define TG3_BDINFO_MAXLEN_FLAGS 0x8UL /* 32-bit */
  39296. +#define BDINFO_FLAGS_USE_EXT_RECV 0x00000001 /* ext rx_buffer_desc */
  39297. +#define BDINFO_FLAGS_DISABLED 0x00000002
  39298. +#define BDINFO_FLAGS_MAXLEN_MASK 0xffff0000
  39299. +#define BDINFO_FLAGS_MAXLEN_SHIFT 16
  39300. +#define TG3_BDINFO_NIC_ADDR 0xcUL /* 32-bit */
  39301. +#define TG3_BDINFO_SIZE 0x10UL
  39302. +
  39303. +#define RX_COPY_THRESHOLD 256
  39304. +
  39305. +#define RX_STD_MAX_SIZE 1536
  39306. +#define RX_STD_MAX_SIZE_5705 512
  39307. +#define RX_JUMBO_MAX_SIZE 0xdeadbeef /* XXX */
  39308. +
  39309. +/* First 256 bytes are a mirror of PCI config space. */
  39310. +#define TG3PCI_VENDOR 0x00000000
  39311. +#define TG3PCI_VENDOR_BROADCOM 0x14e4
  39312. +#define TG3PCI_DEVICE 0x00000002
  39313. +#define TG3PCI_DEVICE_TIGON3_1 0x1644 /* BCM5700 */
  39314. +#define TG3PCI_DEVICE_TIGON3_2 0x1645 /* BCM5701 */
  39315. +#define TG3PCI_DEVICE_TIGON3_3 0x1646 /* BCM5702 */
  39316. +#define TG3PCI_DEVICE_TIGON3_4 0x1647 /* BCM5703 */
  39317. +#define TG3PCI_COMMAND 0x00000004
  39318. +#define TG3PCI_STATUS 0x00000006
  39319. +#define TG3PCI_CCREVID 0x00000008
  39320. +#define TG3PCI_CACHELINESZ 0x0000000c
  39321. +#define TG3PCI_LATTIMER 0x0000000d
  39322. +#define TG3PCI_HEADERTYPE 0x0000000e
  39323. +#define TG3PCI_BIST 0x0000000f
  39324. +#define TG3PCI_BASE0_LOW 0x00000010
  39325. +#define TG3PCI_BASE0_HIGH 0x00000014
  39326. +/* 0x18 --> 0x2c unused */
  39327. +#define TG3PCI_SUBSYSVENID 0x0000002c
  39328. +#define TG3PCI_SUBSYSID 0x0000002e
  39329. +#define TG3PCI_ROMADDR 0x00000030
  39330. +#define TG3PCI_CAPLIST 0x00000034
  39331. +/* 0x35 --> 0x3c unused */
  39332. +#define TG3PCI_IRQ_LINE 0x0000003c
  39333. +#define TG3PCI_IRQ_PIN 0x0000003d
  39334. +#define TG3PCI_MIN_GNT 0x0000003e
  39335. +#define TG3PCI_MAX_LAT 0x0000003f
  39336. +#define TG3PCI_X_CAPS 0x00000040
  39337. +#define PCIX_CAPS_RELAXED_ORDERING 0x00020000
  39338. +#define PCIX_CAPS_SPLIT_MASK 0x00700000
  39339. +#define PCIX_CAPS_SPLIT_SHIFT 20
  39340. +#define PCIX_CAPS_BURST_MASK 0x000c0000
  39341. +#define PCIX_CAPS_BURST_SHIFT 18
  39342. +#define PCIX_CAPS_MAX_BURST_CPIOB 2
  39343. +#define TG3PCI_PM_CAP_PTR 0x00000041
  39344. +#define TG3PCI_X_COMMAND 0x00000042
  39345. +#define TG3PCI_X_STATUS 0x00000044
  39346. +#define TG3PCI_PM_CAP_ID 0x00000048
  39347. +#define TG3PCI_VPD_CAP_PTR 0x00000049
  39348. +#define TG3PCI_PM_CAPS 0x0000004a
  39349. +#define TG3PCI_PM_CTRL_STAT 0x0000004c
  39350. +#define TG3PCI_BR_SUPP_EXT 0x0000004e
  39351. +#define TG3PCI_PM_DATA 0x0000004f
  39352. +#define TG3PCI_VPD_CAP_ID 0x00000050
  39353. +#define TG3PCI_MSI_CAP_PTR 0x00000051
  39354. +#define TG3PCI_VPD_ADDR_FLAG 0x00000052
  39355. +#define VPD_ADDR_FLAG_WRITE 0x00008000
  39356. +#define TG3PCI_VPD_DATA 0x00000054
  39357. +#define TG3PCI_MSI_CAP_ID 0x00000058
  39358. +#define TG3PCI_NXT_CAP_PTR 0x00000059
  39359. +#define TG3PCI_MSI_CTRL 0x0000005a
  39360. +#define TG3PCI_MSI_ADDR_LOW 0x0000005c
  39361. +#define TG3PCI_MSI_ADDR_HIGH 0x00000060
  39362. +#define TG3PCI_MSI_DATA 0x00000064
  39363. +/* 0x66 --> 0x68 unused */
  39364. +#define TG3PCI_MISC_HOST_CTRL 0x00000068
  39365. +#define MISC_HOST_CTRL_CLEAR_INT 0x00000001
  39366. +#define MISC_HOST_CTRL_MASK_PCI_INT 0x00000002
  39367. +#define MISC_HOST_CTRL_BYTE_SWAP 0x00000004
  39368. +#define MISC_HOST_CTRL_WORD_SWAP 0x00000008
  39369. +#define MISC_HOST_CTRL_PCISTATE_RW 0x00000010
  39370. +#define MISC_HOST_CTRL_CLKREG_RW 0x00000020
  39371. +#define MISC_HOST_CTRL_REGWORD_SWAP 0x00000040
  39372. +#define MISC_HOST_CTRL_INDIR_ACCESS 0x00000080
  39373. +#define MISC_HOST_CTRL_IRQ_MASK_MODE 0x00000100
  39374. +#define MISC_HOST_CTRL_TAGGED_STATUS 0x00000200
  39375. +#define MISC_HOST_CTRL_CHIPREV 0xffff0000
  39376. +#define MISC_HOST_CTRL_CHIPREV_SHIFT 16
  39377. +#define GET_CHIP_REV_ID(MISC_HOST_CTRL) \
  39378. + (((MISC_HOST_CTRL) & MISC_HOST_CTRL_CHIPREV) >> \
  39379. + MISC_HOST_CTRL_CHIPREV_SHIFT)
  39380. +#define CHIPREV_ID_5700_A0 0x7000
  39381. +#define CHIPREV_ID_5700_A1 0x7001
  39382. +#define CHIPREV_ID_5700_B0 0x7100
  39383. +#define CHIPREV_ID_5700_B1 0x7101
  39384. +#define CHIPREV_ID_5700_B3 0x7102
  39385. +#define CHIPREV_ID_5700_ALTIMA 0x7104
  39386. +#define CHIPREV_ID_5700_C0 0x7200
  39387. +#define CHIPREV_ID_5701_A0 0x0000
  39388. +#define CHIPREV_ID_5701_B0 0x0100
  39389. +#define CHIPREV_ID_5701_B2 0x0102
  39390. +#define CHIPREV_ID_5701_B5 0x0105
  39391. +#define CHIPREV_ID_5703_A0 0x1000
  39392. +#define CHIPREV_ID_5703_A1 0x1001
  39393. +#define CHIPREV_ID_5703_A2 0x1002
  39394. +#define CHIPREV_ID_5703_A3 0x1003
  39395. +#define CHIPREV_ID_5704_A0 0x2000
  39396. +#define CHIPREV_ID_5704_A1 0x2001
  39397. +#define CHIPREV_ID_5704_A2 0x2002
  39398. +#define CHIPREV_ID_5705_A0 0x3000
  39399. +#define CHIPREV_ID_5705_A1 0x3001
  39400. +#define CHIPREV_ID_5705_A2 0x3002
  39401. +#define CHIPREV_ID_5705_A3 0x3003
  39402. +#define GET_ASIC_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 12)
  39403. +#define ASIC_REV_5700 0x07
  39404. +#define ASIC_REV_5701 0x00
  39405. +#define ASIC_REV_5703 0x01
  39406. +#define ASIC_REV_5704 0x02
  39407. +#define ASIC_REV_5705 0x03
  39408. +#define GET_CHIP_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 8)
  39409. +#define CHIPREV_5700_AX 0x70
  39410. +#define CHIPREV_5700_BX 0x71
  39411. +#define CHIPREV_5700_CX 0x72
  39412. +#define CHIPREV_5701_AX 0x00
  39413. +#define GET_METAL_REV(CHIP_REV_ID) ((CHIP_REV_ID) & 0xff)
  39414. +#define METAL_REV_A0 0x00
  39415. +#define METAL_REV_A1 0x01
  39416. +#define METAL_REV_B0 0x00
  39417. +#define METAL_REV_B1 0x01
  39418. +#define METAL_REV_B2 0x02
  39419. +#define TG3PCI_DMA_RW_CTRL 0x0000006c
  39420. +#define DMA_RWCTRL_MIN_DMA 0x000000ff
  39421. +#define DMA_RWCTRL_MIN_DMA_SHIFT 0
  39422. +#define DMA_RWCTRL_READ_BNDRY_MASK 0x00000700
  39423. +#define DMA_RWCTRL_READ_BNDRY_DISAB 0x00000000
  39424. +#define DMA_RWCTRL_READ_BNDRY_16 0x00000100
  39425. +#define DMA_RWCTRL_READ_BNDRY_32 0x00000200
  39426. +#define DMA_RWCTRL_READ_BNDRY_64 0x00000300
  39427. +#define DMA_RWCTRL_READ_BNDRY_128 0x00000400
  39428. +#define DMA_RWCTRL_READ_BNDRY_256 0x00000500
  39429. +#define DMA_RWCTRL_READ_BNDRY_512 0x00000600
  39430. +#define DMA_RWCTRL_READ_BNDRY_1024 0x00000700
  39431. +#define DMA_RWCTRL_WRITE_BNDRY_MASK 0x00003800
  39432. +#define DMA_RWCTRL_WRITE_BNDRY_DISAB 0x00000000
  39433. +#define DMA_RWCTRL_WRITE_BNDRY_16 0x00000800
  39434. +#define DMA_RWCTRL_WRITE_BNDRY_32 0x00001000
  39435. +#define DMA_RWCTRL_WRITE_BNDRY_64 0x00001800
  39436. +#define DMA_RWCTRL_WRITE_BNDRY_128 0x00002000
  39437. +#define DMA_RWCTRL_WRITE_BNDRY_256 0x00002800
  39438. +#define DMA_RWCTRL_WRITE_BNDRY_512 0x00003000
  39439. +#define DMA_RWCTRL_WRITE_BNDRY_1024 0x00003800
  39440. +#define DMA_RWCTRL_ONE_DMA 0x00004000
  39441. +#define DMA_RWCTRL_READ_WATER 0x00070000
  39442. +#define DMA_RWCTRL_READ_WATER_SHIFT 16
  39443. +#define DMA_RWCTRL_WRITE_WATER 0x00380000
  39444. +#define DMA_RWCTRL_WRITE_WATER_SHIFT 19
  39445. +#define DMA_RWCTRL_USE_MEM_READ_MULT 0x00400000
  39446. +#define DMA_RWCTRL_ASSERT_ALL_BE 0x00800000
  39447. +#define DMA_RWCTRL_PCI_READ_CMD 0x0f000000
  39448. +#define DMA_RWCTRL_PCI_READ_CMD_SHIFT 24
  39449. +#define DMA_RWCTRL_PCI_WRITE_CMD 0xf0000000
  39450. +#define DMA_RWCTRL_PCI_WRITE_CMD_SHIFT 28
  39451. +#define TG3PCI_PCISTATE 0x00000070
  39452. +#define PCISTATE_FORCE_RESET 0x00000001
  39453. +#define PCISTATE_INT_NOT_ACTIVE 0x00000002
  39454. +#define PCISTATE_CONV_PCI_MODE 0x00000004
  39455. +#define PCISTATE_BUS_SPEED_HIGH 0x00000008
  39456. +#define PCISTATE_BUS_32BIT 0x00000010
  39457. +#define PCISTATE_ROM_ENABLE 0x00000020
  39458. +#define PCISTATE_ROM_RETRY_ENABLE 0x00000040
  39459. +#define PCISTATE_FLAT_VIEW 0x00000100
  39460. +#define PCISTATE_RETRY_SAME_DMA 0x00002000
  39461. +#define TG3PCI_CLOCK_CTRL 0x00000074
  39462. +#define CLOCK_CTRL_CORECLK_DISABLE 0x00000200
  39463. +#define CLOCK_CTRL_RXCLK_DISABLE 0x00000400
  39464. +#define CLOCK_CTRL_TXCLK_DISABLE 0x00000800
  39465. +#define CLOCK_CTRL_ALTCLK 0x00001000
  39466. +#define CLOCK_CTRL_PWRDOWN_PLL133 0x00008000
  39467. +#define CLOCK_CTRL_44MHZ_CORE 0x00040000
  39468. +#define CLOCK_CTRL_625_CORE 0x00100000
  39469. +#define CLOCK_CTRL_FORCE_CLKRUN 0x00200000
  39470. +#define CLOCK_CTRL_CLKRUN_OENABLE 0x00400000
  39471. +#define CLOCK_CTRL_DELAY_PCI_GRANT 0x80000000
  39472. +#define TG3PCI_REG_BASE_ADDR 0x00000078
  39473. +#define TG3PCI_MEM_WIN_BASE_ADDR 0x0000007c
  39474. +#define TG3PCI_REG_DATA 0x00000080
  39475. +#define TG3PCI_MEM_WIN_DATA 0x00000084
  39476. +#define TG3PCI_MODE_CTRL 0x00000088
  39477. +#define TG3PCI_MISC_CFG 0x0000008c
  39478. +#define TG3PCI_MISC_LOCAL_CTRL 0x00000090
  39479. +/* 0x94 --> 0x98 unused */
  39480. +#define TG3PCI_STD_RING_PROD_IDX 0x00000098 /* 64-bit */
  39481. +#define TG3PCI_RCV_RET_RING_CON_IDX 0x000000a0 /* 64-bit */
  39482. +#define TG3PCI_SND_PROD_IDX 0x000000a8 /* 64-bit */
  39483. +/* 0xb0 --> 0x100 unused */
  39484. +
  39485. +/* 0x100 --> 0x200 unused */
  39486. +
  39487. +/* Mailbox registers */
  39488. +#define MAILBOX_INTERRUPT_0 0x00000200 /* 64-bit */
  39489. +#define MAILBOX_INTERRUPT_1 0x00000208 /* 64-bit */
  39490. +#define MAILBOX_INTERRUPT_2 0x00000210 /* 64-bit */
  39491. +#define MAILBOX_INTERRUPT_3 0x00000218 /* 64-bit */
  39492. +#define MAILBOX_GENERAL_0 0x00000220 /* 64-bit */
  39493. +#define MAILBOX_GENERAL_1 0x00000228 /* 64-bit */
  39494. +#define MAILBOX_GENERAL_2 0x00000230 /* 64-bit */
  39495. +#define MAILBOX_GENERAL_3 0x00000238 /* 64-bit */
  39496. +#define MAILBOX_GENERAL_4 0x00000240 /* 64-bit */
  39497. +#define MAILBOX_GENERAL_5 0x00000248 /* 64-bit */
  39498. +#define MAILBOX_GENERAL_6 0x00000250 /* 64-bit */
  39499. +#define MAILBOX_GENERAL_7 0x00000258 /* 64-bit */
  39500. +#define MAILBOX_RELOAD_STAT 0x00000260 /* 64-bit */
  39501. +#define MAILBOX_RCV_STD_PROD_IDX 0x00000268 /* 64-bit */
  39502. +#define MAILBOX_RCV_JUMBO_PROD_IDX 0x00000270 /* 64-bit */
  39503. +#define MAILBOX_RCV_MINI_PROD_IDX 0x00000278 /* 64-bit */
  39504. +#define MAILBOX_RCVRET_CON_IDX_0 0x00000280 /* 64-bit */
  39505. +#define MAILBOX_RCVRET_CON_IDX_1 0x00000288 /* 64-bit */
  39506. +#define MAILBOX_RCVRET_CON_IDX_2 0x00000290 /* 64-bit */
  39507. +#define MAILBOX_RCVRET_CON_IDX_3 0x00000298 /* 64-bit */
  39508. +#define MAILBOX_RCVRET_CON_IDX_4 0x000002a0 /* 64-bit */
  39509. +#define MAILBOX_RCVRET_CON_IDX_5 0x000002a8 /* 64-bit */
  39510. +#define MAILBOX_RCVRET_CON_IDX_6 0x000002b0 /* 64-bit */
  39511. +#define MAILBOX_RCVRET_CON_IDX_7 0x000002b8 /* 64-bit */
  39512. +#define MAILBOX_RCVRET_CON_IDX_8 0x000002c0 /* 64-bit */
  39513. +#define MAILBOX_RCVRET_CON_IDX_9 0x000002c8 /* 64-bit */
  39514. +#define MAILBOX_RCVRET_CON_IDX_10 0x000002d0 /* 64-bit */
  39515. +#define MAILBOX_RCVRET_CON_IDX_11 0x000002d8 /* 64-bit */
  39516. +#define MAILBOX_RCVRET_CON_IDX_12 0x000002e0 /* 64-bit */
  39517. +#define MAILBOX_RCVRET_CON_IDX_13 0x000002e8 /* 64-bit */
  39518. +#define MAILBOX_RCVRET_CON_IDX_14 0x000002f0 /* 64-bit */
  39519. +#define MAILBOX_RCVRET_CON_IDX_15 0x000002f8 /* 64-bit */
  39520. +#define MAILBOX_SNDHOST_PROD_IDX_0 0x00000300 /* 64-bit */
  39521. +#define MAILBOX_SNDHOST_PROD_IDX_1 0x00000308 /* 64-bit */
  39522. +#define MAILBOX_SNDHOST_PROD_IDX_2 0x00000310 /* 64-bit */
  39523. +#define MAILBOX_SNDHOST_PROD_IDX_3 0x00000318 /* 64-bit */
  39524. +#define MAILBOX_SNDHOST_PROD_IDX_4 0x00000320 /* 64-bit */
  39525. +#define MAILBOX_SNDHOST_PROD_IDX_5 0x00000328 /* 64-bit */
  39526. +#define MAILBOX_SNDHOST_PROD_IDX_6 0x00000330 /* 64-bit */
  39527. +#define MAILBOX_SNDHOST_PROD_IDX_7 0x00000338 /* 64-bit */
  39528. +#define MAILBOX_SNDHOST_PROD_IDX_8 0x00000340 /* 64-bit */
  39529. +#define MAILBOX_SNDHOST_PROD_IDX_9 0x00000348 /* 64-bit */
  39530. +#define MAILBOX_SNDHOST_PROD_IDX_10 0x00000350 /* 64-bit */
  39531. +#define MAILBOX_SNDHOST_PROD_IDX_11 0x00000358 /* 64-bit */
  39532. +#define MAILBOX_SNDHOST_PROD_IDX_12 0x00000360 /* 64-bit */
  39533. +#define MAILBOX_SNDHOST_PROD_IDX_13 0x00000368 /* 64-bit */
  39534. +#define MAILBOX_SNDHOST_PROD_IDX_14 0x00000370 /* 64-bit */
  39535. +#define MAILBOX_SNDHOST_PROD_IDX_15 0x00000378 /* 64-bit */
  39536. +#define MAILBOX_SNDNIC_PROD_IDX_0 0x00000380 /* 64-bit */
  39537. +#define MAILBOX_SNDNIC_PROD_IDX_1 0x00000388 /* 64-bit */
  39538. +#define MAILBOX_SNDNIC_PROD_IDX_2 0x00000390 /* 64-bit */
  39539. +#define MAILBOX_SNDNIC_PROD_IDX_3 0x00000398 /* 64-bit */
  39540. +#define MAILBOX_SNDNIC_PROD_IDX_4 0x000003a0 /* 64-bit */
  39541. +#define MAILBOX_SNDNIC_PROD_IDX_5 0x000003a8 /* 64-bit */
  39542. +#define MAILBOX_SNDNIC_PROD_IDX_6 0x000003b0 /* 64-bit */
  39543. +#define MAILBOX_SNDNIC_PROD_IDX_7 0x000003b8 /* 64-bit */
  39544. +#define MAILBOX_SNDNIC_PROD_IDX_8 0x000003c0 /* 64-bit */
  39545. +#define MAILBOX_SNDNIC_PROD_IDX_9 0x000003c8 /* 64-bit */
  39546. +#define MAILBOX_SNDNIC_PROD_IDX_10 0x000003d0 /* 64-bit */
  39547. +#define MAILBOX_SNDNIC_PROD_IDX_11 0x000003d8 /* 64-bit */
  39548. +#define MAILBOX_SNDNIC_PROD_IDX_12 0x000003e0 /* 64-bit */
  39549. +#define MAILBOX_SNDNIC_PROD_IDX_13 0x000003e8 /* 64-bit */
  39550. +#define MAILBOX_SNDNIC_PROD_IDX_14 0x000003f0 /* 64-bit */
  39551. +#define MAILBOX_SNDNIC_PROD_IDX_15 0x000003f8 /* 64-bit */
  39552. +
  39553. +/* MAC control registers */
  39554. +#define MAC_MODE 0x00000400
  39555. +#define MAC_MODE_RESET 0x00000001
  39556. +#define MAC_MODE_HALF_DUPLEX 0x00000002
  39557. +#define MAC_MODE_PORT_MODE_MASK 0x0000000c
  39558. +#define MAC_MODE_PORT_MODE_TBI 0x0000000c
  39559. +#define MAC_MODE_PORT_MODE_GMII 0x00000008
  39560. +#define MAC_MODE_PORT_MODE_MII 0x00000004
  39561. +#define MAC_MODE_PORT_MODE_NONE 0x00000000
  39562. +#define MAC_MODE_PORT_INT_LPBACK 0x00000010
  39563. +#define MAC_MODE_TAGGED_MAC_CTRL 0x00000080
  39564. +#define MAC_MODE_TX_BURSTING 0x00000100
  39565. +#define MAC_MODE_MAX_DEFER 0x00000200
  39566. +#define MAC_MODE_LINK_POLARITY 0x00000400
  39567. +#define MAC_MODE_RXSTAT_ENABLE 0x00000800
  39568. +#define MAC_MODE_RXSTAT_CLEAR 0x00001000
  39569. +#define MAC_MODE_RXSTAT_FLUSH 0x00002000
  39570. +#define MAC_MODE_TXSTAT_ENABLE 0x00004000
  39571. +#define MAC_MODE_TXSTAT_CLEAR 0x00008000
  39572. +#define MAC_MODE_TXSTAT_FLUSH 0x00010000
  39573. +#define MAC_MODE_SEND_CONFIGS 0x00020000
  39574. +#define MAC_MODE_MAGIC_PKT_ENABLE 0x00040000
  39575. +#define MAC_MODE_ACPI_ENABLE 0x00080000
  39576. +#define MAC_MODE_MIP_ENABLE 0x00100000
  39577. +#define MAC_MODE_TDE_ENABLE 0x00200000
  39578. +#define MAC_MODE_RDE_ENABLE 0x00400000
  39579. +#define MAC_MODE_FHDE_ENABLE 0x00800000
  39580. +#define MAC_STATUS 0x00000404
  39581. +#define MAC_STATUS_PCS_SYNCED 0x00000001
  39582. +#define MAC_STATUS_SIGNAL_DET 0x00000002
  39583. +#define MAC_STATUS_RCVD_CFG 0x00000004
  39584. +#define MAC_STATUS_CFG_CHANGED 0x00000008
  39585. +#define MAC_STATUS_SYNC_CHANGED 0x00000010
  39586. +#define MAC_STATUS_PORT_DEC_ERR 0x00000400
  39587. +#define MAC_STATUS_LNKSTATE_CHANGED 0x00001000
  39588. +#define MAC_STATUS_MI_COMPLETION 0x00400000
  39589. +#define MAC_STATUS_MI_INTERRUPT 0x00800000
  39590. +#define MAC_STATUS_AP_ERROR 0x01000000
  39591. +#define MAC_STATUS_ODI_ERROR 0x02000000
  39592. +#define MAC_STATUS_RXSTAT_OVERRUN 0x04000000
  39593. +#define MAC_STATUS_TXSTAT_OVERRUN 0x08000000
  39594. +#define MAC_EVENT 0x00000408
  39595. +#define MAC_EVENT_PORT_DECODE_ERR 0x00000400
  39596. +#define MAC_EVENT_LNKSTATE_CHANGED 0x00001000
  39597. +#define MAC_EVENT_MI_COMPLETION 0x00400000
  39598. +#define MAC_EVENT_MI_INTERRUPT 0x00800000
  39599. +#define MAC_EVENT_AP_ERROR 0x01000000
  39600. +#define MAC_EVENT_ODI_ERROR 0x02000000
  39601. +#define MAC_EVENT_RXSTAT_OVERRUN 0x04000000
  39602. +#define MAC_EVENT_TXSTAT_OVERRUN 0x08000000
  39603. +#define MAC_LED_CTRL 0x0000040c
  39604. +#define LED_CTRL_LNKLED_OVERRIDE 0x00000001
  39605. +#define LED_CTRL_1000MBPS_ON 0x00000002
  39606. +#define LED_CTRL_100MBPS_ON 0x00000004
  39607. +#define LED_CTRL_10MBPS_ON 0x00000008
  39608. +#define LED_CTRL_TRAFFIC_OVERRIDE 0x00000010
  39609. +#define LED_CTRL_TRAFFIC_BLINK 0x00000020
  39610. +#define LED_CTRL_TRAFFIC_LED 0x00000040
  39611. +#define LED_CTRL_1000MBPS_STATUS 0x00000080
  39612. +#define LED_CTRL_100MBPS_STATUS 0x00000100
  39613. +#define LED_CTRL_10MBPS_STATUS 0x00000200
  39614. +#define LED_CTRL_TRAFFIC_STATUS 0x00000400
  39615. +#define LED_CTRL_MAC_MODE 0x00000000
  39616. +#define LED_CTRL_PHY_MODE_1 0x00000800
  39617. +#define LED_CTRL_PHY_MODE_2 0x00001000
  39618. +#define LED_CTRL_BLINK_RATE_MASK 0x7ff80000
  39619. +#define LED_CTRL_BLINK_RATE_SHIFT 19
  39620. +#define LED_CTRL_BLINK_PER_OVERRIDE 0x00080000
  39621. +#define LED_CTRL_BLINK_RATE_OVERRIDE 0x80000000
  39622. +#define MAC_ADDR_0_HIGH 0x00000410 /* upper 2 bytes */
  39623. +#define MAC_ADDR_0_LOW 0x00000414 /* lower 4 bytes */
  39624. +#define MAC_ADDR_1_HIGH 0x00000418 /* upper 2 bytes */
  39625. +#define MAC_ADDR_1_LOW 0x0000041c /* lower 4 bytes */
  39626. +#define MAC_ADDR_2_HIGH 0x00000420 /* upper 2 bytes */
  39627. +#define MAC_ADDR_2_LOW 0x00000424 /* lower 4 bytes */
  39628. +#define MAC_ADDR_3_HIGH 0x00000428 /* upper 2 bytes */
  39629. +#define MAC_ADDR_3_LOW 0x0000042c /* lower 4 bytes */
  39630. +#define MAC_ACPI_MBUF_PTR 0x00000430
  39631. +#define MAC_ACPI_LEN_OFFSET 0x00000434
  39632. +#define ACPI_LENOFF_LEN_MASK 0x0000ffff
  39633. +#define ACPI_LENOFF_LEN_SHIFT 0
  39634. +#define ACPI_LENOFF_OFF_MASK 0x0fff0000
  39635. +#define ACPI_LENOFF_OFF_SHIFT 16
  39636. +#define MAC_TX_BACKOFF_SEED 0x00000438
  39637. +#define TX_BACKOFF_SEED_MASK 0x000003ff
  39638. +#define MAC_RX_MTU_SIZE 0x0000043c
  39639. +#define RX_MTU_SIZE_MASK 0x0000ffff
  39640. +#define MAC_PCS_TEST 0x00000440
  39641. +#define PCS_TEST_PATTERN_MASK 0x000fffff
  39642. +#define PCS_TEST_PATTERN_SHIFT 0
  39643. +#define PCS_TEST_ENABLE 0x00100000
  39644. +#define MAC_TX_AUTO_NEG 0x00000444
  39645. +#define TX_AUTO_NEG_MASK 0x0000ffff
  39646. +#define TX_AUTO_NEG_SHIFT 0
  39647. +#define MAC_RX_AUTO_NEG 0x00000448
  39648. +#define RX_AUTO_NEG_MASK 0x0000ffff
  39649. +#define RX_AUTO_NEG_SHIFT 0
  39650. +#define MAC_MI_COM 0x0000044c
  39651. +#define MI_COM_CMD_MASK 0x0c000000
  39652. +#define MI_COM_CMD_WRITE 0x04000000
  39653. +#define MI_COM_CMD_READ 0x08000000
  39654. +#define MI_COM_READ_FAILED 0x10000000
  39655. +#define MI_COM_START 0x20000000
  39656. +#define MI_COM_BUSY 0x20000000
  39657. +#define MI_COM_PHY_ADDR_MASK 0x03e00000
  39658. +#define MI_COM_PHY_ADDR_SHIFT 21
  39659. +#define MI_COM_REG_ADDR_MASK 0x001f0000
  39660. +#define MI_COM_REG_ADDR_SHIFT 16
  39661. +#define MI_COM_DATA_MASK 0x0000ffff
  39662. +#define MAC_MI_STAT 0x00000450
  39663. +#define MAC_MI_STAT_LNKSTAT_ATTN_ENAB 0x00000001
  39664. +#define MAC_MI_MODE 0x00000454
  39665. +#define MAC_MI_MODE_CLK_10MHZ 0x00000001
  39666. +#define MAC_MI_MODE_SHORT_PREAMBLE 0x00000002
  39667. +#define MAC_MI_MODE_AUTO_POLL 0x00000010
  39668. +#define MAC_MI_MODE_CORE_CLK_62MHZ 0x00008000
  39669. +#define MAC_MI_MODE_BASE 0x000c0000 /* XXX magic values XXX */
  39670. +#define MAC_AUTO_POLL_STATUS 0x00000458
  39671. +#define MAC_AUTO_POLL_ERROR 0x00000001
  39672. +#define MAC_TX_MODE 0x0000045c
  39673. +#define TX_MODE_RESET 0x00000001
  39674. +#define TX_MODE_ENABLE 0x00000002
  39675. +#define TX_MODE_FLOW_CTRL_ENABLE 0x00000010
  39676. +#define TX_MODE_BIG_BCKOFF_ENABLE 0x00000020
  39677. +#define TX_MODE_LONG_PAUSE_ENABLE 0x00000040
  39678. +#define MAC_TX_STATUS 0x00000460
  39679. +#define TX_STATUS_XOFFED 0x00000001
  39680. +#define TX_STATUS_SENT_XOFF 0x00000002
  39681. +#define TX_STATUS_SENT_XON 0x00000004
  39682. +#define TX_STATUS_LINK_UP 0x00000008
  39683. +#define TX_STATUS_ODI_UNDERRUN 0x00000010
  39684. +#define TX_STATUS_ODI_OVERRUN 0x00000020
  39685. +#define MAC_TX_LENGTHS 0x00000464
  39686. +#define TX_LENGTHS_SLOT_TIME_MASK 0x000000ff
  39687. +#define TX_LENGTHS_SLOT_TIME_SHIFT 0
  39688. +#define TX_LENGTHS_IPG_MASK 0x00000f00
  39689. +#define TX_LENGTHS_IPG_SHIFT 8
  39690. +#define TX_LENGTHS_IPG_CRS_MASK 0x00003000
  39691. +#define TX_LENGTHS_IPG_CRS_SHIFT 12
  39692. +#define MAC_RX_MODE 0x00000468
  39693. +#define RX_MODE_RESET 0x00000001
  39694. +#define RX_MODE_ENABLE 0x00000002
  39695. +#define RX_MODE_FLOW_CTRL_ENABLE 0x00000004
  39696. +#define RX_MODE_KEEP_MAC_CTRL 0x00000008
  39697. +#define RX_MODE_KEEP_PAUSE 0x00000010
  39698. +#define RX_MODE_ACCEPT_OVERSIZED 0x00000020
  39699. +#define RX_MODE_ACCEPT_RUNTS 0x00000040
  39700. +#define RX_MODE_LEN_CHECK 0x00000080
  39701. +#define RX_MODE_PROMISC 0x00000100
  39702. +#define RX_MODE_NO_CRC_CHECK 0x00000200
  39703. +#define RX_MODE_KEEP_VLAN_TAG 0x00000400
  39704. +#define MAC_RX_STATUS 0x0000046c
  39705. +#define RX_STATUS_REMOTE_TX_XOFFED 0x00000001
  39706. +#define RX_STATUS_XOFF_RCVD 0x00000002
  39707. +#define RX_STATUS_XON_RCVD 0x00000004
  39708. +#define MAC_HASH_REG_0 0x00000470
  39709. +#define MAC_HASH_REG_1 0x00000474
  39710. +#define MAC_HASH_REG_2 0x00000478
  39711. +#define MAC_HASH_REG_3 0x0000047c
  39712. +#define MAC_RCV_RULE_0 0x00000480
  39713. +#define MAC_RCV_VALUE_0 0x00000484
  39714. +#define MAC_RCV_RULE_1 0x00000488
  39715. +#define MAC_RCV_VALUE_1 0x0000048c
  39716. +#define MAC_RCV_RULE_2 0x00000490
  39717. +#define MAC_RCV_VALUE_2 0x00000494
  39718. +#define MAC_RCV_RULE_3 0x00000498
  39719. +#define MAC_RCV_VALUE_3 0x0000049c
  39720. +#define MAC_RCV_RULE_4 0x000004a0
  39721. +#define MAC_RCV_VALUE_4 0x000004a4
  39722. +#define MAC_RCV_RULE_5 0x000004a8
  39723. +#define MAC_RCV_VALUE_5 0x000004ac
  39724. +#define MAC_RCV_RULE_6 0x000004b0
  39725. +#define MAC_RCV_VALUE_6 0x000004b4
  39726. +#define MAC_RCV_RULE_7 0x000004b8
  39727. +#define MAC_RCV_VALUE_7 0x000004bc
  39728. +#define MAC_RCV_RULE_8 0x000004c0
  39729. +#define MAC_RCV_VALUE_8 0x000004c4
  39730. +#define MAC_RCV_RULE_9 0x000004c8
  39731. +#define MAC_RCV_VALUE_9 0x000004cc
  39732. +#define MAC_RCV_RULE_10 0x000004d0
  39733. +#define MAC_RCV_VALUE_10 0x000004d4
  39734. +#define MAC_RCV_RULE_11 0x000004d8
  39735. +#define MAC_RCV_VALUE_11 0x000004dc
  39736. +#define MAC_RCV_RULE_12 0x000004e0
  39737. +#define MAC_RCV_VALUE_12 0x000004e4
  39738. +#define MAC_RCV_RULE_13 0x000004e8
  39739. +#define MAC_RCV_VALUE_13 0x000004ec
  39740. +#define MAC_RCV_RULE_14 0x000004f0
  39741. +#define MAC_RCV_VALUE_14 0x000004f4
  39742. +#define MAC_RCV_RULE_15 0x000004f8
  39743. +#define MAC_RCV_VALUE_15 0x000004fc
  39744. +#define RCV_RULE_DISABLE_MASK 0x7fffffff
  39745. +#define MAC_RCV_RULE_CFG 0x00000500
  39746. +#define RCV_RULE_CFG_DEFAULT_CLASS 0x00000008
  39747. +#define MAC_LOW_WMARK_MAX_RX_FRAME 0x00000504
  39748. +/* 0x508 --> 0x520 unused */
  39749. +#define MAC_HASHREGU_0 0x00000520
  39750. +#define MAC_HASHREGU_1 0x00000524
  39751. +#define MAC_HASHREGU_2 0x00000528
  39752. +#define MAC_HASHREGU_3 0x0000052c
  39753. +#define MAC_EXTADDR_0_HIGH 0x00000530
  39754. +#define MAC_EXTADDR_0_LOW 0x00000534
  39755. +#define MAC_EXTADDR_1_HIGH 0x00000538
  39756. +#define MAC_EXTADDR_1_LOW 0x0000053c
  39757. +#define MAC_EXTADDR_2_HIGH 0x00000540
  39758. +#define MAC_EXTADDR_2_LOW 0x00000544
  39759. +#define MAC_EXTADDR_3_HIGH 0x00000548
  39760. +#define MAC_EXTADDR_3_LOW 0x0000054c
  39761. +#define MAC_EXTADDR_4_HIGH 0x00000550
  39762. +#define MAC_EXTADDR_4_LOW 0x00000554
  39763. +#define MAC_EXTADDR_5_HIGH 0x00000558
  39764. +#define MAC_EXTADDR_5_LOW 0x0000055c
  39765. +#define MAC_EXTADDR_6_HIGH 0x00000560
  39766. +#define MAC_EXTADDR_6_LOW 0x00000564
  39767. +#define MAC_EXTADDR_7_HIGH 0x00000568
  39768. +#define MAC_EXTADDR_7_LOW 0x0000056c
  39769. +#define MAC_EXTADDR_8_HIGH 0x00000570
  39770. +#define MAC_EXTADDR_8_LOW 0x00000574
  39771. +#define MAC_EXTADDR_9_HIGH 0x00000578
  39772. +#define MAC_EXTADDR_9_LOW 0x0000057c
  39773. +#define MAC_EXTADDR_10_HIGH 0x00000580
  39774. +#define MAC_EXTADDR_10_LOW 0x00000584
  39775. +#define MAC_EXTADDR_11_HIGH 0x00000588
  39776. +#define MAC_EXTADDR_11_LOW 0x0000058c
  39777. +#define MAC_SERDES_CFG 0x00000590
  39778. +#define MAC_SERDES_STAT 0x00000594
  39779. +/* 0x598 --> 0x600 unused */
  39780. +#define MAC_TX_MAC_STATE_BASE 0x00000600 /* 16 bytes */
  39781. +#define MAC_RX_MAC_STATE_BASE 0x00000610 /* 20 bytes */
  39782. +/* 0x624 --> 0x800 unused */
  39783. +#define MAC_TX_STATS_OCTETS 0x00000800
  39784. +#define MAC_TX_STATS_RESV1 0x00000804
  39785. +#define MAC_TX_STATS_COLLISIONS 0x00000808
  39786. +#define MAC_TX_STATS_XON_SENT 0x0000080c
  39787. +#define MAC_TX_STATS_XOFF_SENT 0x00000810
  39788. +#define MAC_TX_STATS_RESV2 0x00000814
  39789. +#define MAC_TX_STATS_MAC_ERRORS 0x00000818
  39790. +#define MAC_TX_STATS_SINGLE_COLLISIONS 0x0000081c
  39791. +#define MAC_TX_STATS_MULT_COLLISIONS 0x00000820
  39792. +#define MAC_TX_STATS_DEFERRED 0x00000824
  39793. +#define MAC_TX_STATS_RESV3 0x00000828
  39794. +#define MAC_TX_STATS_EXCESSIVE_COL 0x0000082c
  39795. +#define MAC_TX_STATS_LATE_COL 0x00000830
  39796. +#define MAC_TX_STATS_RESV4_1 0x00000834
  39797. +#define MAC_TX_STATS_RESV4_2 0x00000838
  39798. +#define MAC_TX_STATS_RESV4_3 0x0000083c
  39799. +#define MAC_TX_STATS_RESV4_4 0x00000840
  39800. +#define MAC_TX_STATS_RESV4_5 0x00000844
  39801. +#define MAC_TX_STATS_RESV4_6 0x00000848
  39802. +#define MAC_TX_STATS_RESV4_7 0x0000084c
  39803. +#define MAC_TX_STATS_RESV4_8 0x00000850
  39804. +#define MAC_TX_STATS_RESV4_9 0x00000854
  39805. +#define MAC_TX_STATS_RESV4_10 0x00000858
  39806. +#define MAC_TX_STATS_RESV4_11 0x0000085c
  39807. +#define MAC_TX_STATS_RESV4_12 0x00000860
  39808. +#define MAC_TX_STATS_RESV4_13 0x00000864
  39809. +#define MAC_TX_STATS_RESV4_14 0x00000868
  39810. +#define MAC_TX_STATS_UCAST 0x0000086c
  39811. +#define MAC_TX_STATS_MCAST 0x00000870
  39812. +#define MAC_TX_STATS_BCAST 0x00000874
  39813. +#define MAC_TX_STATS_RESV5_1 0x00000878
  39814. +#define MAC_TX_STATS_RESV5_2 0x0000087c
  39815. +#define MAC_RX_STATS_OCTETS 0x00000880
  39816. +#define MAC_RX_STATS_RESV1 0x00000884
  39817. +#define MAC_RX_STATS_FRAGMENTS 0x00000888
  39818. +#define MAC_RX_STATS_UCAST 0x0000088c
  39819. +#define MAC_RX_STATS_MCAST 0x00000890
  39820. +#define MAC_RX_STATS_BCAST 0x00000894
  39821. +#define MAC_RX_STATS_FCS_ERRORS 0x00000898
  39822. +#define MAC_RX_STATS_ALIGN_ERRORS 0x0000089c
  39823. +#define MAC_RX_STATS_XON_PAUSE_RECVD 0x000008a0
  39824. +#define MAC_RX_STATS_XOFF_PAUSE_RECVD 0x000008a4
  39825. +#define MAC_RX_STATS_MAC_CTRL_RECVD 0x000008a8
  39826. +#define MAC_RX_STATS_XOFF_ENTERED 0x000008ac
  39827. +#define MAC_RX_STATS_FRAME_TOO_LONG 0x000008b0
  39828. +#define MAC_RX_STATS_JABBERS 0x000008b4
  39829. +#define MAC_RX_STATS_UNDERSIZE 0x000008b8
  39830. +/* 0x8bc --> 0xc00 unused */
  39831. +
  39832. +/* Send data initiator control registers */
  39833. +#define SNDDATAI_MODE 0x00000c00
  39834. +#define SNDDATAI_MODE_RESET 0x00000001
  39835. +#define SNDDATAI_MODE_ENABLE 0x00000002
  39836. +#define SNDDATAI_MODE_STAT_OFLOW_ENAB 0x00000004
  39837. +#define SNDDATAI_STATUS 0x00000c04
  39838. +#define SNDDATAI_STATUS_STAT_OFLOW 0x00000004
  39839. +#define SNDDATAI_STATSCTRL 0x00000c08
  39840. +#define SNDDATAI_SCTRL_ENABLE 0x00000001
  39841. +#define SNDDATAI_SCTRL_FASTUPD 0x00000002
  39842. +#define SNDDATAI_SCTRL_CLEAR 0x00000004
  39843. +#define SNDDATAI_SCTRL_FLUSH 0x00000008
  39844. +#define SNDDATAI_SCTRL_FORCE_ZERO 0x00000010
  39845. +#define SNDDATAI_STATSENAB 0x00000c0c
  39846. +#define SNDDATAI_STATSINCMASK 0x00000c10
  39847. +/* 0xc14 --> 0xc80 unused */
  39848. +#define SNDDATAI_COS_CNT_0 0x00000c80
  39849. +#define SNDDATAI_COS_CNT_1 0x00000c84
  39850. +#define SNDDATAI_COS_CNT_2 0x00000c88
  39851. +#define SNDDATAI_COS_CNT_3 0x00000c8c
  39852. +#define SNDDATAI_COS_CNT_4 0x00000c90
  39853. +#define SNDDATAI_COS_CNT_5 0x00000c94
  39854. +#define SNDDATAI_COS_CNT_6 0x00000c98
  39855. +#define SNDDATAI_COS_CNT_7 0x00000c9c
  39856. +#define SNDDATAI_COS_CNT_8 0x00000ca0
  39857. +#define SNDDATAI_COS_CNT_9 0x00000ca4
  39858. +#define SNDDATAI_COS_CNT_10 0x00000ca8
  39859. +#define SNDDATAI_COS_CNT_11 0x00000cac
  39860. +#define SNDDATAI_COS_CNT_12 0x00000cb0
  39861. +#define SNDDATAI_COS_CNT_13 0x00000cb4
  39862. +#define SNDDATAI_COS_CNT_14 0x00000cb8
  39863. +#define SNDDATAI_COS_CNT_15 0x00000cbc
  39864. +#define SNDDATAI_DMA_RDQ_FULL_CNT 0x00000cc0
  39865. +#define SNDDATAI_DMA_PRIO_RDQ_FULL_CNT 0x00000cc4
  39866. +#define SNDDATAI_SDCQ_FULL_CNT 0x00000cc8
  39867. +#define SNDDATAI_NICRNG_SSND_PIDX_CNT 0x00000ccc
  39868. +#define SNDDATAI_STATS_UPDATED_CNT 0x00000cd0
  39869. +#define SNDDATAI_INTERRUPTS_CNT 0x00000cd4
  39870. +#define SNDDATAI_AVOID_INTERRUPTS_CNT 0x00000cd8
  39871. +#define SNDDATAI_SND_THRESH_HIT_CNT 0x00000cdc
  39872. +/* 0xce0 --> 0x1000 unused */
  39873. +
  39874. +/* Send data completion control registers */
  39875. +#define SNDDATAC_MODE 0x00001000
  39876. +#define SNDDATAC_MODE_RESET 0x00000001
  39877. +#define SNDDATAC_MODE_ENABLE 0x00000002
  39878. +/* 0x1004 --> 0x1400 unused */
  39879. +
  39880. +/* Send BD ring selector */
  39881. +#define SNDBDS_MODE 0x00001400
  39882. +#define SNDBDS_MODE_RESET 0x00000001
  39883. +#define SNDBDS_MODE_ENABLE 0x00000002
  39884. +#define SNDBDS_MODE_ATTN_ENABLE 0x00000004
  39885. +#define SNDBDS_STATUS 0x00001404
  39886. +#define SNDBDS_STATUS_ERROR_ATTN 0x00000004
  39887. +#define SNDBDS_HWDIAG 0x00001408
  39888. +/* 0x140c --> 0x1440 */
  39889. +#define SNDBDS_SEL_CON_IDX_0 0x00001440
  39890. +#define SNDBDS_SEL_CON_IDX_1 0x00001444
  39891. +#define SNDBDS_SEL_CON_IDX_2 0x00001448
  39892. +#define SNDBDS_SEL_CON_IDX_3 0x0000144c
  39893. +#define SNDBDS_SEL_CON_IDX_4 0x00001450
  39894. +#define SNDBDS_SEL_CON_IDX_5 0x00001454
  39895. +#define SNDBDS_SEL_CON_IDX_6 0x00001458
  39896. +#define SNDBDS_SEL_CON_IDX_7 0x0000145c
  39897. +#define SNDBDS_SEL_CON_IDX_8 0x00001460
  39898. +#define SNDBDS_SEL_CON_IDX_9 0x00001464
  39899. +#define SNDBDS_SEL_CON_IDX_10 0x00001468
  39900. +#define SNDBDS_SEL_CON_IDX_11 0x0000146c
  39901. +#define SNDBDS_SEL_CON_IDX_12 0x00001470
  39902. +#define SNDBDS_SEL_CON_IDX_13 0x00001474
  39903. +#define SNDBDS_SEL_CON_IDX_14 0x00001478
  39904. +#define SNDBDS_SEL_CON_IDX_15 0x0000147c
  39905. +/* 0x1480 --> 0x1800 unused */
  39906. +
  39907. +/* Send BD initiator control registers */
  39908. +#define SNDBDI_MODE 0x00001800
  39909. +#define SNDBDI_MODE_RESET 0x00000001
  39910. +#define SNDBDI_MODE_ENABLE 0x00000002
  39911. +#define SNDBDI_MODE_ATTN_ENABLE 0x00000004
  39912. +#define SNDBDI_STATUS 0x00001804
  39913. +#define SNDBDI_STATUS_ERROR_ATTN 0x00000004
  39914. +#define SNDBDI_IN_PROD_IDX_0 0x00001808
  39915. +#define SNDBDI_IN_PROD_IDX_1 0x0000180c
  39916. +#define SNDBDI_IN_PROD_IDX_2 0x00001810
  39917. +#define SNDBDI_IN_PROD_IDX_3 0x00001814
  39918. +#define SNDBDI_IN_PROD_IDX_4 0x00001818
  39919. +#define SNDBDI_IN_PROD_IDX_5 0x0000181c
  39920. +#define SNDBDI_IN_PROD_IDX_6 0x00001820
  39921. +#define SNDBDI_IN_PROD_IDX_7 0x00001824
  39922. +#define SNDBDI_IN_PROD_IDX_8 0x00001828
  39923. +#define SNDBDI_IN_PROD_IDX_9 0x0000182c
  39924. +#define SNDBDI_IN_PROD_IDX_10 0x00001830
  39925. +#define SNDBDI_IN_PROD_IDX_11 0x00001834
  39926. +#define SNDBDI_IN_PROD_IDX_12 0x00001838
  39927. +#define SNDBDI_IN_PROD_IDX_13 0x0000183c
  39928. +#define SNDBDI_IN_PROD_IDX_14 0x00001840
  39929. +#define SNDBDI_IN_PROD_IDX_15 0x00001844
  39930. +/* 0x1848 --> 0x1c00 unused */
  39931. +
  39932. +/* Send BD completion control registers */
  39933. +#define SNDBDC_MODE 0x00001c00
  39934. +#define SNDBDC_MODE_RESET 0x00000001
  39935. +#define SNDBDC_MODE_ENABLE 0x00000002
  39936. +#define SNDBDC_MODE_ATTN_ENABLE 0x00000004
  39937. +/* 0x1c04 --> 0x2000 unused */
  39938. +
  39939. +/* Receive list placement control registers */
  39940. +#define RCVLPC_MODE 0x00002000
  39941. +#define RCVLPC_MODE_RESET 0x00000001
  39942. +#define RCVLPC_MODE_ENABLE 0x00000002
  39943. +#define RCVLPC_MODE_CLASS0_ATTN_ENAB 0x00000004
  39944. +#define RCVLPC_MODE_MAPOOR_AATTN_ENAB 0x00000008
  39945. +#define RCVLPC_MODE_STAT_OFLOW_ENAB 0x00000010
  39946. +#define RCVLPC_STATUS 0x00002004
  39947. +#define RCVLPC_STATUS_CLASS0 0x00000004
  39948. +#define RCVLPC_STATUS_MAPOOR 0x00000008
  39949. +#define RCVLPC_STATUS_STAT_OFLOW 0x00000010
  39950. +#define RCVLPC_LOCK 0x00002008
  39951. +#define RCVLPC_LOCK_REQ_MASK 0x0000ffff
  39952. +#define RCVLPC_LOCK_REQ_SHIFT 0
  39953. +#define RCVLPC_LOCK_GRANT_MASK 0xffff0000
  39954. +#define RCVLPC_LOCK_GRANT_SHIFT 16
  39955. +#define RCVLPC_NON_EMPTY_BITS 0x0000200c
  39956. +#define RCVLPC_NON_EMPTY_BITS_MASK 0x0000ffff
  39957. +#define RCVLPC_CONFIG 0x00002010
  39958. +#define RCVLPC_STATSCTRL 0x00002014
  39959. +#define RCVLPC_STATSCTRL_ENABLE 0x00000001
  39960. +#define RCVLPC_STATSCTRL_FASTUPD 0x00000002
  39961. +#define RCVLPC_STATS_ENABLE 0x00002018
  39962. +#define RCVLPC_STATSENAB_LNGBRST_RFIX 0x00400000
  39963. +#define RCVLPC_STATS_INCMASK 0x0000201c
  39964. +/* 0x2020 --> 0x2100 unused */
  39965. +#define RCVLPC_SELLST_BASE 0x00002100 /* 16 16-byte entries */
  39966. +#define SELLST_TAIL 0x00000004
  39967. +#define SELLST_CONT 0x00000008
  39968. +#define SELLST_UNUSED 0x0000000c
  39969. +#define RCVLPC_COS_CNTL_BASE 0x00002200 /* 16 4-byte entries */
  39970. +#define RCVLPC_DROP_FILTER_CNT 0x00002240
  39971. +#define RCVLPC_DMA_WQ_FULL_CNT 0x00002244
  39972. +#define RCVLPC_DMA_HIPRIO_WQ_FULL_CNT 0x00002248
  39973. +#define RCVLPC_NO_RCV_BD_CNT 0x0000224c
  39974. +#define RCVLPC_IN_DISCARDS_CNT 0x00002250
  39975. +#define RCVLPC_IN_ERRORS_CNT 0x00002254
  39976. +#define RCVLPC_RCV_THRESH_HIT_CNT 0x00002258
  39977. +/* 0x225c --> 0x2400 unused */
  39978. +
  39979. +/* Receive Data and Receive BD Initiator Control */
  39980. +#define RCVDBDI_MODE 0x00002400
  39981. +#define RCVDBDI_MODE_RESET 0x00000001
  39982. +#define RCVDBDI_MODE_ENABLE 0x00000002
  39983. +#define RCVDBDI_MODE_JUMBOBD_NEEDED 0x00000004
  39984. +#define RCVDBDI_MODE_FRM_TOO_BIG 0x00000008
  39985. +#define RCVDBDI_MODE_INV_RING_SZ 0x00000010
  39986. +#define RCVDBDI_STATUS 0x00002404
  39987. +#define RCVDBDI_STATUS_JUMBOBD_NEEDED 0x00000004
  39988. +#define RCVDBDI_STATUS_FRM_TOO_BIG 0x00000008
  39989. +#define RCVDBDI_STATUS_INV_RING_SZ 0x00000010
  39990. +#define RCVDBDI_SPLIT_FRAME_MINSZ 0x00002408
  39991. +/* 0x240c --> 0x2440 unused */
  39992. +#define RCVDBDI_JUMBO_BD 0x00002440 /* TG3_BDINFO_... */
  39993. +#define RCVDBDI_STD_BD 0x00002450 /* TG3_BDINFO_... */
  39994. +#define RCVDBDI_MINI_BD 0x00002460 /* TG3_BDINFO_... */
  39995. +#define RCVDBDI_JUMBO_CON_IDX 0x00002470
  39996. +#define RCVDBDI_STD_CON_IDX 0x00002474
  39997. +#define RCVDBDI_MINI_CON_IDX 0x00002478
  39998. +/* 0x247c --> 0x2480 unused */
  39999. +#define RCVDBDI_BD_PROD_IDX_0 0x00002480
  40000. +#define RCVDBDI_BD_PROD_IDX_1 0x00002484
  40001. +#define RCVDBDI_BD_PROD_IDX_2 0x00002488
  40002. +#define RCVDBDI_BD_PROD_IDX_3 0x0000248c
  40003. +#define RCVDBDI_BD_PROD_IDX_4 0x00002490
  40004. +#define RCVDBDI_BD_PROD_IDX_5 0x00002494
  40005. +#define RCVDBDI_BD_PROD_IDX_6 0x00002498
  40006. +#define RCVDBDI_BD_PROD_IDX_7 0x0000249c
  40007. +#define RCVDBDI_BD_PROD_IDX_8 0x000024a0
  40008. +#define RCVDBDI_BD_PROD_IDX_9 0x000024a4
  40009. +#define RCVDBDI_BD_PROD_IDX_10 0x000024a8
  40010. +#define RCVDBDI_BD_PROD_IDX_11 0x000024ac
  40011. +#define RCVDBDI_BD_PROD_IDX_12 0x000024b0
  40012. +#define RCVDBDI_BD_PROD_IDX_13 0x000024b4
  40013. +#define RCVDBDI_BD_PROD_IDX_14 0x000024b8
  40014. +#define RCVDBDI_BD_PROD_IDX_15 0x000024bc
  40015. +#define RCVDBDI_HWDIAG 0x000024c0
  40016. +/* 0x24c4 --> 0x2800 unused */
  40017. +
  40018. +/* Receive Data Completion Control */
  40019. +#define RCVDCC_MODE 0x00002800
  40020. +#define RCVDCC_MODE_RESET 0x00000001
  40021. +#define RCVDCC_MODE_ENABLE 0x00000002
  40022. +#define RCVDCC_MODE_ATTN_ENABLE 0x00000004
  40023. +/* 0x2804 --> 0x2c00 unused */
  40024. +
  40025. +/* Receive BD Initiator Control Registers */
  40026. +#define RCVBDI_MODE 0x00002c00
  40027. +#define RCVBDI_MODE_RESET 0x00000001
  40028. +#define RCVBDI_MODE_ENABLE 0x00000002
  40029. +#define RCVBDI_MODE_RCB_ATTN_ENAB 0x00000004
  40030. +#define RCVBDI_STATUS 0x00002c04
  40031. +#define RCVBDI_STATUS_RCB_ATTN 0x00000004
  40032. +#define RCVBDI_JUMBO_PROD_IDX 0x00002c08
  40033. +#define RCVBDI_STD_PROD_IDX 0x00002c0c
  40034. +#define RCVBDI_MINI_PROD_IDX 0x00002c10
  40035. +#define RCVBDI_MINI_THRESH 0x00002c14
  40036. +#define RCVBDI_STD_THRESH 0x00002c18
  40037. +#define RCVBDI_JUMBO_THRESH 0x00002c1c
  40038. +/* 0x2c20 --> 0x3000 unused */
  40039. +
  40040. +/* Receive BD Completion Control Registers */
  40041. +#define RCVCC_MODE 0x00003000
  40042. +#define RCVCC_MODE_RESET 0x00000001
  40043. +#define RCVCC_MODE_ENABLE 0x00000002
  40044. +#define RCVCC_MODE_ATTN_ENABLE 0x00000004
  40045. +#define RCVCC_STATUS 0x00003004
  40046. +#define RCVCC_STATUS_ERROR_ATTN 0x00000004
  40047. +#define RCVCC_JUMP_PROD_IDX 0x00003008
  40048. +#define RCVCC_STD_PROD_IDX 0x0000300c
  40049. +#define RCVCC_MINI_PROD_IDX 0x00003010
  40050. +/* 0x3014 --> 0x3400 unused */
  40051. +
  40052. +/* Receive list selector control registers */
  40053. +#define RCVLSC_MODE 0x00003400
  40054. +#define RCVLSC_MODE_RESET 0x00000001
  40055. +#define RCVLSC_MODE_ENABLE 0x00000002
  40056. +#define RCVLSC_MODE_ATTN_ENABLE 0x00000004
  40057. +#define RCVLSC_STATUS 0x00003404
  40058. +#define RCVLSC_STATUS_ERROR_ATTN 0x00000004
  40059. +/* 0x3408 --> 0x3800 unused */
  40060. +
  40061. +/* Mbuf cluster free registers */
  40062. +#define MBFREE_MODE 0x00003800
  40063. +#define MBFREE_MODE_RESET 0x00000001
  40064. +#define MBFREE_MODE_ENABLE 0x00000002
  40065. +#define MBFREE_STATUS 0x00003804
  40066. +/* 0x3808 --> 0x3c00 unused */
  40067. +
  40068. +/* Host coalescing control registers */
  40069. +#define HOSTCC_MODE 0x00003c00
  40070. +#define HOSTCC_MODE_RESET 0x00000001
  40071. +#define HOSTCC_MODE_ENABLE 0x00000002
  40072. +#define HOSTCC_MODE_ATTN 0x00000004
  40073. +#define HOSTCC_MODE_NOW 0x00000008
  40074. +#define HOSTCC_MODE_FULL_STATUS 0x00000000
  40075. +#define HOSTCC_MODE_64BYTE 0x00000080
  40076. +#define HOSTCC_MODE_32BYTE 0x00000100
  40077. +#define HOSTCC_MODE_CLRTICK_RXBD 0x00000200
  40078. +#define HOSTCC_MODE_CLRTICK_TXBD 0x00000400
  40079. +#define HOSTCC_MODE_NOINT_ON_NOW 0x00000800
  40080. +#define HOSTCC_MODE_NOINT_ON_FORCE 0x00001000
  40081. +#define HOSTCC_STATUS 0x00003c04
  40082. +#define HOSTCC_STATUS_ERROR_ATTN 0x00000004
  40083. +#define HOSTCC_RXCOL_TICKS 0x00003c08
  40084. +#define LOW_RXCOL_TICKS 0x00000032
  40085. +#define DEFAULT_RXCOL_TICKS 0x00000048
  40086. +#define HIGH_RXCOL_TICKS 0x00000096
  40087. +#define HOSTCC_TXCOL_TICKS 0x00003c0c
  40088. +#define LOW_TXCOL_TICKS 0x00000096
  40089. +#define DEFAULT_TXCOL_TICKS 0x0000012c
  40090. +#define HIGH_TXCOL_TICKS 0x00000145
  40091. +#define HOSTCC_RXMAX_FRAMES 0x00003c10
  40092. +#define LOW_RXMAX_FRAMES 0x00000005
  40093. +#define DEFAULT_RXMAX_FRAMES 0x00000008
  40094. +#define HIGH_RXMAX_FRAMES 0x00000012
  40095. +#define HOSTCC_TXMAX_FRAMES 0x00003c14
  40096. +#define LOW_TXMAX_FRAMES 0x00000035
  40097. +#define DEFAULT_TXMAX_FRAMES 0x0000004b
  40098. +#define HIGH_TXMAX_FRAMES 0x00000052
  40099. +#define HOSTCC_RXCOAL_TICK_INT 0x00003c18
  40100. +#define DEFAULT_RXCOAL_TICK_INT 0x00000019
  40101. +#define HOSTCC_TXCOAL_TICK_INT 0x00003c1c
  40102. +#define DEFAULT_TXCOAL_TICK_INT 0x00000019
  40103. +#define HOSTCC_RXCOAL_MAXF_INT 0x00003c20
  40104. +#define DEFAULT_RXCOAL_MAXF_INT 0x00000005
  40105. +#define HOSTCC_TXCOAL_MAXF_INT 0x00003c24
  40106. +#define DEFAULT_TXCOAL_MAXF_INT 0x00000005
  40107. +#define HOSTCC_STAT_COAL_TICKS 0x00003c28
  40108. +#define DEFAULT_STAT_COAL_TICKS 0x000f4240
  40109. +/* 0x3c2c --> 0x3c30 unused */
  40110. +#define HOSTCC_STATS_BLK_HOST_ADDR 0x00003c30 /* 64-bit */
  40111. +#define HOSTCC_STATUS_BLK_HOST_ADDR 0x00003c38 /* 64-bit */
  40112. +#define HOSTCC_STATS_BLK_NIC_ADDR 0x00003c40
  40113. +#define HOSTCC_STATUS_BLK_NIC_ADDR 0x00003c44
  40114. +#define HOSTCC_FLOW_ATTN 0x00003c48
  40115. +/* 0x3c4c --> 0x3c50 unused */
  40116. +#define HOSTCC_JUMBO_CON_IDX 0x00003c50
  40117. +#define HOSTCC_STD_CON_IDX 0x00003c54
  40118. +#define HOSTCC_MINI_CON_IDX 0x00003c58
  40119. +/* 0x3c5c --> 0x3c80 unused */
  40120. +#define HOSTCC_RET_PROD_IDX_0 0x00003c80
  40121. +#define HOSTCC_RET_PROD_IDX_1 0x00003c84
  40122. +#define HOSTCC_RET_PROD_IDX_2 0x00003c88
  40123. +#define HOSTCC_RET_PROD_IDX_3 0x00003c8c
  40124. +#define HOSTCC_RET_PROD_IDX_4 0x00003c90
  40125. +#define HOSTCC_RET_PROD_IDX_5 0x00003c94
  40126. +#define HOSTCC_RET_PROD_IDX_6 0x00003c98
  40127. +#define HOSTCC_RET_PROD_IDX_7 0x00003c9c
  40128. +#define HOSTCC_RET_PROD_IDX_8 0x00003ca0
  40129. +#define HOSTCC_RET_PROD_IDX_9 0x00003ca4
  40130. +#define HOSTCC_RET_PROD_IDX_10 0x00003ca8
  40131. +#define HOSTCC_RET_PROD_IDX_11 0x00003cac
  40132. +#define HOSTCC_RET_PROD_IDX_12 0x00003cb0
  40133. +#define HOSTCC_RET_PROD_IDX_13 0x00003cb4
  40134. +#define HOSTCC_RET_PROD_IDX_14 0x00003cb8
  40135. +#define HOSTCC_RET_PROD_IDX_15 0x00003cbc
  40136. +#define HOSTCC_SND_CON_IDX_0 0x00003cc0
  40137. +#define HOSTCC_SND_CON_IDX_1 0x00003cc4
  40138. +#define HOSTCC_SND_CON_IDX_2 0x00003cc8
  40139. +#define HOSTCC_SND_CON_IDX_3 0x00003ccc
  40140. +#define HOSTCC_SND_CON_IDX_4 0x00003cd0
  40141. +#define HOSTCC_SND_CON_IDX_5 0x00003cd4
  40142. +#define HOSTCC_SND_CON_IDX_6 0x00003cd8
  40143. +#define HOSTCC_SND_CON_IDX_7 0x00003cdc
  40144. +#define HOSTCC_SND_CON_IDX_8 0x00003ce0
  40145. +#define HOSTCC_SND_CON_IDX_9 0x00003ce4
  40146. +#define HOSTCC_SND_CON_IDX_10 0x00003ce8
  40147. +#define HOSTCC_SND_CON_IDX_11 0x00003cec
  40148. +#define HOSTCC_SND_CON_IDX_12 0x00003cf0
  40149. +#define HOSTCC_SND_CON_IDX_13 0x00003cf4
  40150. +#define HOSTCC_SND_CON_IDX_14 0x00003cf8
  40151. +#define HOSTCC_SND_CON_IDX_15 0x00003cfc
  40152. +/* 0x3d00 --> 0x4000 unused */
  40153. +
  40154. +/* Memory arbiter control registers */
  40155. +#define MEMARB_MODE 0x00004000
  40156. +#define MEMARB_MODE_RESET 0x00000001
  40157. +#define MEMARB_MODE_ENABLE 0x00000002
  40158. +#define MEMARB_STATUS 0x00004004
  40159. +#define MEMARB_TRAP_ADDR_LOW 0x00004008
  40160. +#define MEMARB_TRAP_ADDR_HIGH 0x0000400c
  40161. +/* 0x4010 --> 0x4400 unused */
  40162. +
  40163. +/* Buffer manager control registers */
  40164. +#define BUFMGR_MODE 0x00004400
  40165. +#define BUFMGR_MODE_RESET 0x00000001
  40166. +#define BUFMGR_MODE_ENABLE 0x00000002
  40167. +#define BUFMGR_MODE_ATTN_ENABLE 0x00000004
  40168. +#define BUFMGR_MODE_BM_TEST 0x00000008
  40169. +#define BUFMGR_MODE_MBLOW_ATTN_ENAB 0x00000010
  40170. +#define BUFMGR_STATUS 0x00004404
  40171. +#define BUFMGR_STATUS_ERROR 0x00000004
  40172. +#define BUFMGR_STATUS_MBLOW 0x00000010
  40173. +#define BUFMGR_MB_POOL_ADDR 0x00004408
  40174. +#define BUFMGR_MB_POOL_SIZE 0x0000440c
  40175. +#define BUFMGR_MB_RDMA_LOW_WATER 0x00004410
  40176. +#define DEFAULT_MB_RDMA_LOW_WATER 0x00000050
  40177. +#define DEFAULT_MB_RDMA_LOW_WATER_5705 0x00000000
  40178. +#define DEFAULT_MB_RDMA_LOW_WATER_JUMBO 0x00000130
  40179. +#define BUFMGR_MB_MACRX_LOW_WATER 0x00004414
  40180. +#define DEFAULT_MB_MACRX_LOW_WATER 0x00000020
  40181. +#define DEFAULT_MB_MACRX_LOW_WATER_5705 0x00000010
  40182. +#define DEFAULT_MB_MACRX_LOW_WATER_JUMBO 0x00000098
  40183. +#define BUFMGR_MB_HIGH_WATER 0x00004418
  40184. +#define DEFAULT_MB_HIGH_WATER 0x00000060
  40185. +#define DEFAULT_MB_HIGH_WATER_5705 0x00000060
  40186. +#define DEFAULT_MB_HIGH_WATER_JUMBO 0x0000017c
  40187. +#define BUFMGR_RX_MB_ALLOC_REQ 0x0000441c
  40188. +#define BUFMGR_MB_ALLOC_BIT 0x10000000
  40189. +#define BUFMGR_RX_MB_ALLOC_RESP 0x00004420
  40190. +#define BUFMGR_TX_MB_ALLOC_REQ 0x00004424
  40191. +#define BUFMGR_TX_MB_ALLOC_RESP 0x00004428
  40192. +#define BUFMGR_DMA_DESC_POOL_ADDR 0x0000442c
  40193. +#define BUFMGR_DMA_DESC_POOL_SIZE 0x00004430
  40194. +#define BUFMGR_DMA_LOW_WATER 0x00004434
  40195. +#define DEFAULT_DMA_LOW_WATER 0x00000005
  40196. +#define BUFMGR_DMA_HIGH_WATER 0x00004438
  40197. +#define DEFAULT_DMA_HIGH_WATER 0x0000000a
  40198. +#define BUFMGR_RX_DMA_ALLOC_REQ 0x0000443c
  40199. +#define BUFMGR_RX_DMA_ALLOC_RESP 0x00004440
  40200. +#define BUFMGR_TX_DMA_ALLOC_REQ 0x00004444
  40201. +#define BUFMGR_TX_DMA_ALLOC_RESP 0x00004448
  40202. +#define BUFMGR_HWDIAG_0 0x0000444c
  40203. +#define BUFMGR_HWDIAG_1 0x00004450
  40204. +#define BUFMGR_HWDIAG_2 0x00004454
  40205. +/* 0x4458 --> 0x4800 unused */
  40206. +
  40207. +/* Read DMA control registers */
  40208. +#define RDMAC_MODE 0x00004800
  40209. +#define RDMAC_MODE_RESET 0x00000001
  40210. +#define RDMAC_MODE_ENABLE 0x00000002
  40211. +#define RDMAC_MODE_TGTABORT_ENAB 0x00000004
  40212. +#define RDMAC_MODE_MSTABORT_ENAB 0x00000008
  40213. +#define RDMAC_MODE_PARITYERR_ENAB 0x00000010
  40214. +#define RDMAC_MODE_ADDROFLOW_ENAB 0x00000020
  40215. +#define RDMAC_MODE_FIFOOFLOW_ENAB 0x00000040
  40216. +#define RDMAC_MODE_FIFOURUN_ENAB 0x00000080
  40217. +#define RDMAC_MODE_FIFOOREAD_ENAB 0x00000100
  40218. +#define RDMAC_MODE_LNGREAD_ENAB 0x00000200
  40219. +#define RDMAC_MODE_SPLIT_ENABLE 0x00000800
  40220. +#define RDMAC_MODE_SPLIT_RESET 0x00001000
  40221. +#define RDMAC_MODE_FIFO_SIZE_128 0x00020000
  40222. +#define RDMAC_MODE_FIFO_LONG_BURST 0x00030000
  40223. +#define RDMAC_STATUS 0x00004804
  40224. +#define RDMAC_STATUS_TGTABORT 0x00000004
  40225. +#define RDMAC_STATUS_MSTABORT 0x00000008
  40226. +#define RDMAC_STATUS_PARITYERR 0x00000010
  40227. +#define RDMAC_STATUS_ADDROFLOW 0x00000020
  40228. +#define RDMAC_STATUS_FIFOOFLOW 0x00000040
  40229. +#define RDMAC_STATUS_FIFOURUN 0x00000080
  40230. +#define RDMAC_STATUS_FIFOOREAD 0x00000100
  40231. +#define RDMAC_STATUS_LNGREAD 0x00000200
  40232. +/* 0x4808 --> 0x4c00 unused */
  40233. +
  40234. +/* Write DMA control registers */
  40235. +#define WDMAC_MODE 0x00004c00
  40236. +#define WDMAC_MODE_RESET 0x00000001
  40237. +#define WDMAC_MODE_ENABLE 0x00000002
  40238. +#define WDMAC_MODE_TGTABORT_ENAB 0x00000004
  40239. +#define WDMAC_MODE_MSTABORT_ENAB 0x00000008
  40240. +#define WDMAC_MODE_PARITYERR_ENAB 0x00000010
  40241. +#define WDMAC_MODE_ADDROFLOW_ENAB 0x00000020
  40242. +#define WDMAC_MODE_FIFOOFLOW_ENAB 0x00000040
  40243. +#define WDMAC_MODE_FIFOURUN_ENAB 0x00000080
  40244. +#define WDMAC_MODE_FIFOOREAD_ENAB 0x00000100
  40245. +#define WDMAC_MODE_LNGREAD_ENAB 0x00000200
  40246. +#define WDMAC_MODE_RX_ACCEL 0x00000400
  40247. +#define WDMAC_STATUS 0x00004c04
  40248. +#define WDMAC_STATUS_TGTABORT 0x00000004
  40249. +#define WDMAC_STATUS_MSTABORT 0x00000008
  40250. +#define WDMAC_STATUS_PARITYERR 0x00000010
  40251. +#define WDMAC_STATUS_ADDROFLOW 0x00000020
  40252. +#define WDMAC_STATUS_FIFOOFLOW 0x00000040
  40253. +#define WDMAC_STATUS_FIFOURUN 0x00000080
  40254. +#define WDMAC_STATUS_FIFOOREAD 0x00000100
  40255. +#define WDMAC_STATUS_LNGREAD 0x00000200
  40256. +/* 0x4c08 --> 0x5000 unused */
  40257. +
  40258. +/* Per-cpu register offsets (arm9) */
  40259. +#define CPU_MODE 0x00000000
  40260. +#define CPU_MODE_RESET 0x00000001
  40261. +#define CPU_MODE_HALT 0x00000400
  40262. +#define CPU_STATE 0x00000004
  40263. +#define CPU_EVTMASK 0x00000008
  40264. +/* 0xc --> 0x1c reserved */
  40265. +#define CPU_PC 0x0000001c
  40266. +#define CPU_INSN 0x00000020
  40267. +#define CPU_SPAD_UFLOW 0x00000024
  40268. +#define CPU_WDOG_CLEAR 0x00000028
  40269. +#define CPU_WDOG_VECTOR 0x0000002c
  40270. +#define CPU_WDOG_PC 0x00000030
  40271. +#define CPU_HW_BP 0x00000034
  40272. +/* 0x38 --> 0x44 unused */
  40273. +#define CPU_WDOG_SAVED_STATE 0x00000044
  40274. +#define CPU_LAST_BRANCH_ADDR 0x00000048
  40275. +#define CPU_SPAD_UFLOW_SET 0x0000004c
  40276. +/* 0x50 --> 0x200 unused */
  40277. +#define CPU_R0 0x00000200
  40278. +#define CPU_R1 0x00000204
  40279. +#define CPU_R2 0x00000208
  40280. +#define CPU_R3 0x0000020c
  40281. +#define CPU_R4 0x00000210
  40282. +#define CPU_R5 0x00000214
  40283. +#define CPU_R6 0x00000218
  40284. +#define CPU_R7 0x0000021c
  40285. +#define CPU_R8 0x00000220
  40286. +#define CPU_R9 0x00000224
  40287. +#define CPU_R10 0x00000228
  40288. +#define CPU_R11 0x0000022c
  40289. +#define CPU_R12 0x00000230
  40290. +#define CPU_R13 0x00000234
  40291. +#define CPU_R14 0x00000238
  40292. +#define CPU_R15 0x0000023c
  40293. +#define CPU_R16 0x00000240
  40294. +#define CPU_R17 0x00000244
  40295. +#define CPU_R18 0x00000248
  40296. +#define CPU_R19 0x0000024c
  40297. +#define CPU_R20 0x00000250
  40298. +#define CPU_R21 0x00000254
  40299. +#define CPU_R22 0x00000258
  40300. +#define CPU_R23 0x0000025c
  40301. +#define CPU_R24 0x00000260
  40302. +#define CPU_R25 0x00000264
  40303. +#define CPU_R26 0x00000268
  40304. +#define CPU_R27 0x0000026c
  40305. +#define CPU_R28 0x00000270
  40306. +#define CPU_R29 0x00000274
  40307. +#define CPU_R30 0x00000278
  40308. +#define CPU_R31 0x0000027c
  40309. +/* 0x280 --> 0x400 unused */
  40310. +
  40311. +#define RX_CPU_BASE 0x00005000
  40312. +#define TX_CPU_BASE 0x00005400
  40313. +
  40314. +/* Mailboxes */
  40315. +#define GRCMBOX_INTERRUPT_0 0x00005800 /* 64-bit */
  40316. +#define GRCMBOX_INTERRUPT_1 0x00005808 /* 64-bit */
  40317. +#define GRCMBOX_INTERRUPT_2 0x00005810 /* 64-bit */
  40318. +#define GRCMBOX_INTERRUPT_3 0x00005818 /* 64-bit */
  40319. +#define GRCMBOX_GENERAL_0 0x00005820 /* 64-bit */
  40320. +#define GRCMBOX_GENERAL_1 0x00005828 /* 64-bit */
  40321. +#define GRCMBOX_GENERAL_2 0x00005830 /* 64-bit */
  40322. +#define GRCMBOX_GENERAL_3 0x00005838 /* 64-bit */
  40323. +#define GRCMBOX_GENERAL_4 0x00005840 /* 64-bit */
  40324. +#define GRCMBOX_GENERAL_5 0x00005848 /* 64-bit */
  40325. +#define GRCMBOX_GENERAL_6 0x00005850 /* 64-bit */
  40326. +#define GRCMBOX_GENERAL_7 0x00005858 /* 64-bit */
  40327. +#define GRCMBOX_RELOAD_STAT 0x00005860 /* 64-bit */
  40328. +#define GRCMBOX_RCVSTD_PROD_IDX 0x00005868 /* 64-bit */
  40329. +#define GRCMBOX_RCVJUMBO_PROD_IDX 0x00005870 /* 64-bit */
  40330. +#define GRCMBOX_RCVMINI_PROD_IDX 0x00005878 /* 64-bit */
  40331. +#define GRCMBOX_RCVRET_CON_IDX_0 0x00005880 /* 64-bit */
  40332. +#define GRCMBOX_RCVRET_CON_IDX_1 0x00005888 /* 64-bit */
  40333. +#define GRCMBOX_RCVRET_CON_IDX_2 0x00005890 /* 64-bit */
  40334. +#define GRCMBOX_RCVRET_CON_IDX_3 0x00005898 /* 64-bit */
  40335. +#define GRCMBOX_RCVRET_CON_IDX_4 0x000058a0 /* 64-bit */
  40336. +#define GRCMBOX_RCVRET_CON_IDX_5 0x000058a8 /* 64-bit */
  40337. +#define GRCMBOX_RCVRET_CON_IDX_6 0x000058b0 /* 64-bit */
  40338. +#define GRCMBOX_RCVRET_CON_IDX_7 0x000058b8 /* 64-bit */
  40339. +#define GRCMBOX_RCVRET_CON_IDX_8 0x000058c0 /* 64-bit */
  40340. +#define GRCMBOX_RCVRET_CON_IDX_9 0x000058c8 /* 64-bit */
  40341. +#define GRCMBOX_RCVRET_CON_IDX_10 0x000058d0 /* 64-bit */
  40342. +#define GRCMBOX_RCVRET_CON_IDX_11 0x000058d8 /* 64-bit */
  40343. +#define GRCMBOX_RCVRET_CON_IDX_12 0x000058e0 /* 64-bit */
  40344. +#define GRCMBOX_RCVRET_CON_IDX_13 0x000058e8 /* 64-bit */
  40345. +#define GRCMBOX_RCVRET_CON_IDX_14 0x000058f0 /* 64-bit */
  40346. +#define GRCMBOX_RCVRET_CON_IDX_15 0x000058f8 /* 64-bit */
  40347. +#define GRCMBOX_SNDHOST_PROD_IDX_0 0x00005900 /* 64-bit */
  40348. +#define GRCMBOX_SNDHOST_PROD_IDX_1 0x00005908 /* 64-bit */
  40349. +#define GRCMBOX_SNDHOST_PROD_IDX_2 0x00005910 /* 64-bit */
  40350. +#define GRCMBOX_SNDHOST_PROD_IDX_3 0x00005918 /* 64-bit */
  40351. +#define GRCMBOX_SNDHOST_PROD_IDX_4 0x00005920 /* 64-bit */
  40352. +#define GRCMBOX_SNDHOST_PROD_IDX_5 0x00005928 /* 64-bit */
  40353. +#define GRCMBOX_SNDHOST_PROD_IDX_6 0x00005930 /* 64-bit */
  40354. +#define GRCMBOX_SNDHOST_PROD_IDX_7 0x00005938 /* 64-bit */
  40355. +#define GRCMBOX_SNDHOST_PROD_IDX_8 0x00005940 /* 64-bit */
  40356. +#define GRCMBOX_SNDHOST_PROD_IDX_9 0x00005948 /* 64-bit */
  40357. +#define GRCMBOX_SNDHOST_PROD_IDX_10 0x00005950 /* 64-bit */
  40358. +#define GRCMBOX_SNDHOST_PROD_IDX_11 0x00005958 /* 64-bit */
  40359. +#define GRCMBOX_SNDHOST_PROD_IDX_12 0x00005960 /* 64-bit */
  40360. +#define GRCMBOX_SNDHOST_PROD_IDX_13 0x00005968 /* 64-bit */
  40361. +#define GRCMBOX_SNDHOST_PROD_IDX_14 0x00005970 /* 64-bit */
  40362. +#define GRCMBOX_SNDHOST_PROD_IDX_15 0x00005978 /* 64-bit */
  40363. +#define GRCMBOX_SNDNIC_PROD_IDX_0 0x00005980 /* 64-bit */
  40364. +#define GRCMBOX_SNDNIC_PROD_IDX_1 0x00005988 /* 64-bit */
  40365. +#define GRCMBOX_SNDNIC_PROD_IDX_2 0x00005990 /* 64-bit */
  40366. +#define GRCMBOX_SNDNIC_PROD_IDX_3 0x00005998 /* 64-bit */
  40367. +#define GRCMBOX_SNDNIC_PROD_IDX_4 0x000059a0 /* 64-bit */
  40368. +#define GRCMBOX_SNDNIC_PROD_IDX_5 0x000059a8 /* 64-bit */
  40369. +#define GRCMBOX_SNDNIC_PROD_IDX_6 0x000059b0 /* 64-bit */
  40370. +#define GRCMBOX_SNDNIC_PROD_IDX_7 0x000059b8 /* 64-bit */
  40371. +#define GRCMBOX_SNDNIC_PROD_IDX_8 0x000059c0 /* 64-bit */
  40372. +#define GRCMBOX_SNDNIC_PROD_IDX_9 0x000059c8 /* 64-bit */
  40373. +#define GRCMBOX_SNDNIC_PROD_IDX_10 0x000059d0 /* 64-bit */
  40374. +#define GRCMBOX_SNDNIC_PROD_IDX_11 0x000059d8 /* 64-bit */
  40375. +#define GRCMBOX_SNDNIC_PROD_IDX_12 0x000059e0 /* 64-bit */
  40376. +#define GRCMBOX_SNDNIC_PROD_IDX_13 0x000059e8 /* 64-bit */
  40377. +#define GRCMBOX_SNDNIC_PROD_IDX_14 0x000059f0 /* 64-bit */
  40378. +#define GRCMBOX_SNDNIC_PROD_IDX_15 0x000059f8 /* 64-bit */
  40379. +#define GRCMBOX_HIGH_PRIO_EV_VECTOR 0x00005a00
  40380. +#define GRCMBOX_HIGH_PRIO_EV_MASK 0x00005a04
  40381. +#define GRCMBOX_LOW_PRIO_EV_VEC 0x00005a08
  40382. +#define GRCMBOX_LOW_PRIO_EV_MASK 0x00005a0c
  40383. +/* 0x5a10 --> 0x5c00 */
  40384. +
  40385. +/* Flow Through queues */
  40386. +#define FTQ_RESET 0x00005c00
  40387. +/* 0x5c04 --> 0x5c10 unused */
  40388. +#define FTQ_DMA_NORM_READ_CTL 0x00005c10
  40389. +#define FTQ_DMA_NORM_READ_FULL_CNT 0x00005c14
  40390. +#define FTQ_DMA_NORM_READ_FIFO_ENQDEQ 0x00005c18
  40391. +#define FTQ_DMA_NORM_READ_WRITE_PEEK 0x00005c1c
  40392. +#define FTQ_DMA_HIGH_READ_CTL 0x00005c20
  40393. +#define FTQ_DMA_HIGH_READ_FULL_CNT 0x00005c24
  40394. +#define FTQ_DMA_HIGH_READ_FIFO_ENQDEQ 0x00005c28
  40395. +#define FTQ_DMA_HIGH_READ_WRITE_PEEK 0x00005c2c
  40396. +#define FTQ_DMA_COMP_DISC_CTL 0x00005c30
  40397. +#define FTQ_DMA_COMP_DISC_FULL_CNT 0x00005c34
  40398. +#define FTQ_DMA_COMP_DISC_FIFO_ENQDEQ 0x00005c38
  40399. +#define FTQ_DMA_COMP_DISC_WRITE_PEEK 0x00005c3c
  40400. +#define FTQ_SEND_BD_COMP_CTL 0x00005c40
  40401. +#define FTQ_SEND_BD_COMP_FULL_CNT 0x00005c44
  40402. +#define FTQ_SEND_BD_COMP_FIFO_ENQDEQ 0x00005c48
  40403. +#define FTQ_SEND_BD_COMP_WRITE_PEEK 0x00005c4c
  40404. +#define FTQ_SEND_DATA_INIT_CTL 0x00005c50
  40405. +#define FTQ_SEND_DATA_INIT_FULL_CNT 0x00005c54
  40406. +#define FTQ_SEND_DATA_INIT_FIFO_ENQDEQ 0x00005c58
  40407. +#define FTQ_SEND_DATA_INIT_WRITE_PEEK 0x00005c5c
  40408. +#define FTQ_DMA_NORM_WRITE_CTL 0x00005c60
  40409. +#define FTQ_DMA_NORM_WRITE_FULL_CNT 0x00005c64
  40410. +#define FTQ_DMA_NORM_WRITE_FIFO_ENQDEQ 0x00005c68
  40411. +#define FTQ_DMA_NORM_WRITE_WRITE_PEEK 0x00005c6c
  40412. +#define FTQ_DMA_HIGH_WRITE_CTL 0x00005c70
  40413. +#define FTQ_DMA_HIGH_WRITE_FULL_CNT 0x00005c74
  40414. +#define FTQ_DMA_HIGH_WRITE_FIFO_ENQDEQ 0x00005c78
  40415. +#define FTQ_DMA_HIGH_WRITE_WRITE_PEEK 0x00005c7c
  40416. +#define FTQ_SWTYPE1_CTL 0x00005c80
  40417. +#define FTQ_SWTYPE1_FULL_CNT 0x00005c84
  40418. +#define FTQ_SWTYPE1_FIFO_ENQDEQ 0x00005c88
  40419. +#define FTQ_SWTYPE1_WRITE_PEEK 0x00005c8c
  40420. +#define FTQ_SEND_DATA_COMP_CTL 0x00005c90
  40421. +#define FTQ_SEND_DATA_COMP_FULL_CNT 0x00005c94
  40422. +#define FTQ_SEND_DATA_COMP_FIFO_ENQDEQ 0x00005c98
  40423. +#define FTQ_SEND_DATA_COMP_WRITE_PEEK 0x00005c9c
  40424. +#define FTQ_HOST_COAL_CTL 0x00005ca0
  40425. +#define FTQ_HOST_COAL_FULL_CNT 0x00005ca4
  40426. +#define FTQ_HOST_COAL_FIFO_ENQDEQ 0x00005ca8
  40427. +#define FTQ_HOST_COAL_WRITE_PEEK 0x00005cac
  40428. +#define FTQ_MAC_TX_CTL 0x00005cb0
  40429. +#define FTQ_MAC_TX_FULL_CNT 0x00005cb4
  40430. +#define FTQ_MAC_TX_FIFO_ENQDEQ 0x00005cb8
  40431. +#define FTQ_MAC_TX_WRITE_PEEK 0x00005cbc
  40432. +#define FTQ_MB_FREE_CTL 0x00005cc0
  40433. +#define FTQ_MB_FREE_FULL_CNT 0x00005cc4
  40434. +#define FTQ_MB_FREE_FIFO_ENQDEQ 0x00005cc8
  40435. +#define FTQ_MB_FREE_WRITE_PEEK 0x00005ccc
  40436. +#define FTQ_RCVBD_COMP_CTL 0x00005cd0
  40437. +#define FTQ_RCVBD_COMP_FULL_CNT 0x00005cd4
  40438. +#define FTQ_RCVBD_COMP_FIFO_ENQDEQ 0x00005cd8
  40439. +#define FTQ_RCVBD_COMP_WRITE_PEEK 0x00005cdc
  40440. +#define FTQ_RCVLST_PLMT_CTL 0x00005ce0
  40441. +#define FTQ_RCVLST_PLMT_FULL_CNT 0x00005ce4
  40442. +#define FTQ_RCVLST_PLMT_FIFO_ENQDEQ 0x00005ce8
  40443. +#define FTQ_RCVLST_PLMT_WRITE_PEEK 0x00005cec
  40444. +#define FTQ_RCVDATA_INI_CTL 0x00005cf0
  40445. +#define FTQ_RCVDATA_INI_FULL_CNT 0x00005cf4
  40446. +#define FTQ_RCVDATA_INI_FIFO_ENQDEQ 0x00005cf8
  40447. +#define FTQ_RCVDATA_INI_WRITE_PEEK 0x00005cfc
  40448. +#define FTQ_RCVDATA_COMP_CTL 0x00005d00
  40449. +#define FTQ_RCVDATA_COMP_FULL_CNT 0x00005d04
  40450. +#define FTQ_RCVDATA_COMP_FIFO_ENQDEQ 0x00005d08
  40451. +#define FTQ_RCVDATA_COMP_WRITE_PEEK 0x00005d0c
  40452. +#define FTQ_SWTYPE2_CTL 0x00005d10
  40453. +#define FTQ_SWTYPE2_FULL_CNT 0x00005d14
  40454. +#define FTQ_SWTYPE2_FIFO_ENQDEQ 0x00005d18
  40455. +#define FTQ_SWTYPE2_WRITE_PEEK 0x00005d1c
  40456. +/* 0x5d20 --> 0x6000 unused */
  40457. +
  40458. +/* Message signaled interrupt registers */
  40459. +#define MSGINT_MODE 0x00006000
  40460. +#define MSGINT_MODE_RESET 0x00000001
  40461. +#define MSGINT_MODE_ENABLE 0x00000002
  40462. +#define MSGINT_STATUS 0x00006004
  40463. +#define MSGINT_FIFO 0x00006008
  40464. +/* 0x600c --> 0x6400 unused */
  40465. +
  40466. +/* DMA completion registers */
  40467. +#define DMAC_MODE 0x00006400
  40468. +#define DMAC_MODE_RESET 0x00000001
  40469. +#define DMAC_MODE_ENABLE 0x00000002
  40470. +/* 0x6404 --> 0x6800 unused */
  40471. +
  40472. +/* GRC registers */
  40473. +#define GRC_MODE 0x00006800
  40474. +#define GRC_MODE_UPD_ON_COAL 0x00000001
  40475. +#define GRC_MODE_BSWAP_NONFRM_DATA 0x00000002
  40476. +#define GRC_MODE_WSWAP_NONFRM_DATA 0x00000004
  40477. +#define GRC_MODE_BSWAP_DATA 0x00000010
  40478. +#define GRC_MODE_WSWAP_DATA 0x00000020
  40479. +#define GRC_MODE_SPLITHDR 0x00000100
  40480. +#define GRC_MODE_NOFRM_CRACKING 0x00000200
  40481. +#define GRC_MODE_INCL_CRC 0x00000400
  40482. +#define GRC_MODE_ALLOW_BAD_FRMS 0x00000800
  40483. +#define GRC_MODE_NOIRQ_ON_SENDS 0x00002000
  40484. +#define GRC_MODE_NOIRQ_ON_RCV 0x00004000
  40485. +#define GRC_MODE_FORCE_PCI32BIT 0x00008000
  40486. +#define GRC_MODE_HOST_STACKUP 0x00010000
  40487. +#define GRC_MODE_HOST_SENDBDS 0x00020000
  40488. +#define GRC_MODE_NO_TX_PHDR_CSUM 0x00100000
  40489. +#define GRC_MODE_NO_RX_PHDR_CSUM 0x00800000
  40490. +#define GRC_MODE_IRQ_ON_TX_CPU_ATTN 0x01000000
  40491. +#define GRC_MODE_IRQ_ON_RX_CPU_ATTN 0x02000000
  40492. +#define GRC_MODE_IRQ_ON_MAC_ATTN 0x04000000
  40493. +#define GRC_MODE_IRQ_ON_DMA_ATTN 0x08000000
  40494. +#define GRC_MODE_IRQ_ON_FLOW_ATTN 0x10000000
  40495. +#define GRC_MODE_4X_NIC_SEND_RINGS 0x20000000
  40496. +#define GRC_MODE_MCAST_FRM_ENABLE 0x40000000
  40497. +#define GRC_MISC_CFG 0x00006804
  40498. +#define GRC_MISC_CFG_CORECLK_RESET 0x00000001
  40499. +#define GRC_MISC_CFG_PRESCALAR_MASK 0x000000fe
  40500. +#define GRC_MISC_CFG_PRESCALAR_SHIFT 1
  40501. +#define GRC_MISC_CFG_BOARD_ID_MASK 0x0001e000
  40502. +#define GRC_MISC_CFG_BOARD_ID_5700 0x0001e000
  40503. +#define GRC_MISC_CFG_BOARD_ID_5701 0x00000000
  40504. +#define GRC_MISC_CFG_BOARD_ID_5702FE 0x00004000
  40505. +#define GRC_MISC_CFG_BOARD_ID_5703 0x00000000
  40506. +#define GRC_MISC_CFG_BOARD_ID_5703S 0x00002000
  40507. +#define GRC_MISC_CFG_BOARD_ID_5704 0x00000000
  40508. +#define GRC_MISC_CFG_BOARD_ID_5704CIOBE 0x00004000
  40509. +#define GRC_MISC_CFG_BOARD_ID_5704_A2 0x00008000
  40510. +#define GRC_MISC_CFG_BOARD_ID_5788 0x00010000
  40511. +#define GRC_MISC_CFG_BOARD_ID_5788M 0x00018000
  40512. +#define GRC_MISC_CFG_BOARD_ID_AC91002A1 0x00018000
  40513. +#define GRC_MISC_CFG_KEEP_GPHY_POWER 0x04000000
  40514. +#define GRC_LOCAL_CTRL 0x00006808
  40515. +#define GRC_LCLCTRL_INT_ACTIVE 0x00000001
  40516. +#define GRC_LCLCTRL_CLEARINT 0x00000002
  40517. +#define GRC_LCLCTRL_SETINT 0x00000004
  40518. +#define GRC_LCLCTRL_INT_ON_ATTN 0x00000008
  40519. +#define GRC_LCLCTRL_GPIO_INPUT0 0x00000100
  40520. +#define GRC_LCLCTRL_GPIO_INPUT1 0x00000200
  40521. +#define GRC_LCLCTRL_GPIO_INPUT2 0x00000400
  40522. +#define GRC_LCLCTRL_GPIO_OE0 0x00000800
  40523. +#define GRC_LCLCTRL_GPIO_OE1 0x00001000
  40524. +#define GRC_LCLCTRL_GPIO_OE2 0x00002000
  40525. +#define GRC_LCLCTRL_GPIO_OUTPUT0 0x00004000
  40526. +#define GRC_LCLCTRL_GPIO_OUTPUT1 0x00008000
  40527. +#define GRC_LCLCTRL_GPIO_OUTPUT2 0x00010000
  40528. +#define GRC_LCLCTRL_EXTMEM_ENABLE 0x00020000
  40529. +#define GRC_LCLCTRL_MEMSZ_MASK 0x001c0000
  40530. +#define GRC_LCLCTRL_MEMSZ_256K 0x00000000
  40531. +#define GRC_LCLCTRL_MEMSZ_512K 0x00040000
  40532. +#define GRC_LCLCTRL_MEMSZ_1M 0x00080000
  40533. +#define GRC_LCLCTRL_MEMSZ_2M 0x000c0000
  40534. +#define GRC_LCLCTRL_MEMSZ_4M 0x00100000
  40535. +#define GRC_LCLCTRL_MEMSZ_8M 0x00140000
  40536. +#define GRC_LCLCTRL_MEMSZ_16M 0x00180000
  40537. +#define GRC_LCLCTRL_BANK_SELECT 0x00200000
  40538. +#define GRC_LCLCTRL_SSRAM_TYPE 0x00400000
  40539. +#define GRC_LCLCTRL_AUTO_SEEPROM 0x01000000
  40540. +#define GRC_TIMER 0x0000680c
  40541. +#define GRC_RX_CPU_EVENT 0x00006810
  40542. +#define GRC_RX_TIMER_REF 0x00006814
  40543. +#define GRC_RX_CPU_SEM 0x00006818
  40544. +#define GRC_REMOTE_RX_CPU_ATTN 0x0000681c
  40545. +#define GRC_TX_CPU_EVENT 0x00006820
  40546. +#define GRC_TX_TIMER_REF 0x00006824
  40547. +#define GRC_TX_CPU_SEM 0x00006828
  40548. +#define GRC_REMOTE_TX_CPU_ATTN 0x0000682c
  40549. +#define GRC_MEM_POWER_UP 0x00006830 /* 64-bit */
  40550. +#define GRC_EEPROM_ADDR 0x00006838
  40551. +#define EEPROM_ADDR_WRITE 0x00000000
  40552. +#define EEPROM_ADDR_READ 0x80000000
  40553. +#define EEPROM_ADDR_COMPLETE 0x40000000
  40554. +#define EEPROM_ADDR_FSM_RESET 0x20000000
  40555. +#define EEPROM_ADDR_DEVID_MASK 0x1c000000
  40556. +#define EEPROM_ADDR_DEVID_SHIFT 26
  40557. +#define EEPROM_ADDR_START 0x02000000
  40558. +#define EEPROM_ADDR_CLKPERD_SHIFT 16
  40559. +#define EEPROM_ADDR_ADDR_MASK 0x0000ffff
  40560. +#define EEPROM_ADDR_ADDR_SHIFT 0
  40561. +#define EEPROM_DEFAULT_CLOCK_PERIOD 0x60
  40562. +#define EEPROM_CHIP_SIZE (64 * 1024)
  40563. +#define GRC_EEPROM_DATA 0x0000683c
  40564. +#define GRC_EEPROM_CTRL 0x00006840
  40565. +#define GRC_MDI_CTRL 0x00006844
  40566. +#define GRC_SEEPROM_DELAY 0x00006848
  40567. +/* 0x684c --> 0x6c00 unused */
  40568. +
  40569. +/* 0x6c00 --> 0x7000 unused */
  40570. +
  40571. +/* NVRAM Control registers */
  40572. +#define NVRAM_CMD 0x00007000
  40573. +#define NVRAM_CMD_RESET 0x00000001
  40574. +#define NVRAM_CMD_DONE 0x00000008
  40575. +#define NVRAM_CMD_GO 0x00000010
  40576. +#define NVRAM_CMD_WR 0x00000020
  40577. +#define NVRAM_CMD_RD 0x00000000
  40578. +#define NVRAM_CMD_ERASE 0x00000040
  40579. +#define NVRAM_CMD_FIRST 0x00000080
  40580. +#define NVRAM_CMD_LAST 0x00000100
  40581. +#define NVRAM_STAT 0x00007004
  40582. +#define NVRAM_WRDATA 0x00007008
  40583. +#define NVRAM_ADDR 0x0000700c
  40584. +#define NVRAM_ADDR_MSK 0x00ffffff
  40585. +#define NVRAM_RDDATA 0x00007010
  40586. +#define NVRAM_CFG1 0x00007014
  40587. +#define NVRAM_CFG1_FLASHIF_ENAB 0x00000001
  40588. +#define NVRAM_CFG1_BUFFERED_MODE 0x00000002
  40589. +#define NVRAM_CFG1_PASS_THRU 0x00000004
  40590. +#define NVRAM_CFG1_BIT_BANG 0x00000008
  40591. +#define NVRAM_CFG1_COMPAT_BYPASS 0x80000000
  40592. +#define NVRAM_CFG2 0x00007018
  40593. +#define NVRAM_CFG3 0x0000701c
  40594. +#define NVRAM_SWARB 0x00007020
  40595. +#define SWARB_REQ_SET0 0x00000001
  40596. +#define SWARB_REQ_SET1 0x00000002
  40597. +#define SWARB_REQ_SET2 0x00000004
  40598. +#define SWARB_REQ_SET3 0x00000008
  40599. +#define SWARB_REQ_CLR0 0x00000010
  40600. +#define SWARB_REQ_CLR1 0x00000020
  40601. +#define SWARB_REQ_CLR2 0x00000040
  40602. +#define SWARB_REQ_CLR3 0x00000080
  40603. +#define SWARB_GNT0 0x00000100
  40604. +#define SWARB_GNT1 0x00000200
  40605. +#define SWARB_GNT2 0x00000400
  40606. +#define SWARB_GNT3 0x00000800
  40607. +#define SWARB_REQ0 0x00001000
  40608. +#define SWARB_REQ1 0x00002000
  40609. +#define SWARB_REQ2 0x00004000
  40610. +#define SWARB_REQ3 0x00008000
  40611. +#define NVRAM_BUFFERED_PAGE_SIZE 264
  40612. +#define NVRAM_BUFFERED_PAGE_POS 9
  40613. +/* 0x7024 --> 0x7400 unused */
  40614. +
  40615. +/* 0x7400 --> 0x8000 unused */
  40616. +
  40617. +/* 32K Window into NIC internal memory */
  40618. +#define NIC_SRAM_WIN_BASE 0x00008000
  40619. +
  40620. +/* Offsets into first 32k of NIC internal memory. */
  40621. +#define NIC_SRAM_PAGE_ZERO 0x00000000
  40622. +#define NIC_SRAM_SEND_RCB 0x00000100 /* 16 * TG3_BDINFO_... */
  40623. +#define NIC_SRAM_RCV_RET_RCB 0x00000200 /* 16 * TG3_BDINFO_... */
  40624. +#define NIC_SRAM_STATS_BLK 0x00000300
  40625. +#define NIC_SRAM_STATUS_BLK 0x00000b00
  40626. +
  40627. +#define NIC_SRAM_FIRMWARE_MBOX 0x00000b50
  40628. +#define NIC_SRAM_FIRMWARE_MBOX_MAGIC1 0x4B657654
  40629. +#define NIC_SRAM_FIRMWARE_MBOX_MAGIC2 0x4861764b /* !dma on linkchg */
  40630. +
  40631. +#define NIC_SRAM_DATA_SIG 0x00000b54
  40632. +#define NIC_SRAM_DATA_SIG_MAGIC 0x4b657654 /* ascii for 'KevT' */
  40633. +
  40634. +#define NIC_SRAM_DATA_CFG 0x00000b58
  40635. +#define NIC_SRAM_DATA_CFG_LED_MODE_MASK 0x0000000c
  40636. +#define NIC_SRAM_DATA_CFG_LED_MODE_UNKNOWN 0x00000000
  40637. +#define NIC_SRAM_DATA_CFG_LED_TRIPLE_SPD 0x00000004
  40638. +#define NIC_SRAM_DATA_CFG_LED_OPEN_DRAIN 0x00000004
  40639. +#define NIC_SRAM_DATA_CFG_LED_LINK_SPD 0x00000008
  40640. +#define NIC_SRAM_DATA_CFG_LED_OUTPUT 0x00000008
  40641. +#define NIC_SRAM_DATA_CFG_PHY_TYPE_MASK 0x00000030
  40642. +#define NIC_SRAM_DATA_CFG_PHY_TYPE_UNKNOWN 0x00000000
  40643. +#define NIC_SRAM_DATA_CFG_PHY_TYPE_COPPER 0x00000010
  40644. +#define NIC_SRAM_DATA_CFG_PHY_TYPE_FIBER 0x00000020
  40645. +#define NIC_SRAM_DATA_CFG_WOL_ENABLE 0x00000040
  40646. +#define NIC_SRAM_DATA_CFG_ASF_ENABLE 0x00000080
  40647. +#define NIC_SRAM_DATA_CFG_EEPROM_WP 0x00000100
  40648. +#define NIC_SRAM_DATA_CFG_MINI_PCI 0x00001000
  40649. +#define NIC_SRAM_DATA_CFG_FIBER_WOL 0x00004000
  40650. +
  40651. +#define NIC_SRAM_DATA_PHY_ID 0x00000b74
  40652. +#define NIC_SRAM_DATA_PHY_ID1_MASK 0xffff0000
  40653. +#define NIC_SRAM_DATA_PHY_ID2_MASK 0x0000ffff
  40654. +
  40655. +#define NIC_SRAM_FW_CMD_MBOX 0x00000b78
  40656. +#define FWCMD_NICDRV_ALIVE 0x00000001
  40657. +#define FWCMD_NICDRV_PAUSE_FW 0x00000002
  40658. +#define FWCMD_NICDRV_IPV4ADDR_CHG 0x00000003
  40659. +#define FWCMD_NICDRV_IPV6ADDR_CHG 0x00000004
  40660. +#define FWCMD_NICDRV_FIX_DMAR 0x00000005
  40661. +#define FWCMD_NICDRV_FIX_DMAW 0x00000006
  40662. +#define NIC_SRAM_FW_CMD_LEN_MBOX 0x00000b7c
  40663. +#define NIC_SRAM_FW_CMD_DATA_MBOX 0x00000b80
  40664. +#define NIC_SRAM_FW_ASF_STATUS_MBOX 0x00000c00
  40665. +#define NIC_SRAM_FW_DRV_STATE_MBOX 0x00000c04
  40666. +#define DRV_STATE_START 0x00000001
  40667. +#define DRV_STATE_UNLOAD 0x00000002
  40668. +#define DRV_STATE_WOL 0x00000003
  40669. +#define DRV_STATE_SUSPEND 0x00000004
  40670. +
  40671. +#define NIC_SRAM_FW_RESET_TYPE_MBOX 0x00000c08
  40672. +
  40673. +#define NIC_SRAM_MAC_ADDR_HIGH_MBOX 0x00000c14
  40674. +#define NIC_SRAM_MAC_ADDR_LOW_MBOX 0x00000c18
  40675. +
  40676. +#define NIC_SRAM_RX_MINI_BUFFER_DESC 0x00001000
  40677. +
  40678. +#define NIC_SRAM_DMA_DESC_POOL_BASE 0x00002000
  40679. +#define NIC_SRAM_DMA_DESC_POOL_SIZE 0x00002000
  40680. +#define NIC_SRAM_TX_BUFFER_DESC 0x00004000 /* 512 entries */
  40681. +#define NIC_SRAM_RX_BUFFER_DESC 0x00006000 /* 256 entries */
  40682. +#define NIC_SRAM_RX_JUMBO_BUFFER_DESC 0x00007000 /* 256 entries */
  40683. +#define NIC_SRAM_MBUF_POOL_BASE 0x00008000
  40684. +#define NIC_SRAM_MBUF_POOL_SIZE96 0x00018000
  40685. +#define NIC_SRAM_MBUF_POOL_SIZE64 0x00010000
  40686. +#define NIC_SRAM_MBUF_POOL_BASE5705 0x00010000
  40687. +#define NIC_SRAM_MBUF_POOL_SIZE5705 0x0000e000
  40688. +
  40689. +/* Currently this is fixed. */
  40690. +#define PHY_ADDR 0x01
  40691. +
  40692. +/* Tigon3 specific PHY MII registers. */
  40693. +#define TG3_BMCR_SPEED1000 0x0040
  40694. +
  40695. +#define MII_TG3_CTRL 0x09 /* 1000-baseT control register */
  40696. +#define MII_TG3_CTRL_ADV_1000_HALF 0x0100
  40697. +#define MII_TG3_CTRL_ADV_1000_FULL 0x0200
  40698. +#define MII_TG3_CTRL_AS_MASTER 0x0800
  40699. +#define MII_TG3_CTRL_ENABLE_AS_MASTER 0x1000
  40700. +
  40701. +#define MII_TG3_EXT_CTRL 0x10 /* Extended control register */
  40702. +#define MII_TG3_EXT_CTRL_LNK3_LED_MODE 0x0002
  40703. +#define MII_TG3_EXT_CTRL_TBI 0x8000
  40704. +
  40705. +#define MII_TG3_EXT_STAT 0x11 /* Extended status register */
  40706. +#define MII_TG3_EXT_STAT_LPASS 0x0100
  40707. +
  40708. +#define MII_TG3_DSP_RW_PORT 0x15 /* DSP coefficient read/write port */
  40709. +
  40710. +#define MII_TG3_DSP_ADDRESS 0x17 /* DSP address register */
  40711. +
  40712. +#define MII_TG3_AUX_CTRL 0x18 /* auxilliary control register */
  40713. +
  40714. +#define MII_TG3_AUX_STAT 0x19 /* auxilliary status register */
  40715. +#define MII_TG3_AUX_STAT_LPASS 0x0004
  40716. +#define MII_TG3_AUX_STAT_SPDMASK 0x0700
  40717. +#define MII_TG3_AUX_STAT_10HALF 0x0100
  40718. +#define MII_TG3_AUX_STAT_10FULL 0x0200
  40719. +#define MII_TG3_AUX_STAT_100HALF 0x0300
  40720. +#define MII_TG3_AUX_STAT_100_4 0x0400
  40721. +#define MII_TG3_AUX_STAT_100FULL 0x0500
  40722. +#define MII_TG3_AUX_STAT_1000HALF 0x0600
  40723. +#define MII_TG3_AUX_STAT_1000FULL 0x0700
  40724. +
  40725. +#define MII_TG3_ISTAT 0x1a /* IRQ status register */
  40726. +#define MII_TG3_IMASK 0x1b /* IRQ mask register */
  40727. +
  40728. +/* ISTAT/IMASK event bits */
  40729. +#define MII_TG3_INT_LINKCHG 0x0002
  40730. +#define MII_TG3_INT_SPEEDCHG 0x0004
  40731. +#define MII_TG3_INT_DUPLEXCHG 0x0008
  40732. +#define MII_TG3_INT_ANEG_PAGE_RX 0x0400
  40733. +
  40734. +/* XXX Add this to mii.h */
  40735. +#ifndef ADVERTISE_PAUSE
  40736. +#define ADVERTISE_PAUSE_CAP 0x0400
  40737. +#endif
  40738. +#ifndef ADVERTISE_PAUSE_ASYM
  40739. +#define ADVERTISE_PAUSE_ASYM 0x0800
  40740. +#endif
  40741. +#ifndef LPA_PAUSE
  40742. +#define LPA_PAUSE_CAP 0x0400
  40743. +#endif
  40744. +#ifndef LPA_PAUSE_ASYM
  40745. +#define LPA_PAUSE_ASYM 0x0800
  40746. +#endif
  40747. +
  40748. +/* There are two ways to manage the TX descriptors on the tigon3.
  40749. + * Either the descriptors are in host DMA'able memory, or they
  40750. + * exist only in the cards on-chip SRAM. All 16 send bds are under
  40751. + * the same mode, they may not be configured individually.
  40752. + *
  40753. + * The mode we use is controlled by TG3_FLAG_HOST_TXDS in tp->tg3_flags.
  40754. + *
  40755. + * To use host memory TX descriptors:
  40756. + * 1) Set GRC_MODE_HOST_SENDBDS in GRC_MODE register.
  40757. + * Make sure GRC_MODE_4X_NIC_SEND_RINGS is clear.
  40758. + * 2) Allocate DMA'able memory.
  40759. + * 3) In NIC_SRAM_SEND_RCB (of desired index) of on-chip SRAM:
  40760. + * a) Set TG3_BDINFO_HOST_ADDR to DMA address of memory
  40761. + * obtained in step 2
  40762. + * b) Set TG3_BDINFO_NIC_ADDR to NIC_SRAM_TX_BUFFER_DESC.
  40763. + * c) Set len field of TG3_BDINFO_MAXLEN_FLAGS to number
  40764. + * of TX descriptors. Leave flags field clear.
  40765. + * 4) Access TX descriptors via host memory. The chip
  40766. + * will refetch into local SRAM as needed when producer
  40767. + * index mailboxes are updated.
  40768. + *
  40769. + * To use on-chip TX descriptors:
  40770. + * 1) Set GRC_MODE_4X_NIC_SEND_RINGS in GRC_MODE register.
  40771. + * Make sure GRC_MODE_HOST_SENDBDS is clear.
  40772. + * 2) In NIC_SRAM_SEND_RCB (of desired index) of on-chip SRAM:
  40773. + * a) Set TG3_BDINFO_HOST_ADDR to zero.
  40774. + * b) Set TG3_BDINFO_NIC_ADDR to NIC_SRAM_TX_BUFFER_DESC
  40775. + * c) TG3_BDINFO_MAXLEN_FLAGS is don't care.
  40776. + * 3) Access TX descriptors directly in on-chip SRAM
  40777. + * using normal {read,write}l(). (and not using
  40778. + * pointer dereferencing of ioremap()'d memory like
  40779. + * the broken Broadcom driver does)
  40780. + *
  40781. + * Note that BDINFO_FLAGS_DISABLED should be set in the flags field of
  40782. + * TG3_BDINFO_MAXLEN_FLAGS of all unused SEND_RCB indices.
  40783. + */
  40784. +struct tg3_tx_buffer_desc {
  40785. + uint32_t addr_hi;
  40786. + uint32_t addr_lo;
  40787. +
  40788. + uint32_t len_flags;
  40789. +#define TXD_FLAG_TCPUDP_CSUM 0x0001
  40790. +#define TXD_FLAG_IP_CSUM 0x0002
  40791. +#define TXD_FLAG_END 0x0004
  40792. +#define TXD_FLAG_IP_FRAG 0x0008
  40793. +#define TXD_FLAG_IP_FRAG_END 0x0010
  40794. +#define TXD_FLAG_VLAN 0x0040
  40795. +#define TXD_FLAG_COAL_NOW 0x0080
  40796. +#define TXD_FLAG_CPU_PRE_DMA 0x0100
  40797. +#define TXD_FLAG_CPU_POST_DMA 0x0200
  40798. +#define TXD_FLAG_ADD_SRC_ADDR 0x1000
  40799. +#define TXD_FLAG_CHOOSE_SRC_ADDR 0x6000
  40800. +#define TXD_FLAG_NO_CRC 0x8000
  40801. +#define TXD_LEN_SHIFT 16
  40802. +
  40803. + uint32_t vlan_tag;
  40804. +#define TXD_VLAN_TAG_SHIFT 0
  40805. +#define TXD_MSS_SHIFT 16
  40806. +};
  40807. +
  40808. +#define TXD_ADDR 0x00UL /* 64-bit */
  40809. +#define TXD_LEN_FLAGS 0x08UL /* 32-bit (upper 16-bits are len) */
  40810. +#define TXD_VLAN_TAG 0x0cUL /* 32-bit (upper 16-bits are tag) */
  40811. +#define TXD_SIZE 0x10UL
  40812. +
  40813. +struct tg3_rx_buffer_desc {
  40814. + uint32_t addr_hi;
  40815. + uint32_t addr_lo;
  40816. +
  40817. + uint32_t idx_len;
  40818. +#define RXD_IDX_MASK 0xffff0000
  40819. +#define RXD_IDX_SHIFT 16
  40820. +#define RXD_LEN_MASK 0x0000ffff
  40821. +#define RXD_LEN_SHIFT 0
  40822. +
  40823. + uint32_t type_flags;
  40824. +#define RXD_TYPE_SHIFT 16
  40825. +#define RXD_FLAGS_SHIFT 0
  40826. +
  40827. +#define RXD_FLAG_END 0x0004
  40828. +#define RXD_FLAG_MINI 0x0800
  40829. +#define RXD_FLAG_JUMBO 0x0020
  40830. +#define RXD_FLAG_VLAN 0x0040
  40831. +#define RXD_FLAG_ERROR 0x0400
  40832. +#define RXD_FLAG_IP_CSUM 0x1000
  40833. +#define RXD_FLAG_TCPUDP_CSUM 0x2000
  40834. +#define RXD_FLAG_IS_TCP 0x4000
  40835. +
  40836. + uint32_t ip_tcp_csum;
  40837. +#define RXD_IPCSUM_MASK 0xffff0000
  40838. +#define RXD_IPCSUM_SHIFT 16
  40839. +#define RXD_TCPCSUM_MASK 0x0000ffff
  40840. +#define RXD_TCPCSUM_SHIFT 0
  40841. +
  40842. + uint32_t err_vlan;
  40843. +
  40844. +#define RXD_VLAN_MASK 0x0000ffff
  40845. +
  40846. +#define RXD_ERR_BAD_CRC 0x00010000
  40847. +#define RXD_ERR_COLLISION 0x00020000
  40848. +#define RXD_ERR_LINK_LOST 0x00040000
  40849. +#define RXD_ERR_PHY_DECODE 0x00080000
  40850. +#define RXD_ERR_ODD_NIBBLE_RCVD_MII 0x00100000
  40851. +#define RXD_ERR_MAC_ABRT 0x00200000
  40852. +#define RXD_ERR_TOO_SMALL 0x00400000
  40853. +#define RXD_ERR_NO_RESOURCES 0x00800000
  40854. +#define RXD_ERR_HUGE_FRAME 0x01000000
  40855. +#define RXD_ERR_MASK 0xffff0000
  40856. +
  40857. + uint32_t reserved;
  40858. + uint32_t opaque;
  40859. +#define RXD_OPAQUE_INDEX_MASK 0x0000ffff
  40860. +#define RXD_OPAQUE_INDEX_SHIFT 0
  40861. +#define RXD_OPAQUE_RING_STD 0x00010000
  40862. +#define RXD_OPAQUE_RING_JUMBO 0x00020000
  40863. +#define RXD_OPAQUE_RING_MINI 0x00040000
  40864. +#define RXD_OPAQUE_RING_MASK 0x00070000
  40865. +};
  40866. +
  40867. +struct tg3_ext_rx_buffer_desc {
  40868. + struct {
  40869. + uint32_t addr_hi;
  40870. + uint32_t addr_lo;
  40871. + } addrlist[3];
  40872. + uint32_t len2_len1;
  40873. + uint32_t resv_len3;
  40874. + struct tg3_rx_buffer_desc std;
  40875. +};
  40876. +
  40877. +/* We only use this when testing out the DMA engine
  40878. + * at probe time. This is the internal format of buffer
  40879. + * descriptors used by the chip at NIC_SRAM_DMA_DESCS.
  40880. + */
  40881. +struct tg3_internal_buffer_desc {
  40882. + uint32_t addr_hi;
  40883. + uint32_t addr_lo;
  40884. + uint32_t nic_mbuf;
  40885. + /* XXX FIX THIS */
  40886. +#if __BYTE_ORDER == __BIG_ENDIAN
  40887. + uint16_t cqid_sqid;
  40888. + uint16_t len;
  40889. +#else
  40890. + uint16_t len;
  40891. + uint16_t cqid_sqid;
  40892. +#endif
  40893. + uint32_t flags;
  40894. + uint32_t __cookie1;
  40895. + uint32_t __cookie2;
  40896. + uint32_t __cookie3;
  40897. +};
  40898. +
  40899. +#define TG3_HW_STATUS_SIZE 0x50
  40900. +struct tg3_hw_status {
  40901. + uint32_t status;
  40902. +#define SD_STATUS_UPDATED 0x00000001
  40903. +#define SD_STATUS_LINK_CHG 0x00000002
  40904. +#define SD_STATUS_ERROR 0x00000004
  40905. +
  40906. + uint32_t status_tag;
  40907. +
  40908. +#if __BYTE_ORDER == __BIG_ENDIAN
  40909. + uint16_t rx_consumer;
  40910. + uint16_t rx_jumbo_consumer;
  40911. +#else
  40912. + uint16_t rx_jumbo_consumer;
  40913. + uint16_t rx_consumer;
  40914. +#endif
  40915. +
  40916. +#if __BYTE_ORDER == __BIG_ENDIAN
  40917. + uint16_t reserved;
  40918. + uint16_t rx_mini_consumer;
  40919. +#else
  40920. + uint16_t rx_mini_consumer;
  40921. + uint16_t reserved;
  40922. +#endif
  40923. + struct {
  40924. +#if __BYTE_ORDER == __BIG_ENDIAN
  40925. + uint16_t tx_consumer;
  40926. + uint16_t rx_producer;
  40927. +#else
  40928. + uint16_t rx_producer;
  40929. + uint16_t tx_consumer;
  40930. +#endif
  40931. + } idx[16];
  40932. +};
  40933. +
  40934. +typedef struct {
  40935. + uint32_t high, low;
  40936. +} tg3_stat64_t;
  40937. +
  40938. +struct tg3_hw_stats {
  40939. + uint8_t __reserved0[0x400-0x300];
  40940. +
  40941. + /* Statistics maintained by Receive MAC. */
  40942. + tg3_stat64_t rx_octets;
  40943. + uint64_t __reserved1;
  40944. + tg3_stat64_t rx_fragments;
  40945. + tg3_stat64_t rx_ucast_packets;
  40946. + tg3_stat64_t rx_mcast_packets;
  40947. + tg3_stat64_t rx_bcast_packets;
  40948. + tg3_stat64_t rx_fcs_errors;
  40949. + tg3_stat64_t rx_align_errors;
  40950. + tg3_stat64_t rx_xon_pause_rcvd;
  40951. + tg3_stat64_t rx_xoff_pause_rcvd;
  40952. + tg3_stat64_t rx_mac_ctrl_rcvd;
  40953. + tg3_stat64_t rx_xoff_entered;
  40954. + tg3_stat64_t rx_frame_too_long_errors;
  40955. + tg3_stat64_t rx_jabbers;
  40956. + tg3_stat64_t rx_undersize_packets;
  40957. + tg3_stat64_t rx_in_length_errors;
  40958. + tg3_stat64_t rx_out_length_errors;
  40959. + tg3_stat64_t rx_64_or_less_octet_packets;
  40960. + tg3_stat64_t rx_65_to_127_octet_packets;
  40961. + tg3_stat64_t rx_128_to_255_octet_packets;
  40962. + tg3_stat64_t rx_256_to_511_octet_packets;
  40963. + tg3_stat64_t rx_512_to_1023_octet_packets;
  40964. + tg3_stat64_t rx_1024_to_1522_octet_packets;
  40965. + tg3_stat64_t rx_1523_to_2047_octet_packets;
  40966. + tg3_stat64_t rx_2048_to_4095_octet_packets;
  40967. + tg3_stat64_t rx_4096_to_8191_octet_packets;
  40968. + tg3_stat64_t rx_8192_to_9022_octet_packets;
  40969. +
  40970. + uint64_t __unused0[37];
  40971. +
  40972. + /* Statistics maintained by Transmit MAC. */
  40973. + tg3_stat64_t tx_octets;
  40974. + uint64_t __reserved2;
  40975. + tg3_stat64_t tx_collisions;
  40976. + tg3_stat64_t tx_xon_sent;
  40977. + tg3_stat64_t tx_xoff_sent;
  40978. + tg3_stat64_t tx_flow_control;
  40979. + tg3_stat64_t tx_mac_errors;
  40980. + tg3_stat64_t tx_single_collisions;
  40981. + tg3_stat64_t tx_mult_collisions;
  40982. + tg3_stat64_t tx_deferred;
  40983. + uint64_t __reserved3;
  40984. + tg3_stat64_t tx_excessive_collisions;
  40985. + tg3_stat64_t tx_late_collisions;
  40986. + tg3_stat64_t tx_collide_2times;
  40987. + tg3_stat64_t tx_collide_3times;
  40988. + tg3_stat64_t tx_collide_4times;
  40989. + tg3_stat64_t tx_collide_5times;
  40990. + tg3_stat64_t tx_collide_6times;
  40991. + tg3_stat64_t tx_collide_7times;
  40992. + tg3_stat64_t tx_collide_8times;
  40993. + tg3_stat64_t tx_collide_9times;
  40994. + tg3_stat64_t tx_collide_10times;
  40995. + tg3_stat64_t tx_collide_11times;
  40996. + tg3_stat64_t tx_collide_12times;
  40997. + tg3_stat64_t tx_collide_13times;
  40998. + tg3_stat64_t tx_collide_14times;
  40999. + tg3_stat64_t tx_collide_15times;
  41000. + tg3_stat64_t tx_ucast_packets;
  41001. + tg3_stat64_t tx_mcast_packets;
  41002. + tg3_stat64_t tx_bcast_packets;
  41003. + tg3_stat64_t tx_carrier_sense_errors;
  41004. + tg3_stat64_t tx_discards;
  41005. + tg3_stat64_t tx_errors;
  41006. +
  41007. + uint64_t __unused1[31];
  41008. +
  41009. + /* Statistics maintained by Receive List Placement. */
  41010. + tg3_stat64_t COS_rx_packets[16];
  41011. + tg3_stat64_t COS_rx_filter_dropped;
  41012. + tg3_stat64_t dma_writeq_full;
  41013. + tg3_stat64_t dma_write_prioq_full;
  41014. + tg3_stat64_t rxbds_empty;
  41015. + tg3_stat64_t rx_discards;
  41016. + tg3_stat64_t rx_errors;
  41017. + tg3_stat64_t rx_threshold_hit;
  41018. +
  41019. + uint64_t __unused2[9];
  41020. +
  41021. + /* Statistics maintained by Send Data Initiator. */
  41022. + tg3_stat64_t COS_out_packets[16];
  41023. + tg3_stat64_t dma_readq_full;
  41024. + tg3_stat64_t dma_read_prioq_full;
  41025. + tg3_stat64_t tx_comp_queue_full;
  41026. +
  41027. + /* Statistics maintained by Host Coalescing. */
  41028. + tg3_stat64_t ring_set_send_prod_index;
  41029. + tg3_stat64_t ring_status_update;
  41030. + tg3_stat64_t nic_irqs;
  41031. + tg3_stat64_t nic_avoided_irqs;
  41032. + tg3_stat64_t nic_tx_threshold_hit;
  41033. +
  41034. + uint8_t __reserved4[0xb00-0x9c0];
  41035. +};
  41036. +
  41037. +enum phy_led_mode {
  41038. + led_mode_auto,
  41039. + led_mode_three_link,
  41040. + led_mode_link10
  41041. +};
  41042. +
  41043. +#if 0
  41044. +/* 'mapping' is superfluous as the chip does not write into
  41045. + * the tx/rx post rings so we could just fetch it from there.
  41046. + * But the cache behavior is better how we are doing it now.
  41047. + */
  41048. +struct ring_info {
  41049. + struct sk_buff *skb;
  41050. + DECLARE_PCI_UNMAP_ADDR(mapping)
  41051. +};
  41052. +
  41053. +struct tx_ring_info {
  41054. + struct sk_buff *skb;
  41055. + DECLARE_PCI_UNMAP_ADDR(mapping)
  41056. + uint32_t prev_vlan_tag;
  41057. +};
  41058. +#endif
  41059. +
  41060. +struct tg3_config_info {
  41061. + uint32_t flags;
  41062. +};
  41063. +
  41064. +struct tg3_link_config {
  41065. + /* Describes what we're trying to get. */
  41066. + uint32_t advertising;
  41067. +#if 0
  41068. + uint16_t speed;
  41069. + uint8_t duplex;
  41070. + uint8_t autoneg;
  41071. +#define SPEED_INVALID 0xffff
  41072. +#define DUPLEX_INVALID 0xff
  41073. +#define AUTONEG_INVALID 0xff
  41074. +#endif
  41075. +
  41076. + /* Describes what we actually have. */
  41077. + uint8_t active_speed;
  41078. + uint8_t active_duplex;
  41079. +
  41080. + /* When we go in and out of low power mode we need
  41081. + * to swap with this state.
  41082. + */
  41083. +#if 0
  41084. + int phy_is_low_power;
  41085. + uint16_t orig_speed;
  41086. + uint8_t orig_duplex;
  41087. + uint8_t orig_autoneg;
  41088. +#endif
  41089. +};
  41090. +
  41091. +struct tg3_bufmgr_config {
  41092. + uint32_t mbuf_read_dma_low_water;
  41093. + uint32_t mbuf_mac_rx_low_water;
  41094. + uint32_t mbuf_high_water;
  41095. +
  41096. + uint32_t mbuf_read_dma_low_water_jumbo;
  41097. + uint32_t mbuf_mac_rx_low_water_jumbo;
  41098. + uint32_t mbuf_high_water_jumbo;
  41099. +
  41100. + uint32_t dma_low_water;
  41101. + uint32_t dma_high_water;
  41102. +};
  41103. +
  41104. +struct tg3 {
  41105. +#if 0
  41106. + /* SMP locking strategy:
  41107. + *
  41108. + * lock: Held during all operations except TX packet
  41109. + * processing.
  41110. + *
  41111. + * tx_lock: Held during tg3_start_xmit{,_4gbug} and tg3_tx
  41112. + *
  41113. + * If you want to shut up all asynchronous processing you must
  41114. + * acquire both locks, 'lock' taken before 'tx_lock'. IRQs must
  41115. + * be disabled to take 'lock' but only softirq disabling is
  41116. + * necessary for acquisition of 'tx_lock'.
  41117. + */
  41118. + spinlock_t lock;
  41119. + spinlock_t tx_lock;
  41120. +#endif
  41121. +
  41122. + uint32_t tx_prod;
  41123. +#if 0
  41124. + uint32_t tx_cons;
  41125. +#endif
  41126. + uint32_t rx_rcb_ptr;
  41127. + uint32_t rx_std_ptr;
  41128. +#if 0
  41129. + uint32_t rx_jumbo_ptr;
  41130. + spinlock_t indirect_lock;
  41131. +
  41132. + struct net_device_stats net_stats;
  41133. + struct net_device_stats net_stats_prev;
  41134. +#endif
  41135. + unsigned long phy_crc_errors;
  41136. +
  41137. +#if 0
  41138. + uint32_t rx_offset;
  41139. +#endif
  41140. + uint32_t tg3_flags;
  41141. +#if 0
  41142. +#define TG3_FLAG_HOST_TXDS 0x00000001
  41143. +#endif
  41144. +#define TG3_FLAG_TXD_MBOX_HWBUG 0x00000002
  41145. +#define TG3_FLAG_RX_CHECKSUMS 0x00000004
  41146. +#define TG3_FLAG_USE_LINKCHG_REG 0x00000008
  41147. +#define TG3_FLAG_USE_MI_INTERRUPT 0x00000010
  41148. +#define TG3_FLAG_ENABLE_ASF 0x00000020
  41149. +#define TG3_FLAG_5701_REG_WRITE_BUG 0x00000040
  41150. +#define TG3_FLAG_POLL_SERDES 0x00000080
  41151. +#define TG3_FLAG_MBOX_WRITE_REORDER 0x00000100
  41152. +#define TG3_FLAG_PCIX_TARGET_HWBUG 0x00000200
  41153. +#define TG3_FLAG_WOL_SPEED_100MB 0x00000400
  41154. +#define TG3_FLAG_WOL_ENABLE 0x00000800
  41155. +#define TG3_FLAG_EEPROM_WRITE_PROT 0x00001000
  41156. +#define TG3_FLAG_NVRAM 0x00002000
  41157. +#define TG3_FLAG_NVRAM_BUFFERED 0x00004000
  41158. +#define TG3_FLAG_RX_PAUSE 0x00008000
  41159. +#define TG3_FLAG_TX_PAUSE 0x00010000
  41160. +#define TG3_FLAG_PCIX_MODE 0x00020000
  41161. +#define TG3_FLAG_PCI_HIGH_SPEED 0x00040000
  41162. +#define TG3_FLAG_PCI_32BIT 0x00080000
  41163. +#define TG3_FLAG_NO_TX_PSEUDO_CSUM 0x00100000
  41164. +#define TG3_FLAG_NO_RX_PSEUDO_CSUM 0x00200000
  41165. +#define TG3_FLAG_SERDES_WOL_CAP 0x00400000
  41166. +#define TG3_FLAG_JUMBO_ENABLE 0x00800000
  41167. +#define TG3_FLAG_10_100_ONLY 0x01000000
  41168. +#define TG3_FLAG_PAUSE_AUTONEG 0x02000000
  41169. +#define TG3_FLAG_PAUSE_RX 0x04000000
  41170. +#define TG3_FLAG_PAUSE_TX 0x08000000
  41171. +#define TG3_FLAG_BROKEN_CHECKSUMS 0x10000000
  41172. +#define TG3_FLAG_GOT_SERDES_FLOWCTL 0x20000000
  41173. +#define TG3_FLAG_SPLIT_MODE 0x40000000
  41174. +#define TG3_FLAG_INIT_COMPLETE 0x80000000
  41175. +
  41176. + uint32_t tg3_flags2;
  41177. +#define TG3_FLG2_RESTART_TIMER 0x00000001
  41178. +#define TG3_FLG2_SUN_5704 0x00000002
  41179. +#define TG3_FLG2_NO_ETH_WIRE_SPEED 0x00000004
  41180. +#define TG3_FLG2_IS_5788 0x00000008
  41181. +#define TG3_FLG2_MAX_RXPEND_64 0x00000010
  41182. +#define TG3_FLG2_TSO_CAPABLE 0x00000020
  41183. +
  41184. +
  41185. +
  41186. + uint32_t split_mode_max_reqs;
  41187. +#define SPLIT_MODE_5704_MAX_REQ 3
  41188. +
  41189. +#if 0
  41190. + struct timer_list timer;
  41191. + uint16_t timer_counter;
  41192. + uint16_t timer_multiplier;
  41193. + uint32_t timer_offset;
  41194. + uint16_t asf_counter;
  41195. + uint16_t asf_multiplier;
  41196. +#endif
  41197. +
  41198. + struct tg3_link_config link_config;
  41199. + struct tg3_bufmgr_config bufmgr_config;
  41200. +
  41201. +#if 0
  41202. + uint32_t rx_pending;
  41203. + uint32_t rx_jumbo_pending;
  41204. + uint32_t tx_pending;
  41205. +#endif
  41206. +
  41207. + /* cache h/w values, often passed straight to h/w */
  41208. + uint32_t rx_mode;
  41209. + uint32_t tx_mode;
  41210. + uint32_t mac_mode;
  41211. + uint32_t mi_mode;
  41212. + uint32_t misc_host_ctrl;
  41213. + uint32_t grc_mode;
  41214. + uint32_t grc_local_ctrl;
  41215. + uint32_t dma_rwctrl;
  41216. +#if 0
  41217. + uint32_t coalesce_mode;
  41218. +#endif
  41219. +
  41220. + /* PCI block */
  41221. + uint16_t pci_chip_rev_id;
  41222. +#if 0
  41223. + uint8_t pci_cacheline_sz;
  41224. + uint8_t pci_lat_timer;
  41225. + uint8_t pci_hdr_type;
  41226. + uint8_t pci_bist;
  41227. +#endif
  41228. + uint32_t pci_cfg_state[64 / sizeof(uint32_t)];
  41229. +
  41230. + int pm_cap;
  41231. +
  41232. + /* PHY info */
  41233. + uint32_t phy_id;
  41234. +#define PHY_ID_MASK 0xfffffff0
  41235. +#define PHY_ID_BCM5400 0x60008040
  41236. +#define PHY_ID_BCM5401 0x60008050
  41237. +#define PHY_ID_BCM5411 0x60008070
  41238. +#define PHY_ID_BCM5701 0x60008110
  41239. +#define PHY_ID_BCM5703 0x60008160
  41240. +#define PHY_ID_BCM5704 0x60008190
  41241. +#define PHY_ID_BCM5705 0x600081a0
  41242. +#define PHY_ID_BCM8002 0x60010140
  41243. +#define PHY_ID_SERDES 0xfeedbee0
  41244. +#define PHY_ID_INVALID 0xffffffff
  41245. +#define PHY_ID_REV_MASK 0x0000000f
  41246. +#define PHY_REV_BCM5401_B0 0x1
  41247. +#define PHY_REV_BCM5401_B2 0x3
  41248. +#define PHY_REV_BCM5401_C0 0x6
  41249. +#define PHY_REV_BCM5411_X0 0x1 /* Found on Netgear GA302T */
  41250. +
  41251. + enum phy_led_mode led_mode;
  41252. +
  41253. + char board_part_number[24];
  41254. + uint32_t nic_sram_data_cfg;
  41255. + uint32_t pci_clock_ctrl;
  41256. +#if 0
  41257. + struct pci_device *pdev_peer;
  41258. +#endif
  41259. +
  41260. + /* This macro assumes the passed PHY ID is already masked
  41261. + * with PHY_ID_MASK.
  41262. + */
  41263. +#define KNOWN_PHY_ID(X) \
  41264. + ((X) == PHY_ID_BCM5400 || (X) == PHY_ID_BCM5401 || \
  41265. + (X) == PHY_ID_BCM5411 || (X) == PHY_ID_BCM5701 || \
  41266. + (X) == PHY_ID_BCM5703 || (X) == PHY_ID_BCM5704 || \
  41267. + (X) == PHY_ID_BCM5705 || \
  41268. + (X) == PHY_ID_BCM8002 || (X) == PHY_ID_SERDES)
  41269. +
  41270. + unsigned long regs;
  41271. + struct pci_device *pdev;
  41272. + struct nic *nic;
  41273. +#if 0
  41274. + struct net_device *dev;
  41275. +#endif
  41276. +#if TG3_VLAN_TAG_USED
  41277. + struct vlan_group *vlgrp;
  41278. +#endif
  41279. +
  41280. + struct tg3_rx_buffer_desc *rx_std;
  41281. +#if 0
  41282. + struct ring_info *rx_std_buffers;
  41283. + dma_addr_t rx_std_mapping;
  41284. + struct tg3_rx_buffer_desc *rx_jumbo;
  41285. + struct ring_info *rx_jumbo_buffers;
  41286. + dma_addr_t rx_jumbo_mapping;
  41287. +#endif
  41288. +
  41289. + struct tg3_rx_buffer_desc *rx_rcb;
  41290. +#if 0
  41291. + dma_addr_t rx_rcb_mapping;
  41292. +#endif
  41293. +
  41294. + /* TX descs are only used if TG3_FLAG_HOST_TXDS is set. */
  41295. + struct tg3_tx_buffer_desc *tx_ring;
  41296. +#if 0
  41297. + struct tx_ring_info *tx_buffers;
  41298. + dma_addr_t tx_desc_mapping;
  41299. +#endif
  41300. +
  41301. + struct tg3_hw_status *hw_status;
  41302. +#if 0
  41303. + dma_addr_t status_mapping;
  41304. +#endif
  41305. +#if 0
  41306. + uint32_t msg_enable;
  41307. +#endif
  41308. +
  41309. + struct tg3_hw_stats *hw_stats;
  41310. +#if 0
  41311. + dma_addr_t stats_mapping;
  41312. +#endif
  41313. +
  41314. + int carrier_ok;
  41315. + uint16_t subsystem_vendor;
  41316. + uint16_t subsystem_device;
  41317. +};
  41318. +
  41319. +#endif /* !(_T3_H) */
  41320. diff -Naur grub-0.97.orig/netboot/tiara.c grub-0.97/netboot/tiara.c
  41321. --- grub-0.97.orig/netboot/tiara.c 2003-07-09 11:45:38.000000000 +0000
  41322. +++ grub-0.97/netboot/tiara.c 1970-01-01 00:00:00.000000000 +0000
  41323. @@ -1,255 +0,0 @@
  41324. -/**************************************************************************
  41325. -Etherboot - BOOTP/TFTP Bootstrap Program
  41326. -
  41327. -TIARA (Fujitsu Etherstar) NIC driver for Etherboot
  41328. -Copyright (c) Ken Yap 1998
  41329. -
  41330. -Information gleaned from:
  41331. -
  41332. -TIARA.ASM Packet driver by Brian Fisher, Queens U, Kingston, Ontario
  41333. -Fujitsu MB86960 spec sheet (different chip but same family)
  41334. -***************************************************************************/
  41335. -
  41336. -/*
  41337. - * This program is free software; you can redistribute it and/or
  41338. - * modify it under the terms of the GNU General Public License as
  41339. - * published by the Free Software Foundation; either version 2, or (at
  41340. - * your option) any later version.
  41341. - */
  41342. -
  41343. -/* to get some global routines like printf */
  41344. -#include "etherboot.h"
  41345. -/* to get the interface to the body of the program */
  41346. -#include "nic.h"
  41347. -#include "cards.h"
  41348. -
  41349. -/*
  41350. - EtherStar I/O Register offsets
  41351. -*/
  41352. -
  41353. -/* Offsets of registers */
  41354. -#define DLCR_XMIT_STAT 0x00
  41355. -#define DLCR_XMIT_MASK 0x01
  41356. -#define DLCR_RECV_STAT 0x02
  41357. -#define DLCR_RECV_MASK 0x03
  41358. -#define DLCR_XMIT_MODE 0x04
  41359. -#define DLCR_RECV_MODE 0x05
  41360. -#define DLCR_ENABLE 0x06
  41361. -#define DLCR_TDR_LOW 0x07
  41362. -#define DLCR_NODE_ID 0x08
  41363. -#define DLCR_TDR_HIGH 0x0F
  41364. -#define BMPR_MEM_PORT 0x10
  41365. -#define BMPR_PKT_LEN 0x12
  41366. -#define BMPR_DMA_ENABLE 0x14
  41367. -#define PROM_ID 0x18
  41368. -
  41369. -#define TMST 0x80
  41370. -#define TMT_OK 0x80
  41371. -#define TMT_16COLL 0x02
  41372. -#define BUF_EMPTY 0x40
  41373. -
  41374. -#define CARD_DISABLE 0x80 /* written to DLCR_ENABLE to disable card */
  41375. -#define CARD_ENABLE 0 /* written to DLCR_ENABLE to enable card */
  41376. -
  41377. -#define CLEAR_STATUS 0x0F /* used to clear status info */
  41378. -/*
  41379. - 00001111B
  41380. - !!!!!!!!--------
  41381. - !!!!!!!+--------CLEAR BUS WRITE ERROR
  41382. - !!!!!!+---------CLEAR 16 COLLISION
  41383. - !!!!!+----------CLEAR COLLISION
  41384. - !!!!+-----------CLEAR UNDERFLOW
  41385. - !!!+------------NC
  41386. - !!+-------------NC
  41387. - !+--------------NC
  41388. - +---------------NC
  41389. -*/
  41390. -
  41391. -#define NO_TX_IRQS 0 /* written to clear transmit IRQs */
  41392. -
  41393. -#define CLR_RCV_STATUS 0xCF /* clears receive status */
  41394. -
  41395. -#define EN_RCV_IRQS 0x80 /* enable receive interrupts */
  41396. -/*
  41397. - 10000000B
  41398. - !!!!!!!!--------
  41399. - !!!!!!!+--------ENABLE OVERFLOW
  41400. - !!!!!!+---------ENABLE CRC
  41401. - !!!!!+----------ENABLE ALIGN
  41402. - !!!!+-----------ENABLE SHORT PKT
  41403. - !!!+------------DISABLE REMOTE RESET
  41404. - !!+-------------RESERVED
  41405. - !+--------------RESERVED
  41406. - +---------------ENABLE PKT READY
  41407. -*/
  41408. -
  41409. -#define XMIT_MODE 0x02
  41410. -/*
  41411. - 00000010B
  41412. - !!!!!!!!---------ENABLE CARRIER DETECT
  41413. - !!!!!!!+---------DISABLE LOOPBACK
  41414. -*/
  41415. -
  41416. -#define RECV_MODE 0x02
  41417. -/*
  41418. - 00000010B
  41419. - !!!!!!!!---------ACCEPT ALL PACKETS
  41420. - !!!!!!!+---------ACCEPT PHYSICAL, MULTICAST, AND
  41421. - !!!!!!+----------BROADCAST PACKETS
  41422. - !!!!!+-----------DISABLE REMOTE RESET
  41423. - !!!!+------------DISABLE SHORT PACKETS
  41424. - !!!+-------------USE 6 BYTE ADDRESS
  41425. - !!+--------------NC
  41426. - !+---------------NC
  41427. - +----------------DISABLE CRC TEST MODE
  41428. -*/
  41429. -
  41430. -/* NIC specific static variables go here */
  41431. -
  41432. -static unsigned short ioaddr;
  41433. -
  41434. -/**************************************************************************
  41435. -RESET - Reset adapter
  41436. -***************************************************************************/
  41437. -static void tiara_reset(struct nic *nic)
  41438. -{
  41439. - int i;
  41440. -
  41441. - outb(CARD_DISABLE, ioaddr + DLCR_ENABLE);
  41442. - outb(CLEAR_STATUS, ioaddr + DLCR_XMIT_STAT);
  41443. - outb(NO_TX_IRQS, ioaddr + DLCR_XMIT_MASK);
  41444. - outb(CLR_RCV_STATUS, ioaddr + DLCR_RECV_STAT);
  41445. - outb(XMIT_MODE, ioaddr + DLCR_XMIT_MODE);
  41446. - outb(RECV_MODE, ioaddr + DLCR_RECV_MODE);
  41447. - /* Vacuum recv buffer */
  41448. - while ((inb(ioaddr + DLCR_RECV_MODE) & BUF_EMPTY) == 0)
  41449. - inb(ioaddr + BMPR_MEM_PORT);
  41450. - /* Set node address */
  41451. - for (i = 0; i < ETH_ALEN; ++i)
  41452. - outb(nic->node_addr[i], ioaddr + DLCR_NODE_ID + i);
  41453. - outb(CLR_RCV_STATUS, ioaddr + DLCR_RECV_STAT);
  41454. - outb(CARD_ENABLE, ioaddr + DLCR_ENABLE);
  41455. -}
  41456. -
  41457. -/**************************************************************************
  41458. -POLL - Wait for a frame
  41459. -***************************************************************************/
  41460. -static int tiara_poll(struct nic *nic)
  41461. -{
  41462. - unsigned int len;
  41463. -
  41464. - if (inb(ioaddr + DLCR_RECV_MODE) & BUF_EMPTY)
  41465. - return (0);
  41466. - /* Ack packet */
  41467. - outw(CLR_RCV_STATUS, ioaddr + DLCR_RECV_STAT);
  41468. - len = inw(ioaddr + BMPR_MEM_PORT); /* throw away status */
  41469. - len = inw(ioaddr + BMPR_MEM_PORT);
  41470. - /* Drop overlength packets */
  41471. - if (len > ETH_FRAME_LEN)
  41472. - return (0); /* should we drain the buffer? */
  41473. - insw(ioaddr + BMPR_MEM_PORT, nic->packet, len / 2);
  41474. - /* If it's our own, drop it */
  41475. - if (memcmp(nic->packet + ETH_ALEN, nic->node_addr, ETH_ALEN) == 0)
  41476. - return (0);
  41477. - nic->packetlen = len;
  41478. - return (1);
  41479. -}
  41480. -
  41481. -/**************************************************************************
  41482. -TRANSMIT - Transmit a frame
  41483. -***************************************************************************/
  41484. -static void tiara_transmit(
  41485. -struct nic *nic,
  41486. -const char *d, /* Destination */
  41487. -unsigned int t, /* Type */
  41488. -unsigned int s, /* size */
  41489. -const char *p) /* Packet */
  41490. -{
  41491. - unsigned int len;
  41492. - unsigned long time;
  41493. -
  41494. - len = s + ETH_HLEN;
  41495. - if (len < ETH_ZLEN)
  41496. - len = ETH_ZLEN;
  41497. - t = htons(t);
  41498. - outsw(ioaddr + BMPR_MEM_PORT, d, ETH_ALEN / 2);
  41499. - outsw(ioaddr + BMPR_MEM_PORT, nic->node_addr, ETH_ALEN / 2);
  41500. - outw(t, ioaddr + BMPR_MEM_PORT);
  41501. - outsw(ioaddr + BMPR_MEM_PORT, p, s / 2);
  41502. - if (s & 1) /* last byte */
  41503. - outb(p[s-1], ioaddr + BMPR_MEM_PORT);
  41504. - while (s++ < ETH_ZLEN - ETH_HLEN) /* pad */
  41505. - outb(0, ioaddr + BMPR_MEM_PORT);
  41506. - outw(len | (TMST << 8), ioaddr + BMPR_PKT_LEN);
  41507. - /* wait for transmit complete */
  41508. - time = currticks() + TICKS_PER_SEC; /* wait one second */
  41509. - while (currticks() < time && (inb(ioaddr) & (TMT_OK|TMT_16COLL)) == 0)
  41510. - ;
  41511. - if ((inb(ioaddr) & (TMT_OK|TMT_16COLL)) == 0)
  41512. - printf("Tiara timed out on transmit\n");
  41513. - /* Do we need to ack the transmit? */
  41514. -}
  41515. -
  41516. -/**************************************************************************
  41517. -DISABLE - Turn off ethernet interface
  41518. -***************************************************************************/
  41519. -static void tiara_disable(struct nic *nic)
  41520. -{
  41521. - /* Apparently only a power down can do this properly */
  41522. - outb(CARD_DISABLE, ioaddr + DLCR_ENABLE);
  41523. -}
  41524. -
  41525. -static int tiara_probe1(struct nic *nic)
  41526. -{
  41527. - /* Hope all the Tiara cards have this vendor prefix */
  41528. - static char vendor_prefix[] = { 0x08, 0x00, 0x1A };
  41529. - static char all_ones[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
  41530. - int i;
  41531. -
  41532. - for (i = 0; i < ETH_ALEN; ++i)
  41533. - nic->node_addr[i] = inb(ioaddr + PROM_ID + i);
  41534. - if (memcmp(nic->node_addr, vendor_prefix, sizeof(vendor_prefix)) != 0)
  41535. - return (0);
  41536. - if (memcmp(nic->node_addr, all_ones, sizeof(all_ones)) == 0)
  41537. - return (0);
  41538. - printf("\nTiara ioaddr %#hX, addr %!\n", ioaddr, nic->node_addr);
  41539. - return (1);
  41540. -}
  41541. -
  41542. -/**************************************************************************
  41543. -PROBE - Look for an adapter, this routine's visible to the outside
  41544. -***************************************************************************/
  41545. -struct nic *tiara_probe(struct nic *nic, unsigned short *probe_addrs)
  41546. -{
  41547. - /* missing entries are addresses usually already used */
  41548. - static unsigned short io_addrs[] = {
  41549. - 0x100, 0x120, 0x140, 0x160,
  41550. - 0x180, 0x1A0, 0x1C0, 0x1E0,
  41551. - 0x200, 0x220, 0x240, /*Par*/
  41552. - 0x280, 0x2A0, 0x2C0, /*Ser*/
  41553. - 0x300, 0x320, 0x340, /*Par*/
  41554. - 0x380, /*Vid,Par*/ 0x3C0, /*Ser*/
  41555. - 0x0
  41556. - };
  41557. - unsigned short *p;
  41558. -
  41559. - /* if probe_addrs is 0, then routine can use a hardwired default */
  41560. - if (probe_addrs == 0)
  41561. - probe_addrs = io_addrs;
  41562. - for (p = probe_addrs; (ioaddr = *p) != 0; ++p)
  41563. - if (tiara_probe1(nic))
  41564. - break;
  41565. - /* if board found */
  41566. - if (ioaddr != 0)
  41567. - {
  41568. - tiara_reset(nic);
  41569. - /* point to NIC specific routines */
  41570. - nic->reset = tiara_reset;
  41571. - nic->poll = tiara_poll;
  41572. - nic->transmit = tiara_transmit;
  41573. - nic->disable = tiara_disable;
  41574. - return nic;
  41575. - }
  41576. - else
  41577. - return (0);
  41578. -}
  41579. diff -Naur grub-0.97.orig/netboot/timer.c grub-0.97/netboot/timer.c
  41580. --- grub-0.97.orig/netboot/timer.c 2003-07-09 11:45:38.000000000 +0000
  41581. +++ grub-0.97/netboot/timer.c 2005-08-31 19:03:35.000000000 +0000
  41582. @@ -6,122 +6,24 @@
  41583. * published by the Free Software Foundation; either version 2, or (at
  41584. * your option) any later version.
  41585. */
  41586. -
  41587. -#include "etherboot.h"
  41588. +#include "grub.h"
  41589. #include "timer.h"
  41590. -void load_timer2(unsigned int ticks)
  41591. -{
  41592. - /* Set up the timer gate, turn off the speaker */
  41593. - outb((inb(PPC_PORTB) & ~PPCB_SPKR) | PPCB_T2GATE, PPC_PORTB);
  41594. - outb(TIMER2_SEL|WORD_ACCESS|MODE0|BINARY_COUNT, TIMER_MODE_PORT);
  41595. - outb(ticks & 0xFF, TIMER2_PORT);
  41596. - outb(ticks >> 8, TIMER2_PORT);
  41597. -}
  41598. -
  41599. -#if defined(CONFIG_TSC_CURRTICKS)
  41600. -#define rdtsc(low,high) \
  41601. - __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))
  41602. -
  41603. -#define rdtscll(val) \
  41604. - __asm__ __volatile__ ("rdtsc" : "=A" (val))
  41605. -
  41606. -
  41607. -#define HZ TICKS_PER_SEC
  41608. -#define CLOCK_TICK_RATE 1193180U /* Underlying HZ */
  41609. -/* LATCH is used in the interval timer and ftape setup. */
  41610. -#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */
  41611. +/* Machine Independant timer helper functions */
  41612. -
  41613. -/* ------ Calibrate the TSC -------
  41614. - * Return 2^32 * (1 / (TSC clocks per usec)) for do_fast_gettimeoffset().
  41615. - * Too much 64-bit arithmetic here to do this cleanly in C, and for
  41616. - * accuracy's sake we want to keep the overhead on the CTC speaker (channel 2)
  41617. - * output busy loop as low as possible. We avoid reading the CTC registers
  41618. - * directly because of the awkward 8-bit access mechanism of the 82C54
  41619. - * device.
  41620. - */
  41621. -
  41622. -#define CALIBRATE_LATCH (5 * LATCH)
  41623. -
  41624. -static unsigned long long calibrate_tsc(void)
  41625. +void mdelay(unsigned int msecs)
  41626. {
  41627. - /* Set the Gate high, disable speaker */
  41628. - outb((inb(0x61) & ~0x02) | 0x01, 0x61);
  41629. -
  41630. - /*
  41631. - * Now let's take care of CTC channel 2
  41632. - *
  41633. - * Set the Gate high, program CTC channel 2 for mode 0,
  41634. - * (interrupt on terminal count mode), binary count,
  41635. - * load 5 * LATCH count, (LSB and MSB) to begin countdown.
  41636. - */
  41637. - outb(0xb0, 0x43); /* binary, mode 0, LSB/MSB, Ch 2 */
  41638. - outb(CALIBRATE_LATCH & 0xff, 0x42); /* LSB of count */
  41639. - outb(CALIBRATE_LATCH >> 8, 0x42); /* MSB of count */
  41640. -
  41641. - {
  41642. - unsigned long startlow, starthigh;
  41643. - unsigned long endlow, endhigh;
  41644. - unsigned long count;
  41645. -
  41646. - rdtsc(startlow,starthigh);
  41647. - count = 0;
  41648. - do {
  41649. - count++;
  41650. - } while ((inb(0x61) & 0x20) == 0);
  41651. - rdtsc(endlow,endhigh);
  41652. -
  41653. - /* Error: ECTCNEVERSET */
  41654. - if (count <= 1)
  41655. - goto bad_ctc;
  41656. -
  41657. - /* 64-bit subtract - gcc just messes up with long longs */
  41658. - __asm__("subl %2,%0\n\t"
  41659. - "sbbl %3,%1"
  41660. - :"=a" (endlow), "=d" (endhigh)
  41661. - :"g" (startlow), "g" (starthigh),
  41662. - "0" (endlow), "1" (endhigh));
  41663. -
  41664. - /* Error: ECPUTOOFAST */
  41665. - if (endhigh)
  41666. - goto bad_ctc;
  41667. -
  41668. - endlow /= 5;
  41669. - return endlow;
  41670. + unsigned int i;
  41671. + for(i = 0; i < msecs; i++) {
  41672. + udelay(1000);
  41673. + poll_interruptions();
  41674. }
  41675. -
  41676. - /*
  41677. - * The CTC wasn't reliable: we got a hit on the very first read,
  41678. - * or the CPU was so fast/slow that the quotient wouldn't fit in
  41679. - * 32 bits..
  41680. - */
  41681. -bad_ctc:
  41682. - printf("bad_ctc\n");
  41683. - return 0;
  41684. }
  41685. -
  41686. -unsigned long currticks(void)
  41687. +void waiton_timer2(unsigned int ticks)
  41688. {
  41689. - static unsigned long clocks_per_tick;
  41690. - unsigned long clocks_high, clocks_low;
  41691. - unsigned long currticks;
  41692. - if (!clocks_per_tick) {
  41693. - clocks_per_tick = calibrate_tsc();
  41694. - printf("clocks_per_tick = %d\n", clocks_per_tick);
  41695. + load_timer2(ticks);
  41696. + while(timer2_running()) {
  41697. + poll_interruptions();
  41698. }
  41699. -
  41700. - /* Read the Time Stamp Counter */
  41701. - rdtsc(clocks_low, clocks_high);
  41702. -
  41703. - /* currticks = clocks / clocks_per_tick; */
  41704. - __asm__("divl %1"
  41705. - :"=a" (currticks)
  41706. - :"r" (clocks_per_tick), "0" (clocks_low), "d" (clocks_high));
  41707. -
  41708. -
  41709. - return currticks;
  41710. }
  41711. -
  41712. -#endif /* RTC_CURRTICKS */
  41713. diff -Naur grub-0.97.orig/netboot/timer.h grub-0.97/netboot/timer.h
  41714. --- grub-0.97.orig/netboot/timer.h 2003-07-09 11:45:38.000000000 +0000
  41715. +++ grub-0.97/netboot/timer.h 2005-08-31 19:03:35.000000000 +0000
  41716. @@ -36,7 +36,8 @@
  41717. #define BCD_COUNT 0x01
  41718. /* Timers tick over at this rate */
  41719. -#define TICKS_PER_MS 1193
  41720. +#define CLOCK_TICK_RATE 1193180U
  41721. +#define TICKS_PER_MS (CLOCK_TICK_RATE/1000)
  41722. /* Parallel Peripheral Controller Port B */
  41723. #define PPC_PORTB 0x61
  41724. @@ -49,16 +50,19 @@
  41725. /* Ticks must be between 0 and 65535 (0 == 65536)
  41726. because it is a 16 bit counter */
  41727. extern void load_timer2(unsigned int ticks);
  41728. -extern inline int timer2_running(void)
  41729. -{
  41730. - return ((inb(PPC_PORTB) & PPCB_T2OUT) == 0);
  41731. -}
  41732. -
  41733. -extern inline void waiton_timer2(unsigned int ticks)
  41734. -{
  41735. - load_timer2(ticks);
  41736. - while ((inb(PPC_PORTB) & PPCB_T2OUT) == 0)
  41737. - ;
  41738. -}
  41739. +extern inline int timer2_running(void);
  41740. +extern void waiton_timer2(unsigned int ticks);
  41741. +extern void __load_timer2(unsigned int ticks);
  41742. +
  41743. +extern void setup_timers(void);
  41744. +extern void ndelay(unsigned int nsecs);
  41745. +extern void udelay(unsigned int usecs);
  41746. +extern void mdelay(unsigned int msecs);
  41747. +//extern unsigned long currticks(void);
  41748. +
  41749. +struct timeval {
  41750. + long tv_sec;
  41751. + long tv_usec;
  41752. +};
  41753. #endif /* TIMER_H */
  41754. diff -Naur grub-0.97.orig/netboot/tlan.c grub-0.97/netboot/tlan.c
  41755. --- grub-0.97.orig/netboot/tlan.c 2003-07-09 11:45:38.000000000 +0000
  41756. +++ grub-0.97/netboot/tlan.c 2005-09-01 00:05:20.000000000 +0000
  41757. @@ -1,3746 +1,1814 @@
  41758. +#define EB51
  41759. +
  41760. +#ifdef EB50
  41761. +#define __unused __attribute__((unused))
  41762. +#endif
  41763. +
  41764. /**************************************************************************
  41765. -Etherboot - BOOTP/TFTP Bootstrap Program
  41766. -TLAN driver for Etherboot
  41767. +*
  41768. +* tlan.c -- Etherboot device driver for the Texas Instruments ThunderLAN
  41769. +* Written 2003-2003 by Timothy Legge <tlegge@rogers.com>
  41770. +*
  41771. +* This program is free software; you can redistribute it and/or modify
  41772. +* it under the terms of the GNU General Public License as published by
  41773. +* the Free Software Foundation; either version 2 of the License, or
  41774. +* (at your option) any later version.
  41775. +*
  41776. +* This program is distributed in the hope that it will be useful,
  41777. +* but WITHOUT ANY WARRANTY; without even the implied warranty of
  41778. +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  41779. +* GNU General Public License for more details.
  41780. +*
  41781. +* You should have received a copy of the GNU General Public License
  41782. +* along with this program; if not, write to the Free Software
  41783. +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  41784. +*
  41785. +* Portions of this code based on:
  41786. +* lan.c: Linux ThunderLan Driver:
  41787. +*
  41788. +* by James Banks
  41789. +*
  41790. +* (C) 1997-1998 Caldera, Inc.
  41791. +* (C) 1998 James Banks
  41792. +* (C) 1999-2001 Torben Mathiasen
  41793. +* (C) 2002 Samuel Chessman
  41794. +*
  41795. +* REVISION HISTORY:
  41796. +* ================
  41797. +* v1.0 07-08-2003 timlegge Initial not quite working version
  41798. +* v1.1 07-27-2003 timlegge Sync 5.0 and 5.1 versions
  41799. +* v1.2 08-19-2003 timlegge Implement Multicast Support
  41800. +* v1.3 08-23-2003 timlegge Fix the transmit Function
  41801. +* v1.4 01-17-2004 timlegge Initial driver output cleanup
  41802. +*
  41803. +* Indent Options: indent -kr -i8
  41804. ***************************************************************************/
  41805. -/*
  41806. - * This program is free software; you can redistribute it and/or
  41807. - * modify it under the terms of the GNU General Public License as
  41808. - * published by the Free Software Foundation; either version 2, or (at
  41809. - * your option) any later version.
  41810. - */
  41811. -
  41812. /* to get some global routines like printf */
  41813. #include "etherboot.h"
  41814. /* to get the interface to the body of the program */
  41815. #include "nic.h"
  41816. /* to get the PCI support functions, if this is a PCI NIC */
  41817. #include "pci.h"
  41818. -/* to get our own prototype */
  41819. -#include "cards.h"
  41820. -
  41821. - /*****************************************************************
  41822. - * TLan Definitions
  41823. - *
  41824. - ****************************************************************/
  41825. +#include "timer.h"
  41826. +#include "tlan.h"
  41827. -#define TLAN_MIN_FRAME_SIZE 64
  41828. -#define TLAN_MAX_FRAME_SIZE 1600
  41829. +#define drv_version "v1.4"
  41830. +#define drv_date "01-17-2004"
  41831. -#define TLAN_NUM_RX_LISTS 32
  41832. -#define TLAN_NUM_TX_LISTS 64
  41833. +/* NIC specific static variables go here */
  41834. +#define HZ 100
  41835. +#define TX_TIME_OUT (6*HZ)
  41836. -#define TLAN_IGNORE 0
  41837. -#define TLAN_RECORD 1
  41838. +#ifdef EB50
  41839. +#define cpu_to_le32(val) (val)
  41840. +#define le32_to_cpu(val) (val)
  41841. +#define virt_to_bus(x) ((unsigned long) x)
  41842. +#define bus_to_virt(x) ((unsigned long) x)
  41843. +#endif
  41844. -#define TLAN_DBG(lvl, format, args...) if (debug&lvl) printf("TLAN: " format, ##args );
  41845. -#define TLAN_DEBUG_GNRL 0x0001
  41846. -#define TLAN_DEBUG_TX 0x0002
  41847. -#define TLAN_DEBUG_RX 0x0004
  41848. -#define TLAN_DEBUG_LIST 0x0008
  41849. -#define TLAN_DEBUG_PROBE 0x0010
  41850. +/* Condensed operations for readability. */
  41851. +#define virt_to_le32desc(addr) cpu_to_le32(virt_to_bus(addr))
  41852. +#define le32desc_to_virt(addr) bus_to_virt(le32_to_cpu(addr))
  41853. -#define MAX_TLAN_BOARDS 8 /* Max number of boards installed at a time */
  41854. - /*****************************************************************
  41855. - * Device Identification Definitions
  41856. - *
  41857. - ****************************************************************/
  41858. -
  41859. -#define PCI_DEVICE_ID_NETELLIGENT_10_T2 0xB012
  41860. -#define PCI_DEVICE_ID_NETELLIGENT_10_100_WS_5100 0xB030
  41861. -#ifndef PCI_DEVICE_ID_OLICOM_OC2183
  41862. -#define PCI_DEVICE_ID_OLICOM_OC2183 0x0013
  41863. -#endif
  41864. -#ifndef PCI_DEVICE_ID_OLICOM_OC2325
  41865. -#define PCI_DEVICE_ID_OLICOM_OC2325 0x0012
  41866. -#endif
  41867. -#ifndef PCI_DEVICE_ID_OLICOM_OC2326
  41868. -#define PCI_DEVICE_ID_OLICOM_OC2326 0x0014
  41869. -#endif
  41870. -#define TLAN_ADAPTER_NONE 0x00000000
  41871. -#define TLAN_ADAPTER_UNMANAGED_PHY 0x00000001
  41872. -#define TLAN_ADAPTER_BIT_RATE_PHY 0x00000002
  41873. -#define TLAN_ADAPTER_USE_INTERN_10 0x00000004
  41874. -#define TLAN_ADAPTER_ACTIVITY_LED 0x00000008
  41875. -#define TLAN_SPEED_DEFAULT 0
  41876. -#define TLAN_SPEED_10 10
  41877. -#define TLAN_SPEED_100 100
  41878. -#define TLAN_DUPLEX_DEFAULT 0
  41879. -#define TLAN_DUPLEX_HALF 1
  41880. -#define TLAN_DUPLEX_FULL 2
  41881. -#define TLAN_BUFFERS_PER_LIST 10
  41882. -#define TLAN_LAST_BUFFER 0x80000000
  41883. -#define TLAN_CSTAT_UNUSED 0x8000
  41884. -#define TLAN_CSTAT_FRM_CMP 0x4000
  41885. -#define TLAN_CSTAT_READY 0x3000
  41886. -#define TLAN_CSTAT_EOC 0x0800
  41887. -#define TLAN_CSTAT_RX_ERROR 0x0400
  41888. -#define TLAN_CSTAT_PASS_CRC 0x0200
  41889. -#define TLAN_CSTAT_DP_PR 0x0100
  41890. -
  41891. - /*****************************************************************
  41892. - * PHY definitions
  41893. - *
  41894. - ****************************************************************/
  41895. -
  41896. -#define TLAN_PHY_MAX_ADDR 0x1F
  41897. -#define TLAN_PHY_NONE 0x20
  41898. -
  41899. - /*****************************************************************
  41900. - * TLan Driver Timer Definitions
  41901. - *
  41902. - ****************************************************************/
  41903. -
  41904. -#define TLAN_TIMER_LINK_BEAT 1
  41905. -#define TLAN_TIMER_ACTIVITY 2
  41906. -#define TLAN_TIMER_PHY_PDOWN 3
  41907. -#define TLAN_TIMER_PHY_PUP 4
  41908. -#define TLAN_TIMER_PHY_RESET 5
  41909. -#define TLAN_TIMER_PHY_START_LINK 6
  41910. -#define TLAN_TIMER_PHY_FINISH_AN 7
  41911. -#define TLAN_TIMER_FINISH_RESET 8
  41912. -#define TLAN_TIMER_ACT_DELAY (HZ/10)
  41913. -
  41914. - /*****************************************************************
  41915. - * TLan Driver Eeprom Definitions
  41916. - *
  41917. - ****************************************************************/
  41918. -
  41919. -#define TLAN_EEPROM_ACK 0
  41920. -#define TLAN_EEPROM_STOP 1
  41921. -
  41922. - /*****************************************************************
  41923. - * Host Register Offsets and Contents
  41924. - *
  41925. - ****************************************************************/
  41926. -
  41927. -#define TLAN_HOST_CMD 0x00
  41928. -#define TLAN_HC_GO 0x80000000
  41929. -#define TLAN_HC_STOP 0x40000000
  41930. -#define TLAN_HC_ACK 0x20000000
  41931. -#define TLAN_HC_CS_MASK 0x1FE00000
  41932. -#define TLAN_HC_EOC 0x00100000
  41933. -#define TLAN_HC_RT 0x00080000
  41934. -#define TLAN_HC_NES 0x00040000
  41935. -#define TLAN_HC_AD_RST 0x00008000
  41936. -#define TLAN_HC_LD_TMR 0x00004000
  41937. -#define TLAN_HC_LD_THR 0x00002000
  41938. -#define TLAN_HC_REQ_INT 0x00001000
  41939. -#define TLAN_HC_INT_OFF 0x00000800
  41940. -#define TLAN_HC_INT_ON 0x00000400
  41941. -#define TLAN_HC_AC_MASK 0x000000FF
  41942. -#define TLAN_CH_PARM 0x04
  41943. -#define TLAN_DIO_ADR 0x08
  41944. -#define TLAN_DA_ADR_INC 0x8000
  41945. -#define TLAN_DA_RAM_ADR 0x4000
  41946. -#define TLAN_HOST_INT 0x0A
  41947. -#define TLAN_HI_IV_MASK 0x1FE0
  41948. -#define TLAN_HI_IT_MASK 0x001C
  41949. -#define TLAN_DIO_DATA 0x0C
  41950. -
  41951. -/* ThunderLAN Internal Register DIO Offsets */
  41952. -
  41953. -#define TLAN_NET_CMD 0x00
  41954. -#define TLAN_NET_CMD_NRESET 0x80
  41955. -#define TLAN_NET_CMD_NWRAP 0x40
  41956. -#define TLAN_NET_CMD_CSF 0x20
  41957. -#define TLAN_NET_CMD_CAF 0x10
  41958. -#define TLAN_NET_CMD_NOBRX 0x08
  41959. -#define TLAN_NET_CMD_DUPLEX 0x04
  41960. -#define TLAN_NET_CMD_TRFRAM 0x02
  41961. -#define TLAN_NET_CMD_TXPACE 0x01
  41962. -#define TLAN_NET_SIO 0x01
  41963. -#define TLAN_NET_SIO_MINTEN 0x80
  41964. -#define TLAN_NET_SIO_ECLOK 0x40
  41965. -#define TLAN_NET_SIO_ETXEN 0x20
  41966. -#define TLAN_NET_SIO_EDATA 0x10
  41967. -#define TLAN_NET_SIO_NMRST 0x08
  41968. -#define TLAN_NET_SIO_MCLK 0x04
  41969. -#define TLAN_NET_SIO_MTXEN 0x02
  41970. -#define TLAN_NET_SIO_MDATA 0x01
  41971. -#define TLAN_NET_STS 0x02
  41972. -#define TLAN_NET_STS_MIRQ 0x80
  41973. -#define TLAN_NET_STS_HBEAT 0x40
  41974. -#define TLAN_NET_STS_TXSTOP 0x20
  41975. -#define TLAN_NET_STS_RXSTOP 0x10
  41976. -#define TLAN_NET_STS_RSRVD 0x0F
  41977. -#define TLAN_NET_MASK 0x03
  41978. -#define TLAN_NET_MASK_MASK7 0x80
  41979. -#define TLAN_NET_MASK_MASK6 0x40
  41980. -#define TLAN_NET_MASK_MASK5 0x20
  41981. -#define TLAN_NET_MASK_MASK4 0x10
  41982. -#define TLAN_NET_MASK_RSRVD 0x0F
  41983. -#define TLAN_NET_CONFIG 0x04
  41984. -#define TLAN_NET_CFG_RCLK 0x8000
  41985. -#define TLAN_NET_CFG_TCLK 0x4000
  41986. -#define TLAN_NET_CFG_BIT 0x2000
  41987. -#define TLAN_NET_CFG_RXCRC 0x1000
  41988. -#define TLAN_NET_CFG_PEF 0x0800
  41989. -#define TLAN_NET_CFG_1FRAG 0x0400
  41990. -#define TLAN_NET_CFG_1CHAN 0x0200
  41991. -#define TLAN_NET_CFG_MTEST 0x0100
  41992. -#define TLAN_NET_CFG_PHY_EN 0x0080
  41993. -#define TLAN_NET_CFG_MSMASK 0x007F
  41994. -#define TLAN_MAN_TEST 0x06
  41995. -#define TLAN_DEF_VENDOR_ID 0x08
  41996. -#define TLAN_DEF_DEVICE_ID 0x0A
  41997. -#define TLAN_DEF_REVISION 0x0C
  41998. -#define TLAN_DEF_SUBCLASS 0x0D
  41999. -#define TLAN_DEF_MIN_LAT 0x0E
  42000. -#define TLAN_DEF_MAX_LAT 0x0F
  42001. -#define TLAN_AREG_0 0x10
  42002. -#define TLAN_AREG_1 0x16
  42003. -#define TLAN_AREG_2 0x1C
  42004. -#define TLAN_AREG_3 0x22
  42005. -#define TLAN_HASH_1 0x28
  42006. -#define TLAN_HASH_2 0x2C
  42007. -#define TLAN_GOOD_TX_FRMS 0x30
  42008. -#define TLAN_TX_UNDERUNS 0x33
  42009. -#define TLAN_GOOD_RX_FRMS 0x34
  42010. -#define TLAN_RX_OVERRUNS 0x37
  42011. -#define TLAN_DEFERRED_TX 0x38
  42012. -#define TLAN_CRC_ERRORS 0x3A
  42013. -#define TLAN_CODE_ERRORS 0x3B
  42014. -#define TLAN_MULTICOL_FRMS 0x3C
  42015. -#define TLAN_SINGLECOL_FRMS 0x3E
  42016. -#define TLAN_EXCESSCOL_FRMS 0x40
  42017. -#define TLAN_LATE_COLS 0x41
  42018. -#define TLAN_CARRIER_LOSS 0x42
  42019. -#define TLAN_ACOMMIT 0x43
  42020. -#define TLAN_LED_REG 0x44
  42021. -#define TLAN_LED_ACT 0x10
  42022. -#define TLAN_LED_LINK 0x01
  42023. -#define TLAN_BSIZE_REG 0x45
  42024. -#define TLAN_MAX_RX 0x46
  42025. -#define TLAN_INT_DIS 0x48
  42026. -#define TLAN_ID_TX_EOC 0x04
  42027. -#define TLAN_ID_RX_EOF 0x02
  42028. -#define TLAN_ID_RX_EOC 0x01
  42029. -
  42030. -/* ThunderLAN Interrupt Codes */
  42031. -
  42032. -#define TLAN_INT_NUMBER_OF_INTS 8
  42033. -
  42034. -#define TLAN_INT_NONE 0x0000
  42035. -#define TLAN_INT_TX_EOF 0x0001
  42036. -#define TLAN_INT_STAT_OVERFLOW 0x0002
  42037. -#define TLAN_INT_RX_EOF 0x0003
  42038. -#define TLAN_INT_DUMMY 0x0004
  42039. -#define TLAN_INT_TX_EOC 0x0005
  42040. -#define TLAN_INT_STATUS_CHECK 0x0006
  42041. -#define TLAN_INT_RX_EOC 0x0007
  42042. -#define TLAN_TLPHY_ID 0x10
  42043. -#define TLAN_TLPHY_CTL 0x11
  42044. -#define TLAN_TC_IGLINK 0x8000
  42045. -#define TLAN_TC_SWAPOL 0x4000
  42046. -#define TLAN_TC_AUISEL 0x2000
  42047. -#define TLAN_TC_SQEEN 0x1000
  42048. -#define TLAN_TC_MTEST 0x0800
  42049. -#define TLAN_TC_RESERVED 0x07F8
  42050. -#define TLAN_TC_NFEW 0x0004
  42051. -#define TLAN_TC_INTEN 0x0002
  42052. -#define TLAN_TC_TINT 0x0001
  42053. -#define TLAN_TLPHY_STS 0x12
  42054. -#define TLAN_TS_MINT 0x8000
  42055. -#define TLAN_TS_PHOK 0x4000
  42056. -#define TLAN_TS_POLOK 0x2000
  42057. -#define TLAN_TS_TPENERGY 0x1000
  42058. -#define TLAN_TS_RESERVED 0x0FFF
  42059. -#define TLAN_TLPHY_PAR 0x19
  42060. -#define TLAN_PHY_CIM_STAT 0x0020
  42061. -#define TLAN_PHY_SPEED_100 0x0040
  42062. -#define TLAN_PHY_DUPLEX_FULL 0x0080
  42063. -#define TLAN_PHY_AN_EN_STAT 0x0400
  42064. -
  42065. -
  42066. -/* ThunderLAN MII Registers */
  42067. -
  42068. -/* Generic MII/PHY Registers */
  42069. -
  42070. -#define MII_GEN_CTL 0x00
  42071. -#define MII_GC_RESET 0x8000
  42072. -#define MII_GC_LOOPBK 0x4000
  42073. -#define MII_GC_SPEEDSEL 0x2000
  42074. -#define MII_GC_AUTOENB 0x1000
  42075. -#define MII_GC_PDOWN 0x0800
  42076. -#define MII_GC_ISOLATE 0x0400
  42077. -#define MII_GC_AUTORSRT 0x0200
  42078. -#define MII_GC_DUPLEX 0x0100
  42079. -#define MII_GC_COLTEST 0x0080
  42080. -#define MII_GC_RESERVED 0x007F
  42081. -#define MII_GEN_STS 0x01
  42082. -#define MII_GS_100BT4 0x8000
  42083. -#define MII_GS_100BTXFD 0x4000
  42084. -#define MII_GS_100BTXHD 0x2000
  42085. -#define MII_GS_10BTFD 0x1000
  42086. -#define MII_GS_10BTHD 0x0800
  42087. -#define MII_GS_RESERVED 0x07C0
  42088. -#define MII_GS_AUTOCMPLT 0x0020
  42089. -#define MII_GS_RFLT 0x0010
  42090. -#define MII_GS_AUTONEG 0x0008
  42091. -#define MII_GS_LINK 0x0004
  42092. -#define MII_GS_JABBER 0x0002
  42093. -#define MII_GS_EXTCAP 0x0001
  42094. -#define MII_GEN_ID_HI 0x02
  42095. -#define MII_GEN_ID_LO 0x03
  42096. -#define MII_GIL_OUI 0xFC00
  42097. -#define MII_GIL_MODEL 0x03F0
  42098. -#define MII_GIL_REVISION 0x000F
  42099. -#define MII_AN_ADV 0x04
  42100. -#define MII_AN_LPA 0x05
  42101. -#define MII_AN_EXP 0x06
  42102. -
  42103. -/* ThunderLAN Specific MII/PHY Registers */
  42104. -
  42105. -#define TLAN_TC_IGLINK 0x8000
  42106. -#define TLAN_TC_SWAPOL 0x4000
  42107. -#define TLAN_TC_AUISEL 0x2000
  42108. -#define TLAN_TC_SQEEN 0x1000
  42109. -#define TLAN_TC_MTEST 0x0800
  42110. -#define TLAN_TC_RESERVED 0x07F8
  42111. -#define TLAN_TC_NFEW 0x0004
  42112. -#define TLAN_TC_INTEN 0x0002
  42113. -#define TLAN_TC_TINT 0x0001
  42114. -#define TLAN_TS_MINT 0x8000
  42115. -#define TLAN_TS_PHOK 0x4000
  42116. -#define TLAN_TS_POLOK 0x2000
  42117. -#define TLAN_TS_TPENERGY 0x1000
  42118. -#define TLAN_TS_RESERVED 0x0FFF
  42119. -#define TLAN_PHY_CIM_STAT 0x0020
  42120. -#define TLAN_PHY_SPEED_100 0x0040
  42121. -#define TLAN_PHY_DUPLEX_FULL 0x0080
  42122. -#define TLAN_PHY_AN_EN_STAT 0x0400
  42123. -
  42124. -/* National Sem. & Level1 PHY id's */
  42125. -#define NAT_SEM_ID1 0x2000
  42126. -#define NAT_SEM_ID2 0x5C01
  42127. -#define LEVEL1_ID1 0x7810
  42128. -#define LEVEL1_ID2 0x0000
  42129. -
  42130. -#define TLan_ClearBit( bit, port ) outb_p(inb_p(port) & ~bit, port)
  42131. -#define TLan_GetBit( bit, port ) ((int) (inb_p(port) & bit))
  42132. -#define TLan_SetBit( bit, port ) outb_p(inb_p(port) | bit, port)
  42133. -
  42134. -typedef unsigned int u32;
  42135. -typedef unsigned short u16;
  42136. -typedef unsigned char u8;
  42137. +static void TLan_ResetLists(struct nic *nic __unused);
  42138. +static void TLan_ResetAdapter(struct nic *nic __unused);
  42139. +static void TLan_FinishReset(struct nic *nic __unused);
  42140. -/* Routines to access internal registers. */
  42141. +static void TLan_EeSendStart(u16);
  42142. +static int TLan_EeSendByte(u16, u8, int);
  42143. +static void TLan_EeReceiveByte(u16, u8 *, int);
  42144. +static int TLan_EeReadByte(u16 io_base, u8, u8 *);
  42145. -inline u8 TLan_DioRead8(u16 base_addr, u16 internal_addr)
  42146. -{
  42147. - outw(internal_addr, base_addr + TLAN_DIO_ADR);
  42148. - return (inb((base_addr + TLAN_DIO_DATA) + (internal_addr & 0x3)));
  42149. -
  42150. -} /* TLan_DioRead8 */
  42151. +static void TLan_PhyDetect(struct nic *nic);
  42152. +static void TLan_PhyPowerDown(struct nic *nic);
  42153. +static void TLan_PhyPowerUp(struct nic *nic);
  42154. -inline u16 TLan_DioRead16(u16 base_addr, u16 internal_addr)
  42155. -{
  42156. - outw(internal_addr, base_addr + TLAN_DIO_ADR);
  42157. - return (inw((base_addr + TLAN_DIO_DATA) + (internal_addr & 0x2)));
  42158. -} /* TLan_DioRead16 */
  42159. +static void TLan_SetMac(struct nic *nic __unused, int areg, char *mac);
  42160. -inline u32 TLan_DioRead32(u16 base_addr, u16 internal_addr)
  42161. -{
  42162. - outw(internal_addr, base_addr + TLAN_DIO_ADR);
  42163. - return (inl(base_addr + TLAN_DIO_DATA));
  42164. +static void TLan_PhyReset(struct nic *nic);
  42165. +static void TLan_PhyStartLink(struct nic *nic);
  42166. +static void TLan_PhyFinishAutoNeg(struct nic *nic);
  42167. -} /* TLan_DioRead32 */
  42168. +#ifdef MONITOR
  42169. +static void TLan_PhyMonitor(struct nic *nic);
  42170. +#endif
  42171. -inline void TLan_DioWrite8(u16 base_addr, u16 internal_addr, u8 data)
  42172. -{
  42173. - outw(internal_addr, base_addr + TLAN_DIO_ADR);
  42174. - outb(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x3));
  42175. -}
  42176. +static void refill_rx(struct nic *nic __unused);
  42177. -inline void TLan_DioWrite16(u16 base_addr, u16 internal_addr, u16 data)
  42178. -{
  42179. - outw(internal_addr, base_addr + TLAN_DIO_ADR);
  42180. - outw(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x2));
  42181. +static int TLan_MiiReadReg(struct nic *nic __unused, u16, u16, u16 *);
  42182. +static void TLan_MiiSendData(u16, u32, unsigned);
  42183. +static void TLan_MiiSync(u16);
  42184. +static void TLan_MiiWriteReg(struct nic *nic __unused, u16, u16, u16);
  42185. -}
  42186. -inline void TLan_DioWrite32(u16 base_addr, u16 internal_addr, u32 data)
  42187. -{
  42188. - outw(internal_addr, base_addr + TLAN_DIO_ADR);
  42189. - outl(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x2));
  42190. +const char *media[] = {
  42191. + "10BaseT-HD ", "10BaseT-FD ", "100baseTx-HD ",
  42192. + "100baseTx-FD", "100baseT4", 0
  42193. +};
  42194. -}
  42195. +/* This much match tlan_pci_tbl[]! */
  42196. +enum tlan_nics {
  42197. + NETEL10 = 0, NETEL100 = 1, NETFLEX3I = 2, THUNDER = 3, NETFLEX3B =
  42198. + 4, NETEL100PI = 5,
  42199. + NETEL100D = 6, NETEL100I = 7, OC2183 = 8, OC2325 = 9, OC2326 =
  42200. + 10, NETELLIGENT_10_100_WS_5100 = 11,
  42201. + NETELLIGENT_10_T2 = 12
  42202. +};
  42203. -/* NIC specific static variables go here */
  42204. +struct pci_id_info {
  42205. + const char *name;
  42206. + int nic_id;
  42207. + struct match_info {
  42208. + u32 pci, pci_mask, subsystem, subsystem_mask;
  42209. + u32 revision, revision_mask; /* Only 8 bits. */
  42210. + } id;
  42211. + u32 flags;
  42212. + u16 addrOfs; /* Address Offset */
  42213. +};
  42214. -/*****************************************************************************
  42215. -******************************************************************************
  42216. +static struct pci_id_info tlan_pci_tbl[] = {
  42217. + {"Compaq Netelligent 10 T PCI UTP", NETEL10,
  42218. + {0xae340e11, 0xffffffff, 0, 0, 0, 0},
  42219. + TLAN_ADAPTER_ACTIVITY_LED, 0x83},
  42220. + {"Compaq Netelligent 10/100 TX PCI UTP", NETEL100,
  42221. + {0xae320e11, 0xffffffff, 0, 0, 0, 0},
  42222. + TLAN_ADAPTER_ACTIVITY_LED, 0x83},
  42223. + {"Compaq Integrated NetFlex-3/P", NETFLEX3I,
  42224. + {0xae350e11, 0xffffffff, 0, 0, 0, 0},
  42225. + TLAN_ADAPTER_NONE, 0x83},
  42226. + {"Compaq NetFlex-3/P", THUNDER,
  42227. + {0xf1300e11, 0xffffffff, 0, 0, 0, 0},
  42228. + TLAN_ADAPTER_UNMANAGED_PHY | TLAN_ADAPTER_BIT_RATE_PHY, 0x83},
  42229. + {"Compaq NetFlex-3/P", NETFLEX3B,
  42230. + {0xf1500e11, 0xffffffff, 0, 0, 0, 0},
  42231. + TLAN_ADAPTER_NONE, 0x83},
  42232. + {"Compaq Netelligent Integrated 10/100 TX UTP", NETEL100PI,
  42233. + {0xae430e11, 0xffffffff, 0, 0, 0, 0},
  42234. + TLAN_ADAPTER_ACTIVITY_LED, 0x83},
  42235. + {"Compaq Netelligent Dual 10/100 TX PCI UTP", NETEL100D,
  42236. + {0xae400e11, 0xffffffff, 0, 0, 0, 0},
  42237. + TLAN_ADAPTER_NONE, 0x83},
  42238. + {"Compaq Netelligent 10/100 TX Embedded UTP", NETEL100I,
  42239. + {0xb0110e11, 0xffffffff, 0, 0, 0, 0},
  42240. + TLAN_ADAPTER_NONE, 0x83},
  42241. + {"Olicom OC-2183/2185", OC2183,
  42242. + {0x0013108d, 0xffffffff, 0, 0, 0, 0},
  42243. + TLAN_ADAPTER_USE_INTERN_10, 0x83},
  42244. + {"Olicom OC-2325", OC2325,
  42245. + {0x0012108d, 0xffffffff, 0, 0, 0, 0},
  42246. + TLAN_ADAPTER_UNMANAGED_PHY, 0xF8},
  42247. + {"Olicom OC-2326", OC2326,
  42248. + {0x0014108d, 0xffffffff, 0, 0, 0, 0},
  42249. + TLAN_ADAPTER_USE_INTERN_10, 0xF8},
  42250. + {"Compaq Netelligent 10/100 TX UTP", NETELLIGENT_10_100_WS_5100,
  42251. + {0xb0300e11, 0xffffffff, 0, 0, 0, 0},
  42252. + TLAN_ADAPTER_ACTIVITY_LED, 0x83},
  42253. + {"Compaq Netelligent 10 T/2 PCI UTP/Coax", NETELLIGENT_10_T2,
  42254. + {0xb0120e11, 0xffffffff, 0, 0, 0, 0},
  42255. + TLAN_ADAPTER_NONE, 0x83},
  42256. + {"Compaq NetFlex-3/E", 0, /* EISA card */
  42257. + {0, 0, 0, 0, 0, 0},
  42258. + TLAN_ADAPTER_ACTIVITY_LED | TLAN_ADAPTER_UNMANAGED_PHY |
  42259. + TLAN_ADAPTER_BIT_RATE_PHY, 0x83},
  42260. + {"Compaq NetFlex-3/E", 0, /* EISA card */
  42261. + {0, 0, 0, 0, 0, 0},
  42262. + TLAN_ADAPTER_ACTIVITY_LED, 0x83},
  42263. + {0, 0,
  42264. + {0, 0, 0, 0, 0, 0},
  42265. + 0, 0},
  42266. +};
  42267. - ThunderLAN Driver Eeprom routines
  42268. - The Compaq Netelligent 10 and 10/100 cards use a Microchip 24C02A
  42269. - EEPROM. These functions are based on information in Microchip's
  42270. - data sheet. I don't know how well this functions will work with
  42271. - other EEPROMs.
  42272. +struct TLanList {
  42273. + u32 forward;
  42274. + u16 cStat;
  42275. + u16 frameSize;
  42276. + struct {
  42277. + u32 count;
  42278. + u32 address;
  42279. + } buffer[TLAN_BUFFERS_PER_LIST];
  42280. +};
  42281. -******************************************************************************
  42282. -*****************************************************************************/
  42283. - /***************************************************************
  42284. - * TLan_EeSendStart
  42285. - *
  42286. - * Returns:
  42287. - * Nothing
  42288. - * Parms:
  42289. - * io_base The IO port base address for the
  42290. - * TLAN device with the EEPROM to
  42291. - * use.
  42292. - *
  42293. - * This function sends a start cycle to an EEPROM attached
  42294. - * to a TLAN chip.
  42295. - *
  42296. - **************************************************************/
  42297. -static void TLan_EeSendStart( u16 io_base )
  42298. -{
  42299. - u16 sio;
  42300. +struct TLanList tx_ring[TLAN_NUM_TX_LISTS];
  42301. +static unsigned char txb[TLAN_MAX_FRAME_SIZE * TLAN_NUM_TX_LISTS];
  42302. - outw( TLAN_NET_SIO, io_base + TLAN_DIO_ADR );
  42303. - sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO;
  42304. +struct TLanList rx_ring[TLAN_NUM_RX_LISTS];
  42305. +static unsigned char rxb[TLAN_MAX_FRAME_SIZE * TLAN_NUM_RX_LISTS];
  42306. - TLan_SetBit( TLAN_NET_SIO_ECLOK, sio );
  42307. - TLan_SetBit( TLAN_NET_SIO_EDATA, sio );
  42308. - TLan_SetBit( TLAN_NET_SIO_ETXEN, sio );
  42309. - TLan_ClearBit( TLAN_NET_SIO_EDATA, sio );
  42310. - TLan_ClearBit( TLAN_NET_SIO_ECLOK, sio );
  42311. +typedef u8 TLanBuffer[TLAN_MAX_FRAME_SIZE];
  42312. -} /* TLan_EeSendStart */
  42313. - /***************************************************************
  42314. - * TLan_EeSendByte
  42315. - *
  42316. - * Returns:
  42317. - * If the correct ack was received, 0, otherwise 1
  42318. - * Parms: io_base The IO port base address for the
  42319. - * TLAN device with the EEPROM to
  42320. - * use.
  42321. - * data The 8 bits of information to
  42322. - * send to the EEPROM.
  42323. - * stop If TLAN_EEPROM_STOP is passed, a
  42324. - * stop cycle is sent after the
  42325. - * byte is sent after the ack is
  42326. - * read.
  42327. - *
  42328. - * This function sends a byte on the serial EEPROM line,
  42329. - * driving the clock to send each bit. The function then
  42330. - * reverses transmission direction and reads an acknowledge
  42331. - * bit.
  42332. - *
  42333. - **************************************************************/
  42334. +int chip_idx;
  42335. -static int TLan_EeSendByte( u16 io_base, u8 data, int stop )
  42336. -{
  42337. - int err;
  42338. - u8 place;
  42339. - u16 sio;
  42340. - outw( TLAN_NET_SIO, io_base + TLAN_DIO_ADR );
  42341. - sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO;
  42342. +/*****************************************************************
  42343. +* TLAN Private Information Structure
  42344. +*
  42345. +****************************************************************/
  42346. +struct tlan_private {
  42347. + unsigned short vendor_id; /* PCI Vendor code */
  42348. + unsigned short dev_id; /* PCI Device code */
  42349. + const char *nic_name;
  42350. + u8 *padBuffer;
  42351. + u8 *rxBuffer;
  42352. + struct TLanList *rx_head_desc;
  42353. + u32 rxHead;
  42354. + u32 rxTail;
  42355. + u32 rxEocCount;
  42356. + unsigned int cur_rx, dirty_rx; /* Producer/consumer ring indicies */
  42357. + unsigned int cur_tx, dirty_tx;
  42358. + unsigned rx_buf_sz; /* Based on mtu + Slack */
  42359. + struct TLanList *txList;
  42360. + struct TLanList *rxList;
  42361. + u8 *txBuffer;
  42362. + u32 txHead;
  42363. + u32 txInProgress;
  42364. + u32 txTail;
  42365. + int eoc;
  42366. + u32 txBusyCount;
  42367. + u32 phyOnline;
  42368. + u32 timerSetAt;
  42369. + u32 timerType;
  42370. + u32 adapterRev;
  42371. + u32 aui;
  42372. + u32 debug;
  42373. + u32 duplex;
  42374. + u32 phy[2];
  42375. + u32 phyNum;
  42376. + u32 speed;
  42377. + u8 tlanRev;
  42378. + u8 tlanFullDuplex;
  42379. + char devName[8];
  42380. + u8 link;
  42381. + u8 is_eisa;
  42382. + u8 neg_be_verbose;
  42383. +} TLanPrivateInfo;
  42384. - /* Assume clock is low, tx is enabled; */
  42385. - for ( place = 0x80; place != 0; place >>= 1 ) {
  42386. - if ( place & data )
  42387. - TLan_SetBit( TLAN_NET_SIO_EDATA, sio );
  42388. - else
  42389. - TLan_ClearBit( TLAN_NET_SIO_EDATA, sio );
  42390. - TLan_SetBit( TLAN_NET_SIO_ECLOK, sio );
  42391. - TLan_ClearBit( TLAN_NET_SIO_ECLOK, sio );
  42392. - }
  42393. - TLan_ClearBit( TLAN_NET_SIO_ETXEN, sio );
  42394. - TLan_SetBit( TLAN_NET_SIO_ECLOK, sio );
  42395. - err = TLan_GetBit( TLAN_NET_SIO_EDATA, sio );
  42396. - TLan_ClearBit( TLAN_NET_SIO_ECLOK, sio );
  42397. - TLan_SetBit( TLAN_NET_SIO_ETXEN, sio );
  42398. +static struct tlan_private *priv;
  42399. - if ( ( ! err ) && stop ) {
  42400. - TLan_ClearBit( TLAN_NET_SIO_EDATA, sio ); /* STOP, raise data while clock is high */
  42401. - TLan_SetBit( TLAN_NET_SIO_ECLOK, sio );
  42402. - TLan_SetBit( TLAN_NET_SIO_EDATA, sio );
  42403. - }
  42404. +u32 BASE;
  42405. - return ( err );
  42406. -} /* TLan_EeSendByte */
  42407. - /***************************************************************
  42408. - * TLan_EeReceiveByte
  42409. - *
  42410. - * Returns:
  42411. - * Nothing
  42412. - * Parms:
  42413. - * io_base The IO port base address for the
  42414. - * TLAN device with the EEPROM to
  42415. - * use.
  42416. - * data An address to a char to hold the
  42417. - * data sent from the EEPROM.
  42418. - * stop If TLAN_EEPROM_STOP is passed, a
  42419. - * stop cycle is sent after the
  42420. - * byte is received, and no ack is
  42421. - * sent.
  42422. - *
  42423. - * This function receives 8 bits of data from the EEPROM
  42424. - * over the serial link. It then sends and ack bit, or no
  42425. - * ack and a stop bit. This function is used to retrieve
  42426. - * data after the address of a byte in the EEPROM has been
  42427. - * sent.
  42428. - *
  42429. - **************************************************************/
  42430. +/***************************************************************
  42431. +* TLan_ResetLists
  42432. +*
  42433. +* Returns:
  42434. +* Nothing
  42435. +* Parms:
  42436. +* dev The device structure with the list
  42437. +* stuctures to be reset.
  42438. +*
  42439. +* This routine sets the variables associated with managing
  42440. +* the TLAN lists to their initial values.
  42441. +*
  42442. +**************************************************************/
  42443. -static void TLan_EeReceiveByte( u16 io_base, u8 *data, int stop )
  42444. +void TLan_ResetLists(struct nic *nic __unused)
  42445. {
  42446. - u8 place;
  42447. - u16 sio;
  42448. - outw( TLAN_NET_SIO, io_base + TLAN_DIO_ADR );
  42449. - sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO;
  42450. - *data = 0;
  42451. + int i;
  42452. + struct TLanList *list;
  42453. + priv->txHead = 0;
  42454. + priv->txTail = 0;
  42455. - /* Assume clock is low, tx is enabled; */
  42456. - TLan_ClearBit( TLAN_NET_SIO_ETXEN, sio );
  42457. - for ( place = 0x80; place; place >>= 1 ) {
  42458. - TLan_SetBit( TLAN_NET_SIO_ECLOK, sio );
  42459. - if ( TLan_GetBit( TLAN_NET_SIO_EDATA, sio ) )
  42460. - *data |= place;
  42461. - TLan_ClearBit( TLAN_NET_SIO_ECLOK, sio );
  42462. + for (i = 0; i < TLAN_NUM_TX_LISTS; i++) {
  42463. + list = &tx_ring[i];
  42464. + list->cStat = TLAN_CSTAT_UNUSED;
  42465. +/* list->buffer[0].address = 0; */
  42466. + list->buffer[0].address = virt_to_bus(txb +
  42467. + (i * TLAN_MAX_FRAME_SIZE));
  42468. + list->buffer[2].count = 0;
  42469. + list->buffer[2].address = 0;
  42470. + list->buffer[9].address = 0;
  42471. +/* list->forward = 0; */
  42472. }
  42473. - TLan_SetBit( TLAN_NET_SIO_ETXEN, sio );
  42474. - if ( ! stop ) {
  42475. - TLan_ClearBit( TLAN_NET_SIO_EDATA, sio ); /* Ack = 0 */
  42476. - TLan_SetBit( TLAN_NET_SIO_ECLOK, sio );
  42477. - TLan_ClearBit( TLAN_NET_SIO_ECLOK, sio );
  42478. - } else {
  42479. - TLan_SetBit( TLAN_NET_SIO_EDATA, sio ); /* No ack = 1 (?) */
  42480. - TLan_SetBit( TLAN_NET_SIO_ECLOK, sio );
  42481. - TLan_ClearBit( TLAN_NET_SIO_ECLOK, sio );
  42482. - TLan_ClearBit( TLAN_NET_SIO_EDATA, sio ); /* STOP, raise data while clock is high */
  42483. - TLan_SetBit( TLAN_NET_SIO_ECLOK, sio );
  42484. - TLan_SetBit( TLAN_NET_SIO_EDATA, sio );
  42485. - }
  42486. + priv->cur_rx = 0;
  42487. + priv->rx_buf_sz = (TLAN_MAX_FRAME_SIZE);
  42488. + priv->rx_head_desc = &rx_ring[0];
  42489. +
  42490. + /* Initialize all the Rx descriptors */
  42491. + for (i = 0; i < TLAN_NUM_RX_LISTS; i++) {
  42492. + rx_ring[i].forward = virt_to_le32desc(&rx_ring[i + 1]);
  42493. + rx_ring[i].cStat = TLAN_CSTAT_READY;
  42494. + rx_ring[i].frameSize = TLAN_MAX_FRAME_SIZE;
  42495. + rx_ring[i].buffer[0].count =
  42496. + TLAN_MAX_FRAME_SIZE | TLAN_LAST_BUFFER;
  42497. + rx_ring[i].buffer[0].address =
  42498. + virt_to_le32desc(&rxb[i * TLAN_MAX_FRAME_SIZE]);
  42499. + rx_ring[i].buffer[1].count = 0;
  42500. + rx_ring[i].buffer[1].address = 0;
  42501. + }
  42502. +
  42503. + /* Mark the last entry as wrapping the ring */
  42504. + rx_ring[i - 1].forward = virt_to_le32desc(&rx_ring[0]);
  42505. + priv->dirty_rx = (unsigned int) (i - TLAN_NUM_RX_LISTS);
  42506. -} /* TLan_EeReceiveByte */
  42507. +} /* TLan_ResetLists */
  42508. - /***************************************************************
  42509. - * TLan_EeReadByte
  42510. - *
  42511. - * Returns:
  42512. - * No error = 0, else, the stage at which the error
  42513. - * occurred.
  42514. - * Parms:
  42515. - * io_base The IO port base address for the
  42516. - * TLAN device with the EEPROM to
  42517. - * use.
  42518. - * ee_addr The address of the byte in the
  42519. - * EEPROM whose contents are to be
  42520. - * retrieved.
  42521. - * data An address to a char to hold the
  42522. - * data obtained from the EEPROM.
  42523. - *
  42524. - * This function reads a byte of information from an byte
  42525. - * cell in the EEPROM.
  42526. - *
  42527. - **************************************************************/
  42528. +/***************************************************************
  42529. +* TLan_Reset
  42530. +*
  42531. +* Returns:
  42532. +* 0
  42533. +* Parms:
  42534. +* dev Pointer to device structure of adapter
  42535. +* to be reset.
  42536. +*
  42537. +* This function resets the adapter and it's physical
  42538. +* device. See Chap. 3, pp. 9-10 of the "ThunderLAN
  42539. +* Programmer's Guide" for details. The routine tries to
  42540. +* implement what is detailed there, though adjustments
  42541. +* have been made.
  42542. +*
  42543. +**************************************************************/
  42544. -static int TLan_EeReadByte( u16 io_base, u8 ee_addr, u8 *data )
  42545. +void TLan_ResetAdapter(struct nic *nic __unused)
  42546. {
  42547. - int err;
  42548. - unsigned long flags = 0;
  42549. - int ret=0;
  42550. + int i;
  42551. + u32 addr;
  42552. + u32 data;
  42553. + u8 data8;
  42554. - TLan_EeSendStart( io_base );
  42555. - err = TLan_EeSendByte( io_base, 0xA0, TLAN_EEPROM_ACK );
  42556. - if (err)
  42557. - {
  42558. - ret=1;
  42559. - goto fail;
  42560. - }
  42561. - err = TLan_EeSendByte( io_base, ee_addr, TLAN_EEPROM_ACK );
  42562. - if (err)
  42563. - {
  42564. - ret=2;
  42565. - goto fail;
  42566. - }
  42567. - TLan_EeSendStart( io_base );
  42568. - err = TLan_EeSendByte( io_base, 0xA1, TLAN_EEPROM_ACK );
  42569. - if (err)
  42570. - {
  42571. - ret=3;
  42572. - goto fail;
  42573. - }
  42574. - TLan_EeReceiveByte( io_base, data, TLAN_EEPROM_STOP );
  42575. -fail:
  42576. + priv->tlanFullDuplex = FALSE;
  42577. + priv->phyOnline = 0;
  42578. +/* 1. Assert reset bit. */
  42579. - return ret;
  42580. + data = inl(BASE + TLAN_HOST_CMD);
  42581. + data |= TLAN_HC_AD_RST;
  42582. + outl(data, BASE + TLAN_HOST_CMD);
  42583. -} /* TLan_EeReadByte */
  42584. + udelay(1000);
  42585. -#if 0
  42586. -/* Not yet converted from Linux driver */
  42587. -/*****************************************************************************
  42588. -******************************************************************************
  42589. +/* 2. Turn off interrupts. ( Probably isn't necessary ) */
  42590. - ThunderLAN Driver PHY Layer Routines
  42591. + data = inl(BASE + TLAN_HOST_CMD);
  42592. + data |= TLAN_HC_INT_OFF;
  42593. + outl(data, BASE + TLAN_HOST_CMD);
  42594. +/* 3. Clear AREGs and HASHs. */
  42595. -******************************************************************************
  42596. -*****************************************************************************/
  42597. + for (i = TLAN_AREG_0; i <= TLAN_HASH_2; i += 4) {
  42598. + TLan_DioWrite32(BASE, (u16) i, 0);
  42599. + }
  42600. - /*********************************************************************
  42601. - * TLan_PhyPrint
  42602. - *
  42603. - * Returns:
  42604. - * Nothing
  42605. - * Parms:
  42606. - * dev A pointer to the device structure of the
  42607. - * TLAN device having the PHYs to be detailed.
  42608. - *
  42609. - * This function prints the registers a PHY (aka tranceiver).
  42610. - *
  42611. - ********************************************************************/
  42612. +/* 4. Setup NetConfig register. */
  42613. -void TLan_PhyPrint( struct net_device *dev )
  42614. -{
  42615. - TLanPrivateInfo *priv = dev->priv;
  42616. - u16 i, data0, data1, data2, data3, phy;
  42617. + data =
  42618. + TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN | TLAN_NET_CFG_PHY_EN;
  42619. + TLan_DioWrite16(BASE, TLAN_NET_CONFIG, (u16) data);
  42620. - phy = priv->phy[priv->phyNum];
  42621. +/* 5. Load Ld_Tmr and Ld_Thr in HOST_CMD. */
  42622. - if ( priv->adapter->flags & TLAN_ADAPTER_UNMANAGED_PHY ) {
  42623. - printk( "TLAN: Device %s, Unmanaged PHY.\n", dev->name );
  42624. - } else if ( phy <= TLAN_PHY_MAX_ADDR ) {
  42625. - printk( "TLAN: Device %s, PHY 0x%02x.\n", dev->name, phy );
  42626. - printk( "TLAN: Off. +0 +1 +2 +3 \n" );
  42627. - for ( i = 0; i < 0x20; i+= 4 ) {
  42628. - printk( "TLAN: 0x%02x", i );
  42629. - TLan_MiiReadReg( dev, phy, i, &data0 );
  42630. - printk( " 0x%04hx", data0 );
  42631. - TLan_MiiReadReg( dev, phy, i + 1, &data1 );
  42632. - printk( " 0x%04hx", data1 );
  42633. - TLan_MiiReadReg( dev, phy, i + 2, &data2 );
  42634. - printk( " 0x%04hx", data2 );
  42635. - TLan_MiiReadReg( dev, phy, i + 3, &data3 );
  42636. - printk( " 0x%04hx\n", data3 );
  42637. - }
  42638. - } else {
  42639. - printk( "TLAN: Device %s, Invalid PHY.\n", dev->name );
  42640. - }
  42641. + outl(TLAN_HC_LD_TMR | 0x3f, BASE + TLAN_HOST_CMD);
  42642. + outl(TLAN_HC_LD_THR | 0x0, BASE + TLAN_HOST_CMD);
  42643. -} /* TLan_PhyPrint */
  42644. +/* 6. Unreset the MII by setting NMRST (in NetSio) to 1. */
  42645. - /*********************************************************************
  42646. - * TLan_PhyDetect
  42647. - *
  42648. - * Returns:
  42649. - * Nothing
  42650. - * Parms:
  42651. - * dev A pointer to the device structure of the adapter
  42652. - * for which the PHY needs determined.
  42653. - *
  42654. - * So far I've found that adapters which have external PHYs
  42655. - * may also use the internal PHY for part of the functionality.
  42656. - * (eg, AUI/Thinnet). This function finds out if this TLAN
  42657. - * chip has an internal PHY, and then finds the first external
  42658. - * PHY (starting from address 0) if it exists).
  42659. - *
  42660. - ********************************************************************/
  42661. + outw(TLAN_NET_SIO, BASE + TLAN_DIO_ADR);
  42662. + addr = BASE + TLAN_DIO_DATA + TLAN_NET_SIO;
  42663. + TLan_SetBit(TLAN_NET_SIO_NMRST, addr);
  42664. -void TLan_PhyDetect( struct net_device *dev )
  42665. -{
  42666. - TLanPrivateInfo *priv = dev->priv;
  42667. - u16 control;
  42668. - u16 hi;
  42669. - u16 lo;
  42670. - u32 phy;
  42671. +/* 7. Setup the remaining registers. */
  42672. - if ( priv->adapter->flags & TLAN_ADAPTER_UNMANAGED_PHY ) {
  42673. - priv->phyNum = 0xFFFF;
  42674. - return;
  42675. + if (priv->tlanRev >= 0x30) {
  42676. + data8 = TLAN_ID_TX_EOC | TLAN_ID_RX_EOC;
  42677. + TLan_DioWrite8(BASE, TLAN_INT_DIS, data8);
  42678. }
  42679. + TLan_PhyDetect(nic);
  42680. + data = TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN;
  42681. - TLan_MiiReadReg( dev, TLAN_PHY_MAX_ADDR, MII_GEN_ID_HI, &hi );
  42682. -
  42683. - if ( hi != 0xFFFF ) {
  42684. - priv->phy[0] = TLAN_PHY_MAX_ADDR;
  42685. - } else {
  42686. - priv->phy[0] = TLAN_PHY_NONE;
  42687. + if (tlan_pci_tbl[chip_idx].flags & TLAN_ADAPTER_BIT_RATE_PHY) {
  42688. + data |= TLAN_NET_CFG_BIT;
  42689. + if (priv->aui == 1) {
  42690. + TLan_DioWrite8(BASE, TLAN_ACOMMIT, 0x0a);
  42691. + } else if (priv->duplex == TLAN_DUPLEX_FULL) {
  42692. + TLan_DioWrite8(BASE, TLAN_ACOMMIT, 0x00);
  42693. + priv->tlanFullDuplex = TRUE;
  42694. + } else {
  42695. + TLan_DioWrite8(BASE, TLAN_ACOMMIT, 0x08);
  42696. + }
  42697. }
  42698. - priv->phy[1] = TLAN_PHY_NONE;
  42699. - for ( phy = 0; phy <= TLAN_PHY_MAX_ADDR; phy++ ) {
  42700. - TLan_MiiReadReg( dev, phy, MII_GEN_CTL, &control );
  42701. - TLan_MiiReadReg( dev, phy, MII_GEN_ID_HI, &hi );
  42702. - TLan_MiiReadReg( dev, phy, MII_GEN_ID_LO, &lo );
  42703. - if ( ( control != 0xFFFF ) || ( hi != 0xFFFF ) || ( lo != 0xFFFF ) ) {
  42704. - TLAN_DBG( TLAN_DEBUG_GNRL, "PHY found at %02x %04x %04x %04x\n", phy, control, hi, lo );
  42705. - if ( ( priv->phy[1] == TLAN_PHY_NONE ) && ( phy != TLAN_PHY_MAX_ADDR ) ) {
  42706. - priv->phy[1] = phy;
  42707. - }
  42708. - }
  42709. + if (priv->phyNum == 0) {
  42710. + data |= TLAN_NET_CFG_PHY_EN;
  42711. }
  42712. + TLan_DioWrite16(BASE, TLAN_NET_CONFIG, (u16) data);
  42713. - if ( priv->phy[1] != TLAN_PHY_NONE ) {
  42714. - priv->phyNum = 1;
  42715. - } else if ( priv->phy[0] != TLAN_PHY_NONE ) {
  42716. - priv->phyNum = 0;
  42717. + if (tlan_pci_tbl[chip_idx].flags & TLAN_ADAPTER_UNMANAGED_PHY) {
  42718. + TLan_FinishReset(nic);
  42719. } else {
  42720. - printk( "TLAN: Cannot initialize device, no PHY was found!\n" );
  42721. + TLan_PhyPowerDown(nic);
  42722. }
  42723. -} /* TLan_PhyDetect */
  42724. +} /* TLan_ResetAdapter */
  42725. -void TLan_PhyPowerDown( struct net_device *dev )
  42726. +void TLan_FinishReset(struct nic *nic)
  42727. {
  42728. - TLanPrivateInfo *priv = dev->priv;
  42729. - u16 value;
  42730. - TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Powering down PHY(s).\n", dev->name );
  42731. - value = MII_GC_PDOWN | MII_GC_LOOPBK | MII_GC_ISOLATE;
  42732. - TLan_MiiSync( dev->base_addr );
  42733. - TLan_MiiWriteReg( dev, priv->phy[priv->phyNum], MII_GEN_CTL, value );
  42734. - if ( ( priv->phyNum == 0 ) && ( priv->phy[1] != TLAN_PHY_NONE ) && ( ! ( priv->adapter->flags & TLAN_ADAPTER_USE_INTERN_10 ) ) ) {
  42735. - TLan_MiiSync( dev->base_addr );
  42736. - TLan_MiiWriteReg( dev, priv->phy[1], MII_GEN_CTL, value );
  42737. + u8 data;
  42738. + u32 phy;
  42739. + u8 sio;
  42740. + u16 status;
  42741. + u16 partner;
  42742. + u16 tlphy_ctl;
  42743. + u16 tlphy_par;
  42744. + u16 tlphy_id1, tlphy_id2;
  42745. + int i;
  42746. +
  42747. + phy = priv->phy[priv->phyNum];
  42748. +
  42749. + data = TLAN_NET_CMD_NRESET | TLAN_NET_CMD_NWRAP;
  42750. + if (priv->tlanFullDuplex) {
  42751. + data |= TLAN_NET_CMD_DUPLEX;
  42752. }
  42753. + TLan_DioWrite8(BASE, TLAN_NET_CMD, data);
  42754. + data = TLAN_NET_MASK_MASK4 | TLAN_NET_MASK_MASK5;
  42755. + if (priv->phyNum == 0) {
  42756. + data |= TLAN_NET_MASK_MASK7;
  42757. + }
  42758. + TLan_DioWrite8(BASE, TLAN_NET_MASK, data);
  42759. + TLan_DioWrite16(BASE, TLAN_MAX_RX, ((1536) + 7) & ~7);
  42760. + TLan_MiiReadReg(nic, phy, MII_GEN_ID_HI, &tlphy_id1);
  42761. + TLan_MiiReadReg(nic, phy, MII_GEN_ID_LO, &tlphy_id2);
  42762. - /* Wait for 50 ms and powerup
  42763. - * This is abitrary. It is intended to make sure the
  42764. - * tranceiver settles.
  42765. - */
  42766. - TLan_SetTimer( dev, (HZ/20), TLAN_TIMER_PHY_PUP );
  42767. + if ((tlan_pci_tbl[chip_idx].flags & TLAN_ADAPTER_UNMANAGED_PHY)
  42768. + || (priv->aui)) {
  42769. + status = MII_GS_LINK;
  42770. + printf("TLAN: %s: Link forced.\n", priv->nic_name);
  42771. + } else {
  42772. + TLan_MiiReadReg(nic, phy, MII_GEN_STS, &status);
  42773. + udelay(1000);
  42774. + TLan_MiiReadReg(nic, phy, MII_GEN_STS, &status);
  42775. + if ((status & MII_GS_LINK) && /* We only support link info on Nat.Sem. PHY's */
  42776. + (tlphy_id1 == NAT_SEM_ID1)
  42777. + && (tlphy_id2 == NAT_SEM_ID2)) {
  42778. + TLan_MiiReadReg(nic, phy, MII_AN_LPA, &partner);
  42779. + TLan_MiiReadReg(nic, phy, TLAN_TLPHY_PAR,
  42780. + &tlphy_par);
  42781. -} /* TLan_PhyPowerDown */
  42782. + printf("TLAN: %s: Link active with ",
  42783. + priv->nic_name);
  42784. + if (!(tlphy_par & TLAN_PHY_AN_EN_STAT)) {
  42785. + printf("forced 10%sMbps %s-Duplex\n",
  42786. + tlphy_par & TLAN_PHY_SPEED_100 ? ""
  42787. + : "0",
  42788. + tlphy_par & TLAN_PHY_DUPLEX_FULL ?
  42789. + "Full" : "Half");
  42790. + } else {
  42791. + printf
  42792. + ("AutoNegotiation enabled, at 10%sMbps %s-Duplex\n",
  42793. + tlphy_par & TLAN_PHY_SPEED_100 ? "" :
  42794. + "0",
  42795. + tlphy_par & TLAN_PHY_DUPLEX_FULL ?
  42796. + "Full" : "Half");
  42797. + printf("TLAN: Partner capability: ");
  42798. + for (i = 5; i <= 10; i++)
  42799. + if (partner & (1 << i))
  42800. + printf("%s", media[i - 5]);
  42801. + printf("\n");
  42802. + }
  42803. -void TLan_PhyPowerUp( struct net_device *dev )
  42804. -{
  42805. - TLanPrivateInfo *priv = dev->priv;
  42806. - u16 value;
  42807. + TLan_DioWrite8(BASE, TLAN_LED_REG, TLAN_LED_LINK);
  42808. +#ifdef MONITOR
  42809. + /* We have link beat..for now anyway */
  42810. + priv->link = 1;
  42811. + /*Enabling link beat monitoring */
  42812. + /* TLan_SetTimer( nic, (10*HZ), TLAN_TIMER_LINK_BEAT ); */
  42813. + mdelay(10000);
  42814. + TLan_PhyMonitor(nic);
  42815. +#endif
  42816. + } else if (status & MII_GS_LINK) {
  42817. + printf("TLAN: %s: Link active\n", priv->nic_name);
  42818. + TLan_DioWrite8(BASE, TLAN_LED_REG, TLAN_LED_LINK);
  42819. + }
  42820. + }
  42821. - TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Powering up PHY.\n", dev->name );
  42822. - TLan_MiiSync( dev->base_addr );
  42823. - value = MII_GC_LOOPBK;
  42824. - TLan_MiiWriteReg( dev, priv->phy[priv->phyNum], MII_GEN_CTL, value );
  42825. - TLan_MiiSync(dev->base_addr);
  42826. - /* Wait for 500 ms and reset the
  42827. - * tranceiver. The TLAN docs say both 50 ms and
  42828. - * 500 ms, so do the longer, just in case.
  42829. - */
  42830. - TLan_SetTimer( dev, (HZ/20), TLAN_TIMER_PHY_RESET );
  42831. + if (priv->phyNum == 0) {
  42832. + TLan_MiiReadReg(nic, phy, TLAN_TLPHY_CTL, &tlphy_ctl);
  42833. + tlphy_ctl |= TLAN_TC_INTEN;
  42834. + TLan_MiiWriteReg(nic, phy, TLAN_TLPHY_CTL, tlphy_ctl);
  42835. + sio = TLan_DioRead8(BASE, TLAN_NET_SIO);
  42836. + sio |= TLAN_NET_SIO_MINTEN;
  42837. + TLan_DioWrite8(BASE, TLAN_NET_SIO, sio);
  42838. + }
  42839. -} /* TLan_PhyPowerUp */
  42840. + if (status & MII_GS_LINK) {
  42841. + TLan_SetMac(nic, 0, nic->node_addr);
  42842. + priv->phyOnline = 1;
  42843. + outb((TLAN_HC_INT_ON >> 8), BASE + TLAN_HOST_CMD + 1);
  42844. +/* if ( debug >= 1 && debug != TLAN_DEBUG_PROBE ) {
  42845. + outb( ( TLAN_HC_REQ_INT >> 8 ), BASE + TLAN_HOST_CMD + 1 );
  42846. + }
  42847. -void TLan_PhyReset( struct net_device *dev )
  42848. -{
  42849. - TLanPrivateInfo *priv = dev->priv;
  42850. - u16 phy;
  42851. - u16 value;
  42852. + */
  42853. + outl(virt_to_bus(&rx_ring), BASE + TLAN_CH_PARM);
  42854. + outl(TLAN_HC_GO | TLAN_HC_RT, BASE + TLAN_HOST_CMD);
  42855. + } else {
  42856. + printf
  42857. + ("TLAN: %s: Link inactive, will retry in 10 secs...\n",
  42858. + priv->nic_name);
  42859. + /* TLan_SetTimer( nic, (10*HZ), TLAN_TIMER_FINISH_RESET ); */
  42860. + mdelay(10000);
  42861. + TLan_FinishReset(nic);
  42862. + return;
  42863. - phy = priv->phy[priv->phyNum];
  42864. + }
  42865. - TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Reseting PHY.\n", dev->name );
  42866. - TLan_MiiSync( dev->base_addr );
  42867. - value = MII_GC_LOOPBK | MII_GC_RESET;
  42868. - TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, value );
  42869. - TLan_MiiReadReg( dev, phy, MII_GEN_CTL, &value );
  42870. - while ( value & MII_GC_RESET ) {
  42871. - TLan_MiiReadReg( dev, phy, MII_GEN_CTL, &value );
  42872. - }
  42873. -
  42874. - /* Wait for 500 ms and initialize.
  42875. - * I don't remember why I wait this long.
  42876. - * I've changed this to 50ms, as it seems long enough.
  42877. - */
  42878. - TLan_SetTimer( dev, (HZ/20), TLAN_TIMER_PHY_START_LINK );
  42879. -
  42880. -} /* TLan_PhyReset */
  42881. -
  42882. -void TLan_PhyStartLink( struct net_device *dev )
  42883. -{
  42884. - TLanPrivateInfo *priv = dev->priv;
  42885. - u16 ability;
  42886. - u16 control;
  42887. - u16 data;
  42888. - u16 phy;
  42889. - u16 status;
  42890. - u16 tctl;
  42891. -
  42892. - phy = priv->phy[priv->phyNum];
  42893. - TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Trying to activate link.\n", dev->name );
  42894. - TLan_MiiReadReg( dev, phy, MII_GEN_STS, &status );
  42895. - TLan_MiiReadReg( dev, phy, MII_GEN_STS, &ability );
  42896. -
  42897. - if ( ( status & MII_GS_AUTONEG ) &&
  42898. - ( ! priv->aui ) ) {
  42899. - ability = status >> 11;
  42900. - if ( priv->speed == TLAN_SPEED_10 &&
  42901. - priv->duplex == TLAN_DUPLEX_HALF) {
  42902. - TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, 0x0000);
  42903. - } else if ( priv->speed == TLAN_SPEED_10 &&
  42904. - priv->duplex == TLAN_DUPLEX_FULL) {
  42905. - priv->tlanFullDuplex = TRUE;
  42906. - TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, 0x0100);
  42907. - } else if ( priv->speed == TLAN_SPEED_100 &&
  42908. - priv->duplex == TLAN_DUPLEX_HALF) {
  42909. - TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, 0x2000);
  42910. - } else if ( priv->speed == TLAN_SPEED_100 &&
  42911. - priv->duplex == TLAN_DUPLEX_FULL) {
  42912. - priv->tlanFullDuplex = TRUE;
  42913. - TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, 0x2100);
  42914. - } else {
  42915. -
  42916. - /* Set Auto-Neg advertisement */
  42917. - TLan_MiiWriteReg( dev, phy, MII_AN_ADV, (ability << 5) | 1);
  42918. - /* Enablee Auto-Neg */
  42919. - TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, 0x1000 );
  42920. - /* Restart Auto-Neg */
  42921. - TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, 0x1200 );
  42922. - /* Wait for 4 sec for autonegotiation
  42923. - * to complete. The max spec time is less than this
  42924. - * but the card need additional time to start AN.
  42925. - * .5 sec should be plenty extra.
  42926. - */
  42927. - printk( "TLAN: %s: Starting autonegotiation.\n", dev->name );
  42928. - TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_PHY_FINISH_AN );
  42929. - return;
  42930. - }
  42931. -
  42932. - }
  42933. -
  42934. - if ( ( priv->aui ) && ( priv->phyNum != 0 ) ) {
  42935. - priv->phyNum = 0;
  42936. - data = TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN | TLAN_NET_CFG_PHY_EN;
  42937. - TLan_DioWrite16( dev->base_addr, TLAN_NET_CONFIG, data );
  42938. - TLan_SetTimer( dev, (40*HZ/1000), TLAN_TIMER_PHY_PDOWN );
  42939. - return;
  42940. - } else if ( priv->phyNum == 0 ) {
  42941. - TLan_MiiReadReg( dev, phy, TLAN_TLPHY_CTL, &tctl );
  42942. - if ( priv->aui ) {
  42943. - tctl |= TLAN_TC_AUISEL;
  42944. - } else {
  42945. - tctl &= ~TLAN_TC_AUISEL;
  42946. - control = 0;
  42947. - if ( priv->duplex == TLAN_DUPLEX_FULL ) {
  42948. - control |= MII_GC_DUPLEX;
  42949. - priv->tlanFullDuplex = TRUE;
  42950. - }
  42951. - if ( priv->speed == TLAN_SPEED_100 ) {
  42952. - control |= MII_GC_SPEEDSEL;
  42953. - }
  42954. - TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, control );
  42955. - }
  42956. - TLan_MiiWriteReg( dev, phy, TLAN_TLPHY_CTL, tctl );
  42957. - }
  42958. -
  42959. - /* Wait for 2 sec to give the tranceiver time
  42960. - * to establish link.
  42961. - */
  42962. - TLan_SetTimer( dev, (4*HZ), TLAN_TIMER_FINISH_RESET );
  42963. -
  42964. -} /* TLan_PhyStartLink */
  42965. -
  42966. -void TLan_PhyFinishAutoNeg( struct net_device *dev )
  42967. -{
  42968. - TLanPrivateInfo *priv = dev->priv;
  42969. - u16 an_adv;
  42970. - u16 an_lpa;
  42971. - u16 data;
  42972. - u16 mode;
  42973. - u16 phy;
  42974. - u16 status;
  42975. -
  42976. - phy = priv->phy[priv->phyNum];
  42977. -
  42978. - TLan_MiiReadReg( dev, phy, MII_GEN_STS, &status );
  42979. - udelay( 1000 );
  42980. - TLan_MiiReadReg( dev, phy, MII_GEN_STS, &status );
  42981. -
  42982. - if ( ! ( status & MII_GS_AUTOCMPLT ) ) {
  42983. - /* Wait for 8 sec to give the process
  42984. - * more time. Perhaps we should fail after a while.
  42985. - */
  42986. - if (!priv->neg_be_verbose++) {
  42987. - printk(KERN_INFO "TLAN: Giving autonegotiation more time.\n");
  42988. - printk(KERN_INFO "TLAN: Please check that your adapter has\n");
  42989. - printk(KERN_INFO "TLAN: been properly connected to a HUB or Switch.\n");
  42990. - printk(KERN_INFO "TLAN: Trying to establish link in the background...\n");
  42991. - }
  42992. - TLan_SetTimer( dev, (8*HZ), TLAN_TIMER_PHY_FINISH_AN );
  42993. - return;
  42994. - }
  42995. -
  42996. - printk( "TLAN: %s: Autonegotiation complete.\n", dev->name );
  42997. - TLan_MiiReadReg( dev, phy, MII_AN_ADV, &an_adv );
  42998. - TLan_MiiReadReg( dev, phy, MII_AN_LPA, &an_lpa );
  42999. - mode = an_adv & an_lpa & 0x03E0;
  43000. - if ( mode & 0x0100 ) {
  43001. - priv->tlanFullDuplex = TRUE;
  43002. - } else if ( ! ( mode & 0x0080 ) && ( mode & 0x0040 ) ) {
  43003. - priv->tlanFullDuplex = TRUE;
  43004. - }
  43005. -
  43006. - if ( ( ! ( mode & 0x0180 ) ) && ( priv->adapter->flags & TLAN_ADAPTER_USE_INTERN_10 ) && ( priv->phyNum != 0 ) ) {
  43007. - priv->phyNum = 0;
  43008. - data = TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN | TLAN_NET_CFG_PHY_EN;
  43009. - TLan_DioWrite16( dev->base_addr, TLAN_NET_CONFIG, data );
  43010. - TLan_SetTimer( dev, (400*HZ/1000), TLAN_TIMER_PHY_PDOWN );
  43011. - return;
  43012. - }
  43013. -
  43014. - if ( priv->phyNum == 0 ) {
  43015. - if ( ( priv->duplex == TLAN_DUPLEX_FULL ) || ( an_adv & an_lpa & 0x0040 ) ) {
  43016. - TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, MII_GC_AUTOENB | MII_GC_DUPLEX );
  43017. - printk( "TLAN: Starting internal PHY with FULL-DUPLEX\n" );
  43018. - } else {
  43019. - TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, MII_GC_AUTOENB );
  43020. - printk( "TLAN: Starting internal PHY with HALF-DUPLEX\n" );
  43021. - }
  43022. - }
  43023. -
  43024. - /* Wait for 100 ms. No reason in partiticular.
  43025. - */
  43026. - TLan_SetTimer( dev, (HZ/10), TLAN_TIMER_FINISH_RESET );
  43027. -
  43028. -} /* TLan_PhyFinishAutoNeg */
  43029. -
  43030. -#ifdef MONITOR
  43031. -
  43032. - /*********************************************************************
  43033. - *
  43034. - * TLan_phyMonitor
  43035. - *
  43036. - * Returns:
  43037. - * None
  43038. - *
  43039. - * Params:
  43040. - * dev The device structure of this device.
  43041. - *
  43042. - *
  43043. - * This function monitors PHY condition by reading the status
  43044. - * register via the MII bus. This can be used to give info
  43045. - * about link changes (up/down), and possible switch to alternate
  43046. - * media.
  43047. - *
  43048. - * ******************************************************************/
  43049. -
  43050. -void TLan_PhyMonitor( struct net_device *dev )
  43051. -{
  43052. - TLanPrivateInfo *priv = dev->priv;
  43053. - u16 phy;
  43054. - u16 phy_status;
  43055. -
  43056. - phy = priv->phy[priv->phyNum];
  43057. -
  43058. - /* Get PHY status register */
  43059. - TLan_MiiReadReg( dev, phy, MII_GEN_STS, &phy_status );
  43060. -
  43061. - /* Check if link has been lost */
  43062. - if (!(phy_status & MII_GS_LINK)) {
  43063. - if (priv->link) {
  43064. - priv->link = 0;
  43065. - printk(KERN_DEBUG "TLAN: %s has lost link\n", dev->name);
  43066. - dev->flags &= ~IFF_RUNNING;
  43067. - TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_LINK_BEAT );
  43068. - return;
  43069. - }
  43070. - }
  43071. -
  43072. - /* Link restablished? */
  43073. - if ((phy_status & MII_GS_LINK) && !priv->link) {
  43074. - priv->link = 1;
  43075. - printk(KERN_DEBUG "TLAN: %s has reestablished link\n", dev->name);
  43076. - dev->flags |= IFF_RUNNING;
  43077. - }
  43078. -
  43079. - /* Setup a new monitor */
  43080. - TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_LINK_BEAT );
  43081. -}
  43082. -
  43083. -#endif /* MONITOR */
  43084. -
  43085. -/*****************************************************************************
  43086. -******************************************************************************
  43087. -
  43088. - ThunderLAN Driver MII Routines
  43089. -
  43090. - These routines are based on the information in Chap. 2 of the
  43091. - "ThunderLAN Programmer's Guide", pp. 15-24.
  43092. -
  43093. -******************************************************************************
  43094. -*****************************************************************************/
  43095. -
  43096. - /***************************************************************
  43097. - * TLan_MiiReadReg
  43098. - *
  43099. - * Returns:
  43100. - * 0 if ack received ok
  43101. - * 1 otherwise.
  43102. - *
  43103. - * Parms:
  43104. - * dev The device structure containing
  43105. - * The io address and interrupt count
  43106. - * for this device.
  43107. - * phy The address of the PHY to be queried.
  43108. - * reg The register whose contents are to be
  43109. - * retreived.
  43110. - * val A pointer to a variable to store the
  43111. - * retrieved value.
  43112. - *
  43113. - * This function uses the TLAN's MII bus to retreive the contents
  43114. - * of a given register on a PHY. It sends the appropriate info
  43115. - * and then reads the 16-bit register value from the MII bus via
  43116. - * the TLAN SIO register.
  43117. - *
  43118. - **************************************************************/
  43119. -
  43120. -int TLan_MiiReadReg( struct net_device *dev, u16 phy, u16 reg, u16 *val )
  43121. -{
  43122. - u8 nack;
  43123. - u16 sio, tmp;
  43124. - u32 i;
  43125. - int err;
  43126. - int minten;
  43127. - TLanPrivateInfo *priv = dev->priv;
  43128. - unsigned long flags = 0;
  43129. -
  43130. - err = FALSE;
  43131. - outw(TLAN_NET_SIO, dev->base_addr + TLAN_DIO_ADR);
  43132. - sio = dev->base_addr + TLAN_DIO_DATA + TLAN_NET_SIO;
  43133. -
  43134. - if (!in_irq())
  43135. - spin_lock_irqsave(&priv->lock, flags);
  43136. -
  43137. - TLan_MiiSync(dev->base_addr);
  43138. -
  43139. - minten = TLan_GetBit( TLAN_NET_SIO_MINTEN, sio );
  43140. - if ( minten )
  43141. - TLan_ClearBit(TLAN_NET_SIO_MINTEN, sio);
  43142. -
  43143. - TLan_MiiSendData( dev->base_addr, 0x1, 2 ); /* Start ( 01b ) */
  43144. - TLan_MiiSendData( dev->base_addr, 0x2, 2 ); /* Read ( 10b ) */
  43145. - TLan_MiiSendData( dev->base_addr, phy, 5 ); /* Device # */
  43146. - TLan_MiiSendData( dev->base_addr, reg, 5 ); /* Register # */
  43147. -
  43148. - TLan_ClearBit(TLAN_NET_SIO_MTXEN, sio); /* Change direction */
  43149. -
  43150. - TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Clock Idle bit */
  43151. - TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  43152. - TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Wait 300ns */
  43153. -
  43154. - nack = TLan_GetBit(TLAN_NET_SIO_MDATA, sio); /* Check for ACK */
  43155. - TLan_SetBit(TLAN_NET_SIO_MCLK, sio); /* Finish ACK */
  43156. - if (nack) { /* No ACK, so fake it */
  43157. - for (i = 0; i < 16; i++) {
  43158. - TLan_ClearBit(TLAN_NET_SIO_MCLK, sio);
  43159. - TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  43160. - }
  43161. - tmp = 0xffff;
  43162. - err = TRUE;
  43163. - } else { /* ACK, so read data */
  43164. - for (tmp = 0, i = 0x8000; i; i >>= 1) {
  43165. - TLan_ClearBit(TLAN_NET_SIO_MCLK, sio);
  43166. - if (TLan_GetBit(TLAN_NET_SIO_MDATA, sio))
  43167. - tmp |= i;
  43168. - TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  43169. - }
  43170. - }
  43171. -
  43172. - TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Idle cycle */
  43173. - TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  43174. -
  43175. - if ( minten )
  43176. - TLan_SetBit(TLAN_NET_SIO_MINTEN, sio);
  43177. -
  43178. - *val = tmp;
  43179. -
  43180. - if (!in_irq())
  43181. - spin_unlock_irqrestore(&priv->lock, flags);
  43182. -
  43183. - return err;
  43184. -
  43185. -} /* TLan_MiiReadReg */
  43186. -
  43187. - /***************************************************************
  43188. - * TLan_MiiSendData
  43189. - *
  43190. - * Returns:
  43191. - * Nothing
  43192. - * Parms:
  43193. - * base_port The base IO port of the adapter in
  43194. - * question.
  43195. - * dev The address of the PHY to be queried.
  43196. - * data The value to be placed on the MII bus.
  43197. - * num_bits The number of bits in data that are to
  43198. - * be placed on the MII bus.
  43199. - *
  43200. - * This function sends on sequence of bits on the MII
  43201. - * configuration bus.
  43202. - *
  43203. - **************************************************************/
  43204. -
  43205. -void TLan_MiiSendData( u16 base_port, u32 data, unsigned num_bits )
  43206. -{
  43207. - u16 sio;
  43208. - u32 i;
  43209. -
  43210. - if ( num_bits == 0 )
  43211. - return;
  43212. -
  43213. - outw( TLAN_NET_SIO, base_port + TLAN_DIO_ADR );
  43214. - sio = base_port + TLAN_DIO_DATA + TLAN_NET_SIO;
  43215. - TLan_SetBit( TLAN_NET_SIO_MTXEN, sio );
  43216. -
  43217. - for ( i = ( 0x1 << ( num_bits - 1 ) ); i; i >>= 1 ) {
  43218. - TLan_ClearBit( TLAN_NET_SIO_MCLK, sio );
  43219. - (void) TLan_GetBit( TLAN_NET_SIO_MCLK, sio );
  43220. - if ( data & i )
  43221. - TLan_SetBit( TLAN_NET_SIO_MDATA, sio );
  43222. - else
  43223. - TLan_ClearBit( TLAN_NET_SIO_MDATA, sio );
  43224. - TLan_SetBit( TLAN_NET_SIO_MCLK, sio );
  43225. - (void) TLan_GetBit( TLAN_NET_SIO_MCLK, sio );
  43226. - }
  43227. -
  43228. -} /* TLan_MiiSendData */
  43229. -
  43230. - /***************************************************************
  43231. - * TLan_MiiSync
  43232. - *
  43233. - * Returns:
  43234. - * Nothing
  43235. - * Parms:
  43236. - * base_port The base IO port of the adapter in
  43237. - * question.
  43238. - *
  43239. - * This functions syncs all PHYs in terms of the MII configuration
  43240. - * bus.
  43241. - *
  43242. - **************************************************************/
  43243. -
  43244. -void TLan_MiiSync( u16 base_port )
  43245. -{
  43246. - int i;
  43247. - u16 sio;
  43248. -
  43249. - outw( TLAN_NET_SIO, base_port + TLAN_DIO_ADR );
  43250. - sio = base_port + TLAN_DIO_DATA + TLAN_NET_SIO;
  43251. -
  43252. - TLan_ClearBit( TLAN_NET_SIO_MTXEN, sio );
  43253. - for ( i = 0; i < 32; i++ ) {
  43254. - TLan_ClearBit( TLAN_NET_SIO_MCLK, sio );
  43255. - TLan_SetBit( TLAN_NET_SIO_MCLK, sio );
  43256. - }
  43257. -
  43258. -} /* TLan_MiiSync */
  43259. -
  43260. - /***************************************************************
  43261. - * TLan_MiiWriteReg
  43262. - *
  43263. - * Returns:
  43264. - * Nothing
  43265. - * Parms:
  43266. - * dev The device structure for the device
  43267. - * to write to.
  43268. - * phy The address of the PHY to be written to.
  43269. - * reg The register whose contents are to be
  43270. - * written.
  43271. - * val The value to be written to the register.
  43272. - *
  43273. - * This function uses the TLAN's MII bus to write the contents of a
  43274. - * given register on a PHY. It sends the appropriate info and then
  43275. - * writes the 16-bit register value from the MII configuration bus
  43276. - * via the TLAN SIO register.
  43277. - *
  43278. - **************************************************************/
  43279. -
  43280. -void TLan_MiiWriteReg( struct net_device *dev, u16 phy, u16 reg, u16 val )
  43281. -{
  43282. - u16 sio;
  43283. - int minten;
  43284. - unsigned long flags = 0;
  43285. - TLanPrivateInfo *priv = dev->priv;
  43286. -
  43287. - outw(TLAN_NET_SIO, dev->base_addr + TLAN_DIO_ADR);
  43288. - sio = dev->base_addr + TLAN_DIO_DATA + TLAN_NET_SIO;
  43289. -
  43290. - if (!in_irq())
  43291. - spin_lock_irqsave(&priv->lock, flags);
  43292. -
  43293. - TLan_MiiSync( dev->base_addr );
  43294. -
  43295. - minten = TLan_GetBit( TLAN_NET_SIO_MINTEN, sio );
  43296. - if ( minten )
  43297. - TLan_ClearBit( TLAN_NET_SIO_MINTEN, sio );
  43298. -
  43299. - TLan_MiiSendData( dev->base_addr, 0x1, 2 ); /* Start ( 01b ) */
  43300. - TLan_MiiSendData( dev->base_addr, 0x1, 2 ); /* Write ( 01b ) */
  43301. - TLan_MiiSendData( dev->base_addr, phy, 5 ); /* Device # */
  43302. - TLan_MiiSendData( dev->base_addr, reg, 5 ); /* Register # */
  43303. -
  43304. - TLan_MiiSendData( dev->base_addr, 0x2, 2 ); /* Send ACK */
  43305. - TLan_MiiSendData( dev->base_addr, val, 16 ); /* Send Data */
  43306. -
  43307. - TLan_ClearBit( TLAN_NET_SIO_MCLK, sio ); /* Idle cycle */
  43308. - TLan_SetBit( TLAN_NET_SIO_MCLK, sio );
  43309. -
  43310. - if ( minten )
  43311. - TLan_SetBit( TLAN_NET_SIO_MINTEN, sio );
  43312. -
  43313. - if (!in_irq())
  43314. - spin_unlock_irqrestore(&priv->lock, flags);
  43315. -
  43316. -} /* TLan_MiiWriteReg */
  43317. -#endif
  43318. -
  43319. -/**************************************************************************
  43320. -RESET - Reset adapter
  43321. -***************************************************************************/
  43322. -static void skel_reset(struct nic *nic)
  43323. -{
  43324. - /* put the card in its initial state */
  43325. -}
  43326. -
  43327. -/**************************************************************************
  43328. -POLL - Wait for a frame
  43329. -***************************************************************************/
  43330. -static int skel_poll(struct nic *nic)
  43331. -{
  43332. - /* return true if there's an ethernet packet ready to read */
  43333. - /* nic->packet should contain data on return */
  43334. - /* nic->packetlen should contain length of data */
  43335. - return (0); /* initially as this is called to flush the input */
  43336. -}
  43337. -
  43338. -/**************************************************************************
  43339. -TRANSMIT - Transmit a frame
  43340. -***************************************************************************/
  43341. -static void skel_transmit(
  43342. - struct nic *nic,
  43343. - const char *d, /* Destination */
  43344. - unsigned int t, /* Type */
  43345. - unsigned int s, /* size */
  43346. - const char *p) /* Packet */
  43347. -{
  43348. - /* send the packet to destination */
  43349. -}
  43350. -
  43351. -/**************************************************************************
  43352. -DISABLE - Turn off ethernet interface
  43353. -***************************************************************************/
  43354. -static void skel_disable(struct nic *nic)
  43355. -{
  43356. -}
  43357. -
  43358. -/**************************************************************************
  43359. -PROBE - Look for an adapter, this routine's visible to the outside
  43360. -You should omit the last argument struct pci_device * for a non-PCI NIC
  43361. -***************************************************************************/
  43362. -struct nic *tlan_probe(struct nic *nic, unsigned short *probe_addrs,
  43363. - struct pci_device *p)
  43364. -{
  43365. - /* if probe_addrs is 0, then routine can use a hardwired default */
  43366. - /* if board found */
  43367. - {
  43368. - /* point to NIC specific routines */
  43369. - nic->reset = skel_reset;
  43370. - nic->poll = skel_poll;
  43371. - nic->transmit = skel_transmit;
  43372. - nic->disable = skel_disable;
  43373. - return nic;
  43374. - }
  43375. - /* else */
  43376. - return 0;
  43377. -}
  43378. -
  43379. -#if 0
  43380. -#ifndef TLAN_H
  43381. -#define TLAN_H
  43382. -/********************************************************************
  43383. - *
  43384. - * Linux ThunderLAN Driver
  43385. - *
  43386. - * tlan.h
  43387. - * by James Banks
  43388. - *
  43389. - * (C) 1997-1998 Caldera, Inc.
  43390. - * (C) 1999-2001 Torben Mathiasen
  43391. - *
  43392. - * This software may be used and distributed according to the terms
  43393. - * of the GNU General Public License, incorporated herein by reference.
  43394. - *
  43395. - ** This file is best viewed/edited with tabstop=4, colums>=132
  43396. - *
  43397. - *
  43398. - * Dec 10, 1999 Torben Mathiasen <torben.mathiasen@compaq.com>
  43399. - * New Maintainer
  43400. - *
  43401. - ********************************************************************/
  43402. -
  43403. -#include <asm/io.h>
  43404. -#include <asm/types.h>
  43405. -#include <linux/netdevice.h>
  43406. -
  43407. -#define FALSE 0
  43408. -#define TRUE 1
  43409. -
  43410. -#define TX_TIMEOUT (10*HZ) /* We need time for auto-neg */
  43411. -
  43412. -typedef struct tlan_adapter_entry {
  43413. - u16 vendorId;
  43414. - u16 deviceId;
  43415. - char *deviceLabel;
  43416. - u32 flags;
  43417. - u16 addrOfs;
  43418. -} TLanAdapterEntry;
  43419. -
  43420. - /*****************************************************************
  43421. - * EISA Definitions
  43422. - *
  43423. - ****************************************************************/
  43424. -
  43425. -#define EISA_ID 0xc80 /* EISA ID Registers */
  43426. -#define EISA_ID0 0xc80 /* EISA ID Register 0 */
  43427. -#define EISA_ID1 0xc81 /* EISA ID Register 1 */
  43428. -#define EISA_ID2 0xc82 /* EISA ID Register 2 */
  43429. -#define EISA_ID3 0xc83 /* EISA ID Register 3 */
  43430. -#define EISA_CR 0xc84 /* EISA Control Register */
  43431. -#define EISA_REG0 0xc88 /* EISA Configuration Register 0 */
  43432. -#define EISA_REG1 0xc89 /* EISA Configuration Register 1 */
  43433. -#define EISA_REG2 0xc8a /* EISA Configuration Register 2 */
  43434. -#define EISA_REG3 0xc8f /* EISA Configuration Register 3 */
  43435. -#define EISA_APROM 0xc90 /* Ethernet Address PROM */
  43436. -
  43437. - /*****************************************************************
  43438. - * Rx/Tx List Definitions
  43439. - *
  43440. - ****************************************************************/
  43441. -
  43442. -typedef struct tlan_buffer_ref_tag {
  43443. - u32 count;
  43444. - u32 address;
  43445. -} TLanBufferRef;
  43446. -
  43447. -typedef struct tlan_list_tag {
  43448. - u32 forward;
  43449. - u16 cStat;
  43450. - u16 frameSize;
  43451. - TLanBufferRef buffer[TLAN_BUFFERS_PER_LIST];
  43452. -} TLanList;
  43453. -
  43454. -typedef u8 TLanBuffer[TLAN_MAX_FRAME_SIZE];
  43455. -
  43456. - /*****************************************************************
  43457. - * TLAN Private Information Structure
  43458. - *
  43459. - ****************************************************************/
  43460. -
  43461. -typedef struct tlan_private_tag {
  43462. - struct net_device *nextDevice;
  43463. - void *dmaStorage;
  43464. - u8 *padBuffer;
  43465. - TLanList *rxList;
  43466. - u8 *rxBuffer;
  43467. - u32 rxHead;
  43468. - u32 rxTail;
  43469. - u32 rxEocCount;
  43470. - TLanList *txList;
  43471. - u8 *txBuffer;
  43472. - u32 txHead;
  43473. - u32 txInProgress;
  43474. - u32 txTail;
  43475. - u32 txBusyCount;
  43476. - u32 phyOnline;
  43477. - u32 timerSetAt;
  43478. - u32 timerType;
  43479. - struct timer_list timer;
  43480. - struct net_device_stats stats;
  43481. - struct board *adapter;
  43482. - u32 adapterRev;
  43483. - u32 aui;
  43484. - u32 debug;
  43485. - u32 duplex;
  43486. - u32 phy[2];
  43487. - u32 phyNum;
  43488. - u32 speed;
  43489. - u8 tlanRev;
  43490. - u8 tlanFullDuplex;
  43491. - char devName[8];
  43492. - spinlock_t lock;
  43493. - u8 link;
  43494. - u8 is_eisa;
  43495. - struct tq_struct tlan_tqueue;
  43496. - u8 neg_be_verbose;
  43497. -} TLanPrivateInfo;
  43498. -
  43499. -#define TLAN_HC_GO 0x80000000
  43500. -#define TLAN_HC_STOP 0x40000000
  43501. -#define TLAN_HC_ACK 0x20000000
  43502. -#define TLAN_HC_CS_MASK 0x1FE00000
  43503. -#define TLAN_HC_EOC 0x00100000
  43504. -#define TLAN_HC_RT 0x00080000
  43505. -#define TLAN_HC_NES 0x00040000
  43506. -#define TLAN_HC_AD_RST 0x00008000
  43507. -#define TLAN_HC_LD_TMR 0x00004000
  43508. -#define TLAN_HC_LD_THR 0x00002000
  43509. -#define TLAN_HC_REQ_INT 0x00001000
  43510. -#define TLAN_HC_INT_OFF 0x00000800
  43511. -#define TLAN_HC_INT_ON 0x00000400
  43512. -#define TLAN_HC_AC_MASK 0x000000FF
  43513. -#define TLAN_DA_ADR_INC 0x8000
  43514. -#define TLAN_DA_RAM_ADR 0x4000
  43515. -#define TLAN_HI_IV_MASK 0x1FE0
  43516. -#define TLAN_HI_IT_MASK 0x001C
  43517. -
  43518. -#define TLAN_NET_CMD_NRESET 0x80
  43519. -#define TLAN_NET_CMD_NWRAP 0x40
  43520. -#define TLAN_NET_CMD_CSF 0x20
  43521. -#define TLAN_NET_CMD_CAF 0x10
  43522. -#define TLAN_NET_CMD_NOBRX 0x08
  43523. -#define TLAN_NET_CMD_DUPLEX 0x04
  43524. -#define TLAN_NET_CMD_TRFRAM 0x02
  43525. -#define TLAN_NET_CMD_TXPACE 0x01
  43526. -#define TLAN_NET_SIO_MINTEN 0x80
  43527. -#define TLAN_NET_SIO_ECLOK 0x40
  43528. -#define TLAN_NET_SIO_ETXEN 0x20
  43529. -#define TLAN_NET_SIO_EDATA 0x10
  43530. -#define TLAN_NET_SIO_NMRST 0x08
  43531. -#define TLAN_NET_SIO_MCLK 0x04
  43532. -#define TLAN_NET_SIO_MTXEN 0x02
  43533. -#define TLAN_NET_SIO_MDATA 0x01
  43534. -#define TLAN_NET_STS_MIRQ 0x80
  43535. -#define TLAN_NET_STS_HBEAT 0x40
  43536. -#define TLAN_NET_STS_TXSTOP 0x20
  43537. -#define TLAN_NET_STS_RXSTOP 0x10
  43538. -#define TLAN_NET_STS_RSRVD 0x0F
  43539. -#define TLAN_NET_MASK_MASK7 0x80
  43540. -#define TLAN_NET_MASK_MASK6 0x40
  43541. -#define TLAN_NET_MASK_MASK5 0x20
  43542. -#define TLAN_NET_MASK_MASK4 0x10
  43543. -#define TLAN_NET_MASK_RSRVD 0x0F
  43544. -#define TLAN_NET_CFG_RCLK 0x8000
  43545. -#define TLAN_NET_CFG_TCLK 0x4000
  43546. -#define TLAN_NET_CFG_BIT 0x2000
  43547. -#define TLAN_NET_CFG_RXCRC 0x1000
  43548. -#define TLAN_NET_CFG_PEF 0x0800
  43549. -#define TLAN_NET_CFG_1FRAG 0x0400
  43550. -#define TLAN_NET_CFG_1CHAN 0x0200
  43551. -#define TLAN_NET_CFG_MTEST 0x0100
  43552. -#define TLAN_NET_CFG_PHY_EN 0x0080
  43553. -#define TLAN_NET_CFG_MSMASK 0x007F
  43554. -#define TLAN_LED_ACT 0x10
  43555. -#define TLAN_LED_LINK 0x01
  43556. -#define TLAN_ID_TX_EOC 0x04
  43557. -#define TLAN_ID_RX_EOF 0x02
  43558. -#define TLAN_ID_RX_EOC 0x01
  43559. -
  43560. -#define CIRC_INC( a, b ) if ( ++a >= b ) a = 0
  43561. -
  43562. -#ifdef I_LIKE_A_FAST_HASH_FUNCTION
  43563. -/* given 6 bytes, view them as 8 6-bit numbers and return the XOR of those */
  43564. -/* the code below is about seven times as fast as the original code */
  43565. -inline u32 TLan_HashFunc( u8 *a )
  43566. -{
  43567. - u8 hash;
  43568. -
  43569. - hash = (a[0]^a[3]); /* & 077 */
  43570. - hash ^= ((a[0]^a[3])>>6); /* & 003 */
  43571. - hash ^= ((a[1]^a[4])<<2); /* & 074 */
  43572. - hash ^= ((a[1]^a[4])>>4); /* & 017 */
  43573. - hash ^= ((a[2]^a[5])<<4); /* & 060 */
  43574. - hash ^= ((a[2]^a[5])>>2); /* & 077 */
  43575. -
  43576. - return (hash & 077);
  43577. -}
  43578. -
  43579. -#else /* original code */
  43580. -
  43581. -inline u32 xor( u32 a, u32 b )
  43582. -{
  43583. - return ( ( a && ! b ) || ( ! a && b ) );
  43584. -}
  43585. -#define XOR8( a, b, c, d, e, f, g, h ) xor( a, xor( b, xor( c, xor( d, xor( e, xor( f, xor( g, h ) ) ) ) ) ) )
  43586. -#define DA( a, bit ) ( ( (u8) a[bit/8] ) & ( (u8) ( 1 << bit%8 ) ) )
  43587. -
  43588. -inline u32 TLan_HashFunc( u8 *a )
  43589. -{
  43590. - u32 hash;
  43591. -
  43592. - hash = XOR8( DA(a,0), DA(a, 6), DA(a,12), DA(a,18), DA(a,24), DA(a,30), DA(a,36), DA(a,42) );
  43593. - hash |= XOR8( DA(a,1), DA(a, 7), DA(a,13), DA(a,19), DA(a,25), DA(a,31), DA(a,37), DA(a,43) ) << 1;
  43594. - hash |= XOR8( DA(a,2), DA(a, 8), DA(a,14), DA(a,20), DA(a,26), DA(a,32), DA(a,38), DA(a,44) ) << 2;
  43595. - hash |= XOR8( DA(a,3), DA(a, 9), DA(a,15), DA(a,21), DA(a,27), DA(a,33), DA(a,39), DA(a,45) ) << 3;
  43596. - hash |= XOR8( DA(a,4), DA(a,10), DA(a,16), DA(a,22), DA(a,28), DA(a,34), DA(a,40), DA(a,46) ) << 4;
  43597. - hash |= XOR8( DA(a,5), DA(a,11), DA(a,17), DA(a,23), DA(a,29), DA(a,35), DA(a,41), DA(a,47) ) << 5;
  43598. -
  43599. - return hash;
  43600. -
  43601. -}
  43602. -
  43603. -#endif /* I_LIKE_A_FAST_HASH_FUNCTION */
  43604. -#endif
  43605. -/*******************************************************************************
  43606. - *
  43607. - * Linux ThunderLAN Driver
  43608. - *
  43609. - * tlan.c
  43610. - * by James Banks
  43611. - *
  43612. - * (C) 1997-1998 Caldera, Inc.
  43613. - * (C) 1998 James Banks
  43614. - * (C) 1999-2001 Torben Mathiasen
  43615. - *
  43616. - * This software may be used and distributed according to the terms
  43617. - * of the GNU General Public License, incorporated herein by reference.
  43618. - *
  43619. - ** This file is best viewed/edited with columns>=132.
  43620. - *
  43621. - ** Useful (if not required) reading:
  43622. - *
  43623. - * Texas Instruments, ThunderLAN Programmer's Guide,
  43624. - * TI Literature Number SPWU013A
  43625. - * available in PDF format from www.ti.com
  43626. - * Level One, LXT901 and LXT970 Data Sheets
  43627. - * available in PDF format from www.level1.com
  43628. - * National Semiconductor, DP83840A Data Sheet
  43629. - * available in PDF format from www.national.com
  43630. - * Microchip Technology, 24C01A/02A/04A Data Sheet
  43631. - * available in PDF format from www.microchip.com
  43632. - *
  43633. - * Change History
  43634. - *
  43635. - * Tigran Aivazian <tigran@sco.com>: TLan_PciProbe() now uses
  43636. - * new PCI BIOS interface.
  43637. - * Alan Cox <alan@redhat.com>: Fixed the out of memory
  43638. - * handling.
  43639. - *
  43640. - * Torben Mathiasen <torben.mathiasen@compaq.com> New Maintainer!
  43641. - *
  43642. - * v1.1 Dec 20, 1999 - Removed linux version checking
  43643. - * Patch from Tigran Aivazian.
  43644. - * - v1.1 includes Alan's SMP updates.
  43645. - * - We still have problems on SMP though,
  43646. - * but I'm looking into that.
  43647. - *
  43648. - * v1.2 Jan 02, 2000 - Hopefully fixed the SMP deadlock.
  43649. - * - Removed dependency of HZ being 100.
  43650. - * - We now allow higher priority timers to
  43651. - * overwrite timers like TLAN_TIMER_ACTIVITY
  43652. - * Patch from John Cagle <john.cagle@compaq.com>.
  43653. - * - Fixed a few compiler warnings.
  43654. - *
  43655. - * v1.3 Feb 04, 2000 - Fixed the remaining HZ issues.
  43656. - * - Removed call to pci_present().
  43657. - * - Removed SA_INTERRUPT flag from irq handler.
  43658. - * - Added __init and __initdata to reduce resisdent
  43659. - * code size.
  43660. - * - Driver now uses module_init/module_exit.
  43661. - * - Rewrote init_module and tlan_probe to
  43662. - * share a lot more code. We now use tlan_probe
  43663. - * with builtin and module driver.
  43664. - * - Driver ported to new net API.
  43665. - * - tlan.txt has been reworked to reflect current
  43666. - * driver (almost)
  43667. - * - Other minor stuff
  43668. - *
  43669. - * v1.4 Feb 10, 2000 - Updated with more changes required after Dave's
  43670. - * network cleanup in 2.3.43pre7 (Tigran & myself)
  43671. - * - Minor stuff.
  43672. - *
  43673. - * v1.5 March 22, 2000 - Fixed another timer bug that would hang the driver
  43674. - * if no cable/link were present.
  43675. - * - Cosmetic changes.
  43676. - * - TODO: Port completely to new PCI/DMA API
  43677. - * Auto-Neg fallback.
  43678. - *
  43679. - * v1.6 April 04, 2000 - Fixed driver support for kernel-parameters. Haven't
  43680. - * tested it though, as the kernel support is currently
  43681. - * broken (2.3.99p4p3).
  43682. - * - Updated tlan.txt accordingly.
  43683. - * - Adjusted minimum/maximum frame length.
  43684. - * - There is now a TLAN website up at
  43685. - * http://tlan.kernel.dk
  43686. - *
  43687. - * v1.7 April 07, 2000 - Started to implement custom ioctls. Driver now
  43688. - * reports PHY information when used with Donald
  43689. - * Beckers userspace MII diagnostics utility.
  43690. - *
  43691. - * v1.8 April 23, 2000 - Fixed support for forced speed/duplex settings.
  43692. - * - Added link information to Auto-Neg and forced
  43693. - * modes. When NIC operates with auto-neg the driver
  43694. - * will report Link speed & duplex modes as well as
  43695. - * link partner abilities. When forced link is used,
  43696. - * the driver will report status of the established
  43697. - * link.
  43698. - * Please read tlan.txt for additional information.
  43699. - * - Removed call to check_region(), and used
  43700. - * return value of request_region() instead.
  43701. - *
  43702. - * v1.8a May 28, 2000 - Minor updates.
  43703. - *
  43704. - * v1.9 July 25, 2000 - Fixed a few remaining Full-Duplex issues.
  43705. - * - Updated with timer fixes from Andrew Morton.
  43706. - * - Fixed module race in TLan_Open.
  43707. - * - Added routine to monitor PHY status.
  43708. - * - Added activity led support for Proliant devices.
  43709. - *
  43710. - * v1.10 Aug 30, 2000 - Added support for EISA based tlan controllers
  43711. - * like the Compaq NetFlex3/E.
  43712. - * - Rewrote tlan_probe to better handle multiple
  43713. - * bus probes. Probing and device setup is now
  43714. - * done through TLan_Probe and TLan_init_one. Actual
  43715. - * hardware probe is done with kernel API and
  43716. - * TLan_EisaProbe.
  43717. - * - Adjusted debug information for probing.
  43718. - * - Fixed bug that would cause general debug information
  43719. - * to be printed after driver removal.
  43720. - * - Added transmit timeout handling.
  43721. - * - Fixed OOM return values in tlan_probe.
  43722. - * - Fixed possible mem leak in tlan_exit
  43723. - * (now tlan_remove_one).
  43724. - * - Fixed timer bug in TLan_phyMonitor.
  43725. - * - This driver version is alpha quality, please
  43726. - * send me any bug issues you may encounter.
  43727. - *
  43728. - * v1.11 Aug 31, 2000 - Do not try to register irq 0 if no irq line was
  43729. - * set for EISA cards.
  43730. - * - Added support for NetFlex3/E with nibble-rate
  43731. - * 10Base-T PHY. This is untestet as I haven't got
  43732. - * one of these cards.
  43733. - * - Fixed timer being added twice.
  43734. - * - Disabled PhyMonitoring by default as this is
  43735. - * work in progress. Define MONITOR to enable it.
  43736. - * - Now we don't display link info with PHYs that
  43737. - * doesn't support it (level1).
  43738. - * - Incresed tx_timeout beacuse of auto-neg.
  43739. - * - Adjusted timers for forced speeds.
  43740. - *
  43741. - * v1.12 Oct 12, 2000 - Minor fixes (memleak, init, etc.)
  43742. - *
  43743. - * v1.13 Nov 28, 2000 - Stop flooding console with auto-neg issues
  43744. - * when link can't be established.
  43745. - * - Added the bbuf option as a kernel parameter.
  43746. - * - Fixed ioaddr probe bug.
  43747. - * - Fixed stupid deadlock with MII interrupts.
  43748. - * - Added support for speed/duplex selection with
  43749. - * multiple nics.
  43750. - * - Added partly fix for TX Channel lockup with
  43751. - * TLAN v1.0 silicon. This needs to be investigated
  43752. - * further.
  43753. - *
  43754. - * v1.14 Dec 16, 2000 - Added support for servicing multiple frames per.
  43755. - * interrupt. Thanks goes to
  43756. - * Adam Keys <adam@ti.com>
  43757. - * Denis Beaudoin <dbeaudoin@ti.com>
  43758. - * for providing the patch.
  43759. - * - Fixed auto-neg output when using multiple
  43760. - * adapters.
  43761. - * - Converted to use new taskq interface.
  43762. - *
  43763. - * v1.14a Jan 6, 2001 - Minor adjustments (spinlocks, etc.)
  43764. - *
  43765. - *******************************************************************************/
  43766. -
  43767. -
  43768. -#include <linux/module.h>
  43769. -
  43770. -#include "tlan.h"
  43771. -
  43772. -#include <linux/init.h>
  43773. -#include <linux/ioport.h>
  43774. -#include <linux/pci.h>
  43775. -#include <linux/etherdevice.h>
  43776. -#include <linux/delay.h>
  43777. -#include <linux/spinlock.h>
  43778. -#include <linux/mii.h>
  43779. -
  43780. -typedef u32 (TLanIntVectorFunc)( struct net_device *, u16 );
  43781. -
  43782. -/* For removing EISA devices */
  43783. -static struct net_device *TLan_Eisa_Devices;
  43784. -
  43785. -static int TLanDevicesInstalled;
  43786. -
  43787. -/* Set speed, duplex and aui settings */
  43788. -static int aui[MAX_TLAN_BOARDS];
  43789. -static int duplex[MAX_TLAN_BOARDS];
  43790. -static int speed[MAX_TLAN_BOARDS];
  43791. -static int boards_found;
  43792. -
  43793. -MODULE_AUTHOR("Maintainer: Torben Mathiasen <torben.mathiasen@compaq.com>");
  43794. -MODULE_DESCRIPTION("Driver for TI ThunderLAN based ethernet PCI adapters");
  43795. -MODULE_LICENSE("GPL");
  43796. -
  43797. -MODULE_PARM(aui, "1-" __MODULE_STRING(MAX_TLAN_BOARDS) "i");
  43798. -MODULE_PARM(duplex, "1-" __MODULE_STRING(MAX_TLAN_BOARDS) "i");
  43799. -MODULE_PARM(speed, "1-" __MODULE_STRING(MAX_TLAN_BOARDS) "i");
  43800. -MODULE_PARM(debug, "i");
  43801. -MODULE_PARM(bbuf, "i");
  43802. -MODULE_PARM_DESC(aui, "ThunderLAN use AUI port(s) (0-1)");
  43803. -MODULE_PARM_DESC(duplex, "ThunderLAN duplex setting(s) (0-default, 1-half, 2-full)");
  43804. -MODULE_PARM_DESC(speed, "ThunderLAN port speen setting(s) (0,10,100)");
  43805. -MODULE_PARM_DESC(debug, "ThunderLAN debug mask");
  43806. -MODULE_PARM_DESC(bbuf, "ThunderLAN use big buffer (0-1)");
  43807. -EXPORT_NO_SYMBOLS;
  43808. -
  43809. -/* Define this to enable Link beat monitoring */
  43810. -#undef MONITOR
  43811. -
  43812. -/* Turn on debugging. See linux/Documentation/networking/tlan.txt for details */
  43813. -static int debug;
  43814. -
  43815. -static int bbuf;
  43816. -static u8 *TLanPadBuffer;
  43817. -static char TLanSignature[] = "TLAN";
  43818. -static const char tlan_banner[] = "ThunderLAN driver v1.14a\n";
  43819. -static int tlan_have_pci;
  43820. -static int tlan_have_eisa;
  43821. -
  43822. -const char *media[] = {
  43823. - "10BaseT-HD ", "10BaseT-FD ","100baseTx-HD ",
  43824. - "100baseTx-FD", "100baseT4", 0
  43825. -};
  43826. -
  43827. -int media_map[] = { 0x0020, 0x0040, 0x0080, 0x0100, 0x0200,};
  43828. -
  43829. -static struct board {
  43830. - const char *deviceLabel;
  43831. - u32 flags;
  43832. - u16 addrOfs;
  43833. -} board_info[] __devinitdata = {
  43834. - { "Compaq Netelligent 10 T PCI UTP", TLAN_ADAPTER_ACTIVITY_LED, 0x83 },
  43835. - { "Compaq Netelligent 10/100 TX PCI UTP", TLAN_ADAPTER_ACTIVITY_LED, 0x83 },
  43836. - { "Compaq Integrated NetFlex-3/P", TLAN_ADAPTER_NONE, 0x83 },
  43837. - { "Compaq NetFlex-3/P", TLAN_ADAPTER_UNMANAGED_PHY | TLAN_ADAPTER_BIT_RATE_PHY, 0x83 },
  43838. - { "Compaq NetFlex-3/P", TLAN_ADAPTER_NONE, 0x83 },
  43839. - { "Compaq Netelligent Integrated 10/100 TX UTP", TLAN_ADAPTER_ACTIVITY_LED, 0x83 },
  43840. - { "Compaq Netelligent Dual 10/100 TX PCI UTP", TLAN_ADAPTER_NONE, 0x83 },
  43841. - { "Compaq Netelligent 10/100 TX Embedded UTP", TLAN_ADAPTER_NONE, 0x83 },
  43842. - { "Olicom OC-2183/2185", TLAN_ADAPTER_USE_INTERN_10, 0x83 },
  43843. - { "Olicom OC-2325", TLAN_ADAPTER_UNMANAGED_PHY, 0xF8 },
  43844. - { "Olicom OC-2326", TLAN_ADAPTER_USE_INTERN_10, 0xF8 },
  43845. - { "Compaq Netelligent 10/100 TX UTP", TLAN_ADAPTER_ACTIVITY_LED, 0x83 },
  43846. - { "Compaq Netelligent 10 T/2 PCI UTP/Coax", TLAN_ADAPTER_NONE, 0x83 },
  43847. - { "Compaq NetFlex-3/E", TLAN_ADAPTER_ACTIVITY_LED | /* EISA card */
  43848. - TLAN_ADAPTER_UNMANAGED_PHY | TLAN_ADAPTER_BIT_RATE_PHY, 0x83 },
  43849. - { "Compaq NetFlex-3/E", TLAN_ADAPTER_ACTIVITY_LED, 0x83 }, /* EISA card */
  43850. -};
  43851. -
  43852. -static struct pci_device_id tlan_pci_tbl[] __devinitdata = {
  43853. - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL10,
  43854. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
  43855. - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL100,
  43856. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 },
  43857. - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETFLEX3I,
  43858. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2 },
  43859. - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_THUNDER,
  43860. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3 },
  43861. - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETFLEX3B,
  43862. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 },
  43863. - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL100PI,
  43864. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5 },
  43865. - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL100D,
  43866. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6 },
  43867. - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL100I,
  43868. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 7 },
  43869. - { PCI_VENDOR_ID_OLICOM, PCI_DEVICE_ID_OLICOM_OC2183,
  43870. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 8 },
  43871. - { PCI_VENDOR_ID_OLICOM, PCI_DEVICE_ID_OLICOM_OC2325,
  43872. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 9 },
  43873. - { PCI_VENDOR_ID_OLICOM, PCI_DEVICE_ID_OLICOM_OC2326,
  43874. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 10 },
  43875. - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_NETELLIGENT_10_100_WS_5100,
  43876. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 11 },
  43877. - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_NETELLIGENT_10_T2,
  43878. - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 12 },
  43879. - { 0,}
  43880. -};
  43881. -MODULE_DEVICE_TABLE(pci, tlan_pci_tbl);
  43882. -
  43883. -static void TLan_EisaProbe( void );
  43884. -static void TLan_Eisa_Cleanup( void );
  43885. -static int TLan_Init( struct net_device * );
  43886. -static int TLan_Open( struct net_device *dev );
  43887. -static int TLan_StartTx( struct sk_buff *, struct net_device *);
  43888. -static void TLan_HandleInterrupt( int, void *, struct pt_regs *);
  43889. -static int TLan_Close( struct net_device *);
  43890. -static struct net_device_stats *TLan_GetStats( struct net_device *);
  43891. -static void TLan_SetMulticastList( struct net_device *);
  43892. -static int TLan_ioctl( struct net_device *dev, struct ifreq *rq, int cmd);
  43893. -static int TLan_probe1( struct pci_dev *pdev, long ioaddr, int irq, int rev, const struct pci_device_id *ent);
  43894. -static void TLan_tx_timeout( struct net_device *dev);
  43895. -static int tlan_init_one( struct pci_dev *pdev, const struct pci_device_id *ent);
  43896. -
  43897. -static u32 TLan_HandleInvalid( struct net_device *, u16 );
  43898. -static u32 TLan_HandleTxEOF( struct net_device *, u16 );
  43899. -static u32 TLan_HandleStatOverflow( struct net_device *, u16 );
  43900. -static u32 TLan_HandleRxEOF( struct net_device *, u16 );
  43901. -static u32 TLan_HandleDummy( struct net_device *, u16 );
  43902. -static u32 TLan_HandleTxEOC( struct net_device *, u16 );
  43903. -static u32 TLan_HandleStatusCheck( struct net_device *, u16 );
  43904. -static u32 TLan_HandleRxEOC( struct net_device *, u16 );
  43905. -
  43906. -static void TLan_Timer( unsigned long );
  43907. -
  43908. -static void TLan_ResetLists( struct net_device * );
  43909. -static void TLan_FreeLists( struct net_device * );
  43910. -static void TLan_PrintDio( u16 );
  43911. -static void TLan_PrintList( TLanList *, char *, int );
  43912. -static void TLan_ReadAndClearStats( struct net_device *, int );
  43913. -static void TLan_ResetAdapter( struct net_device * );
  43914. -static void TLan_FinishReset( struct net_device * );
  43915. -static void TLan_SetMac( struct net_device *, int areg, char *mac );
  43916. -
  43917. -static void TLan_PhyPrint( struct net_device * );
  43918. -static void TLan_PhyDetect( struct net_device * );
  43919. -static void TLan_PhyPowerDown( struct net_device * );
  43920. -static void TLan_PhyPowerUp( struct net_device * );
  43921. -static void TLan_PhyReset( struct net_device * );
  43922. -static void TLan_PhyStartLink( struct net_device * );
  43923. -static void TLan_PhyFinishAutoNeg( struct net_device * );
  43924. -#ifdef MONITOR
  43925. -static void TLan_PhyMonitor( struct net_device * );
  43926. -#endif
  43927. -
  43928. -/*
  43929. -static int TLan_PhyNop( struct net_device * );
  43930. -static int TLan_PhyInternalCheck( struct net_device * );
  43931. -static int TLan_PhyInternalService( struct net_device * );
  43932. -static int TLan_PhyDp83840aCheck( struct net_device * );
  43933. -*/
  43934. -
  43935. -static int TLan_MiiReadReg( struct net_device *, u16, u16, u16 * );
  43936. -static void TLan_MiiSendData( u16, u32, unsigned );
  43937. -static void TLan_MiiSync( u16 );
  43938. -static void TLan_MiiWriteReg( struct net_device *, u16, u16, u16 );
  43939. -
  43940. -static void TLan_EeSendStart( u16 );
  43941. -static int TLan_EeSendByte( u16, u8, int );
  43942. -static void TLan_EeReceiveByte( u16, u8 *, int );
  43943. -static int TLan_EeReadByte( struct net_device *, u8, u8 * );
  43944. -
  43945. -static TLanIntVectorFunc *TLanIntVector[TLAN_INT_NUMBER_OF_INTS] = {
  43946. - TLan_HandleInvalid,
  43947. - TLan_HandleTxEOF,
  43948. - TLan_HandleStatOverflow,
  43949. - TLan_HandleRxEOF,
  43950. - TLan_HandleDummy,
  43951. - TLan_HandleTxEOC,
  43952. - TLan_HandleStatusCheck,
  43953. - TLan_HandleRxEOC
  43954. -};
  43955. -
  43956. -static inline void
  43957. -TLan_SetTimer( struct net_device *dev, u32 ticks, u32 type )
  43958. -{
  43959. - TLanPrivateInfo *priv = dev->priv;
  43960. - unsigned long flags = 0;
  43961. -
  43962. - if (!in_irq())
  43963. - spin_lock_irqsave(&priv->lock, flags);
  43964. - if ( priv->timer.function != NULL &&
  43965. - priv->timerType != TLAN_TIMER_ACTIVITY ) {
  43966. - if (!in_irq())
  43967. - spin_unlock_irqrestore(&priv->lock, flags);
  43968. - return;
  43969. - }
  43970. - priv->timer.function = &TLan_Timer;
  43971. - if (!in_irq())
  43972. - spin_unlock_irqrestore(&priv->lock, flags);
  43973. -
  43974. - priv->timer.data = (unsigned long) dev;
  43975. - priv->timerSetAt = jiffies;
  43976. - priv->timerType = type;
  43977. - mod_timer(&priv->timer, jiffies + ticks);
  43978. -
  43979. -} /* TLan_SetTimer */
  43980. -
  43981. -/*****************************************************************************
  43982. -******************************************************************************
  43983. -
  43984. - ThunderLAN Driver Primary Functions
  43985. -
  43986. - These functions are more or less common to all Linux network drivers.
  43987. -
  43988. -******************************************************************************
  43989. -*****************************************************************************/
  43990. -
  43991. - /***************************************************************
  43992. - * tlan_remove_one
  43993. - *
  43994. - * Returns:
  43995. - * Nothing
  43996. - * Parms:
  43997. - * None
  43998. - *
  43999. - * Goes through the TLanDevices list and frees the device
  44000. - * structs and memory associated with each device (lists
  44001. - * and buffers). It also ureserves the IO port regions
  44002. - * associated with this device.
  44003. - *
  44004. - **************************************************************/
  44005. -
  44006. -static void __devexit tlan_remove_one( struct pci_dev *pdev)
  44007. -{
  44008. - struct net_device *dev = pci_get_drvdata( pdev );
  44009. - TLanPrivateInfo *priv = dev->priv;
  44010. -
  44011. - unregister_netdev( dev );
  44012. -
  44013. - if ( priv->dmaStorage ) {
  44014. - kfree( priv->dmaStorage );
  44015. - }
  44016. -
  44017. - release_region( dev->base_addr, 0x10 );
  44018. -
  44019. - kfree( dev );
  44020. -
  44021. - pci_set_drvdata( pdev, NULL );
  44022. -}
  44023. -
  44024. -static struct pci_driver tlan_driver = {
  44025. - name: "tlan",
  44026. - id_table: tlan_pci_tbl,
  44027. - probe: tlan_init_one,
  44028. - remove: tlan_remove_one,
  44029. -};
  44030. -
  44031. -static int __init tlan_probe(void)
  44032. -{
  44033. - static int pad_allocated;
  44034. -
  44035. - printk(KERN_INFO "%s", tlan_banner);
  44036. -
  44037. - TLanPadBuffer = (u8 *) kmalloc(TLAN_MIN_FRAME_SIZE,
  44038. - GFP_KERNEL);
  44039. -
  44040. - if (TLanPadBuffer == NULL) {
  44041. - printk(KERN_ERR "TLAN: Could not allocate memory for pad buffer.\n");
  44042. - return -ENOMEM;
  44043. - }
  44044. -
  44045. - memset(TLanPadBuffer, 0, TLAN_MIN_FRAME_SIZE);
  44046. - pad_allocated = 1;
  44047. -
  44048. - TLAN_DBG(TLAN_DEBUG_PROBE, "Starting PCI Probe....\n");
  44049. -
  44050. - /* Use new style PCI probing. Now the kernel will
  44051. - do most of this for us */
  44052. - pci_register_driver(&tlan_driver);
  44053. -
  44054. - TLAN_DBG(TLAN_DEBUG_PROBE, "Starting EISA Probe....\n");
  44055. - TLan_EisaProbe();
  44056. -
  44057. - printk(KERN_INFO "TLAN: %d device%s installed, PCI: %d EISA: %d\n",
  44058. - TLanDevicesInstalled, TLanDevicesInstalled == 1 ? "" : "s",
  44059. - tlan_have_pci, tlan_have_eisa);
  44060. -
  44061. - if (TLanDevicesInstalled == 0) {
  44062. - pci_unregister_driver(&tlan_driver);
  44063. - kfree(TLanPadBuffer);
  44064. - return -ENODEV;
  44065. - }
  44066. - return 0;
  44067. -}
  44068. -
  44069. -
  44070. -static int __devinit tlan_init_one( struct pci_dev *pdev,
  44071. - const struct pci_device_id *ent)
  44072. -{
  44073. - return TLan_probe1( pdev, -1, -1, 0, ent);
  44074. -}
  44075. -
  44076. -/*
  44077. - ***************************************************************
  44078. - * tlan_probe1
  44079. - *
  44080. - * Returns:
  44081. - * 0 on success, error code on error
  44082. - * Parms:
  44083. - * none
  44084. - *
  44085. - * The name is lower case to fit in with all the rest of
  44086. - * the netcard_probe names. This function looks for
  44087. - * another TLan based adapter, setting it up with the
  44088. - * allocated device struct if one is found.
  44089. - * tlan_probe has been ported to the new net API and
  44090. - * now allocates its own device structure. This function
  44091. - * is also used by modules.
  44092. - *
  44093. - **************************************************************/
  44094. -
  44095. -static int __devinit TLan_probe1(struct pci_dev *pdev,
  44096. - long ioaddr, int irq, int rev, const struct pci_device_id *ent )
  44097. -{
  44098. -
  44099. - struct net_device *dev;
  44100. - TLanPrivateInfo *priv;
  44101. - u8 pci_rev;
  44102. - u16 device_id;
  44103. - int reg;
  44104. -
  44105. - if (pdev && pci_enable_device(pdev))
  44106. - return -EIO;
  44107. -
  44108. - dev = init_etherdev(NULL, sizeof(TLanPrivateInfo));
  44109. - if (dev == NULL) {
  44110. - printk(KERN_ERR "TLAN: Could not allocate memory for device.\n");
  44111. - return -ENOMEM;
  44112. - }
  44113. - SET_MODULE_OWNER(dev);
  44114. -
  44115. - priv = dev->priv;
  44116. -
  44117. - /* Is this a PCI device? */
  44118. - if (pdev) {
  44119. - u32 pci_io_base = 0;
  44120. -
  44121. - priv->adapter = &board_info[ent->driver_data];
  44122. -
  44123. - pci_read_config_byte ( pdev, PCI_REVISION_ID, &pci_rev);
  44124. -
  44125. - for ( reg= 0; reg <= 5; reg ++ ) {
  44126. - if (pci_resource_flags(pdev, reg) & IORESOURCE_IO) {
  44127. - pci_io_base = pci_resource_start(pdev, reg);
  44128. - TLAN_DBG( TLAN_DEBUG_GNRL, "IO mapping is available at %x.\n",
  44129. - pci_io_base);
  44130. - break;
  44131. - }
  44132. - }
  44133. - if (!pci_io_base) {
  44134. - printk(KERN_ERR "TLAN: No IO mappings available\n");
  44135. - unregister_netdev(dev);
  44136. - kfree(dev);
  44137. - return -ENODEV;
  44138. - }
  44139. -
  44140. - dev->base_addr = pci_io_base;
  44141. - dev->irq = pdev->irq;
  44142. - priv->adapterRev = pci_rev;
  44143. - pci_set_master(pdev);
  44144. - pci_set_drvdata(pdev, dev);
  44145. -
  44146. - } else { /* EISA card */
  44147. - /* This is a hack. We need to know which board structure
  44148. - * is suited for this adapter */
  44149. - device_id = inw(ioaddr + EISA_ID2);
  44150. - priv->is_eisa = 1;
  44151. - if (device_id == 0x20F1) {
  44152. - priv->adapter = &board_info[13]; /* NetFlex-3/E */
  44153. - priv->adapterRev = 23; /* TLAN 2.3 */
  44154. - } else {
  44155. - priv->adapter = &board_info[14];
  44156. - priv->adapterRev = 10; /* TLAN 1.0 */
  44157. - }
  44158. - dev->base_addr = ioaddr;
  44159. - dev->irq = irq;
  44160. - }
  44161. -
  44162. - /* Kernel parameters */
  44163. - if (dev->mem_start) {
  44164. - priv->aui = dev->mem_start & 0x01;
  44165. - priv->duplex = ((dev->mem_start & 0x06) == 0x06) ? 0 : (dev->mem_start & 0x06) >> 1;
  44166. - priv->speed = ((dev->mem_start & 0x18) == 0x18) ? 0 : (dev->mem_start & 0x18) >> 3;
  44167. -
  44168. - if (priv->speed == 0x1) {
  44169. - priv->speed = TLAN_SPEED_10;
  44170. - } else if (priv->speed == 0x2) {
  44171. - priv->speed = TLAN_SPEED_100;
  44172. - }
  44173. - debug = priv->debug = dev->mem_end;
  44174. - } else {
  44175. - priv->aui = aui[boards_found];
  44176. - priv->speed = speed[boards_found];
  44177. - priv->duplex = duplex[boards_found];
  44178. - priv->debug = debug;
  44179. - }
  44180. -
  44181. - /* This will be used when we get an adapter error from
  44182. - * within our irq handler */
  44183. - INIT_LIST_HEAD(&priv->tlan_tqueue.list);
  44184. - priv->tlan_tqueue.sync = 0;
  44185. - priv->tlan_tqueue.routine = (void *)(void*)TLan_tx_timeout;
  44186. - priv->tlan_tqueue.data = dev;
  44187. -
  44188. - spin_lock_init(&priv->lock);
  44189. -
  44190. - if (TLan_Init(dev)) {
  44191. - printk(KERN_ERR "TLAN: Could not register device.\n");
  44192. - unregister_netdev(dev);
  44193. - kfree(dev);
  44194. - return -EAGAIN;
  44195. - } else {
  44196. -
  44197. - TLanDevicesInstalled++;
  44198. - boards_found++;
  44199. -
  44200. - /* pdev is NULL if this is an EISA device */
  44201. - if (pdev)
  44202. - tlan_have_pci++;
  44203. - else {
  44204. - priv->nextDevice = TLan_Eisa_Devices;
  44205. - TLan_Eisa_Devices = dev;
  44206. - tlan_have_eisa++;
  44207. - }
  44208. -
  44209. - printk(KERN_INFO "TLAN: %s irq=%2d, io=%04x, %s, Rev. %d\n",
  44210. - dev->name,
  44211. - (int) dev->irq,
  44212. - (int) dev->base_addr,
  44213. - priv->adapter->deviceLabel,
  44214. - priv->adapterRev);
  44215. - return 0;
  44216. - }
  44217. -
  44218. -}
  44219. +} /* TLan_FinishReset */
  44220. -static void TLan_Eisa_Cleanup(void)
  44221. -{
  44222. - struct net_device *dev;
  44223. - TLanPrivateInfo *priv;
  44224. -
  44225. - while( tlan_have_eisa ) {
  44226. - dev = TLan_Eisa_Devices;
  44227. - priv = dev->priv;
  44228. - if (priv->dmaStorage) {
  44229. - kfree(priv->dmaStorage);
  44230. - }
  44231. - release_region( dev->base_addr, 0x10);
  44232. - unregister_netdev( dev );
  44233. - TLan_Eisa_Devices = priv->nextDevice;
  44234. - kfree( dev );
  44235. - tlan_have_eisa--;
  44236. - }
  44237. -}
  44238. -
  44239. -
  44240. -static void __exit tlan_exit(void)
  44241. -{
  44242. - pci_unregister_driver(&tlan_driver);
  44243. -
  44244. - if (tlan_have_eisa)
  44245. - TLan_Eisa_Cleanup();
  44246. -
  44247. - kfree( TLanPadBuffer );
  44248. -
  44249. -}
  44250. -
  44251. -/* Module loading/unloading */
  44252. -module_init(tlan_probe);
  44253. -module_exit(tlan_exit);
  44254. -
  44255. - /**************************************************************
  44256. - * TLan_EisaProbe
  44257. - *
  44258. - * Returns: 0 on success, 1 otherwise
  44259. - *
  44260. - * Parms: None
  44261. - *
  44262. - *
  44263. - * This functions probes for EISA devices and calls
  44264. - * TLan_probe1 when one is found.
  44265. - *
  44266. - *************************************************************/
  44267. -
  44268. -static void __init TLan_EisaProbe (void)
  44269. +/**************************************************************************
  44270. +POLL - Wait for a frame
  44271. +***************************************************************************/
  44272. +static int tlan_poll(struct nic *nic, int retrieve)
  44273. {
  44274. - long ioaddr;
  44275. - int rc = -ENODEV;
  44276. - int irq;
  44277. - u16 device_id;
  44278. -
  44279. - if (!EISA_bus) {
  44280. - TLAN_DBG(TLAN_DEBUG_PROBE, "No EISA bus present\n");
  44281. - return;
  44282. - }
  44283. -
  44284. - /* Loop through all slots of the EISA bus */
  44285. - for (ioaddr = 0x1000; ioaddr < 0x9000; ioaddr += 0x1000) {
  44286. -
  44287. - TLAN_DBG(TLAN_DEBUG_PROBE,"EISA_ID 0x%4x: 0x%4x\n", (int) ioaddr + 0xC80, inw(ioaddr + EISA_ID));
  44288. - TLAN_DBG(TLAN_DEBUG_PROBE,"EISA_ID 0x%4x: 0x%4x\n", (int) ioaddr + 0xC82, inw(ioaddr + EISA_ID2));
  44289. + /* return true if there's an ethernet packet ready to read */
  44290. + /* nic->packet should contain data on return */
  44291. + /* nic->packetlen should contain length of data */
  44292. + u32 framesize;
  44293. + u32 host_cmd = 0;
  44294. + u32 ack = 1;
  44295. + int eoc = 0;
  44296. + int entry = priv->cur_rx % TLAN_NUM_RX_LISTS;
  44297. + u16 tmpCStat = le32_to_cpu(rx_ring[entry].cStat);
  44298. + u16 host_int = inw(BASE + TLAN_HOST_INT);
  44299. - TLAN_DBG(TLAN_DEBUG_PROBE, "Probing for EISA adapter at IO: 0x%4x : ",
  44300. - (int) ioaddr);
  44301. - if (request_region(ioaddr, 0x10, TLanSignature) == NULL)
  44302. - goto out;
  44303. -
  44304. - if (inw(ioaddr + EISA_ID) != 0x110E) {
  44305. - release_region(ioaddr, 0x10);
  44306. - goto out;
  44307. - }
  44308. -
  44309. - device_id = inw(ioaddr + EISA_ID2);
  44310. - if (device_id != 0x20F1 && device_id != 0x40F1) {
  44311. - release_region (ioaddr, 0x10);
  44312. - goto out;
  44313. - }
  44314. -
  44315. - if (inb(ioaddr + EISA_CR) != 0x1) { /* Check if adapter is enabled */
  44316. - release_region (ioaddr, 0x10);
  44317. - goto out2;
  44318. - }
  44319. -
  44320. - if (debug == 0x10)
  44321. - printk("Found one\n");
  44322. + if ((tmpCStat & TLAN_CSTAT_FRM_CMP) && !retrieve)
  44323. + return 1;
  44324. - /* Get irq from board */
  44325. - switch (inb(ioaddr + 0xCC0)) {
  44326. - case(0x10):
  44327. - irq=5;
  44328. - break;
  44329. - case(0x20):
  44330. - irq=9;
  44331. - break;
  44332. - case(0x40):
  44333. - irq=10;
  44334. - break;
  44335. - case(0x80):
  44336. - irq=11;
  44337. - break;
  44338. - default:
  44339. - goto out;
  44340. - }
  44341. -
  44342. -
  44343. - /* Setup the newly found eisa adapter */
  44344. - rc = TLan_probe1( NULL, ioaddr, irq,
  44345. - 12, NULL);
  44346. - continue;
  44347. -
  44348. - out:
  44349. - if (debug == 0x10)
  44350. - printk("None found\n");
  44351. - continue;
  44352. -
  44353. - out2: if (debug == 0x10)
  44354. - printk("Card found but it is not enabled, skipping\n");
  44355. - continue;
  44356. -
  44357. - }
  44358. + outw(host_int, BASE + TLAN_HOST_INT);
  44359. -} /* TLan_EisaProbe */
  44360. + if (!(tmpCStat & TLAN_CSTAT_FRM_CMP))
  44361. + return 0;
  44362. -
  44363. + /* printf("PI-1: 0x%hX\n", host_int); */
  44364. + if (tmpCStat & TLAN_CSTAT_EOC)
  44365. + eoc = 1;
  44366. - /***************************************************************
  44367. - * TLan_Init
  44368. - *
  44369. - * Returns:
  44370. - * 0 on success, error code otherwise.
  44371. - * Parms:
  44372. - * dev The structure of the device to be
  44373. - * init'ed.
  44374. - *
  44375. - * This function completes the initialization of the
  44376. - * device structure and driver. It reserves the IO
  44377. - * addresses, allocates memory for the lists and bounce
  44378. - * buffers, retrieves the MAC address from the eeprom
  44379. - * and assignes the device's methods.
  44380. - *
  44381. - **************************************************************/
  44382. + framesize = rx_ring[entry].frameSize;
  44383. -static int TLan_Init( struct net_device *dev )
  44384. -{
  44385. - int dma_size;
  44386. - int err;
  44387. - int i;
  44388. - TLanPrivateInfo *priv;
  44389. + nic->packetlen = framesize;
  44390. - priv = dev->priv;
  44391. -
  44392. - if (!priv->is_eisa) /* EISA devices have already requested IO */
  44393. - if (!request_region( dev->base_addr, 0x10, TLanSignature )) {
  44394. - printk(KERN_ERR "TLAN: %s: IO port region 0x%lx size 0x%x in use.\n",
  44395. - dev->name,
  44396. - dev->base_addr,
  44397. - 0x10 );
  44398. - return -EIO;
  44399. +#ifdef EBDEBUG
  44400. + printf(".%d.", framesize);
  44401. +#endif
  44402. +
  44403. + memcpy(nic->packet, rxb +
  44404. + (priv->cur_rx * TLAN_MAX_FRAME_SIZE), nic->packetlen);
  44405. +
  44406. + rx_ring[entry].cStat = 0;
  44407. +#ifdef EBDEBUG
  44408. + //hex_dump(nic->packet, nic->packetlen);
  44409. + printf("%d", entry);
  44410. +#endif
  44411. + entry = (entry + 1) % TLAN_NUM_RX_LISTS;
  44412. + priv->cur_rx = entry;
  44413. + if (eoc) {
  44414. + if ((rx_ring[entry].cStat & TLAN_CSTAT_READY) ==
  44415. + TLAN_CSTAT_READY) {
  44416. + ack |= TLAN_HC_GO | TLAN_HC_RT;
  44417. + host_cmd = TLAN_HC_ACK | ack | 0x001C0000;
  44418. + outl(host_cmd, BASE + TLAN_HOST_CMD);
  44419. }
  44420. -
  44421. - if ( bbuf ) {
  44422. - dma_size = ( TLAN_NUM_RX_LISTS + TLAN_NUM_TX_LISTS )
  44423. - * ( sizeof(TLanList) + TLAN_MAX_FRAME_SIZE );
  44424. } else {
  44425. - dma_size = ( TLAN_NUM_RX_LISTS + TLAN_NUM_TX_LISTS )
  44426. - * ( sizeof(TLanList) );
  44427. - }
  44428. - priv->dmaStorage = kmalloc(dma_size, GFP_KERNEL | GFP_DMA);
  44429. - if ( priv->dmaStorage == NULL ) {
  44430. - printk(KERN_ERR "TLAN: Could not allocate lists and buffers for %s.\n",
  44431. - dev->name );
  44432. - release_region( dev->base_addr, 0x10 );
  44433. - return -ENOMEM;
  44434. - }
  44435. - memset( priv->dmaStorage, 0, dma_size );
  44436. - priv->rxList = (TLanList *)
  44437. - ( ( ( (u32) priv->dmaStorage ) + 7 ) & 0xFFFFFFF8 );
  44438. - priv->txList = priv->rxList + TLAN_NUM_RX_LISTS;
  44439. - if ( bbuf ) {
  44440. - priv->rxBuffer = (u8 *) ( priv->txList + TLAN_NUM_TX_LISTS );
  44441. - priv->txBuffer = priv->rxBuffer
  44442. - + ( TLAN_NUM_RX_LISTS * TLAN_MAX_FRAME_SIZE );
  44443. - }
  44444. -
  44445. - err = 0;
  44446. - for ( i = 0; i < 6 ; i++ )
  44447. - err |= TLan_EeReadByte( dev,
  44448. - (u8) priv->adapter->addrOfs + i,
  44449. - (u8 *) &dev->dev_addr[i] );
  44450. - if ( err ) {
  44451. - printk(KERN_ERR "TLAN: %s: Error reading MAC from eeprom: %d\n",
  44452. - dev->name,
  44453. - err );
  44454. - }
  44455. - dev->addr_len = 6;
  44456. -
  44457. - /* Device methods */
  44458. - dev->open = &TLan_Open;
  44459. - dev->hard_start_xmit = &TLan_StartTx;
  44460. - dev->stop = &TLan_Close;
  44461. - dev->get_stats = &TLan_GetStats;
  44462. - dev->set_multicast_list = &TLan_SetMulticastList;
  44463. - dev->do_ioctl = &TLan_ioctl;
  44464. - dev->tx_timeout = &TLan_tx_timeout;
  44465. - dev->watchdog_timeo = TX_TIMEOUT;
  44466. -
  44467. - return 0;
  44468. -
  44469. -} /* TLan_Init */
  44470. -
  44471. - /***************************************************************
  44472. - * TLan_Open
  44473. - *
  44474. - * Returns:
  44475. - * 0 on success, error code otherwise.
  44476. - * Parms:
  44477. - * dev Structure of device to be opened.
  44478. - *
  44479. - * This routine puts the driver and TLAN adapter in a
  44480. - * state where it is ready to send and receive packets.
  44481. - * It allocates the IRQ, resets and brings the adapter
  44482. - * out of reset, and allows interrupts. It also delays
  44483. - * the startup for autonegotiation or sends a Rx GO
  44484. - * command to the adapter, as appropriate.
  44485. - *
  44486. - **************************************************************/
  44487. -
  44488. -static int TLan_Open( struct net_device *dev )
  44489. -{
  44490. - TLanPrivateInfo *priv = dev->priv;
  44491. - int err;
  44492. -
  44493. - priv->tlanRev = TLan_DioRead8( dev->base_addr, TLAN_DEF_REVISION );
  44494. - err = request_irq( dev->irq, TLan_HandleInterrupt, SA_SHIRQ, TLanSignature, dev );
  44495. -
  44496. - if ( err ) {
  44497. - printk(KERN_ERR "TLAN: Cannot open %s because IRQ %d is already in use.\n", dev->name, dev->irq );
  44498. - return err;
  44499. + host_cmd = TLAN_HC_ACK | ack | (0x000C0000);
  44500. + outl(host_cmd, BASE + TLAN_HOST_CMD);
  44501. +#ifdef EBDEBUG
  44502. + printf("AC: 0x%hX\n", inw(BASE + TLAN_CH_PARM));
  44503. + host_int = inw(BASE + TLAN_HOST_INT);
  44504. + printf("PI-2: 0x%hX\n", host_int);
  44505. +#endif
  44506. }
  44507. -
  44508. - init_timer(&priv->timer);
  44509. - netif_start_queue(dev);
  44510. -
  44511. - /* NOTE: It might not be necessary to read the stats before a
  44512. - reset if you don't care what the values are.
  44513. - */
  44514. - TLan_ResetLists( dev );
  44515. - TLan_ReadAndClearStats( dev, TLAN_IGNORE );
  44516. - TLan_ResetAdapter( dev );
  44517. -
  44518. - TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Opened. TLAN Chip Rev: %x\n", dev->name, priv->tlanRev );
  44519. -
  44520. - return 0;
  44521. -
  44522. -} /* TLan_Open */
  44523. -
  44524. - /**************************************************************
  44525. - * TLan_ioctl
  44526. - *
  44527. - * Returns:
  44528. - * 0 on success, error code otherwise
  44529. - * Params:
  44530. - * dev structure of device to receive ioctl.
  44531. - *
  44532. - * rq ifreq structure to hold userspace data.
  44533. - *
  44534. - * cmd ioctl command.
  44535. - *
  44536. - *
  44537. - *************************************************************/
  44538. + refill_rx(nic);
  44539. + return (1); /* initially as this is called to flush the input */
  44540. +}
  44541. -static int TLan_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
  44542. +static void refill_rx(struct nic *nic __unused)
  44543. {
  44544. - TLanPrivateInfo *priv = dev->priv;
  44545. - struct mii_ioctl_data *data = (struct mii_ioctl_data *)&rq->ifr_data;
  44546. - u32 phy = priv->phy[priv->phyNum];
  44547. -
  44548. - if (!priv->phyOnline)
  44549. - return -EAGAIN;
  44550. -
  44551. - switch(cmd) {
  44552. - case SIOCGMIIPHY: /* Get address of MII PHY in use. */
  44553. - case SIOCDEVPRIVATE: /* for binary compat, remove in 2.5 */
  44554. - data->phy_id = phy;
  44555. -
  44556. - case SIOCGMIIREG: /* Read MII PHY register. */
  44557. - case SIOCDEVPRIVATE+1: /* for binary compat, remove in 2.5 */
  44558. - TLan_MiiReadReg(dev, data->phy_id & 0x1f, data->reg_num & 0x1f, &data->val_out);
  44559. - return 0;
  44560. -
  44561. + int entry = 0;
  44562. - case SIOCSMIIREG: /* Write MII PHY register. */
  44563. - case SIOCDEVPRIVATE+2: /* for binary compat, remove in 2.5 */
  44564. - if (!capable(CAP_NET_ADMIN))
  44565. - return -EPERM;
  44566. - TLan_MiiWriteReg(dev, data->phy_id & 0x1f, data->reg_num & 0x1f, data->val_in);
  44567. - return 0;
  44568. - default:
  44569. - return -EOPNOTSUPP;
  44570. + for (;
  44571. + (priv->cur_rx - priv->dirty_rx +
  44572. + TLAN_NUM_RX_LISTS) % TLAN_NUM_RX_LISTS > 0;
  44573. + priv->dirty_rx = (priv->dirty_rx + 1) % TLAN_NUM_RX_LISTS) {
  44574. + entry = priv->dirty_rx % TLAN_NUM_TX_LISTS;
  44575. + rx_ring[entry].frameSize = TLAN_MAX_FRAME_SIZE;
  44576. + rx_ring[entry].cStat = TLAN_CSTAT_READY;
  44577. }
  44578. -} /* tlan_ioctl */
  44579. -
  44580. - /***************************************************************
  44581. - * TLan_tx_timeout
  44582. - *
  44583. - * Returns: nothing
  44584. - *
  44585. - * Params:
  44586. - * dev structure of device which timed out
  44587. - * during transmit.
  44588. - *
  44589. - **************************************************************/
  44590. -
  44591. -static void TLan_tx_timeout(struct net_device *dev)
  44592. -{
  44593. -
  44594. - TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Transmit timed out.\n", dev->name);
  44595. -
  44596. - /* Ok so we timed out, lets see what we can do about it...*/
  44597. - TLan_FreeLists( dev );
  44598. - TLan_ResetLists( dev );
  44599. - TLan_ReadAndClearStats( dev, TLAN_IGNORE );
  44600. - TLan_ResetAdapter( dev );
  44601. - dev->trans_start = jiffies;
  44602. - netif_wake_queue( dev );
  44603. }
  44604. -
  44605. - /***************************************************************
  44606. - * TLan_StartTx
  44607. - *
  44608. - * Returns:
  44609. - * 0 on success, non-zero on failure.
  44610. - * Parms:
  44611. - * skb A pointer to the sk_buff containing the
  44612. - * frame to be sent.
  44613. - * dev The device to send the data on.
  44614. - *
  44615. - * This function adds a frame to the Tx list to be sent
  44616. - * ASAP. First it verifies that the adapter is ready and
  44617. - * there is room in the queue. Then it sets up the next
  44618. - * available list, copies the frame to the corresponding
  44619. - * buffer. If the adapter Tx channel is idle, it gives
  44620. - * the adapter a Tx Go command on the list, otherwise it
  44621. - * sets the forward address of the previous list to point
  44622. - * to this one. Then it frees the sk_buff.
  44623. - *
  44624. - **************************************************************/
  44625. +/* #define EBDEBUG */
  44626. +/**************************************************************************
  44627. +TRANSMIT - Transmit a frame
  44628. +***************************************************************************/
  44629. +static void tlan_transmit(struct nic *nic, const char *d, /* Destination */
  44630. + unsigned int t, /* Type */
  44631. + unsigned int s, /* size */
  44632. + const char *p)
  44633. +{ /* Packet */
  44634. + u16 nstype;
  44635. + u32 to;
  44636. + struct TLanList *tail_list;
  44637. + struct TLanList *head_list;
  44638. + u8 *tail_buffer;
  44639. + u32 ack = 0;
  44640. + u32 host_cmd;
  44641. + int eoc = 0;
  44642. + u16 tmpCStat;
  44643. +#ifdef EBDEBUG
  44644. + u16 host_int = inw(BASE + TLAN_HOST_INT);
  44645. +#endif
  44646. + int entry = 0;
  44647. -static int TLan_StartTx( struct sk_buff *skb, struct net_device *dev )
  44648. -{
  44649. - TLanPrivateInfo *priv = dev->priv;
  44650. - TLanList *tail_list;
  44651. - u8 *tail_buffer;
  44652. - int pad;
  44653. - unsigned long flags;
  44654. -
  44655. - if ( ! priv->phyOnline ) {
  44656. - TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: %s PHY is not ready\n", dev->name );
  44657. - dev_kfree_skb_any(skb);
  44658. - return 0;
  44659. +#ifdef EBDEBUG
  44660. + printf("INT0-0x%hX\n", host_int);
  44661. +#endif
  44662. +
  44663. + if (!priv->phyOnline) {
  44664. + printf("TRANSMIT: %s PHY is not ready\n", priv->nic_name);
  44665. + return;
  44666. }
  44667. tail_list = priv->txList + priv->txTail;
  44668. -
  44669. - if ( tail_list->cStat != TLAN_CSTAT_UNUSED ) {
  44670. - TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: %s is busy (Head=%d Tail=%d)\n", dev->name, priv->txHead, priv->txTail );
  44671. - netif_stop_queue(dev);
  44672. +
  44673. + if (tail_list->cStat != TLAN_CSTAT_UNUSED) {
  44674. + printf("TRANSMIT: %s is busy (Head=%d Tail=%d)\n",
  44675. + priv->nic_name, priv->txList, priv->txTail);
  44676. + tx_ring[entry].cStat = TLAN_CSTAT_UNUSED;
  44677. priv->txBusyCount++;
  44678. - return 1;
  44679. + return;
  44680. }
  44681. tail_list->forward = 0;
  44682. - if ( bbuf ) {
  44683. - tail_buffer = priv->txBuffer + ( priv->txTail * TLAN_MAX_FRAME_SIZE );
  44684. - memcpy( tail_buffer, skb->data, skb->len );
  44685. - } else {
  44686. - tail_list->buffer[0].address = virt_to_bus( skb->data );
  44687. - tail_list->buffer[9].address = (u32) skb;
  44688. - }
  44689. + tail_buffer = txb + (priv->txTail * TLAN_MAX_FRAME_SIZE);
  44690. - pad = TLAN_MIN_FRAME_SIZE - skb->len;
  44691. -
  44692. - if ( pad > 0 ) {
  44693. - tail_list->frameSize = (u16) skb->len + pad;
  44694. - tail_list->buffer[0].count = (u32) skb->len;
  44695. - tail_list->buffer[1].count = TLAN_LAST_BUFFER | (u32) pad;
  44696. - tail_list->buffer[1].address = virt_to_bus( TLanPadBuffer );
  44697. - } else {
  44698. - tail_list->frameSize = (u16) skb->len;
  44699. - tail_list->buffer[0].count = TLAN_LAST_BUFFER | (u32) skb->len;
  44700. - tail_list->buffer[1].count = 0;
  44701. - tail_list->buffer[1].address = 0;
  44702. - }
  44703. + /* send the packet to destination */
  44704. + memcpy(tail_buffer, d, ETH_ALEN);
  44705. + memcpy(tail_buffer + ETH_ALEN, nic->node_addr, ETH_ALEN);
  44706. + nstype = htons((u16) t);
  44707. + memcpy(tail_buffer + 2 * ETH_ALEN, (u8 *) & nstype, 2);
  44708. + memcpy(tail_buffer + ETH_HLEN, p, s);
  44709. +
  44710. + s += ETH_HLEN;
  44711. + s &= 0x0FFF;
  44712. + while (s < ETH_ZLEN)
  44713. + tail_buffer[s++] = '\0';
  44714. +
  44715. + /*=====================================================*/
  44716. + /* Receive
  44717. + * 0000 0000 0001 1100
  44718. + * 0000 0000 0000 1100
  44719. + * 0000 0000 0000 0011 = 0x0003
  44720. + *
  44721. + * 0000 0000 0000 0000 0000 0000 0000 0011
  44722. + * 0000 0000 0000 1100 0000 0000 0000 0000 = 0x000C0000
  44723. + *
  44724. + * Transmit
  44725. + * 0000 0000 0001 1100
  44726. + * 0000 0000 0000 0100
  44727. + * 0000 0000 0000 0001 = 0x0001
  44728. + *
  44729. + * 0000 0000 0000 0000 0000 0000 0000 0001
  44730. + * 0000 0000 0000 0100 0000 0000 0000 0000 = 0x00040000
  44731. + * */
  44732. +
  44733. + /* Setup the transmit descriptor */
  44734. + tail_list->frameSize = (u16) s;
  44735. + tail_list->buffer[0].count = TLAN_LAST_BUFFER | (u32) s;
  44736. + tail_list->buffer[1].count = 0;
  44737. + tail_list->buffer[1].address = 0;
  44738. - spin_lock_irqsave(&priv->lock, flags);
  44739. tail_list->cStat = TLAN_CSTAT_READY;
  44740. - if ( ! priv->txInProgress ) {
  44741. +
  44742. +#ifdef EBDEBUG
  44743. + host_int = inw(BASE + TLAN_HOST_INT);
  44744. + printf("INT1-0x%hX\n", host_int);
  44745. +#endif
  44746. +
  44747. + if (!priv->txInProgress) {
  44748. priv->txInProgress = 1;
  44749. - TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: Starting TX on buffer %d\n", priv->txTail );
  44750. - outl( virt_to_bus( tail_list ), dev->base_addr + TLAN_CH_PARM );
  44751. - outl( TLAN_HC_GO, dev->base_addr + TLAN_HOST_CMD );
  44752. + outl(virt_to_le32desc(tail_list), BASE + TLAN_CH_PARM);
  44753. + outl(TLAN_HC_GO, BASE + TLAN_HOST_CMD);
  44754. } else {
  44755. - TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: Adding buffer %d to TX channel\n", priv->txTail );
  44756. - if ( priv->txTail == 0 ) {
  44757. - ( priv->txList + ( TLAN_NUM_TX_LISTS - 1 ) )->forward = virt_to_bus( tail_list );
  44758. + if (priv->txTail == 0) {
  44759. +#ifdef EBDEBUG
  44760. + printf("Out buffer\n");
  44761. +#endif
  44762. + (priv->txList + (TLAN_NUM_TX_LISTS - 1))->forward =
  44763. + virt_to_le32desc(tail_list);
  44764. } else {
  44765. - ( priv->txList + ( priv->txTail - 1 ) )->forward = virt_to_bus( tail_list );
  44766. +#ifdef EBDEBUG
  44767. + printf("Fix this \n");
  44768. +#endif
  44769. + (priv->txList + (priv->txTail - 1))->forward =
  44770. + virt_to_le32desc(tail_list);
  44771. }
  44772. }
  44773. - spin_unlock_irqrestore(&priv->lock, flags);
  44774. -
  44775. - CIRC_INC( priv->txTail, TLAN_NUM_TX_LISTS );
  44776. -
  44777. - if ( bbuf )
  44778. - dev_kfree_skb_any(skb);
  44779. -
  44780. - dev->trans_start = jiffies;
  44781. - return 0;
  44782. -
  44783. -} /* TLan_StartTx */
  44784. -
  44785. - /***************************************************************
  44786. - * TLan_HandleInterrupt
  44787. - *
  44788. - * Returns:
  44789. - * Nothing
  44790. - * Parms:
  44791. - * irq The line on which the interrupt
  44792. - * occurred.
  44793. - * dev_id A pointer to the device assigned to
  44794. - * this irq line.
  44795. - * regs ???
  44796. - *
  44797. - * This function handles an interrupt generated by its
  44798. - * assigned TLAN adapter. The function deactivates
  44799. - * interrupts on its adapter, records the type of
  44800. - * interrupt, executes the appropriate subhandler, and
  44801. - * acknowdges the interrupt to the adapter (thus
  44802. - * re-enabling adapter interrupts.
  44803. - *
  44804. - **************************************************************/
  44805. -
  44806. -static void TLan_HandleInterrupt(int irq, void *dev_id, struct pt_regs *regs)
  44807. -{
  44808. - u32 ack;
  44809. - struct net_device *dev;
  44810. - u32 host_cmd;
  44811. - u16 host_int;
  44812. - int type;
  44813. - TLanPrivateInfo *priv;
  44814. -
  44815. - dev = dev_id;
  44816. - priv = dev->priv;
  44817. -
  44818. - spin_lock(&priv->lock);
  44819. -
  44820. - host_int = inw( dev->base_addr + TLAN_HOST_INT );
  44821. - outw( host_int, dev->base_addr + TLAN_HOST_INT );
  44822. +
  44823. + CIRC_INC(priv->txTail, TLAN_NUM_TX_LISTS);
  44824. - type = ( host_int & TLAN_HI_IT_MASK ) >> 2;
  44825. +#ifdef EBDEBUG
  44826. + host_int = inw(BASE + TLAN_HOST_INT);
  44827. + printf("INT2-0x%hX\n", host_int);
  44828. +#endif
  44829. - ack = TLanIntVector[type]( dev, host_int );
  44830. + to = currticks() + TX_TIME_OUT;
  44831. + while ((tail_list->cStat == TLAN_CSTAT_READY) && currticks() < to);
  44832. - if ( ack ) {
  44833. - host_cmd = TLAN_HC_ACK | ack | ( type << 18 );
  44834. - outl( host_cmd, dev->base_addr + TLAN_HOST_CMD );
  44835. + head_list = priv->txList + priv->txHead;
  44836. + while (((tmpCStat = head_list->cStat) & TLAN_CSTAT_FRM_CMP)
  44837. + && (ack < 255)) {
  44838. + ack++;
  44839. + if(tmpCStat & TLAN_CSTAT_EOC)
  44840. + eoc =1;
  44841. + head_list->cStat = TLAN_CSTAT_UNUSED;
  44842. + CIRC_INC(priv->txHead, TLAN_NUM_TX_LISTS);
  44843. + head_list = priv->txList + priv->txHead;
  44844. +
  44845. }
  44846. + if(!ack)
  44847. + printf("Incomplete TX Frame\n");
  44848. - spin_unlock(&priv->lock);
  44849. -
  44850. -} /* TLan_HandleInterrupts */
  44851. -
  44852. - /***************************************************************
  44853. - * TLan_Close
  44854. - *
  44855. - * Returns:
  44856. - * An error code.
  44857. - * Parms:
  44858. - * dev The device structure of the device to
  44859. - * close.
  44860. - *
  44861. - * This function shuts down the adapter. It records any
  44862. - * stats, puts the adapter into reset state, deactivates
  44863. - * its time as needed, and frees the irq it is using.
  44864. - *
  44865. - **************************************************************/
  44866. -
  44867. -static int TLan_Close(struct net_device *dev)
  44868. -{
  44869. - TLanPrivateInfo *priv = dev->priv;
  44870. -
  44871. - netif_stop_queue(dev);
  44872. - priv->neg_be_verbose = 0;
  44873. -
  44874. - TLan_ReadAndClearStats( dev, TLAN_RECORD );
  44875. - outl( TLAN_HC_AD_RST, dev->base_addr + TLAN_HOST_CMD );
  44876. - if ( priv->timer.function != NULL ) {
  44877. - del_timer_sync( &priv->timer );
  44878. - priv->timer.function = NULL;
  44879. + if(eoc) {
  44880. + head_list = priv->txList + priv->txHead;
  44881. + if ((head_list->cStat & TLAN_CSTAT_READY) == TLAN_CSTAT_READY) {
  44882. + outl(virt_to_le32desc(head_list), BASE + TLAN_CH_PARM);
  44883. + ack |= TLAN_HC_GO;
  44884. + } else {
  44885. + priv->txInProgress = 0;
  44886. + }
  44887. }
  44888. -
  44889. - free_irq( dev->irq, dev );
  44890. - TLan_FreeLists( dev );
  44891. - TLAN_DBG( TLAN_DEBUG_GNRL, "Device %s closed.\n", dev->name );
  44892. -
  44893. - return 0;
  44894. -
  44895. -} /* TLan_Close */
  44896. -
  44897. - /***************************************************************
  44898. - * TLan_GetStats
  44899. - *
  44900. - * Returns:
  44901. - * A pointer to the device's statistics structure.
  44902. - * Parms:
  44903. - * dev The device structure to return the
  44904. - * stats for.
  44905. - *
  44906. - * This function updates the devices statistics by reading
  44907. - * the TLAN chip's onboard registers. Then it returns the
  44908. - * address of the statistics structure.
  44909. - *
  44910. - **************************************************************/
  44911. -
  44912. -static struct net_device_stats *TLan_GetStats( struct net_device *dev )
  44913. -{
  44914. - TLanPrivateInfo *priv = dev->priv;
  44915. - int i;
  44916. -
  44917. - /* Should only read stats if open ? */
  44918. - TLan_ReadAndClearStats( dev, TLAN_RECORD );
  44919. -
  44920. - TLAN_DBG( TLAN_DEBUG_RX, "RECEIVE: %s EOC count = %d\n", dev->name, priv->rxEocCount );
  44921. - TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: %s Busy count = %d\n", dev->name, priv->txBusyCount );
  44922. - if ( debug & TLAN_DEBUG_GNRL ) {
  44923. - TLan_PrintDio( dev->base_addr );
  44924. - TLan_PhyPrint( dev );
  44925. - }
  44926. - if ( debug & TLAN_DEBUG_LIST ) {
  44927. - for ( i = 0; i < TLAN_NUM_RX_LISTS; i++ )
  44928. - TLan_PrintList( priv->rxList + i, "RX", i );
  44929. - for ( i = 0; i < TLAN_NUM_TX_LISTS; i++ )
  44930. - TLan_PrintList( priv->txList + i, "TX", i );
  44931. + if(ack) {
  44932. + host_cmd = TLAN_HC_ACK | ack;
  44933. + outl(host_cmd, BASE + TLAN_HOST_CMD);
  44934. }
  44935. - return ( &( (TLanPrivateInfo *) dev->priv )->stats );
  44936. -
  44937. -} /* TLan_GetStats */
  44938. -
  44939. - /***************************************************************
  44940. - * TLan_SetMulticastList
  44941. - *
  44942. - * Returns:
  44943. - * Nothing
  44944. - * Parms:
  44945. - * dev The device structure to set the
  44946. - * multicast list for.
  44947. - *
  44948. - * This function sets the TLAN adaptor to various receive
  44949. - * modes. If the IFF_PROMISC flag is set, promiscuous
  44950. - * mode is acitviated. Otherwise, promiscuous mode is
  44951. - * turned off. If the IFF_ALLMULTI flag is set, then
  44952. - * the hash table is set to receive all group addresses.
  44953. - * Otherwise, the first three multicast addresses are
  44954. - * stored in AREG_1-3, and the rest are selected via the
  44955. - * hash table, as necessary.
  44956. - *
  44957. - **************************************************************/
  44958. -
  44959. -static void TLan_SetMulticastList( struct net_device *dev )
  44960. -{
  44961. - struct dev_mc_list *dmi = dev->mc_list;
  44962. - u32 hash1 = 0;
  44963. - u32 hash2 = 0;
  44964. - int i;
  44965. - u32 offset;
  44966. - u8 tmp;
  44967. -
  44968. - if ( dev->flags & IFF_PROMISC ) {
  44969. - tmp = TLan_DioRead8( dev->base_addr, TLAN_NET_CMD );
  44970. - TLan_DioWrite8( dev->base_addr, TLAN_NET_CMD, tmp | TLAN_NET_CMD_CAF );
  44971. - } else {
  44972. - tmp = TLan_DioRead8( dev->base_addr, TLAN_NET_CMD );
  44973. - TLan_DioWrite8( dev->base_addr, TLAN_NET_CMD, tmp & ~TLAN_NET_CMD_CAF );
  44974. - if ( dev->flags & IFF_ALLMULTI ) {
  44975. - for ( i = 0; i < 3; i++ )
  44976. - TLan_SetMac( dev, i + 1, NULL );
  44977. - TLan_DioWrite32( dev->base_addr, TLAN_HASH_1, 0xFFFFFFFF );
  44978. - TLan_DioWrite32( dev->base_addr, TLAN_HASH_2, 0xFFFFFFFF );
  44979. + if(priv->tlanRev < 0x30 ) {
  44980. + ack = 1;
  44981. + head_list = priv->txList + priv->txHead;
  44982. + if ((head_list->cStat & TLAN_CSTAT_READY) == TLAN_CSTAT_READY) {
  44983. + outl(virt_to_le32desc(head_list), BASE + TLAN_CH_PARM);
  44984. + ack |= TLAN_HC_GO;
  44985. } else {
  44986. - for ( i = 0; i < dev->mc_count; i++ ) {
  44987. - if ( i < 3 ) {
  44988. - TLan_SetMac( dev, i + 1, (char *) &dmi->dmi_addr );
  44989. - } else {
  44990. - offset = TLan_HashFunc( (u8 *) &dmi->dmi_addr );
  44991. - if ( offset < 32 )
  44992. - hash1 |= ( 1 << offset );
  44993. - else
  44994. - hash2 |= ( 1 << ( offset - 32 ) );
  44995. - }
  44996. - dmi = dmi->next;
  44997. - }
  44998. - for ( ; i < 3; i++ )
  44999. - TLan_SetMac( dev, i + 1, NULL );
  45000. - TLan_DioWrite32( dev->base_addr, TLAN_HASH_1, hash1 );
  45001. - TLan_DioWrite32( dev->base_addr, TLAN_HASH_2, hash2 );
  45002. + priv->txInProgress = 0;
  45003. }
  45004. + host_cmd = TLAN_HC_ACK | ack | 0x00140000;
  45005. + outl(host_cmd, BASE + TLAN_HOST_CMD);
  45006. +
  45007. }
  45008. +
  45009. + if (currticks() >= to) {
  45010. + printf("TX Time Out");
  45011. + }
  45012. +}
  45013. -} /* TLan_SetMulticastList */
  45014. -
  45015. -/*****************************************************************************
  45016. -******************************************************************************
  45017. -
  45018. - ThunderLAN Driver Interrupt Vectors and Table
  45019. -
  45020. - Please see Chap. 4, "Interrupt Handling" of the "ThunderLAN
  45021. - Programmer's Guide" for more informations on handling interrupts
  45022. - generated by TLAN based adapters.
  45023. -
  45024. -******************************************************************************
  45025. -*****************************************************************************/
  45026. -
  45027. - /***************************************************************
  45028. - * TLan_HandleInvalid
  45029. - *
  45030. - * Returns:
  45031. - * 0
  45032. - * Parms:
  45033. - * dev Device assigned the IRQ that was
  45034. - * raised.
  45035. - * host_int The contents of the HOST_INT
  45036. - * port.
  45037. - *
  45038. - * This function handles invalid interrupts. This should
  45039. - * never happen unless some other adapter is trying to use
  45040. - * the IRQ line assigned to the device.
  45041. - *
  45042. - **************************************************************/
  45043. -
  45044. -u32 TLan_HandleInvalid( struct net_device *dev, u16 host_int )
  45045. +/**************************************************************************
  45046. +DISABLE - Turn off ethernet interface
  45047. +***************************************************************************/
  45048. +#ifdef EB51
  45049. +static void tlan_disable(struct dev *dev __unused)
  45050. +#else
  45051. +static void tlan_disable(struct nic *nic __unused)
  45052. +#endif
  45053. {
  45054. - /* printk( "TLAN: Invalid interrupt on %s.\n", dev->name ); */
  45055. - return 0;
  45056. -
  45057. -} /* TLan_HandleInvalid */
  45058. -
  45059. - /***************************************************************
  45060. - * TLan_HandleTxEOF
  45061. - *
  45062. - * Returns:
  45063. - * 1
  45064. - * Parms:
  45065. - * dev Device assigned the IRQ that was
  45066. - * raised.
  45067. - * host_int The contents of the HOST_INT
  45068. - * port.
  45069. - *
  45070. - * This function handles Tx EOF interrupts which are raised
  45071. - * by the adapter when it has completed sending the
  45072. - * contents of a buffer. If detemines which list/buffer
  45073. - * was completed and resets it. If the buffer was the last
  45074. - * in the channel (EOC), then the function checks to see if
  45075. - * another buffer is ready to send, and if so, sends a Tx
  45076. - * Go command. Finally, the driver activates/continues the
  45077. - * activity LED.
  45078. + /* put the card in its initial state */
  45079. + /* This function serves 3 purposes.
  45080. + * This disables DMA and interrupts so we don't receive
  45081. + * unexpected packets or interrupts from the card after
  45082. + * etherboot has finished.
  45083. + * This frees resources so etherboot may use
  45084. + * this driver on another interface
  45085. + * This allows etherboot to reinitialize the interface
  45086. + * if something is something goes wrong.
  45087. *
  45088. - **************************************************************/
  45089. + */
  45090. + outl(TLAN_HC_AD_RST, BASE + TLAN_HOST_CMD);
  45091. +}
  45092. -u32 TLan_HandleTxEOF( struct net_device *dev, u16 host_int )
  45093. +/**************************************************************************
  45094. +IRQ - Enable, Disable, or Force interrupts
  45095. +***************************************************************************/
  45096. +static void tlan_irq(struct nic *nic __unused, irq_action_t action __unused)
  45097. {
  45098. - TLanPrivateInfo *priv = dev->priv;
  45099. - int eoc = 0;
  45100. - TLanList *head_list;
  45101. - u32 ack = 0;
  45102. - u16 tmpCStat;
  45103. -
  45104. - TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: Handling TX EOF (Head=%d Tail=%d)\n", priv->txHead, priv->txTail );
  45105. - head_list = priv->txList + priv->txHead;
  45106. + switch ( action ) {
  45107. + case DISABLE :
  45108. + break;
  45109. + case ENABLE :
  45110. + break;
  45111. + case FORCE :
  45112. + break;
  45113. + }
  45114. +}
  45115. - while (((tmpCStat = head_list->cStat ) & TLAN_CSTAT_FRM_CMP) && (ack < 255)) {
  45116. - ack++;
  45117. - if ( ! bbuf ) {
  45118. - dev_kfree_skb_any( (struct sk_buff *) head_list->buffer[9].address );
  45119. - head_list->buffer[9].address = 0;
  45120. - }
  45121. -
  45122. - if ( tmpCStat & TLAN_CSTAT_EOC )
  45123. - eoc = 1;
  45124. -
  45125. - priv->stats.tx_bytes += head_list->frameSize;
  45126. +static void TLan_SetMulticastList(struct nic *nic) {
  45127. + int i;
  45128. + u8 tmp;
  45129. - head_list->cStat = TLAN_CSTAT_UNUSED;
  45130. - netif_start_queue(dev);
  45131. - CIRC_INC( priv->txHead, TLAN_NUM_TX_LISTS );
  45132. - head_list = priv->txList + priv->txHead;
  45133. - }
  45134. + /* !IFF_PROMISC */
  45135. + tmp = TLan_DioRead8(BASE, TLAN_NET_CMD);
  45136. + TLan_DioWrite8(BASE, TLAN_NET_CMD, tmp & ~TLAN_NET_CMD_CAF);
  45137. +
  45138. + /* IFF_ALLMULTI */
  45139. + for(i = 0; i< 3; i++)
  45140. + TLan_SetMac(nic, i + 1, NULL);
  45141. + TLan_DioWrite32(BASE, TLAN_HASH_1, 0xFFFFFFFF);
  45142. + TLan_DioWrite32(BASE, TLAN_HASH_2, 0xFFFFFFFF);
  45143. - if (!ack)
  45144. - printk(KERN_INFO "TLAN: Received interrupt for uncompleted TX frame.\n");
  45145. -
  45146. - if ( eoc ) {
  45147. - TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: Handling TX EOC (Head=%d Tail=%d)\n", priv->txHead, priv->txTail );
  45148. - head_list = priv->txList + priv->txHead;
  45149. - if ( ( head_list->cStat & TLAN_CSTAT_READY ) == TLAN_CSTAT_READY ) {
  45150. - outl( virt_to_bus( head_list ), dev->base_addr + TLAN_CH_PARM );
  45151. - ack |= TLAN_HC_GO;
  45152. - } else {
  45153. - priv->txInProgress = 0;
  45154. - }
  45155. - }
  45156. - if ( priv->adapter->flags & TLAN_ADAPTER_ACTIVITY_LED ) {
  45157. - TLan_DioWrite8( dev->base_addr, TLAN_LED_REG, TLAN_LED_LINK | TLAN_LED_ACT );
  45158. - if ( priv->timer.function == NULL ) {
  45159. - priv->timer.function = &TLan_Timer;
  45160. - priv->timer.data = (unsigned long) dev;
  45161. - priv->timer.expires = jiffies + TLAN_TIMER_ACT_DELAY;
  45162. - priv->timerSetAt = jiffies;
  45163. - priv->timerType = TLAN_TIMER_ACTIVITY;
  45164. - add_timer(&priv->timer);
  45165. - } else if ( priv->timerType == TLAN_TIMER_ACTIVITY ) {
  45166. - priv->timerSetAt = jiffies;
  45167. +}
  45168. +/**************************************************************************
  45169. +PROBE - Look for an adapter, this routine's visible to the outside
  45170. +***************************************************************************/
  45171. +
  45172. +#define board_found 1
  45173. +#define valid_link 0
  45174. +#ifdef EB51
  45175. +static int tlan_probe(struct dev *dev, struct pci_device *pci)
  45176. +{
  45177. + struct nic *nic = (struct nic *) dev;
  45178. +#else
  45179. +struct nic *tlan_probe(struct nic *nic, unsigned short *io_addrs, struct pci_device *pci)
  45180. +{
  45181. +#endif
  45182. + u16 data = 0;
  45183. + int err;
  45184. + int i;
  45185. +
  45186. + if (pci->ioaddr == 0)
  45187. + return 0;
  45188. +
  45189. + nic->irqno = 0;
  45190. + nic->ioaddr = pci->ioaddr & ~3;
  45191. +
  45192. + BASE = pci->ioaddr;
  45193. + printf("\n");
  45194. + printf("tlan.c: %s, %s\n", drv_version, drv_date);
  45195. + printf("%s: Probing for Vendor 0x%hX, Device 0x%hX",
  45196. + pci->name, pci->vendor, pci->dev_id);
  45197. +
  45198. +
  45199. + /* I really must find out what this does */
  45200. + adjust_pci_device(pci);
  45201. +
  45202. + /* Point to private storage */
  45203. + priv = &TLanPrivateInfo;
  45204. + /* Figure out which chip we're dealing with */
  45205. + i = 0;
  45206. + chip_idx = -1;
  45207. +
  45208. + while (tlan_pci_tbl[i].name) {
  45209. + if ((((u32) pci->dev_id << 16) | pci->vendor) ==
  45210. + (tlan_pci_tbl[i].id.pci & 0xffffffff)) {
  45211. + chip_idx = i;
  45212. + break;
  45213. }
  45214. + i++;
  45215. }
  45216. - return ack;
  45217. + priv->vendor_id = pci->vendor;
  45218. + priv->dev_id = pci->dev_id;
  45219. + priv->nic_name = pci->name;
  45220. + priv->eoc = 0;
  45221. -} /* TLan_HandleTxEOF */
  45222. + err = 0;
  45223. + for (i = 0; i < 6; i++)
  45224. + err |= TLan_EeReadByte(BASE,
  45225. + (u8) tlan_pci_tbl[chip_idx].
  45226. + addrOfs + i,
  45227. + (u8 *) & nic->node_addr[i]);
  45228. + if (err) {
  45229. + printf("TLAN: %s: Error reading MAC from eeprom: %d\n",
  45230. + pci->name, err);
  45231. + } else
  45232. + printf("\nAddress: %!\n", nic->node_addr);
  45233. - /***************************************************************
  45234. - * TLan_HandleStatOverflow
  45235. - *
  45236. - * Returns:
  45237. - * 1
  45238. - * Parms:
  45239. - * dev Device assigned the IRQ that was
  45240. - * raised.
  45241. - * host_int The contents of the HOST_INT
  45242. - * port.
  45243. - *
  45244. - * This function handles the Statistics Overflow interrupt
  45245. - * which means that one or more of the TLAN statistics
  45246. - * registers has reached 1/2 capacity and needs to be read.
  45247. - *
  45248. - **************************************************************/
  45249. + priv->tlanRev = TLan_DioRead8(BASE, TLAN_DEF_REVISION);
  45250. + printf("\nRevision = 0x%hX\n", priv->tlanRev);
  45251. -u32 TLan_HandleStatOverflow( struct net_device *dev, u16 host_int )
  45252. -{
  45253. - TLan_ReadAndClearStats( dev, TLAN_RECORD );
  45254. + TLan_ResetLists(nic);
  45255. + TLan_ResetAdapter(nic);
  45256. +/*
  45257. + data = inl(BASE + TLAN_HOST_CMD);
  45258. + data |= TLAN_HC_EOC;
  45259. + outw(data, BASE + TLAN_HOST_CMD);
  45260. +*/
  45261. +
  45262. + data = inl(BASE + TLAN_HOST_CMD);
  45263. + data |= TLAN_HC_INT_OFF;
  45264. + outw(data, BASE + TLAN_HOST_CMD);
  45265. + TLan_SetMulticastList(nic);
  45266. + udelay(100);
  45267. + priv->txList = tx_ring;
  45268. + priv->rxList = rx_ring;
  45269. +/* if (board_found && valid_link)
  45270. + {*/
  45271. + /* point to NIC specific routines */
  45272. +#ifdef EB51
  45273. + dev->disable = tlan_disable;
  45274. + nic->poll = tlan_poll;
  45275. + nic->transmit = tlan_transmit;
  45276. + nic->irq = tlan_irq;
  45277. return 1;
  45278. +#else
  45279. + nic->disable = tlan_disable;
  45280. + nic->poll = tlan_poll;
  45281. + nic->transmit = tlan_transmit;
  45282. + nic->irq = tlan_irq;
  45283. + return nic;
  45284. +#endif
  45285. +}
  45286. +
  45287. +
  45288. +/*****************************************************************************
  45289. +******************************************************************************
  45290. +
  45291. + ThunderLAN Driver Eeprom routines
  45292. +
  45293. + The Compaq Netelligent 10 and 10/100 cards use a Microchip 24C02A
  45294. + EEPROM. These functions are based on information in Microchip's
  45295. + data sheet. I don't know how well this functions will work with
  45296. + other EEPROMs.
  45297. +
  45298. +******************************************************************************
  45299. +*****************************************************************************/
  45300. -} /* TLan_HandleStatOverflow */
  45301. /***************************************************************
  45302. - * TLan_HandleRxEOF
  45303. + * TLan_EeSendStart
  45304. *
  45305. * Returns:
  45306. - * 1
  45307. + * Nothing
  45308. * Parms:
  45309. - * dev Device assigned the IRQ that was
  45310. - * raised.
  45311. - * host_int The contents of the HOST_INT
  45312. - * port.
  45313. - *
  45314. - * This function handles the Rx EOF interrupt which
  45315. - * indicates a frame has been received by the adapter from
  45316. - * the net and the frame has been transferred to memory.
  45317. - * The function determines the bounce buffer the frame has
  45318. - * been loaded into, creates a new sk_buff big enough to
  45319. - * hold the frame, and sends it to protocol stack. It
  45320. - * then resets the used buffer and appends it to the end
  45321. - * of the list. If the frame was the last in the Rx
  45322. - * channel (EOC), the function restarts the receive channel
  45323. - * by sending an Rx Go command to the adapter. Then it
  45324. - * activates/continues the activity LED.
  45325. + * io_base The IO port base address for the
  45326. + * TLAN device with the EEPROM to
  45327. + * use.
  45328. + *
  45329. + * This function sends a start cycle to an EEPROM attached
  45330. + * to a TLAN chip.
  45331. *
  45332. **************************************************************/
  45333. -u32 TLan_HandleRxEOF( struct net_device *dev, u16 host_int )
  45334. +void TLan_EeSendStart(u16 io_base)
  45335. {
  45336. - TLanPrivateInfo *priv = dev->priv;
  45337. - u32 ack = 0;
  45338. - int eoc = 0;
  45339. - u8 *head_buffer;
  45340. - TLanList *head_list;
  45341. - struct sk_buff *skb;
  45342. - TLanList *tail_list;
  45343. - void *t;
  45344. - u32 frameSize;
  45345. - u16 tmpCStat;
  45346. -
  45347. - TLAN_DBG( TLAN_DEBUG_RX, "RECEIVE: Handling RX EOF (Head=%d Tail=%d)\n", priv->rxHead, priv->rxTail );
  45348. - head_list = priv->rxList + priv->rxHead;
  45349. -
  45350. - while (((tmpCStat = head_list->cStat) & TLAN_CSTAT_FRM_CMP) && (ack < 255)) {
  45351. - frameSize = head_list->frameSize;
  45352. - ack++;
  45353. - if (tmpCStat & TLAN_CSTAT_EOC)
  45354. - eoc = 1;
  45355. -
  45356. - if (bbuf) {
  45357. - skb = dev_alloc_skb(frameSize + 7);
  45358. - if (skb == NULL)
  45359. - printk(KERN_INFO "TLAN: Couldn't allocate memory for received data.\n");
  45360. - else {
  45361. - head_buffer = priv->rxBuffer + (priv->rxHead * TLAN_MAX_FRAME_SIZE);
  45362. - skb->dev = dev;
  45363. - skb_reserve(skb, 2);
  45364. - t = (void *) skb_put(skb, frameSize);
  45365. -
  45366. - priv->stats.rx_bytes += head_list->frameSize;
  45367. -
  45368. - memcpy( t, head_buffer, frameSize );
  45369. - skb->protocol = eth_type_trans( skb, dev );
  45370. - netif_rx( skb );
  45371. - }
  45372. - } else {
  45373. - struct sk_buff *new_skb;
  45374. -
  45375. - /*
  45376. - * I changed the algorithm here. What we now do
  45377. - * is allocate the new frame. If this fails we
  45378. - * simply recycle the frame.
  45379. - */
  45380. -
  45381. - new_skb = dev_alloc_skb( TLAN_MAX_FRAME_SIZE + 7 );
  45382. -
  45383. - if ( new_skb != NULL ) {
  45384. - /* If this ever happened it would be a problem */
  45385. - /* not any more - ac */
  45386. - skb = (struct sk_buff *) head_list->buffer[9].address;
  45387. - skb_trim( skb, frameSize );
  45388. -
  45389. - priv->stats.rx_bytes += frameSize;
  45390. + u16 sio;
  45391. - skb->protocol = eth_type_trans( skb, dev );
  45392. - netif_rx( skb );
  45393. -
  45394. - new_skb->dev = dev;
  45395. - skb_reserve( new_skb, 2 );
  45396. - t = (void *) skb_put( new_skb, TLAN_MAX_FRAME_SIZE );
  45397. - head_list->buffer[0].address = virt_to_bus( t );
  45398. - head_list->buffer[8].address = (u32) t;
  45399. - head_list->buffer[9].address = (u32) new_skb;
  45400. - } else
  45401. - printk(KERN_WARNING "TLAN: Couldn't allocate memory for received data.\n" );
  45402. - }
  45403. + outw(TLAN_NET_SIO, io_base + TLAN_DIO_ADR);
  45404. + sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO;
  45405. - head_list->forward = 0;
  45406. - head_list->cStat = 0;
  45407. - tail_list = priv->rxList + priv->rxTail;
  45408. - tail_list->forward = virt_to_bus( head_list );
  45409. -
  45410. - CIRC_INC( priv->rxHead, TLAN_NUM_RX_LISTS );
  45411. - CIRC_INC( priv->rxTail, TLAN_NUM_RX_LISTS );
  45412. - head_list = priv->rxList + priv->rxHead;
  45413. - }
  45414. + TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  45415. + TLan_SetBit(TLAN_NET_SIO_EDATA, sio);
  45416. + TLan_SetBit(TLAN_NET_SIO_ETXEN, sio);
  45417. + TLan_ClearBit(TLAN_NET_SIO_EDATA, sio);
  45418. + TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  45419. - if (!ack)
  45420. - printk(KERN_INFO "TLAN: Received interrupt for uncompleted RX frame.\n");
  45421. -
  45422. +} /* TLan_EeSendStart */
  45423. - if ( eoc ) {
  45424. - TLAN_DBG( TLAN_DEBUG_RX, "RECEIVE: Handling RX EOC (Head=%d Tail=%d)\n", priv->rxHead, priv->rxTail );
  45425. - head_list = priv->rxList + priv->rxHead;
  45426. - outl( virt_to_bus( head_list ), dev->base_addr + TLAN_CH_PARM );
  45427. - ack |= TLAN_HC_GO | TLAN_HC_RT;
  45428. - priv->rxEocCount++;
  45429. - }
  45430. -
  45431. - if ( priv->adapter->flags & TLAN_ADAPTER_ACTIVITY_LED ) {
  45432. - TLan_DioWrite8( dev->base_addr, TLAN_LED_REG, TLAN_LED_LINK | TLAN_LED_ACT );
  45433. - if ( priv->timer.function == NULL ) {
  45434. - priv->timer.function = &TLan_Timer;
  45435. - priv->timer.data = (unsigned long) dev;
  45436. - priv->timer.expires = jiffies + TLAN_TIMER_ACT_DELAY;
  45437. - priv->timerSetAt = jiffies;
  45438. - priv->timerType = TLAN_TIMER_ACTIVITY;
  45439. - add_timer(&priv->timer);
  45440. - } else if ( priv->timerType == TLAN_TIMER_ACTIVITY ) {
  45441. - priv->timerSetAt = jiffies;
  45442. - }
  45443. - }
  45444. - dev->last_rx = jiffies;
  45445. -
  45446. - return ack;
  45447. -} /* TLan_HandleRxEOF */
  45448. /***************************************************************
  45449. - * TLan_HandleDummy
  45450. + * TLan_EeSendByte
  45451. *
  45452. * Returns:
  45453. - * 1
  45454. - * Parms:
  45455. - * dev Device assigned the IRQ that was
  45456. - * raised.
  45457. - * host_int The contents of the HOST_INT
  45458. - * port.
  45459. - *
  45460. - * This function handles the Dummy interrupt, which is
  45461. - * raised whenever a test interrupt is generated by setting
  45462. - * the Req_Int bit of HOST_CMD to 1.
  45463. + * If the correct ack was received, 0, otherwise 1
  45464. + * Parms: io_base The IO port base address for the
  45465. + * TLAN device with the EEPROM to
  45466. + * use.
  45467. + * data The 8 bits of information to
  45468. + * send to the EEPROM.
  45469. + * stop If TLAN_EEPROM_STOP is passed, a
  45470. + * stop cycle is sent after the
  45471. + * byte is sent after the ack is
  45472. + * read.
  45473. + *
  45474. + * This function sends a byte on the serial EEPROM line,
  45475. + * driving the clock to send each bit. The function then
  45476. + * reverses transmission direction and reads an acknowledge
  45477. + * bit.
  45478. *
  45479. **************************************************************/
  45480. -u32 TLan_HandleDummy( struct net_device *dev, u16 host_int )
  45481. +int TLan_EeSendByte(u16 io_base, u8 data, int stop)
  45482. {
  45483. - printk( "TLAN: Test interrupt on %s.\n", dev->name );
  45484. - return 1;
  45485. + int err;
  45486. + u8 place;
  45487. + u16 sio;
  45488. -} /* TLan_HandleDummy */
  45489. + outw(TLAN_NET_SIO, io_base + TLAN_DIO_ADR);
  45490. + sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO;
  45491. - /***************************************************************
  45492. - * TLan_HandleTxEOC
  45493. - *
  45494. - * Returns:
  45495. - * 1
  45496. - * Parms:
  45497. - * dev Device assigned the IRQ that was
  45498. - * raised.
  45499. - * host_int The contents of the HOST_INT
  45500. - * port.
  45501. - *
  45502. - * This driver is structured to determine EOC occurances by
  45503. - * reading the CSTAT member of the list structure. Tx EOC
  45504. - * interrupts are disabled via the DIO INTDIS register.
  45505. - * However, TLAN chips before revision 3.0 didn't have this
  45506. - * functionality, so process EOC events if this is the
  45507. - * case.
  45508. - *
  45509. - **************************************************************/
  45510. + /* Assume clock is low, tx is enabled; */
  45511. + for (place = 0x80; place != 0; place >>= 1) {
  45512. + if (place & data)
  45513. + TLan_SetBit(TLAN_NET_SIO_EDATA, sio);
  45514. + else
  45515. + TLan_ClearBit(TLAN_NET_SIO_EDATA, sio);
  45516. + TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  45517. + TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  45518. + }
  45519. + TLan_ClearBit(TLAN_NET_SIO_ETXEN, sio);
  45520. + TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  45521. + err = TLan_GetBit(TLAN_NET_SIO_EDATA, sio);
  45522. + TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  45523. + TLan_SetBit(TLAN_NET_SIO_ETXEN, sio);
  45524. -u32 TLan_HandleTxEOC( struct net_device *dev, u16 host_int )
  45525. -{
  45526. - TLanPrivateInfo *priv = dev->priv;
  45527. - TLanList *head_list;
  45528. - u32 ack = 1;
  45529. -
  45530. - host_int = 0;
  45531. - if ( priv->tlanRev < 0x30 ) {
  45532. - TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: Handling TX EOC (Head=%d Tail=%d) -- IRQ\n", priv->txHead, priv->txTail );
  45533. - head_list = priv->txList + priv->txHead;
  45534. - if ( ( head_list->cStat & TLAN_CSTAT_READY ) == TLAN_CSTAT_READY ) {
  45535. - netif_stop_queue(dev);
  45536. - outl( virt_to_bus( head_list ), dev->base_addr + TLAN_CH_PARM );
  45537. - ack |= TLAN_HC_GO;
  45538. - } else {
  45539. - priv->txInProgress = 0;
  45540. - }
  45541. + if ((!err) && stop) {
  45542. + TLan_ClearBit(TLAN_NET_SIO_EDATA, sio); /* STOP, raise data while clock is high */
  45543. + TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  45544. + TLan_SetBit(TLAN_NET_SIO_EDATA, sio);
  45545. }
  45546. - return ack;
  45547. + return (err);
  45548. +
  45549. +} /* TLan_EeSendByte */
  45550. +
  45551. +
  45552. -} /* TLan_HandleTxEOC */
  45553. /***************************************************************
  45554. - * TLan_HandleStatusCheck
  45555. + * TLan_EeReceiveByte
  45556. *
  45557. * Returns:
  45558. - * 0 if Adapter check, 1 if Network Status check.
  45559. + * Nothing
  45560. * Parms:
  45561. - * dev Device assigned the IRQ that was
  45562. - * raised.
  45563. - * host_int The contents of the HOST_INT
  45564. - * port.
  45565. - *
  45566. - * This function handles Adapter Check/Network Status
  45567. - * interrupts generated by the adapter. It checks the
  45568. - * vector in the HOST_INT register to determine if it is
  45569. - * an Adapter Check interrupt. If so, it resets the
  45570. - * adapter. Otherwise it clears the status registers
  45571. - * and services the PHY.
  45572. + * io_base The IO port base address for the
  45573. + * TLAN device with the EEPROM to
  45574. + * use.
  45575. + * data An address to a char to hold the
  45576. + * data sent from the EEPROM.
  45577. + * stop If TLAN_EEPROM_STOP is passed, a
  45578. + * stop cycle is sent after the
  45579. + * byte is received, and no ack is
  45580. + * sent.
  45581. + *
  45582. + * This function receives 8 bits of data from the EEPROM
  45583. + * over the serial link. It then sends and ack bit, or no
  45584. + * ack and a stop bit. This function is used to retrieve
  45585. + * data after the address of a byte in the EEPROM has been
  45586. + * sent.
  45587. *
  45588. **************************************************************/
  45589. -u32 TLan_HandleStatusCheck( struct net_device *dev, u16 host_int )
  45590. -{
  45591. - TLanPrivateInfo *priv = dev->priv;
  45592. - u32 ack;
  45593. - u32 error;
  45594. - u8 net_sts;
  45595. - u32 phy;
  45596. - u16 tlphy_ctl;
  45597. - u16 tlphy_sts;
  45598. -
  45599. - ack = 1;
  45600. - if ( host_int & TLAN_HI_IV_MASK ) {
  45601. - netif_stop_queue( dev );
  45602. - error = inl( dev->base_addr + TLAN_CH_PARM );
  45603. - printk( "TLAN: %s: Adaptor Error = 0x%x\n", dev->name, error );
  45604. - TLan_ReadAndClearStats( dev, TLAN_RECORD );
  45605. - outl( TLAN_HC_AD_RST, dev->base_addr + TLAN_HOST_CMD );
  45606. -
  45607. - queue_task(&priv->tlan_tqueue, &tq_immediate);
  45608. - mark_bh(IMMEDIATE_BH);
  45609. -
  45610. - netif_wake_queue(dev);
  45611. - ack = 0;
  45612. - } else {
  45613. - TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Status Check\n", dev->name );
  45614. - phy = priv->phy[priv->phyNum];
  45615. +void TLan_EeReceiveByte(u16 io_base, u8 * data, int stop)
  45616. +{
  45617. + u8 place;
  45618. + u16 sio;
  45619. - net_sts = TLan_DioRead8( dev->base_addr, TLAN_NET_STS );
  45620. - if ( net_sts ) {
  45621. - TLan_DioWrite8( dev->base_addr, TLAN_NET_STS, net_sts );
  45622. - TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Net_Sts = %x\n", dev->name, (unsigned) net_sts );
  45623. - }
  45624. - if ( ( net_sts & TLAN_NET_STS_MIRQ ) && ( priv->phyNum == 0 ) ) {
  45625. - TLan_MiiReadReg( dev, phy, TLAN_TLPHY_STS, &tlphy_sts );
  45626. - TLan_MiiReadReg( dev, phy, TLAN_TLPHY_CTL, &tlphy_ctl );
  45627. - if ( ! ( tlphy_sts & TLAN_TS_POLOK ) && ! ( tlphy_ctl & TLAN_TC_SWAPOL ) ) {
  45628. - tlphy_ctl |= TLAN_TC_SWAPOL;
  45629. - TLan_MiiWriteReg( dev, phy, TLAN_TLPHY_CTL, tlphy_ctl);
  45630. - } else if ( ( tlphy_sts & TLAN_TS_POLOK ) && ( tlphy_ctl & TLAN_TC_SWAPOL ) ) {
  45631. - tlphy_ctl &= ~TLAN_TC_SWAPOL;
  45632. - TLan_MiiWriteReg( dev, phy, TLAN_TLPHY_CTL, tlphy_ctl);
  45633. - }
  45634. + outw(TLAN_NET_SIO, io_base + TLAN_DIO_ADR);
  45635. + sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO;
  45636. + *data = 0;
  45637. - if (debug) {
  45638. - TLan_PhyPrint( dev );
  45639. - }
  45640. - }
  45641. + /* Assume clock is low, tx is enabled; */
  45642. + TLan_ClearBit(TLAN_NET_SIO_ETXEN, sio);
  45643. + for (place = 0x80; place; place >>= 1) {
  45644. + TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  45645. + if (TLan_GetBit(TLAN_NET_SIO_EDATA, sio))
  45646. + *data |= place;
  45647. + TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  45648. + }
  45649. +
  45650. + TLan_SetBit(TLAN_NET_SIO_ETXEN, sio);
  45651. + if (!stop) {
  45652. + TLan_ClearBit(TLAN_NET_SIO_EDATA, sio); /* Ack = 0 */
  45653. + TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  45654. + TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  45655. + } else {
  45656. + TLan_SetBit(TLAN_NET_SIO_EDATA, sio); /* No ack = 1 (?) */
  45657. + TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  45658. + TLan_ClearBit(TLAN_NET_SIO_ECLOK, sio);
  45659. + TLan_ClearBit(TLAN_NET_SIO_EDATA, sio); /* STOP, raise data while clock is high */
  45660. + TLan_SetBit(TLAN_NET_SIO_ECLOK, sio);
  45661. + TLan_SetBit(TLAN_NET_SIO_EDATA, sio);
  45662. }
  45663. - return ack;
  45664. +} /* TLan_EeReceiveByte */
  45665. +
  45666. -} /* TLan_HandleStatusCheck */
  45667. /***************************************************************
  45668. - * TLan_HandleRxEOC
  45669. + * TLan_EeReadByte
  45670. *
  45671. * Returns:
  45672. - * 1
  45673. + * No error = 0, else, the stage at which the error
  45674. + * occurred.
  45675. * Parms:
  45676. - * dev Device assigned the IRQ that was
  45677. - * raised.
  45678. - * host_int The contents of the HOST_INT
  45679. - * port.
  45680. - *
  45681. - * This driver is structured to determine EOC occurances by
  45682. - * reading the CSTAT member of the list structure. Rx EOC
  45683. - * interrupts are disabled via the DIO INTDIS register.
  45684. - * However, TLAN chips before revision 3.0 didn't have this
  45685. - * CSTAT member or a INTDIS register, so if this chip is
  45686. - * pre-3.0, process EOC interrupts normally.
  45687. + * io_base The IO port base address for the
  45688. + * TLAN device with the EEPROM to
  45689. + * use.
  45690. + * ee_addr The address of the byte in the
  45691. + * EEPROM whose contents are to be
  45692. + * retrieved.
  45693. + * data An address to a char to hold the
  45694. + * data obtained from the EEPROM.
  45695. + *
  45696. + * This function reads a byte of information from an byte
  45697. + * cell in the EEPROM.
  45698. *
  45699. **************************************************************/
  45700. -u32 TLan_HandleRxEOC( struct net_device *dev, u16 host_int )
  45701. +int TLan_EeReadByte(u16 io_base, u8 ee_addr, u8 * data)
  45702. {
  45703. - TLanPrivateInfo *priv = dev->priv;
  45704. - TLanList *head_list;
  45705. - u32 ack = 1;
  45706. + int err;
  45707. + int ret = 0;
  45708. - if ( priv->tlanRev < 0x30 ) {
  45709. - TLAN_DBG( TLAN_DEBUG_RX, "RECEIVE: Handling RX EOC (Head=%d Tail=%d) -- IRQ\n", priv->rxHead, priv->rxTail );
  45710. - head_list = priv->rxList + priv->rxHead;
  45711. - outl( virt_to_bus( head_list ), dev->base_addr + TLAN_CH_PARM );
  45712. - ack |= TLAN_HC_GO | TLAN_HC_RT;
  45713. - priv->rxEocCount++;
  45714. +
  45715. + TLan_EeSendStart(io_base);
  45716. + err = TLan_EeSendByte(io_base, 0xA0, TLAN_EEPROM_ACK);
  45717. + if (err) {
  45718. + ret = 1;
  45719. + goto fail;
  45720. + }
  45721. + err = TLan_EeSendByte(io_base, ee_addr, TLAN_EEPROM_ACK);
  45722. + if (err) {
  45723. + ret = 2;
  45724. + goto fail;
  45725. + }
  45726. + TLan_EeSendStart(io_base);
  45727. + err = TLan_EeSendByte(io_base, 0xA1, TLAN_EEPROM_ACK);
  45728. + if (err) {
  45729. + ret = 3;
  45730. + goto fail;
  45731. }
  45732. + TLan_EeReceiveByte(io_base, data, TLAN_EEPROM_STOP);
  45733. + fail:
  45734. - return ack;
  45735. + return ret;
  45736. +
  45737. +} /* TLan_EeReadByte */
  45738. -} /* TLan_HandleRxEOC */
  45739. /*****************************************************************************
  45740. ******************************************************************************
  45741. - ThunderLAN Driver Timer Function
  45742. + ThunderLAN Driver MII Routines
  45743. +
  45744. + These routines are based on the information in Chap. 2 of the
  45745. + "ThunderLAN Programmer's Guide", pp. 15-24.
  45746. ******************************************************************************
  45747. *****************************************************************************/
  45748. +
  45749. /***************************************************************
  45750. - * TLan_Timer
  45751. + * TLan_MiiReadReg
  45752. *
  45753. * Returns:
  45754. - * Nothing
  45755. + * 0 if ack received ok
  45756. + * 1 otherwise.
  45757. + *
  45758. * Parms:
  45759. - * data A value given to add timer when
  45760. - * add_timer was called.
  45761. + * dev The device structure containing
  45762. + * The io address and interrupt count
  45763. + * for this device.
  45764. + * phy The address of the PHY to be queried.
  45765. + * reg The register whose contents are to be
  45766. + * retreived.
  45767. + * val A pointer to a variable to store the
  45768. + * retrieved value.
  45769. *
  45770. - * This function handles timed functionality for the
  45771. - * TLAN driver. The two current timer uses are for
  45772. - * delaying for autonegotionation and driving the ACT LED.
  45773. - * - Autonegotiation requires being allowed about
  45774. - * 2 1/2 seconds before attempting to transmit a
  45775. - * packet. It would be a very bad thing to hang
  45776. - * the kernel this long, so the driver doesn't
  45777. - * allow transmission 'til after this time, for
  45778. - * certain PHYs. It would be much nicer if all
  45779. - * PHYs were interrupt-capable like the internal
  45780. - * PHY.
  45781. - * - The ACT LED, which shows adapter activity, is
  45782. - * driven by the driver, and so must be left on
  45783. - * for a short period to power up the LED so it
  45784. - * can be seen. This delay can be changed by
  45785. - * changing the TLAN_TIMER_ACT_DELAY in tlan.h,
  45786. - * if desired. 100 ms produces a slightly
  45787. - * sluggish response.
  45788. + * This function uses the TLAN's MII bus to retreive the contents
  45789. + * of a given register on a PHY. It sends the appropriate info
  45790. + * and then reads the 16-bit register value from the MII bus via
  45791. + * the TLAN SIO register.
  45792. *
  45793. **************************************************************/
  45794. -void TLan_Timer( unsigned long data )
  45795. +int TLan_MiiReadReg(struct nic *nic __unused, u16 phy, u16 reg, u16 * val)
  45796. {
  45797. - struct net_device *dev = (struct net_device *) data;
  45798. - TLanPrivateInfo *priv = dev->priv;
  45799. - u32 elapsed;
  45800. - unsigned long flags = 0;
  45801. -
  45802. - priv->timer.function = NULL;
  45803. -
  45804. - switch ( priv->timerType ) {
  45805. -#ifdef MONITOR
  45806. - case TLAN_TIMER_LINK_BEAT:
  45807. - TLan_PhyMonitor( dev );
  45808. - break;
  45809. -#endif
  45810. - case TLAN_TIMER_PHY_PDOWN:
  45811. - TLan_PhyPowerDown( dev );
  45812. - break;
  45813. - case TLAN_TIMER_PHY_PUP:
  45814. - TLan_PhyPowerUp( dev );
  45815. - break;
  45816. - case TLAN_TIMER_PHY_RESET:
  45817. - TLan_PhyReset( dev );
  45818. - break;
  45819. - case TLAN_TIMER_PHY_START_LINK:
  45820. - TLan_PhyStartLink( dev );
  45821. - break;
  45822. - case TLAN_TIMER_PHY_FINISH_AN:
  45823. - TLan_PhyFinishAutoNeg( dev );
  45824. - break;
  45825. - case TLAN_TIMER_FINISH_RESET:
  45826. - TLan_FinishReset( dev );
  45827. - break;
  45828. - case TLAN_TIMER_ACTIVITY:
  45829. - spin_lock_irqsave(&priv->lock, flags);
  45830. - if ( priv->timer.function == NULL ) {
  45831. - elapsed = jiffies - priv->timerSetAt;
  45832. - if ( elapsed >= TLAN_TIMER_ACT_DELAY ) {
  45833. - TLan_DioWrite8( dev->base_addr, TLAN_LED_REG, TLAN_LED_LINK );
  45834. - } else {
  45835. - priv->timer.function = &TLan_Timer;
  45836. - priv->timer.expires = priv->timerSetAt + TLAN_TIMER_ACT_DELAY;
  45837. - spin_unlock_irqrestore(&priv->lock, flags);
  45838. - add_timer( &priv->timer );
  45839. - break;
  45840. - }
  45841. - }
  45842. - spin_unlock_irqrestore(&priv->lock, flags);
  45843. - break;
  45844. - default:
  45845. - break;
  45846. + u8 nack;
  45847. + u16 sio, tmp;
  45848. + u32 i;
  45849. + int err;
  45850. + int minten;
  45851. +
  45852. + err = FALSE;
  45853. + outw(TLAN_NET_SIO, BASE + TLAN_DIO_ADR);
  45854. + sio = BASE + TLAN_DIO_DATA + TLAN_NET_SIO;
  45855. +
  45856. + TLan_MiiSync(BASE);
  45857. +
  45858. + minten = TLan_GetBit(TLAN_NET_SIO_MINTEN, sio);
  45859. + if (minten)
  45860. + TLan_ClearBit(TLAN_NET_SIO_MINTEN, sio);
  45861. +
  45862. + TLan_MiiSendData(BASE, 0x1, 2); /* Start ( 01b ) */
  45863. + TLan_MiiSendData(BASE, 0x2, 2); /* Read ( 10b ) */
  45864. + TLan_MiiSendData(BASE, phy, 5); /* Device # */
  45865. + TLan_MiiSendData(BASE, reg, 5); /* Register # */
  45866. +
  45867. +
  45868. + TLan_ClearBit(TLAN_NET_SIO_MTXEN, sio); /* Change direction */
  45869. +
  45870. + TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Clock Idle bit */
  45871. + TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  45872. + TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Wait 300ns */
  45873. +
  45874. + nack = TLan_GetBit(TLAN_NET_SIO_MDATA, sio); /* Check for ACK */
  45875. + TLan_SetBit(TLAN_NET_SIO_MCLK, sio); /* Finish ACK */
  45876. + if (nack) { /* No ACK, so fake it */
  45877. + for (i = 0; i < 16; i++) {
  45878. + TLan_ClearBit(TLAN_NET_SIO_MCLK, sio);
  45879. + TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  45880. + }
  45881. + tmp = 0xffff;
  45882. + err = TRUE;
  45883. + } else { /* ACK, so read data */
  45884. + for (tmp = 0, i = 0x8000; i; i >>= 1) {
  45885. + TLan_ClearBit(TLAN_NET_SIO_MCLK, sio);
  45886. + if (TLan_GetBit(TLAN_NET_SIO_MDATA, sio))
  45887. + tmp |= i;
  45888. + TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  45889. + }
  45890. }
  45891. -} /* TLan_Timer */
  45892. -/*****************************************************************************
  45893. -******************************************************************************
  45894. + TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Idle cycle */
  45895. + TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  45896. - ThunderLAN Driver Adapter Related Routines
  45897. + if (minten)
  45898. + TLan_SetBit(TLAN_NET_SIO_MINTEN, sio);
  45899. -******************************************************************************
  45900. -*****************************************************************************/
  45901. + *val = tmp;
  45902. +
  45903. + return err;
  45904. +
  45905. +} /* TLan_MiiReadReg */
  45906. /***************************************************************
  45907. - * TLan_ResetLists
  45908. - *
  45909. + * TLan_MiiSendData
  45910. + *
  45911. * Returns:
  45912. * Nothing
  45913. * Parms:
  45914. - * dev The device structure with the list
  45915. - * stuctures to be reset.
  45916. + * base_port The base IO port of the adapter in
  45917. + * question.
  45918. + * dev The address of the PHY to be queried.
  45919. + * data The value to be placed on the MII bus.
  45920. + * num_bits The number of bits in data that are to
  45921. + * be placed on the MII bus.
  45922. *
  45923. - * This routine sets the variables associated with managing
  45924. - * the TLAN lists to their initial values.
  45925. + * This function sends on sequence of bits on the MII
  45926. + * configuration bus.
  45927. *
  45928. **************************************************************/
  45929. -void TLan_ResetLists( struct net_device *dev )
  45930. +void TLan_MiiSendData(u16 base_port, u32 data, unsigned num_bits)
  45931. {
  45932. - TLanPrivateInfo *priv = dev->priv;
  45933. - int i;
  45934. - TLanList *list;
  45935. - struct sk_buff *skb;
  45936. - void *t = NULL;
  45937. + u16 sio;
  45938. + u32 i;
  45939. - priv->txHead = 0;
  45940. - priv->txTail = 0;
  45941. - for ( i = 0; i < TLAN_NUM_TX_LISTS; i++ ) {
  45942. - list = priv->txList + i;
  45943. - list->cStat = TLAN_CSTAT_UNUSED;
  45944. - if ( bbuf ) {
  45945. - list->buffer[0].address = virt_to_bus( priv->txBuffer + ( i * TLAN_MAX_FRAME_SIZE ) );
  45946. - } else {
  45947. - list->buffer[0].address = 0;
  45948. - }
  45949. - list->buffer[2].count = 0;
  45950. - list->buffer[2].address = 0;
  45951. - list->buffer[9].address = 0;
  45952. - }
  45953. + if (num_bits == 0)
  45954. + return;
  45955. +
  45956. + outw(TLAN_NET_SIO, base_port + TLAN_DIO_ADR);
  45957. + sio = base_port + TLAN_DIO_DATA + TLAN_NET_SIO;
  45958. + TLan_SetBit(TLAN_NET_SIO_MTXEN, sio);
  45959. - priv->rxHead = 0;
  45960. - priv->rxTail = TLAN_NUM_RX_LISTS - 1;
  45961. - for ( i = 0; i < TLAN_NUM_RX_LISTS; i++ ) {
  45962. - list = priv->rxList + i;
  45963. - list->cStat = TLAN_CSTAT_READY;
  45964. - list->frameSize = TLAN_MAX_FRAME_SIZE;
  45965. - list->buffer[0].count = TLAN_MAX_FRAME_SIZE | TLAN_LAST_BUFFER;
  45966. - if ( bbuf ) {
  45967. - list->buffer[0].address = virt_to_bus( priv->rxBuffer + ( i * TLAN_MAX_FRAME_SIZE ) );
  45968. - } else {
  45969. - skb = dev_alloc_skb( TLAN_MAX_FRAME_SIZE + 7 );
  45970. - if ( skb == NULL ) {
  45971. - printk( "TLAN: Couldn't allocate memory for received data.\n" );
  45972. - /* If this ever happened it would be a problem */
  45973. - } else {
  45974. - skb->dev = dev;
  45975. - skb_reserve( skb, 2 );
  45976. - t = (void *) skb_put( skb, TLAN_MAX_FRAME_SIZE );
  45977. - }
  45978. - list->buffer[0].address = virt_to_bus( t );
  45979. - list->buffer[8].address = (u32) t;
  45980. - list->buffer[9].address = (u32) skb;
  45981. - }
  45982. - list->buffer[1].count = 0;
  45983. - list->buffer[1].address = 0;
  45984. - if ( i < TLAN_NUM_RX_LISTS - 1 )
  45985. - list->forward = virt_to_bus( list + 1 );
  45986. + for (i = (0x1 << (num_bits - 1)); i; i >>= 1) {
  45987. + TLan_ClearBit(TLAN_NET_SIO_MCLK, sio);
  45988. + (void) TLan_GetBit(TLAN_NET_SIO_MCLK, sio);
  45989. + if (data & i)
  45990. + TLan_SetBit(TLAN_NET_SIO_MDATA, sio);
  45991. else
  45992. - list->forward = 0;
  45993. + TLan_ClearBit(TLAN_NET_SIO_MDATA, sio);
  45994. + TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  45995. + (void) TLan_GetBit(TLAN_NET_SIO_MCLK, sio);
  45996. }
  45997. -} /* TLan_ResetLists */
  45998. +} /* TLan_MiiSendData */
  45999. -void TLan_FreeLists( struct net_device *dev )
  46000. -{
  46001. - TLanPrivateInfo *priv = dev->priv;
  46002. - int i;
  46003. - TLanList *list;
  46004. - struct sk_buff *skb;
  46005. -
  46006. - if ( ! bbuf ) {
  46007. - for ( i = 0; i < TLAN_NUM_TX_LISTS; i++ ) {
  46008. - list = priv->txList + i;
  46009. - skb = (struct sk_buff *) list->buffer[9].address;
  46010. - if ( skb ) {
  46011. - dev_kfree_skb_any( skb );
  46012. - list->buffer[9].address = 0;
  46013. - }
  46014. - }
  46015. - for ( i = 0; i < TLAN_NUM_RX_LISTS; i++ ) {
  46016. - list = priv->rxList + i;
  46017. - skb = (struct sk_buff *) list->buffer[9].address;
  46018. - if ( skb ) {
  46019. - dev_kfree_skb_any( skb );
  46020. - list->buffer[9].address = 0;
  46021. - }
  46022. - }
  46023. - }
  46024. -} /* TLan_FreeLists */
  46025. /***************************************************************
  46026. - * TLan_PrintDio
  46027. - *
  46028. + * TLan_MiiSync
  46029. + *
  46030. * Returns:
  46031. * Nothing
  46032. * Parms:
  46033. - * io_base Base IO port of the device of
  46034. - * which to print DIO registers.
  46035. + * base_port The base IO port of the adapter in
  46036. + * question.
  46037. *
  46038. - * This function prints out all the internal (DIO)
  46039. - * registers of a TLAN chip.
  46040. + * This functions syncs all PHYs in terms of the MII configuration
  46041. + * bus.
  46042. *
  46043. **************************************************************/
  46044. -void TLan_PrintDio( u16 io_base )
  46045. +void TLan_MiiSync(u16 base_port)
  46046. {
  46047. - u32 data0, data1;
  46048. - int i;
  46049. + int i;
  46050. + u16 sio;
  46051. - printk( "TLAN: Contents of internal registers for io base 0x%04hx.\n", io_base );
  46052. - printk( "TLAN: Off. +0 +4\n" );
  46053. - for ( i = 0; i < 0x4C; i+= 8 ) {
  46054. - data0 = TLan_DioRead32( io_base, i );
  46055. - data1 = TLan_DioRead32( io_base, i + 0x4 );
  46056. - printk( "TLAN: 0x%02x 0x%08x 0x%08x\n", i, data0, data1 );
  46057. + outw(TLAN_NET_SIO, base_port + TLAN_DIO_ADR);
  46058. + sio = base_port + TLAN_DIO_DATA + TLAN_NET_SIO;
  46059. +
  46060. + TLan_ClearBit(TLAN_NET_SIO_MTXEN, sio);
  46061. + for (i = 0; i < 32; i++) {
  46062. + TLan_ClearBit(TLAN_NET_SIO_MCLK, sio);
  46063. + TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  46064. }
  46065. -} /* TLan_PrintDio */
  46066. +} /* TLan_MiiSync */
  46067. +
  46068. +
  46069. +
  46070. /***************************************************************
  46071. - * TLan_PrintList
  46072. - *
  46073. + * TLan_MiiWriteReg
  46074. + *
  46075. * Returns:
  46076. * Nothing
  46077. * Parms:
  46078. - * list A pointer to the TLanList structure to
  46079. - * be printed.
  46080. - * type A string to designate type of list,
  46081. - * "Rx" or "Tx".
  46082. - * num The index of the list.
  46083. + * dev The device structure for the device
  46084. + * to write to.
  46085. + * phy The address of the PHY to be written to.
  46086. + * reg The register whose contents are to be
  46087. + * written.
  46088. + * val The value to be written to the register.
  46089. *
  46090. - * This function prints out the contents of the list
  46091. - * pointed to by the list parameter.
  46092. + * This function uses the TLAN's MII bus to write the contents of a
  46093. + * given register on a PHY. It sends the appropriate info and then
  46094. + * writes the 16-bit register value from the MII configuration bus
  46095. + * via the TLAN SIO register.
  46096. *
  46097. **************************************************************/
  46098. -void TLan_PrintList( TLanList *list, char *type, int num)
  46099. +void TLan_MiiWriteReg(struct nic *nic __unused, u16 phy, u16 reg, u16 val)
  46100. {
  46101. - int i;
  46102. + u16 sio;
  46103. + int minten;
  46104. +
  46105. + outw(TLAN_NET_SIO, BASE + TLAN_DIO_ADR);
  46106. + sio = BASE + TLAN_DIO_DATA + TLAN_NET_SIO;
  46107. +
  46108. + TLan_MiiSync(BASE);
  46109. +
  46110. + minten = TLan_GetBit(TLAN_NET_SIO_MINTEN, sio);
  46111. + if (minten)
  46112. + TLan_ClearBit(TLAN_NET_SIO_MINTEN, sio);
  46113. +
  46114. + TLan_MiiSendData(BASE, 0x1, 2); /* Start ( 01b ) */
  46115. + TLan_MiiSendData(BASE, 0x1, 2); /* Write ( 01b ) */
  46116. + TLan_MiiSendData(BASE, phy, 5); /* Device # */
  46117. + TLan_MiiSendData(BASE, reg, 5); /* Register # */
  46118. +
  46119. + TLan_MiiSendData(BASE, 0x2, 2); /* Send ACK */
  46120. + TLan_MiiSendData(BASE, val, 16); /* Send Data */
  46121. +
  46122. + TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Idle cycle */
  46123. + TLan_SetBit(TLAN_NET_SIO_MCLK, sio);
  46124. +
  46125. + if (minten)
  46126. + TLan_SetBit(TLAN_NET_SIO_MINTEN, sio);
  46127. - printk( "TLAN: %s List %d at 0x%08x\n", type, num, (u32) list );
  46128. - printk( "TLAN: Forward = 0x%08x\n", list->forward );
  46129. - printk( "TLAN: CSTAT = 0x%04hx\n", list->cStat );
  46130. - printk( "TLAN: Frame Size = 0x%04hx\n", list->frameSize );
  46131. - /* for ( i = 0; i < 10; i++ ) { */
  46132. - for ( i = 0; i < 2; i++ ) {
  46133. - printk( "TLAN: Buffer[%d].count, addr = 0x%08x, 0x%08x\n", i, list->buffer[i].count, list->buffer[i].address );
  46134. - }
  46135. -} /* TLan_PrintList */
  46136. +} /* TLan_MiiWriteReg */
  46137. /***************************************************************
  46138. - * TLan_ReadAndClearStats
  46139. + * TLan_SetMac
  46140. *
  46141. * Returns:
  46142. * Nothing
  46143. * Parms:
  46144. * dev Pointer to device structure of adapter
  46145. - * to which to read stats.
  46146. - * record Flag indicating whether to add
  46147. + * on which to change the AREG.
  46148. + * areg The AREG to set the address in (0 - 3).
  46149. + * mac A pointer to an array of chars. Each
  46150. + * element stores one byte of the address.
  46151. + * IE, it isn't in ascii.
  46152. *
  46153. - * This functions reads all the internal status registers
  46154. - * of the TLAN chip, which clears them as a side effect.
  46155. - * It then either adds the values to the device's status
  46156. - * struct, or discards them, depending on whether record
  46157. - * is TLAN_RECORD (!=0) or TLAN_IGNORE (==0).
  46158. + * This function transfers a MAC address to one of the
  46159. + * TLAN AREGs (address registers). The TLAN chip locks
  46160. + * the register on writing to offset 0 and unlocks the
  46161. + * register after writing to offset 5. If NULL is passed
  46162. + * in mac, then the AREG is filled with 0's.
  46163. *
  46164. **************************************************************/
  46165. -void TLan_ReadAndClearStats( struct net_device *dev, int record )
  46166. +void TLan_SetMac(struct nic *nic __unused, int areg, char *mac)
  46167. {
  46168. - TLanPrivateInfo *priv = dev->priv;
  46169. - u32 tx_good, tx_under;
  46170. - u32 rx_good, rx_over;
  46171. - u32 def_tx, crc, code;
  46172. - u32 multi_col, single_col;
  46173. - u32 excess_col, late_col, loss;
  46174. -
  46175. - outw( TLAN_GOOD_TX_FRMS, dev->base_addr + TLAN_DIO_ADR );
  46176. - tx_good = inb( dev->base_addr + TLAN_DIO_DATA );
  46177. - tx_good += inb( dev->base_addr + TLAN_DIO_DATA + 1 ) << 8;
  46178. - tx_good += inb( dev->base_addr + TLAN_DIO_DATA + 2 ) << 16;
  46179. - tx_under = inb( dev->base_addr + TLAN_DIO_DATA + 3 );
  46180. -
  46181. - outw( TLAN_GOOD_RX_FRMS, dev->base_addr + TLAN_DIO_ADR );
  46182. - rx_good = inb( dev->base_addr + TLAN_DIO_DATA );
  46183. - rx_good += inb( dev->base_addr + TLAN_DIO_DATA + 1 ) << 8;
  46184. - rx_good += inb( dev->base_addr + TLAN_DIO_DATA + 2 ) << 16;
  46185. - rx_over = inb( dev->base_addr + TLAN_DIO_DATA + 3 );
  46186. -
  46187. - outw( TLAN_DEFERRED_TX, dev->base_addr + TLAN_DIO_ADR );
  46188. - def_tx = inb( dev->base_addr + TLAN_DIO_DATA );
  46189. - def_tx += inb( dev->base_addr + TLAN_DIO_DATA + 1 ) << 8;
  46190. - crc = inb( dev->base_addr + TLAN_DIO_DATA + 2 );
  46191. - code = inb( dev->base_addr + TLAN_DIO_DATA + 3 );
  46192. -
  46193. - outw( TLAN_MULTICOL_FRMS, dev->base_addr + TLAN_DIO_ADR );
  46194. - multi_col = inb( dev->base_addr + TLAN_DIO_DATA );
  46195. - multi_col += inb( dev->base_addr + TLAN_DIO_DATA + 1 ) << 8;
  46196. - single_col = inb( dev->base_addr + TLAN_DIO_DATA + 2 );
  46197. - single_col += inb( dev->base_addr + TLAN_DIO_DATA + 3 ) << 8;
  46198. -
  46199. - outw( TLAN_EXCESSCOL_FRMS, dev->base_addr + TLAN_DIO_ADR );
  46200. - excess_col = inb( dev->base_addr + TLAN_DIO_DATA );
  46201. - late_col = inb( dev->base_addr + TLAN_DIO_DATA + 1 );
  46202. - loss = inb( dev->base_addr + TLAN_DIO_DATA + 2 );
  46203. -
  46204. - if ( record ) {
  46205. - priv->stats.rx_packets += rx_good;
  46206. - priv->stats.rx_errors += rx_over + crc + code;
  46207. - priv->stats.tx_packets += tx_good;
  46208. - priv->stats.tx_errors += tx_under + loss;
  46209. - priv->stats.collisions += multi_col + single_col + excess_col + late_col;
  46210. -
  46211. - priv->stats.rx_over_errors += rx_over;
  46212. - priv->stats.rx_crc_errors += crc;
  46213. - priv->stats.rx_frame_errors += code;
  46214. + int i;
  46215. - priv->stats.tx_aborted_errors += tx_under;
  46216. - priv->stats.tx_carrier_errors += loss;
  46217. + areg *= 6;
  46218. +
  46219. + if (mac != NULL) {
  46220. + for (i = 0; i < 6; i++)
  46221. + TLan_DioWrite8(BASE, TLAN_AREG_0 + areg + i,
  46222. + mac[i]);
  46223. + } else {
  46224. + for (i = 0; i < 6; i++)
  46225. + TLan_DioWrite8(BASE, TLAN_AREG_0 + areg + i, 0);
  46226. }
  46227. -
  46228. -} /* TLan_ReadAndClearStats */
  46229. - /***************************************************************
  46230. - * TLan_Reset
  46231. +} /* TLan_SetMac */
  46232. +
  46233. + /*********************************************************************
  46234. + * TLan_PhyDetect
  46235. *
  46236. * Returns:
  46237. - * 0
  46238. + * Nothing
  46239. * Parms:
  46240. - * dev Pointer to device structure of adapter
  46241. - * to be reset.
  46242. + * dev A pointer to the device structure of the adapter
  46243. + * for which the PHY needs determined.
  46244. *
  46245. - * This function resets the adapter and it's physical
  46246. - * device. See Chap. 3, pp. 9-10 of the "ThunderLAN
  46247. - * Programmer's Guide" for details. The routine tries to
  46248. - * implement what is detailed there, though adjustments
  46249. - * have been made.
  46250. + * So far I've found that adapters which have external PHYs
  46251. + * may also use the internal PHY for part of the functionality.
  46252. + * (eg, AUI/Thinnet). This function finds out if this TLAN
  46253. + * chip has an internal PHY, and then finds the first external
  46254. + * PHY (starting from address 0) if it exists).
  46255. *
  46256. - **************************************************************/
  46257. + ********************************************************************/
  46258. -void
  46259. -TLan_ResetAdapter( struct net_device *dev )
  46260. +void TLan_PhyDetect(struct nic *nic)
  46261. {
  46262. - TLanPrivateInfo *priv = dev->priv;
  46263. - int i;
  46264. - u32 addr;
  46265. - u32 data;
  46266. - u8 data8;
  46267. + u16 control;
  46268. + u16 hi;
  46269. + u16 lo;
  46270. + u32 phy;
  46271. - priv->tlanFullDuplex = FALSE;
  46272. - priv->phyOnline=0;
  46273. -/* 1. Assert reset bit. */
  46274. + if (tlan_pci_tbl[chip_idx].flags & TLAN_ADAPTER_UNMANAGED_PHY) {
  46275. + priv->phyNum = 0xFFFF;
  46276. + return;
  46277. + }
  46278. - data = inl(dev->base_addr + TLAN_HOST_CMD);
  46279. - data |= TLAN_HC_AD_RST;
  46280. - outl(data, dev->base_addr + TLAN_HOST_CMD);
  46281. -
  46282. - udelay(1000);
  46283. + TLan_MiiReadReg(nic, TLAN_PHY_MAX_ADDR, MII_GEN_ID_HI, &hi);
  46284. -/* 2. Turn off interrupts. ( Probably isn't necessary ) */
  46285. + if (hi != 0xFFFF) {
  46286. + priv->phy[0] = TLAN_PHY_MAX_ADDR;
  46287. + } else {
  46288. + priv->phy[0] = TLAN_PHY_NONE;
  46289. + }
  46290. - data = inl(dev->base_addr + TLAN_HOST_CMD);
  46291. - data |= TLAN_HC_INT_OFF;
  46292. - outl(data, dev->base_addr + TLAN_HOST_CMD);
  46293. + priv->phy[1] = TLAN_PHY_NONE;
  46294. + for (phy = 0; phy <= TLAN_PHY_MAX_ADDR; phy++) {
  46295. + TLan_MiiReadReg(nic, phy, MII_GEN_CTL, &control);
  46296. + TLan_MiiReadReg(nic, phy, MII_GEN_ID_HI, &hi);
  46297. + TLan_MiiReadReg(nic, phy, MII_GEN_ID_LO, &lo);
  46298. + if ((control != 0xFFFF) || (hi != 0xFFFF)
  46299. + || (lo != 0xFFFF)) {
  46300. + printf("PHY found at %hX %hX %hX %hX\n", phy,
  46301. + control, hi, lo);
  46302. + if ((priv->phy[1] == TLAN_PHY_NONE)
  46303. + && (phy != TLAN_PHY_MAX_ADDR)) {
  46304. + priv->phy[1] = phy;
  46305. + }
  46306. + }
  46307. + }
  46308. -/* 3. Clear AREGs and HASHs. */
  46309. + if (priv->phy[1] != TLAN_PHY_NONE) {
  46310. + priv->phyNum = 1;
  46311. + } else if (priv->phy[0] != TLAN_PHY_NONE) {
  46312. + priv->phyNum = 0;
  46313. + } else {
  46314. + printf
  46315. + ("TLAN: Cannot initialize device, no PHY was found!\n");
  46316. + }
  46317. +
  46318. +} /* TLan_PhyDetect */
  46319. - for ( i = TLAN_AREG_0; i <= TLAN_HASH_2; i += 4 ) {
  46320. - TLan_DioWrite32( dev->base_addr, (u16) i, 0 );
  46321. +void TLan_PhyPowerDown(struct nic *nic)
  46322. +{
  46323. +
  46324. + u16 value;
  46325. + printf("%s: Powering down PHY(s).\n", priv->nic_name);
  46326. + value = MII_GC_PDOWN | MII_GC_LOOPBK | MII_GC_ISOLATE;
  46327. + TLan_MiiSync(BASE);
  46328. + TLan_MiiWriteReg(nic, priv->phy[priv->phyNum], MII_GEN_CTL, value);
  46329. + if ((priv->phyNum == 0) && (priv->phy[1] != TLAN_PHY_NONE)
  46330. + &&
  46331. + (!(tlan_pci_tbl[chip_idx].
  46332. + flags & TLAN_ADAPTER_USE_INTERN_10))) {
  46333. + TLan_MiiSync(BASE);
  46334. + TLan_MiiWriteReg(nic, priv->phy[1], MII_GEN_CTL, value);
  46335. }
  46336. -/* 4. Setup NetConfig register. */
  46337. + /* Wait for 50 ms and powerup
  46338. + * This is abitrary. It is intended to make sure the
  46339. + * tranceiver settles.
  46340. + */
  46341. + /* TLan_SetTimer( dev, (HZ/20), TLAN_TIMER_PHY_PUP ); */
  46342. + mdelay(50);
  46343. + TLan_PhyPowerUp(nic);
  46344. - data = TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN | TLAN_NET_CFG_PHY_EN;
  46345. - TLan_DioWrite16( dev->base_addr, TLAN_NET_CONFIG, (u16) data );
  46346. +} /* TLan_PhyPowerDown */
  46347. -/* 5. Load Ld_Tmr and Ld_Thr in HOST_CMD. */
  46348. - outl( TLAN_HC_LD_TMR | 0x3f, dev->base_addr + TLAN_HOST_CMD );
  46349. - outl( TLAN_HC_LD_THR | 0x9, dev->base_addr + TLAN_HOST_CMD );
  46350. +void TLan_PhyPowerUp(struct nic *nic)
  46351. +{
  46352. + u16 value;
  46353. -/* 6. Unreset the MII by setting NMRST (in NetSio) to 1. */
  46354. + printf("%s: Powering up PHY.\n", priv->nic_name);
  46355. + TLan_MiiSync(BASE);
  46356. + value = MII_GC_LOOPBK;
  46357. + TLan_MiiWriteReg(nic, priv->phy[priv->phyNum], MII_GEN_CTL, value);
  46358. + TLan_MiiSync(BASE);
  46359. + /* Wait for 500 ms and reset the
  46360. + * tranceiver. The TLAN docs say both 50 ms and
  46361. + * 500 ms, so do the longer, just in case.
  46362. + */
  46363. + mdelay(500);
  46364. + TLan_PhyReset(nic);
  46365. + /* TLan_SetTimer( dev, (HZ/20), TLAN_TIMER_PHY_RESET ); */
  46366. - outw( TLAN_NET_SIO, dev->base_addr + TLAN_DIO_ADR );
  46367. - addr = dev->base_addr + TLAN_DIO_DATA + TLAN_NET_SIO;
  46368. - TLan_SetBit( TLAN_NET_SIO_NMRST, addr );
  46369. +} /* TLan_PhyPowerUp */
  46370. -/* 7. Setup the remaining registers. */
  46371. +void TLan_PhyReset(struct nic *nic)
  46372. +{
  46373. + u16 phy;
  46374. + u16 value;
  46375. - if ( priv->tlanRev >= 0x30 ) {
  46376. - data8 = TLAN_ID_TX_EOC | TLAN_ID_RX_EOC;
  46377. - TLan_DioWrite8( dev->base_addr, TLAN_INT_DIS, data8 );
  46378. + phy = priv->phy[priv->phyNum];
  46379. +
  46380. + printf("%s: Reseting PHY.\n", priv->nic_name);
  46381. + TLan_MiiSync(BASE);
  46382. + value = MII_GC_LOOPBK | MII_GC_RESET;
  46383. + TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, value);
  46384. + TLan_MiiReadReg(nic, phy, MII_GEN_CTL, &value);
  46385. + while (value & MII_GC_RESET) {
  46386. + TLan_MiiReadReg(nic, phy, MII_GEN_CTL, &value);
  46387. }
  46388. - TLan_PhyDetect( dev );
  46389. - data = TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN;
  46390. -
  46391. - if ( priv->adapter->flags & TLAN_ADAPTER_BIT_RATE_PHY ) {
  46392. - data |= TLAN_NET_CFG_BIT;
  46393. - if ( priv->aui == 1 ) {
  46394. - TLan_DioWrite8( dev->base_addr, TLAN_ACOMMIT, 0x0a );
  46395. - } else if ( priv->duplex == TLAN_DUPLEX_FULL ) {
  46396. - TLan_DioWrite8( dev->base_addr, TLAN_ACOMMIT, 0x00 );
  46397. +
  46398. + /* Wait for 500 ms and initialize.
  46399. + * I don't remember why I wait this long.
  46400. + * I've changed this to 50ms, as it seems long enough.
  46401. + */
  46402. + /* TLan_SetTimer( dev, (HZ/20), TLAN_TIMER_PHY_START_LINK ); */
  46403. + mdelay(50);
  46404. + TLan_PhyStartLink(nic);
  46405. +
  46406. +} /* TLan_PhyReset */
  46407. +
  46408. +
  46409. +void TLan_PhyStartLink(struct nic *nic)
  46410. +{
  46411. +
  46412. + u16 ability;
  46413. + u16 control;
  46414. + u16 data;
  46415. + u16 phy;
  46416. + u16 status;
  46417. + u16 tctl;
  46418. +
  46419. + phy = priv->phy[priv->phyNum];
  46420. + printf("%s: Trying to activate link.\n", priv->nic_name);
  46421. + TLan_MiiReadReg(nic, phy, MII_GEN_STS, &status);
  46422. + TLan_MiiReadReg(nic, phy, MII_GEN_STS, &ability);
  46423. +
  46424. + if ((status & MII_GS_AUTONEG) && (!priv->aui)) {
  46425. + ability = status >> 11;
  46426. + if (priv->speed == TLAN_SPEED_10 &&
  46427. + priv->duplex == TLAN_DUPLEX_HALF) {
  46428. + TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, 0x0000);
  46429. + } else if (priv->speed == TLAN_SPEED_10 &&
  46430. + priv->duplex == TLAN_DUPLEX_FULL) {
  46431. + priv->tlanFullDuplex = TRUE;
  46432. + TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, 0x0100);
  46433. + } else if (priv->speed == TLAN_SPEED_100 &&
  46434. + priv->duplex == TLAN_DUPLEX_HALF) {
  46435. + TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, 0x2000);
  46436. + } else if (priv->speed == TLAN_SPEED_100 &&
  46437. + priv->duplex == TLAN_DUPLEX_FULL) {
  46438. priv->tlanFullDuplex = TRUE;
  46439. + TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, 0x2100);
  46440. } else {
  46441. - TLan_DioWrite8( dev->base_addr, TLAN_ACOMMIT, 0x08 );
  46442. +
  46443. + /* Set Auto-Neg advertisement */
  46444. + TLan_MiiWriteReg(nic, phy, MII_AN_ADV,
  46445. + (ability << 5) | 1);
  46446. + /* Enablee Auto-Neg */
  46447. + TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, 0x1000);
  46448. + /* Restart Auto-Neg */
  46449. + TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, 0x1200);
  46450. + /* Wait for 4 sec for autonegotiation
  46451. + * to complete. The max spec time is less than this
  46452. + * but the card need additional time to start AN.
  46453. + * .5 sec should be plenty extra.
  46454. + */
  46455. + printf("TLAN: %s: Starting autonegotiation.\n",
  46456. + priv->nic_name);
  46457. + mdelay(4000);
  46458. + TLan_PhyFinishAutoNeg(nic);
  46459. + /* TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_PHY_FINISH_AN ); */
  46460. + return;
  46461. }
  46462. - }
  46463. - if ( priv->phyNum == 0 ) {
  46464. - data |= TLAN_NET_CFG_PHY_EN;
  46465. }
  46466. - TLan_DioWrite16( dev->base_addr, TLAN_NET_CONFIG, (u16) data );
  46467. - if ( priv->adapter->flags & TLAN_ADAPTER_UNMANAGED_PHY ) {
  46468. - TLan_FinishReset( dev );
  46469. - } else {
  46470. - TLan_PhyPowerDown( dev );
  46471. + if ((priv->aui) && (priv->phyNum != 0)) {
  46472. + priv->phyNum = 0;
  46473. + data =
  46474. + TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN |
  46475. + TLAN_NET_CFG_PHY_EN;
  46476. + TLan_DioWrite16(BASE, TLAN_NET_CONFIG, data);
  46477. + mdelay(50);
  46478. + /* TLan_SetTimer( dev, (40*HZ/1000), TLAN_TIMER_PHY_PDOWN ); */
  46479. + TLan_PhyPowerDown(nic);
  46480. + return;
  46481. + } else if (priv->phyNum == 0) {
  46482. + control = 0;
  46483. + TLan_MiiReadReg(nic, phy, TLAN_TLPHY_CTL, &tctl);
  46484. + if (priv->aui) {
  46485. + tctl |= TLAN_TC_AUISEL;
  46486. + } else {
  46487. + tctl &= ~TLAN_TC_AUISEL;
  46488. + if (priv->duplex == TLAN_DUPLEX_FULL) {
  46489. + control |= MII_GC_DUPLEX;
  46490. + priv->tlanFullDuplex = TRUE;
  46491. + }
  46492. + if (priv->speed == TLAN_SPEED_100) {
  46493. + control |= MII_GC_SPEEDSEL;
  46494. + }
  46495. + }
  46496. + TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, control);
  46497. + TLan_MiiWriteReg(nic, phy, TLAN_TLPHY_CTL, tctl);
  46498. }
  46499. -} /* TLan_ResetAdapter */
  46500. + /* Wait for 2 sec to give the tranceiver time
  46501. + * to establish link.
  46502. + */
  46503. + /* TLan_SetTimer( dev, (4*HZ), TLAN_TIMER_FINISH_RESET ); */
  46504. + mdelay(2000);
  46505. + TLan_FinishReset(nic);
  46506. +
  46507. +} /* TLan_PhyStartLink */
  46508. -void
  46509. -TLan_FinishReset( struct net_device *dev )
  46510. +void TLan_PhyFinishAutoNeg(struct nic *nic)
  46511. {
  46512. - TLanPrivateInfo *priv = dev->priv;
  46513. - u8 data;
  46514. - u32 phy;
  46515. - u8 sio;
  46516. - u16 status;
  46517. - u16 partner;
  46518. - u16 tlphy_ctl;
  46519. - u16 tlphy_par;
  46520. - u16 tlphy_id1, tlphy_id2;
  46521. - int i;
  46522. +
  46523. + u16 an_adv;
  46524. + u16 an_lpa;
  46525. + u16 data;
  46526. + u16 mode;
  46527. + u16 phy;
  46528. + u16 status;
  46529. phy = priv->phy[priv->phyNum];
  46530. - data = TLAN_NET_CMD_NRESET | TLAN_NET_CMD_NWRAP;
  46531. - if ( priv->tlanFullDuplex ) {
  46532. - data |= TLAN_NET_CMD_DUPLEX;
  46533. + TLan_MiiReadReg(nic, phy, MII_GEN_STS, &status);
  46534. + udelay(1000);
  46535. + TLan_MiiReadReg(nic, phy, MII_GEN_STS, &status);
  46536. +
  46537. + if (!(status & MII_GS_AUTOCMPLT)) {
  46538. + /* Wait for 8 sec to give the process
  46539. + * more time. Perhaps we should fail after a while.
  46540. + */
  46541. + if (!priv->neg_be_verbose++) {
  46542. + printf
  46543. + ("TLAN: Giving autonegotiation more time.\n");
  46544. + printf
  46545. + ("TLAN: Please check that your adapter has\n");
  46546. + printf
  46547. + ("TLAN: been properly connected to a HUB or Switch.\n");
  46548. + printf
  46549. + ("TLAN: Trying to establish link in the background...\n");
  46550. + }
  46551. + mdelay(8000);
  46552. + TLan_PhyFinishAutoNeg(nic);
  46553. + /* TLan_SetTimer( dev, (8*HZ), TLAN_TIMER_PHY_FINISH_AN ); */
  46554. + return;
  46555. }
  46556. - TLan_DioWrite8( dev->base_addr, TLAN_NET_CMD, data );
  46557. - data = TLAN_NET_MASK_MASK4 | TLAN_NET_MASK_MASK5;
  46558. - if ( priv->phyNum == 0 ) {
  46559. - data |= TLAN_NET_MASK_MASK7;
  46560. - }
  46561. - TLan_DioWrite8( dev->base_addr, TLAN_NET_MASK, data );
  46562. - TLan_DioWrite16( dev->base_addr, TLAN_MAX_RX, ((1536)+7)&~7 );
  46563. - TLan_MiiReadReg( dev, phy, MII_GEN_ID_HI, &tlphy_id1 );
  46564. - TLan_MiiReadReg( dev, phy, MII_GEN_ID_LO, &tlphy_id2 );
  46565. -
  46566. - if ( ( priv->adapter->flags & TLAN_ADAPTER_UNMANAGED_PHY ) || ( priv->aui ) ) {
  46567. - status = MII_GS_LINK;
  46568. - printk( "TLAN: %s: Link forced.\n", dev->name );
  46569. - } else {
  46570. - TLan_MiiReadReg( dev, phy, MII_GEN_STS, &status );
  46571. - udelay( 1000 );
  46572. - TLan_MiiReadReg( dev, phy, MII_GEN_STS, &status );
  46573. - if ( (status & MII_GS_LINK) && /* We only support link info on Nat.Sem. PHY's */
  46574. - (tlphy_id1 == NAT_SEM_ID1) &&
  46575. - (tlphy_id2 == NAT_SEM_ID2) ) {
  46576. - TLan_MiiReadReg( dev, phy, MII_AN_LPA, &partner );
  46577. - TLan_MiiReadReg( dev, phy, TLAN_TLPHY_PAR, &tlphy_par );
  46578. -
  46579. - printk( "TLAN: %s: Link active with ", dev->name );
  46580. - if (!(tlphy_par & TLAN_PHY_AN_EN_STAT)) {
  46581. - printk( "forced 10%sMbps %s-Duplex\n",
  46582. - tlphy_par & TLAN_PHY_SPEED_100 ? "" : "0",
  46583. - tlphy_par & TLAN_PHY_DUPLEX_FULL ? "Full" : "Half");
  46584. - } else {
  46585. - printk( "AutoNegotiation enabled, at 10%sMbps %s-Duplex\n",
  46586. - tlphy_par & TLAN_PHY_SPEED_100 ? "" : "0",
  46587. - tlphy_par & TLAN_PHY_DUPLEX_FULL ? "Full" : "Half");
  46588. - printk("TLAN: Partner capability: ");
  46589. - for (i = 5; i <= 10; i++)
  46590. - if (partner & (1<<i))
  46591. - printk("%s", media[i-5]);
  46592. - printk("\n");
  46593. - }
  46594. - TLan_DioWrite8( dev->base_addr, TLAN_LED_REG, TLAN_LED_LINK );
  46595. -#ifdef MONITOR
  46596. - /* We have link beat..for now anyway */
  46597. - priv->link = 1;
  46598. - /*Enabling link beat monitoring */
  46599. - TLan_SetTimer( dev, (10*HZ), TLAN_TIMER_LINK_BEAT );
  46600. -#endif
  46601. - } else if (status & MII_GS_LINK) {
  46602. - printk( "TLAN: %s: Link active\n", dev->name );
  46603. - TLan_DioWrite8( dev->base_addr, TLAN_LED_REG, TLAN_LED_LINK );
  46604. - }
  46605. + printf("TLAN: %s: Autonegotiation complete.\n", priv->nic_name);
  46606. + TLan_MiiReadReg(nic, phy, MII_AN_ADV, &an_adv);
  46607. + TLan_MiiReadReg(nic, phy, MII_AN_LPA, &an_lpa);
  46608. + mode = an_adv & an_lpa & 0x03E0;
  46609. + if (mode & 0x0100) {
  46610. + printf("Full Duplex\n");
  46611. + priv->tlanFullDuplex = TRUE;
  46612. + } else if (!(mode & 0x0080) && (mode & 0x0040)) {
  46613. + priv->tlanFullDuplex = TRUE;
  46614. + printf("Full Duplex\n");
  46615. }
  46616. - if ( priv->phyNum == 0 ) {
  46617. - TLan_MiiReadReg( dev, phy, TLAN_TLPHY_CTL, &tlphy_ctl );
  46618. - tlphy_ctl |= TLAN_TC_INTEN;
  46619. - TLan_MiiWriteReg( dev, phy, TLAN_TLPHY_CTL, tlphy_ctl );
  46620. - sio = TLan_DioRead8( dev->base_addr, TLAN_NET_SIO );
  46621. - sio |= TLAN_NET_SIO_MINTEN;
  46622. - TLan_DioWrite8( dev->base_addr, TLAN_NET_SIO, sio );
  46623. + if ((!(mode & 0x0180))
  46624. + && (tlan_pci_tbl[chip_idx].flags & TLAN_ADAPTER_USE_INTERN_10)
  46625. + && (priv->phyNum != 0)) {
  46626. + priv->phyNum = 0;
  46627. + data =
  46628. + TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN |
  46629. + TLAN_NET_CFG_PHY_EN;
  46630. + TLan_DioWrite16(BASE, TLAN_NET_CONFIG, data);
  46631. + /* TLan_SetTimer( nic, (400*HZ/1000), TLAN_TIMER_PHY_PDOWN ); */
  46632. + mdelay(400);
  46633. + TLan_PhyPowerDown(nic);
  46634. + return;
  46635. }
  46636. - if ( status & MII_GS_LINK ) {
  46637. - TLan_SetMac( dev, 0, dev->dev_addr );
  46638. - priv->phyOnline = 1;
  46639. - outb( ( TLAN_HC_INT_ON >> 8 ), dev->base_addr + TLAN_HOST_CMD + 1 );
  46640. - if ( debug >= 1 && debug != TLAN_DEBUG_PROBE ) {
  46641. - outb( ( TLAN_HC_REQ_INT >> 8 ), dev->base_addr + TLAN_HOST_CMD + 1 );
  46642. + if (priv->phyNum == 0) {
  46643. + if ((priv->duplex == TLAN_DUPLEX_FULL)
  46644. + || (an_adv & an_lpa & 0x0040)) {
  46645. + TLan_MiiWriteReg(nic, phy, MII_GEN_CTL,
  46646. + MII_GC_AUTOENB | MII_GC_DUPLEX);
  46647. + printf
  46648. + ("TLAN: Starting internal PHY with FULL-DUPLEX\n");
  46649. + } else {
  46650. + TLan_MiiWriteReg(nic, phy, MII_GEN_CTL,
  46651. + MII_GC_AUTOENB);
  46652. + printf
  46653. + ("TLAN: Starting internal PHY with HALF-DUPLEX\n");
  46654. }
  46655. - outl( virt_to_bus( priv->rxList ), dev->base_addr + TLAN_CH_PARM );
  46656. - outl( TLAN_HC_GO | TLAN_HC_RT, dev->base_addr + TLAN_HOST_CMD );
  46657. - } else {
  46658. - printk( "TLAN: %s: Link inactive, will retry in 10 secs...\n", dev->name );
  46659. - TLan_SetTimer( dev, (10*HZ), TLAN_TIMER_FINISH_RESET );
  46660. - return;
  46661. }
  46662. -} /* TLan_FinishReset */
  46663. + /* Wait for 100 ms. No reason in partiticular.
  46664. + */
  46665. + /* TLan_SetTimer( dev, (HZ/10), TLAN_TIMER_FINISH_RESET ); */
  46666. + mdelay(100);
  46667. + TLan_FinishReset(nic);
  46668. - /***************************************************************
  46669. - * TLan_SetMac
  46670. - *
  46671. - * Returns:
  46672. - * Nothing
  46673. - * Parms:
  46674. - * dev Pointer to device structure of adapter
  46675. - * on which to change the AREG.
  46676. - * areg The AREG to set the address in (0 - 3).
  46677. - * mac A pointer to an array of chars. Each
  46678. - * element stores one byte of the address.
  46679. - * IE, it isn't in ascii.
  46680. - *
  46681. - * This function transfers a MAC address to one of the
  46682. - * TLAN AREGs (address registers). The TLAN chip locks
  46683. - * the register on writing to offset 0 and unlocks the
  46684. - * register after writing to offset 5. If NULL is passed
  46685. - * in mac, then the AREG is filled with 0's.
  46686. - *
  46687. - **************************************************************/
  46688. +} /* TLan_PhyFinishAutoNeg */
  46689. +
  46690. +#ifdef MONITOR
  46691. +
  46692. + /*********************************************************************
  46693. + *
  46694. + * TLan_phyMonitor
  46695. + *
  46696. + * Returns:
  46697. + * None
  46698. + *
  46699. + * Params:
  46700. + * dev The device structure of this device.
  46701. + *
  46702. + *
  46703. + * This function monitors PHY condition by reading the status
  46704. + * register via the MII bus. This can be used to give info
  46705. + * about link changes (up/down), and possible switch to alternate
  46706. + * media.
  46707. + *
  46708. + * ******************************************************************/
  46709. -void TLan_SetMac( struct net_device *dev, int areg, char *mac )
  46710. +void TLan_PhyMonitor(struct net_device *dev)
  46711. {
  46712. - int i;
  46713. -
  46714. - areg *= 6;
  46715. + TLanPrivateInfo *priv = dev->priv;
  46716. + u16 phy;
  46717. + u16 phy_status;
  46718. - if ( mac != NULL ) {
  46719. - for ( i = 0; i < 6; i++ )
  46720. - TLan_DioWrite8( dev->base_addr, TLAN_AREG_0 + areg + i, mac[i] );
  46721. - } else {
  46722. - for ( i = 0; i < 6; i++ )
  46723. - TLan_DioWrite8( dev->base_addr, TLAN_AREG_0 + areg + i, 0 );
  46724. + phy = priv->phy[priv->phyNum];
  46725. +
  46726. + /* Get PHY status register */
  46727. + TLan_MiiReadReg(nic, phy, MII_GEN_STS, &phy_status);
  46728. +
  46729. + /* Check if link has been lost */
  46730. + if (!(phy_status & MII_GS_LINK)) {
  46731. + if (priv->link) {
  46732. + priv->link = 0;
  46733. + printf("TLAN: %s has lost link\n", priv->nic_name);
  46734. + priv->flags &= ~IFF_RUNNING;
  46735. + mdelay(2000);
  46736. + TLan_PhyMonitor(nic);
  46737. + /* TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_LINK_BEAT ); */
  46738. + return;
  46739. + }
  46740. }
  46741. -} /* TLan_SetMac */
  46742. + /* Link restablished? */
  46743. + if ((phy_status & MII_GS_LINK) && !priv->link) {
  46744. + priv->link = 1;
  46745. + printf("TLAN: %s has reestablished link\n",
  46746. + priv->nic_name);
  46747. + priv->flags |= IFF_RUNNING;
  46748. + }
  46749. +
  46750. + /* Setup a new monitor */
  46751. + /* TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_LINK_BEAT ); */
  46752. + mdelay(2000);
  46753. + TLan_PhyMonitor(nic);
  46754. +}
  46755. +#endif /* MONITOR */
  46756. +
  46757. +#ifdef EB51
  46758. +static struct pci_id tlan_nics[] = {
  46759. + PCI_ROM(0x0e11, 0xae34, "netel10", "Compaq Netelligent 10 T PCI UTP"),
  46760. + PCI_ROM(0x0e11, 0xae32, "netel100","Compaq Netelligent 10/100 TX PCI UTP"),
  46761. + PCI_ROM(0x0e11, 0xae35, "netflex3i", "Compaq Integrated NetFlex-3/P"),
  46762. + PCI_ROM(0x0e11, 0xf130, "thunder", "Compaq NetFlex-3/P"),
  46763. + PCI_ROM(0x0e11, 0xf150, "netflex3b", "Compaq NetFlex-3/P"),
  46764. + PCI_ROM(0x0e11, 0xae43, "netel100pi", "Compaq Netelligent Integrated 10/100 TX UTP"),
  46765. + PCI_ROM(0x0e11, 0xae40, "netel100d", "Compaq Netelligent Dual 10/100 TX PCI UTP"),
  46766. + PCI_ROM(0x0e11, 0xb011, "netel100i", "Compaq Netelligent 10/100 TX Embedded UTP"),
  46767. + PCI_ROM(0x108d, 0x0013, "oc2183", "Olicom OC-2183/2185"),
  46768. + PCI_ROM(0x108d, 0x0012, "oc2325", "Olicom OC-2325"),
  46769. + PCI_ROM(0x108d, 0x0014, "oc2326", "Olicom OC-2326"),
  46770. + PCI_ROM(0x0e11, 0xb030, "netelligent_10_100_ws_5100", "Compaq Netelligent 10/100 TX UTP"),
  46771. + PCI_ROM(0x0e11, 0xb012, "netelligent_10_t2", "Compaq Netelligent 10 T/2 PCI UTP/Coax"),
  46772. +};
  46773. +
  46774. +struct pci_driver tlan_driver = {
  46775. + .type = NIC_DRIVER,
  46776. + .name = "TLAN/PCI",
  46777. + .probe = tlan_probe,
  46778. + .ids = tlan_nics,
  46779. + .id_count = sizeof(tlan_nics) / sizeof(tlan_nics[0]),
  46780. + .class = 0,
  46781. +};
  46782. #endif
  46783. diff -Naur grub-0.97.orig/netboot/tlan.h grub-0.97/netboot/tlan.h
  46784. --- grub-0.97.orig/netboot/tlan.h 1970-01-01 00:00:00.000000000 +0000
  46785. +++ grub-0.97/netboot/tlan.h 2005-08-31 19:03:35.000000000 +0000
  46786. @@ -0,0 +1,536 @@
  46787. +/**************************************************************************
  46788. +*
  46789. +* tlan.c -- Etherboot device driver for the Texas Instruments ThunderLAN
  46790. +* Written 2003-2003 by Timothy Legge <tlegge@rogers.com>
  46791. +*
  46792. +* This program is free software; you can redistribute it and/or modify
  46793. +* it under the terms of the GNU General Public License as published by
  46794. +* the Free Software Foundation; either version 2 of the License, or
  46795. +* (at your option) any later version.
  46796. +*
  46797. +* This program is distributed in the hope that it will be useful,
  46798. +* but WITHOUT ANY WARRANTY; without even the implied warranty of
  46799. +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  46800. +* GNU General Public License for more details.
  46801. +*
  46802. +* You should have received a copy of the GNU General Public License
  46803. +* along with this program; if not, write to the Free Software
  46804. +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  46805. +*
  46806. +* Portions of this code (almost all) based on:
  46807. +* tlan.c: Linux ThunderLan Driver:
  46808. +*
  46809. +* by James Banks
  46810. +*
  46811. +* (C) 1997-1998 Caldera, Inc.
  46812. +* (C) 1998 James Banks
  46813. +* (C) 1999-2001 Torben Mathiasen
  46814. +* (C) 2002 Samuel Chessman
  46815. +*
  46816. +* REVISION HISTORY:
  46817. +* ================
  46818. +* v1.0 07-08-2003 timlegge Initial not quite working version
  46819. +*
  46820. +* Indent Style: indent -kr -i8
  46821. +***************************************************************************/
  46822. +
  46823. +/*
  46824. +#include <asm/io.h>
  46825. +#include <asm/types.h>
  46826. +#include <linux/netdevice.h>
  46827. +*/
  46828. +
  46829. +typedef unsigned char u8;
  46830. +typedef signed char s8;
  46831. +typedef unsigned short u16;
  46832. +typedef signed short s16;
  46833. +typedef unsigned int u32;
  46834. +typedef signed int s32;
  46835. + /*****************************************************************
  46836. + * TLan Definitions
  46837. + *
  46838. + ****************************************************************/
  46839. +
  46840. +#define FALSE 0
  46841. +#define TRUE 1
  46842. +
  46843. +#define TLAN_MIN_FRAME_SIZE 64
  46844. +#define TLAN_MAX_FRAME_SIZE 1600
  46845. +
  46846. +#define TLAN_NUM_RX_LISTS 4
  46847. +#define TLAN_NUM_TX_LISTS 2
  46848. +
  46849. +#define TLAN_IGNORE 0
  46850. +#define TLAN_RECORD 1
  46851. +/*
  46852. +#define TLAN_DBG(lvl, format, args...) if (debug&lvl) printf("TLAN: " format, ##args );
  46853. +*/
  46854. +#define TLAN_DEBUG_GNRL 0x0001
  46855. +#define TLAN_DEBUG_TX 0x0002
  46856. +#define TLAN_DEBUG_RX 0x0004
  46857. +#define TLAN_DEBUG_LIST 0x0008
  46858. +#define TLAN_DEBUG_PROBE 0x0010
  46859. +
  46860. +#define TX_TIMEOUT (10*HZ) /* We need time for auto-neg */
  46861. +#define MAX_TLAN_BOARDS 8 /* Max number of boards installed at a time */
  46862. +
  46863. +
  46864. + /*****************************************************************
  46865. + * Device Identification Definitions
  46866. + *
  46867. + ****************************************************************/
  46868. +
  46869. +#define PCI_DEVICE_ID_NETELLIGENT_10_T2 0xB012
  46870. +#define PCI_DEVICE_ID_NETELLIGENT_10_100_WS_5100 0xB030
  46871. +#ifndef PCI_DEVICE_ID_OLICOM_OC2183
  46872. +#define PCI_DEVICE_ID_OLICOM_OC2183 0x0013
  46873. +#endif
  46874. +#ifndef PCI_DEVICE_ID_OLICOM_OC2325
  46875. +#define PCI_DEVICE_ID_OLICOM_OC2325 0x0012
  46876. +#endif
  46877. +#ifndef PCI_DEVICE_ID_OLICOM_OC2326
  46878. +#define PCI_DEVICE_ID_OLICOM_OC2326 0x0014
  46879. +#endif
  46880. +
  46881. +typedef struct tlan_adapter_entry {
  46882. + u16 vendorId;
  46883. + u16 deviceId;
  46884. + char *deviceLabel;
  46885. + u32 flags;
  46886. + u16 addrOfs;
  46887. +} TLanAdapterEntry;
  46888. +
  46889. +#define TLAN_ADAPTER_NONE 0x00000000
  46890. +#define TLAN_ADAPTER_UNMANAGED_PHY 0x00000001
  46891. +#define TLAN_ADAPTER_BIT_RATE_PHY 0x00000002
  46892. +#define TLAN_ADAPTER_USE_INTERN_10 0x00000004
  46893. +#define TLAN_ADAPTER_ACTIVITY_LED 0x00000008
  46894. +
  46895. +#define TLAN_SPEED_DEFAULT 0
  46896. +#define TLAN_SPEED_10 10
  46897. +#define TLAN_SPEED_100 100
  46898. +
  46899. +#define TLAN_DUPLEX_DEFAULT 0
  46900. +#define TLAN_DUPLEX_HALF 1
  46901. +#define TLAN_DUPLEX_FULL 2
  46902. +
  46903. +
  46904. +
  46905. + /*****************************************************************
  46906. + * EISA Definitions
  46907. + *
  46908. + ****************************************************************/
  46909. +
  46910. +#define EISA_ID 0xc80 /* EISA ID Registers */
  46911. +#define EISA_ID0 0xc80 /* EISA ID Register 0 */
  46912. +#define EISA_ID1 0xc81 /* EISA ID Register 1 */
  46913. +#define EISA_ID2 0xc82 /* EISA ID Register 2 */
  46914. +#define EISA_ID3 0xc83 /* EISA ID Register 3 */
  46915. +#define EISA_CR 0xc84 /* EISA Control Register */
  46916. +#define EISA_REG0 0xc88 /* EISA Configuration Register 0 */
  46917. +#define EISA_REG1 0xc89 /* EISA Configuration Register 1 */
  46918. +#define EISA_REG2 0xc8a /* EISA Configuration Register 2 */
  46919. +#define EISA_REG3 0xc8f /* EISA Configuration Register 3 */
  46920. +#define EISA_APROM 0xc90 /* Ethernet Address PROM */
  46921. +
  46922. +
  46923. +
  46924. + /*****************************************************************
  46925. + * Rx/Tx List Definitions
  46926. + *
  46927. + ****************************************************************/
  46928. +
  46929. +#define TLAN_BUFFERS_PER_LIST 10
  46930. +#define TLAN_LAST_BUFFER 0x80000000
  46931. +#define TLAN_CSTAT_UNUSED 0x8000
  46932. +#define TLAN_CSTAT_FRM_CMP 0x4000
  46933. +#define TLAN_CSTAT_READY 0x3000
  46934. +#define TLAN_CSTAT_EOC 0x0800
  46935. +#define TLAN_CSTAT_RX_ERROR 0x0400
  46936. +#define TLAN_CSTAT_PASS_CRC 0x0200
  46937. +#define TLAN_CSTAT_DP_PR 0x0100
  46938. +
  46939. +
  46940. +
  46941. +
  46942. +
  46943. +
  46944. + /*****************************************************************
  46945. + * PHY definitions
  46946. + *
  46947. + ****************************************************************/
  46948. +
  46949. +#define TLAN_PHY_MAX_ADDR 0x1F
  46950. +#define TLAN_PHY_NONE 0x20
  46951. +
  46952. +
  46953. +
  46954. + /*****************************************************************
  46955. + * TLan Driver Timer Definitions
  46956. + *
  46957. + ****************************************************************/
  46958. +
  46959. +#define TLAN_TIMER_LINK_BEAT 1
  46960. +#define TLAN_TIMER_ACTIVITY 2
  46961. +#define TLAN_TIMER_PHY_PDOWN 3
  46962. +#define TLAN_TIMER_PHY_PUP 4
  46963. +#define TLAN_TIMER_PHY_RESET 5
  46964. +#define TLAN_TIMER_PHY_START_LINK 6
  46965. +#define TLAN_TIMER_PHY_FINISH_AN 7
  46966. +#define TLAN_TIMER_FINISH_RESET 8
  46967. +
  46968. +#define TLAN_TIMER_ACT_DELAY (HZ/10)
  46969. +
  46970. +
  46971. +
  46972. +
  46973. + /*****************************************************************
  46974. + * TLan Driver Eeprom Definitions
  46975. + *
  46976. + ****************************************************************/
  46977. +
  46978. +#define TLAN_EEPROM_ACK 0
  46979. +#define TLAN_EEPROM_STOP 1
  46980. +
  46981. +
  46982. +
  46983. +
  46984. + /*****************************************************************
  46985. + * Host Register Offsets and Contents
  46986. + *
  46987. + ****************************************************************/
  46988. +
  46989. +#define TLAN_HOST_CMD 0x00
  46990. +#define TLAN_HC_GO 0x80000000
  46991. +#define TLAN_HC_STOP 0x40000000
  46992. +#define TLAN_HC_ACK 0x20000000
  46993. +#define TLAN_HC_CS_MASK 0x1FE00000
  46994. +#define TLAN_HC_EOC 0x00100000
  46995. +#define TLAN_HC_RT 0x00080000
  46996. +#define TLAN_HC_NES 0x00040000
  46997. +#define TLAN_HC_AD_RST 0x00008000
  46998. +#define TLAN_HC_LD_TMR 0x00004000
  46999. +#define TLAN_HC_LD_THR 0x00002000
  47000. +#define TLAN_HC_REQ_INT 0x00001000
  47001. +#define TLAN_HC_INT_OFF 0x00000800
  47002. +#define TLAN_HC_INT_ON 0x00000400
  47003. +#define TLAN_HC_AC_MASK 0x000000FF
  47004. +#define TLAN_CH_PARM 0x04
  47005. +#define TLAN_DIO_ADR 0x08
  47006. +#define TLAN_DA_ADR_INC 0x8000
  47007. +#define TLAN_DA_RAM_ADR 0x4000
  47008. +#define TLAN_HOST_INT 0x0A
  47009. +#define TLAN_HI_IV_MASK 0x1FE0
  47010. +#define TLAN_HI_IT_MASK 0x001C
  47011. +#define TLAN_DIO_DATA 0x0C
  47012. +
  47013. +
  47014. +/* ThunderLAN Internal Register DIO Offsets */
  47015. +
  47016. +#define TLAN_NET_CMD 0x00
  47017. +#define TLAN_NET_CMD_NRESET 0x80
  47018. +#define TLAN_NET_CMD_NWRAP 0x40
  47019. +#define TLAN_NET_CMD_CSF 0x20
  47020. +#define TLAN_NET_CMD_CAF 0x10
  47021. +#define TLAN_NET_CMD_NOBRX 0x08
  47022. +#define TLAN_NET_CMD_DUPLEX 0x04
  47023. +#define TLAN_NET_CMD_TRFRAM 0x02
  47024. +#define TLAN_NET_CMD_TXPACE 0x01
  47025. +#define TLAN_NET_SIO 0x01
  47026. +#define TLAN_NET_SIO_MINTEN 0x80
  47027. +#define TLAN_NET_SIO_ECLOK 0x40
  47028. +#define TLAN_NET_SIO_ETXEN 0x20
  47029. +#define TLAN_NET_SIO_EDATA 0x10
  47030. +#define TLAN_NET_SIO_NMRST 0x08
  47031. +#define TLAN_NET_SIO_MCLK 0x04
  47032. +#define TLAN_NET_SIO_MTXEN 0x02
  47033. +#define TLAN_NET_SIO_MDATA 0x01
  47034. +#define TLAN_NET_STS 0x02
  47035. +#define TLAN_NET_STS_MIRQ 0x80
  47036. +#define TLAN_NET_STS_HBEAT 0x40
  47037. +#define TLAN_NET_STS_TXSTOP 0x20
  47038. +#define TLAN_NET_STS_RXSTOP 0x10
  47039. +#define TLAN_NET_STS_RSRVD 0x0F
  47040. +#define TLAN_NET_MASK 0x03
  47041. +#define TLAN_NET_MASK_MASK7 0x80
  47042. +#define TLAN_NET_MASK_MASK6 0x40
  47043. +#define TLAN_NET_MASK_MASK5 0x20
  47044. +#define TLAN_NET_MASK_MASK4 0x10
  47045. +#define TLAN_NET_MASK_RSRVD 0x0F
  47046. +#define TLAN_NET_CONFIG 0x04
  47047. +#define TLAN_NET_CFG_RCLK 0x8000
  47048. +#define TLAN_NET_CFG_TCLK 0x4000
  47049. +#define TLAN_NET_CFG_BIT 0x2000
  47050. +#define TLAN_NET_CFG_RXCRC 0x1000
  47051. +#define TLAN_NET_CFG_PEF 0x0800
  47052. +#define TLAN_NET_CFG_1FRAG 0x0400
  47053. +#define TLAN_NET_CFG_1CHAN 0x0200
  47054. +#define TLAN_NET_CFG_MTEST 0x0100
  47055. +#define TLAN_NET_CFG_PHY_EN 0x0080
  47056. +#define TLAN_NET_CFG_MSMASK 0x007F
  47057. +#define TLAN_MAN_TEST 0x06
  47058. +#define TLAN_DEF_VENDOR_ID 0x08
  47059. +#define TLAN_DEF_DEVICE_ID 0x0A
  47060. +#define TLAN_DEF_REVISION 0x0C
  47061. +#define TLAN_DEF_SUBCLASS 0x0D
  47062. +#define TLAN_DEF_MIN_LAT 0x0E
  47063. +#define TLAN_DEF_MAX_LAT 0x0F
  47064. +#define TLAN_AREG_0 0x10
  47065. +#define TLAN_AREG_1 0x16
  47066. +#define TLAN_AREG_2 0x1C
  47067. +#define TLAN_AREG_3 0x22
  47068. +#define TLAN_HASH_1 0x28
  47069. +#define TLAN_HASH_2 0x2C
  47070. +#define TLAN_GOOD_TX_FRMS 0x30
  47071. +#define TLAN_TX_UNDERUNS 0x33
  47072. +#define TLAN_GOOD_RX_FRMS 0x34
  47073. +#define TLAN_RX_OVERRUNS 0x37
  47074. +#define TLAN_DEFERRED_TX 0x38
  47075. +#define TLAN_CRC_ERRORS 0x3A
  47076. +#define TLAN_CODE_ERRORS 0x3B
  47077. +#define TLAN_MULTICOL_FRMS 0x3C
  47078. +#define TLAN_SINGLECOL_FRMS 0x3E
  47079. +#define TLAN_EXCESSCOL_FRMS 0x40
  47080. +#define TLAN_LATE_COLS 0x41
  47081. +#define TLAN_CARRIER_LOSS 0x42
  47082. +#define TLAN_ACOMMIT 0x43
  47083. +#define TLAN_LED_REG 0x44
  47084. +#define TLAN_LED_ACT 0x10
  47085. +#define TLAN_LED_LINK 0x01
  47086. +#define TLAN_BSIZE_REG 0x45
  47087. +#define TLAN_MAX_RX 0x46
  47088. +#define TLAN_INT_DIS 0x48
  47089. +#define TLAN_ID_TX_EOC 0x04
  47090. +#define TLAN_ID_RX_EOF 0x02
  47091. +#define TLAN_ID_RX_EOC 0x01
  47092. +
  47093. +
  47094. +
  47095. +/* ThunderLAN Interrupt Codes */
  47096. +
  47097. +#define TLAN_INT_NUMBER_OF_INTS 8
  47098. +
  47099. +#define TLAN_INT_NONE 0x0000
  47100. +#define TLAN_INT_TX_EOF 0x0001
  47101. +#define TLAN_INT_STAT_OVERFLOW 0x0002
  47102. +#define TLAN_INT_RX_EOF 0x0003
  47103. +#define TLAN_INT_DUMMY 0x0004
  47104. +#define TLAN_INT_TX_EOC 0x0005
  47105. +#define TLAN_INT_STATUS_CHECK 0x0006
  47106. +#define TLAN_INT_RX_EOC 0x0007
  47107. +
  47108. +
  47109. +
  47110. +/* ThunderLAN MII Registers */
  47111. +
  47112. +/* Generic MII/PHY Registers */
  47113. +
  47114. +#define MII_GEN_CTL 0x00
  47115. +#define MII_GC_RESET 0x8000
  47116. +#define MII_GC_LOOPBK 0x4000
  47117. +#define MII_GC_SPEEDSEL 0x2000
  47118. +#define MII_GC_AUTOENB 0x1000
  47119. +#define MII_GC_PDOWN 0x0800
  47120. +#define MII_GC_ISOLATE 0x0400
  47121. +#define MII_GC_AUTORSRT 0x0200
  47122. +#define MII_GC_DUPLEX 0x0100
  47123. +#define MII_GC_COLTEST 0x0080
  47124. +#define MII_GC_RESERVED 0x007F
  47125. +#define MII_GEN_STS 0x01
  47126. +#define MII_GS_100BT4 0x8000
  47127. +#define MII_GS_100BTXFD 0x4000
  47128. +#define MII_GS_100BTXHD 0x2000
  47129. +#define MII_GS_10BTFD 0x1000
  47130. +#define MII_GS_10BTHD 0x0800
  47131. +#define MII_GS_RESERVED 0x07C0
  47132. +#define MII_GS_AUTOCMPLT 0x0020
  47133. +#define MII_GS_RFLT 0x0010
  47134. +#define MII_GS_AUTONEG 0x0008
  47135. +#define MII_GS_LINK 0x0004
  47136. +#define MII_GS_JABBER 0x0002
  47137. +#define MII_GS_EXTCAP 0x0001
  47138. +#define MII_GEN_ID_HI 0x02
  47139. +#define MII_GEN_ID_LO 0x03
  47140. +#define MII_GIL_OUI 0xFC00
  47141. +#define MII_GIL_MODEL 0x03F0
  47142. +#define MII_GIL_REVISION 0x000F
  47143. +#define MII_AN_ADV 0x04
  47144. +#define MII_AN_LPA 0x05
  47145. +#define MII_AN_EXP 0x06
  47146. +
  47147. +/* ThunderLAN Specific MII/PHY Registers */
  47148. +
  47149. +#define TLAN_TLPHY_ID 0x10
  47150. +#define TLAN_TLPHY_CTL 0x11
  47151. +#define TLAN_TC_IGLINK 0x8000
  47152. +#define TLAN_TC_SWAPOL 0x4000
  47153. +#define TLAN_TC_AUISEL 0x2000
  47154. +#define TLAN_TC_SQEEN 0x1000
  47155. +#define TLAN_TC_MTEST 0x0800
  47156. +#define TLAN_TC_RESERVED 0x07F8
  47157. +#define TLAN_TC_NFEW 0x0004
  47158. +#define TLAN_TC_INTEN 0x0002
  47159. +#define TLAN_TC_TINT 0x0001
  47160. +#define TLAN_TLPHY_STS 0x12
  47161. +#define TLAN_TS_MINT 0x8000
  47162. +#define TLAN_TS_PHOK 0x4000
  47163. +#define TLAN_TS_POLOK 0x2000
  47164. +#define TLAN_TS_TPENERGY 0x1000
  47165. +#define TLAN_TS_RESERVED 0x0FFF
  47166. +#define TLAN_TLPHY_PAR 0x19
  47167. +#define TLAN_PHY_CIM_STAT 0x0020
  47168. +#define TLAN_PHY_SPEED_100 0x0040
  47169. +#define TLAN_PHY_DUPLEX_FULL 0x0080
  47170. +#define TLAN_PHY_AN_EN_STAT 0x0400
  47171. +
  47172. +/* National Sem. & Level1 PHY id's */
  47173. +#define NAT_SEM_ID1 0x2000
  47174. +#define NAT_SEM_ID2 0x5C01
  47175. +#define LEVEL1_ID1 0x7810
  47176. +#define LEVEL1_ID2 0x0000
  47177. +
  47178. +#define CIRC_INC( a, b ) if ( ++a >= b ) a = 0
  47179. +
  47180. +/* Routines to access internal registers. */
  47181. +
  47182. +inline u8 TLan_DioRead8(u16 base_addr, u16 internal_addr)
  47183. +{
  47184. + outw(internal_addr, base_addr + TLAN_DIO_ADR);
  47185. + return (inb((base_addr + TLAN_DIO_DATA) + (internal_addr & 0x3)));
  47186. +
  47187. +} /* TLan_DioRead8 */
  47188. +
  47189. +
  47190. +
  47191. +
  47192. +inline u16 TLan_DioRead16(u16 base_addr, u16 internal_addr)
  47193. +{
  47194. + outw(internal_addr, base_addr + TLAN_DIO_ADR);
  47195. + return (inw((base_addr + TLAN_DIO_DATA) + (internal_addr & 0x2)));
  47196. +
  47197. +} /* TLan_DioRead16 */
  47198. +
  47199. +
  47200. +
  47201. +
  47202. +inline u32 TLan_DioRead32(u16 base_addr, u16 internal_addr)
  47203. +{
  47204. + outw(internal_addr, base_addr + TLAN_DIO_ADR);
  47205. + return (inl(base_addr + TLAN_DIO_DATA));
  47206. +
  47207. +} /* TLan_DioRead32 */
  47208. +
  47209. +
  47210. +
  47211. +
  47212. +inline void TLan_DioWrite8(u16 base_addr, u16 internal_addr, u8 data)
  47213. +{
  47214. + outw(internal_addr, base_addr + TLAN_DIO_ADR);
  47215. + outb(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x3));
  47216. +
  47217. +}
  47218. +
  47219. +
  47220. +
  47221. +
  47222. +inline void TLan_DioWrite16(u16 base_addr, u16 internal_addr, u16 data)
  47223. +{
  47224. + outw(internal_addr, base_addr + TLAN_DIO_ADR);
  47225. + outw(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x2));
  47226. +
  47227. +}
  47228. +
  47229. +
  47230. +
  47231. +
  47232. +inline void TLan_DioWrite32(u16 base_addr, u16 internal_addr, u32 data)
  47233. +{
  47234. + outw(internal_addr, base_addr + TLAN_DIO_ADR);
  47235. + outl(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x2));
  47236. +
  47237. +}
  47238. +
  47239. +
  47240. +
  47241. +#if 0
  47242. +inline void TLan_ClearBit(u8 bit, u16 port)
  47243. +{
  47244. + outb_p(inb_p(port) & ~bit, port);
  47245. +}
  47246. +
  47247. +
  47248. +
  47249. +
  47250. +inline int TLan_GetBit(u8 bit, u16 port)
  47251. +{
  47252. + return ((int) (inb_p(port) & bit));
  47253. +}
  47254. +
  47255. +
  47256. +
  47257. +
  47258. +inline void TLan_SetBit(u8 bit, u16 port)
  47259. +{
  47260. + outb_p(inb_p(port) | bit, port);
  47261. +}
  47262. +#endif
  47263. +
  47264. +#define TLan_ClearBit( bit, port ) outb_p(inb_p(port) & ~bit, port)
  47265. +#define TLan_GetBit( bit, port ) ((int) (inb_p(port) & bit))
  47266. +#define TLan_SetBit( bit, port ) outb_p(inb_p(port) | bit, port)
  47267. +
  47268. +#ifdef I_LIKE_A_FAST_HASH_FUNCTION
  47269. +/* given 6 bytes, view them as 8 6-bit numbers and return the XOR of those */
  47270. +/* the code below is about seven times as fast as the original code */
  47271. +inline u32 TLan_HashFunc(u8 * a)
  47272. +{
  47273. + u8 hash;
  47274. +
  47275. + hash = (a[0] ^ a[3]); /* & 077 */
  47276. + hash ^= ((a[0] ^ a[3]) >> 6); /* & 003 */
  47277. + hash ^= ((a[1] ^ a[4]) << 2); /* & 074 */
  47278. + hash ^= ((a[1] ^ a[4]) >> 4); /* & 017 */
  47279. + hash ^= ((a[2] ^ a[5]) << 4); /* & 060 */
  47280. + hash ^= ((a[2] ^ a[5]) >> 2); /* & 077 */
  47281. +
  47282. + return (hash & 077);
  47283. +}
  47284. +
  47285. +#else /* original code */
  47286. +
  47287. +inline u32 xor(u32 a, u32 b)
  47288. +{
  47289. + return ((a && !b) || (!a && b));
  47290. +}
  47291. +
  47292. +#define XOR8( a, b, c, d, e, f, g, h ) xor( a, xor( b, xor( c, xor( d, xor( e, xor( f, xor( g, h ) ) ) ) ) ) )
  47293. +#define DA( a, bit ) ( ( (u8) a[bit/8] ) & ( (u8) ( 1 << bit%8 ) ) )
  47294. +
  47295. +inline u32 TLan_HashFunc(u8 * a)
  47296. +{
  47297. + u32 hash;
  47298. +
  47299. + hash =
  47300. + XOR8(DA(a, 0), DA(a, 6), DA(a, 12), DA(a, 18), DA(a, 24),
  47301. + DA(a, 30), DA(a, 36), DA(a, 42));
  47302. + hash |=
  47303. + XOR8(DA(a, 1), DA(a, 7), DA(a, 13), DA(a, 19), DA(a, 25),
  47304. + DA(a, 31), DA(a, 37), DA(a, 43)) << 1;
  47305. + hash |=
  47306. + XOR8(DA(a, 2), DA(a, 8), DA(a, 14), DA(a, 20), DA(a, 26),
  47307. + DA(a, 32), DA(a, 38), DA(a, 44)) << 2;
  47308. + hash |=
  47309. + XOR8(DA(a, 3), DA(a, 9), DA(a, 15), DA(a, 21), DA(a, 27),
  47310. + DA(a, 33), DA(a, 39), DA(a, 45)) << 3;
  47311. + hash |=
  47312. + XOR8(DA(a, 4), DA(a, 10), DA(a, 16), DA(a, 22), DA(a, 28),
  47313. + DA(a, 34), DA(a, 40), DA(a, 46)) << 4;
  47314. + hash |=
  47315. + XOR8(DA(a, 5), DA(a, 11), DA(a, 17), DA(a, 23), DA(a, 29),
  47316. + DA(a, 35), DA(a, 41), DA(a, 47)) << 5;
  47317. +
  47318. + return hash;
  47319. +
  47320. +}
  47321. +
  47322. +#endif /* I_LIKE_A_FAST_HASH_FUNCTION */
  47323. diff -Naur grub-0.97.orig/netboot/tulip.c grub-0.97/netboot/tulip.c
  47324. --- grub-0.97.orig/netboot/tulip.c 2003-07-09 11:45:38.000000000 +0000
  47325. +++ grub-0.97/netboot/tulip.c 2005-08-31 19:03:35.000000000 +0000
  47326. @@ -48,6 +48,7 @@
  47327. /*********************************************************************/
  47328. /*
  47329. + 07 Sep 2003 timlegge Multicast Support Added
  47330. 11 Apr 2001 mdc [patch to etherboot 4.7.24]
  47331. Major rewrite to include Linux tulip driver media detection
  47332. code. This driver should support a lot more cards now.
  47333. @@ -98,7 +99,6 @@
  47334. and thinguin mailing lists.
  47335. */
  47336. -
  47337. /*********************************************************************/
  47338. /* Declarations */
  47339. /*********************************************************************/
  47340. @@ -106,31 +106,29 @@
  47341. #include "etherboot.h"
  47342. #include "nic.h"
  47343. #include "pci.h"
  47344. -#include "cards.h"
  47345. /* User settable parameters */
  47346. -#undef TULIP_DEBUG
  47347. -#undef TULIP_DEBUG_WHERE
  47348. +#undef TULIP_DEBUG
  47349. +#undef TULIP_DEBUG_WHERE
  47350. +#ifdef TULIP_DEBUG
  47351. static int tulip_debug = 2; /* 1 normal messages, 0 quiet .. 7 verbose. */
  47352. +#endif
  47353. #define TX_TIME_OUT 2*TICKS_PER_SEC
  47354. -typedef unsigned char u8;
  47355. -typedef signed char s8;
  47356. -typedef unsigned short u16;
  47357. -typedef signed short s16;
  47358. -typedef unsigned int u32;
  47359. -typedef signed int s32;
  47360. +typedef uint8_t u8;
  47361. +typedef int8_t s8;
  47362. +typedef uint16_t u16;
  47363. +typedef int16_t s16;
  47364. +typedef uint32_t u32;
  47365. +typedef int32_t s32;
  47366. /* helpful macros if on a big_endian machine for changing byte order.
  47367. not strictly needed on Intel */
  47368. -#define le16_to_cpu(val) (val)
  47369. -#define cpu_to_le32(val) (val)
  47370. #define get_unaligned(ptr) (*(ptr))
  47371. #define put_unaligned(val, ptr) ((void)( *(ptr) = (val) ))
  47372. #define get_u16(ptr) (*(u16 *)(ptr))
  47373. -#define virt_to_bus(x) ((unsigned long)x)
  47374. #define virt_to_le32desc(addr) virt_to_bus(addr)
  47375. #define TULIP_IOTYPE PCI_USES_MASTER | PCI_USES_IO | PCI_ADDR0
  47376. @@ -212,6 +210,8 @@
  47377. TULIP_IOTYPE, 256, PNIC2 },
  47378. { "ADMtek AN981 Comet", { 0x09811317, 0xffffffff, 0, 0, 0, 0 },
  47379. TULIP_IOTYPE, 256, COMET },
  47380. + { "ADMTek AN983 Comet", { 0x12161113, 0xffffffff, 0, 0, 0, 0 },
  47381. + TULIP_IOTYPE, 256, COMET },
  47382. { "ADMtek Centaur-P", { 0x09851317, 0xffffffff, 0, 0, 0, 0 },
  47383. TULIP_IOTYPE, 256, COMET },
  47384. { "ADMtek Centaur-C", { 0x19851317, 0xffffffff, 0, 0, 0, 0 },
  47385. @@ -280,9 +280,13 @@
  47386. static u16 t21041_csr14[] = { 0xFFFF, 0xF7FD, 0xF7FD, 0x7F3F, 0x7F3D, };
  47387. static u16 t21041_csr15[] = { 0x0008, 0x0006, 0x000E, 0x0008, 0x0008, };
  47388. +/* not used
  47389. static u16 t21142_csr13[] = { 0x0001, 0x0009, 0x0009, 0x0000, 0x0001, };
  47390. +*/
  47391. static u16 t21142_csr14[] = { 0xFFFF, 0x0705, 0x0705, 0x0000, 0x7F3D, };
  47392. +/* not used
  47393. static u16 t21142_csr15[] = { 0x0008, 0x0006, 0x000E, 0x0008, 0x0008, };
  47394. +*/
  47395. /* Offsets to the Command and Status Registers, "CSRs". All accesses
  47396. must be longword instructions and quadword aligned. */
  47397. @@ -300,6 +304,14 @@
  47398. TxFIFOUnderflow=0x20, TxJabber=0x08, TxNoBuf=0x04, TxDied=0x02, TxIntr=0x01,
  47399. };
  47400. +/* The configuration bits in CSR6. */
  47401. +enum csr6_mode_bits {
  47402. + TxOn=0x2000, RxOn=0x0002, FullDuplex=0x0200,
  47403. + AcceptBroadcast=0x0100, AcceptAllMulticast=0x0080,
  47404. + AcceptAllPhys=0x0040, AcceptRunt=0x0008,
  47405. +};
  47406. +
  47407. +
  47408. enum desc_status_bits {
  47409. DescOwnded=0x80000000, RxDescFatalErr=0x8000, RxWholePkt=0x0300,
  47410. };
  47411. @@ -384,21 +396,11 @@
  47412. #define TX_RING_SIZE 2
  47413. static struct tulip_tx_desc tx_ring[TX_RING_SIZE] __attribute__ ((aligned(4)));
  47414. -
  47415. -#ifdef USE_LOWMEM_BUFFER
  47416. -#define txb ((char *)0x10000 - BUFLEN)
  47417. -#else
  47418. static unsigned char txb[BUFLEN] __attribute__ ((aligned(4)));
  47419. -#endif
  47420. #define RX_RING_SIZE 4
  47421. static struct tulip_rx_desc rx_ring[RX_RING_SIZE] __attribute__ ((aligned(4)));
  47422. -
  47423. -#ifdef USE_LOWMEM_BUFFER
  47424. -#define rxb ((char *)0x10000 - RX_RING_SIZE * BUFLEN - BUFLEN)
  47425. -#else
  47426. static unsigned char rxb[RX_RING_SIZE * BUFLEN] __attribute__ ((aligned(4)));
  47427. -#endif
  47428. static struct tulip_private {
  47429. int cur_rx;
  47430. @@ -471,7 +473,6 @@
  47431. static const char * block_name[] = {"21140 non-MII", "21140 MII PHY",
  47432. "21142 Serial PHY", "21142 MII PHY", "21143 SYM PHY", "21143 reset method"};
  47433. -
  47434. /*********************************************************************/
  47435. /* Function Prototypes */
  47436. /*********************************************************************/
  47437. @@ -479,14 +480,13 @@
  47438. static void mdio_write(struct nic *nic, int phy_id, int location, int value);
  47439. static int read_eeprom(unsigned long ioaddr, int location, int addr_len);
  47440. static void parse_eeprom(struct nic *nic);
  47441. -struct nic *tulip_probe(struct nic *nic, unsigned short *io_addrs,
  47442. - struct pci_device *pci);
  47443. +static int tulip_probe(struct dev *dev, struct pci_device *pci);
  47444. static void tulip_init_ring(struct nic *nic);
  47445. static void tulip_reset(struct nic *nic);
  47446. static void tulip_transmit(struct nic *nic, const char *d, unsigned int t,
  47447. unsigned int s, const char *p);
  47448. -static int tulip_poll(struct nic *nic);
  47449. -static void tulip_disable(struct nic *nic);
  47450. +static int tulip_poll(struct nic *nic, int retrieve);
  47451. +static void tulip_disable(struct dev *dev);
  47452. static void nway_start(struct nic *nic);
  47453. static void pnic_do_nway(struct nic *nic);
  47454. static void select_media(struct nic *nic, int startup);
  47455. @@ -504,7 +504,6 @@
  47456. static void tulip_more(void);
  47457. #endif
  47458. -
  47459. /*********************************************************************/
  47460. /* Utility Routines */
  47461. /*********************************************************************/
  47462. @@ -535,7 +534,6 @@
  47463. /* wait */ ;
  47464. }
  47465. -
  47466. /*********************************************************************/
  47467. /* Media Descriptor Code */
  47468. /*********************************************************************/
  47469. @@ -565,7 +563,7 @@
  47470. MDIO protocol. See the MII specifications or DP83840A data sheet
  47471. for details. */
  47472. -int mdio_read(struct nic *nic, int phy_id, int location)
  47473. +int mdio_read(struct nic *nic __unused, int phy_id, int location)
  47474. {
  47475. int i;
  47476. int read_cmd = (0xf6 << 10) | (phy_id << 5) | location;
  47477. @@ -626,7 +624,7 @@
  47478. return (retval>>1) & 0xffff;
  47479. }
  47480. -void mdio_write(struct nic *nic, int phy_id, int location, int value)
  47481. +void mdio_write(struct nic *nic __unused, int phy_id, int location, int value)
  47482. {
  47483. int i;
  47484. int cmd = (0x5002 << 16) | (phy_id << 23) | (location<<18) | value;
  47485. @@ -682,7 +680,6 @@
  47486. }
  47487. }
  47488. -
  47489. /*********************************************************************/
  47490. /* EEPROM Reading Code */
  47491. /*********************************************************************/
  47492. @@ -727,7 +724,6 @@
  47493. return retval;
  47494. }
  47495. -
  47496. /*********************************************************************/
  47497. /* EEPROM Parsing Code */
  47498. /*********************************************************************/
  47499. @@ -895,11 +891,10 @@
  47500. }
  47501. }
  47502. -
  47503. /*********************************************************************/
  47504. /* tulip_init_ring - setup the tx and rx descriptors */
  47505. /*********************************************************************/
  47506. -static void tulip_init_ring(struct nic *nic)
  47507. +static void tulip_init_ring(struct nic *nic __unused)
  47508. {
  47509. int i;
  47510. @@ -935,7 +930,22 @@
  47511. /* Mark the last entry as wrapping the ring, though this should never happen */
  47512. tx_ring[1].length = cpu_to_le32(DESC_RING_WRAP | BUFLEN);
  47513. }
  47514. -
  47515. +
  47516. +static void set_rx_mode(struct nic *nic __unused) {
  47517. + int csr6 = inl(ioaddr + CSR6) & ~0x00D5;
  47518. +
  47519. + tp->csr6 &= ~0x00D5;
  47520. +
  47521. + /* !IFF_PROMISC */
  47522. + tp->csr6 |= AcceptAllMulticast;
  47523. + csr6 |= AcceptAllMulticast;
  47524. +
  47525. + outl(csr6, ioaddr + CSR6);
  47526. +
  47527. +
  47528. +
  47529. +}
  47530. +
  47531. /*********************************************************************/
  47532. /* eth_reset - Reset adapter */
  47533. /*********************************************************************/
  47534. @@ -943,7 +953,6 @@
  47535. {
  47536. int i;
  47537. unsigned long to;
  47538. - u32 addr_low, addr_high;
  47539. #ifdef TULIP_DEBUG_WHERE
  47540. whereami("tulip_reset\n");
  47541. @@ -956,7 +965,7 @@
  47542. if (tp->mii_cnt || (tp->mtable && tp->mtable->has_mii)) {
  47543. outl(0x814C0000, ioaddr + CSR6);
  47544. }
  47545. -
  47546. +
  47547. /* Reset the chip, holding bit 0 set at least 50 PCI cycles. */
  47548. outl(0x00000001, ioaddr + CSR0);
  47549. tulip_wait(1);
  47550. @@ -1022,8 +1031,8 @@
  47551. }
  47552. /* Point to rx and tx descriptors */
  47553. - outl((unsigned long)&rx_ring[0], ioaddr + CSR3);
  47554. - outl((unsigned long)&tx_ring[0], ioaddr + CSR4);
  47555. + outl(virt_to_le32desc(&rx_ring[0]), ioaddr + CSR3);
  47556. + outl(virt_to_le32desc(&tx_ring[0]), ioaddr + CSR4);
  47557. init_media(nic);
  47558. @@ -1049,11 +1058,12 @@
  47559. if (tp->chip_id == LC82C168)
  47560. tulip_check_duplex(nic);
  47561. + set_rx_mode(nic);
  47562. +
  47563. /* enable transmit and receive */
  47564. outl(tp->csr6 | 0x00002002, ioaddr + CSR6);
  47565. }
  47566. -
  47567. /*********************************************************************/
  47568. /* eth_transmit - Transmit a frame */
  47569. /*********************************************************************/
  47570. @@ -1095,7 +1105,7 @@
  47571. tx_ring[0].status = cpu_to_le32(0x80000000);
  47572. /* Point to transmit descriptor */
  47573. - outl((u32)&tx_ring[0], ioaddr + CSR4);
  47574. + outl(virt_to_le32desc(&tx_ring[0]), ioaddr + CSR4);
  47575. /* Enable Tx */
  47576. outl(csr6 | 0x00002000, ioaddr + CSR6);
  47577. @@ -1113,11 +1123,11 @@
  47578. /* Disable Tx */
  47579. outl(csr6 & ~0x00002000, ioaddr + CSR6);
  47580. }
  47581. -
  47582. +
  47583. /*********************************************************************/
  47584. /* eth_poll - Wait for a frame */
  47585. /*********************************************************************/
  47586. -static int tulip_poll(struct nic *nic)
  47587. +static int tulip_poll(struct nic *nic, int retrieve)
  47588. {
  47589. #ifdef TULIP_DEBUG_WHERE
  47590. @@ -1128,6 +1138,8 @@
  47591. if (rx_ring[tp->cur_rx].status & 0x80000000)
  47592. return 0;
  47593. + if ( ! retrieve ) return 1;
  47594. +
  47595. #ifdef TULIP_DEBUG_WHERE
  47596. whereami("tulip_poll got one\n");
  47597. #endif
  47598. @@ -1151,17 +1163,20 @@
  47599. return 1;
  47600. }
  47601. -
  47602. +
  47603. /*********************************************************************/
  47604. /* eth_disable - Disable the interface */
  47605. /*********************************************************************/
  47606. -static void tulip_disable(struct nic *nic)
  47607. +static void tulip_disable(struct dev *dev)
  47608. {
  47609. -
  47610. + struct nic *nic = (struct nic *)dev;
  47611. #ifdef TULIP_DEBUG_WHERE
  47612. whereami("tulip_disable\n");
  47613. #endif
  47614. + /* merge reset and disable */
  47615. + tulip_reset(nic);
  47616. +
  47617. /* disable interrupts */
  47618. outl(0x00000000, ioaddr + CSR7);
  47619. @@ -1171,24 +1186,41 @@
  47620. /* Clear the missed-packet counter. */
  47621. (volatile unsigned long)inl(ioaddr + CSR8);
  47622. }
  47623. -
  47624. +
  47625. +/*********************************************************************/
  47626. +/*IRQ - Enable, Disable, or Force interrupts */
  47627. +/*********************************************************************/
  47628. +static void tulip_irq(struct nic *nic __unused, irq_action_t action __unused)
  47629. +{
  47630. + switch ( action ) {
  47631. + case DISABLE :
  47632. + break;
  47633. + case ENABLE :
  47634. + break;
  47635. + case FORCE :
  47636. + break;
  47637. + }
  47638. +}
  47639. +
  47640. /*********************************************************************/
  47641. /* eth_probe - Look for an adapter */
  47642. /*********************************************************************/
  47643. -struct nic *tulip_probe(struct nic *nic, unsigned short *io_addrs,
  47644. - struct pci_device *pci)
  47645. +static int tulip_probe(struct dev *dev, struct pci_device *pci)
  47646. {
  47647. - u32 i, l1, l2;
  47648. + struct nic *nic = (struct nic *)dev;
  47649. + u32 i;
  47650. u8 chip_rev;
  47651. u8 ee_data[EEPROM_SIZE];
  47652. unsigned short sum;
  47653. int chip_idx;
  47654. static unsigned char last_phys_addr[ETH_ALEN] = {0x00, 'L', 'i', 'n', 'u', 'x'};
  47655. - if (io_addrs == 0 || *io_addrs == 0)
  47656. + if (pci->ioaddr == 0)
  47657. return 0;
  47658. - ioaddr = *io_addrs;
  47659. + ioaddr = pci->ioaddr;
  47660. + nic->ioaddr = pci->ioaddr & ~3;
  47661. + nic->irqno = 0;
  47662. /* point to private storage */
  47663. tp = &tpx;
  47664. @@ -1378,15 +1410,15 @@
  47665. /* reset the device and make ready for tx and rx of packets */
  47666. tulip_reset(nic);
  47667. - nic->reset = tulip_reset;
  47668. + dev->disable = tulip_disable;
  47669. nic->poll = tulip_poll;
  47670. nic->transmit = tulip_transmit;
  47671. - nic->disable = tulip_disable;
  47672. + nic->irq = tulip_irq;
  47673. /* give the board a chance to reset before returning */
  47674. tulip_wait(4*TICKS_PER_SEC);
  47675. - return nic;
  47676. + return 1;
  47677. }
  47678. static void start_link(struct nic *nic)
  47679. @@ -1508,7 +1540,7 @@
  47680. }
  47681. }
  47682. -static void nway_start(struct nic *nic)
  47683. +static void nway_start(struct nic *nic __unused)
  47684. {
  47685. int csr14 = ((tp->sym_advertise & 0x0780) << 9) |
  47686. ((tp->sym_advertise&0x0020)<<1) | 0xffbf;
  47687. @@ -1662,7 +1694,7 @@
  47688. }
  47689. }
  47690. -static void pnic_do_nway(struct nic *nic)
  47691. +static void pnic_do_nway(struct nic *nic __unused)
  47692. {
  47693. u32 phy_reg = inl(ioaddr + 0xB8);
  47694. u32 new_csr6 = tp->csr6 & ~0x40C40200;
  47695. @@ -1886,8 +1918,8 @@
  47696. }
  47697. } else if (tp->chip_id == DC21040) { /* 21040 */
  47698. /* Turn on the xcvr interface. */
  47699. - int csr12 = inl(ioaddr + CSR12);
  47700. #ifdef TULIP_DEBUG
  47701. + int csr12 = inl(ioaddr + CSR12);
  47702. if (tulip_debug > 1)
  47703. printf("%s: 21040 media type is %s, CSR12 is %hhX.\n",
  47704. tp->nic_name, medianame[tp->if_port], csr12);
  47705. @@ -1987,3 +2019,51 @@
  47706. return 0;
  47707. }
  47708. +
  47709. +static struct pci_id tulip_nics[] = {
  47710. +PCI_ROM(0x1011, 0x0002, "dc21040", "Digital Tulip"),
  47711. +PCI_ROM(0x1011, 0x0009, "ds21140", "Digital Tulip Fast"),
  47712. +PCI_ROM(0x1011, 0x0014, "dc21041", "Digital Tulip+"),
  47713. +PCI_ROM(0x1011, 0x0019, "ds21142", "Digital Tulip 21142"),
  47714. +PCI_ROM(0x10b7, 0x9300, "3csoho100b-tx","3ComSOHO100B-TX"),
  47715. +PCI_ROM(0x10b9, 0x5261, "ali1563", "ALi 1563 integrated ethernet"),
  47716. +PCI_ROM(0x10d9, 0x0512, "mx98713", "Macronix MX987x3"),
  47717. +PCI_ROM(0x10d9, 0x0531, "mx98715", "Macronix MX987x5"),
  47718. +PCI_ROM(0x1113, 0x1217, "mxic-98715", "Macronix MX987x5"),
  47719. +PCI_ROM(0x11ad, 0xc115, "lc82c115", "LinkSys LNE100TX"),
  47720. +PCI_ROM(0x11ad, 0x0002, "82c168", "Netgear FA310TX"),
  47721. +PCI_ROM(0x1282, 0x9100, "dm9100", "Davicom 9100"),
  47722. +PCI_ROM(0x1282, 0x9102, "dm9102", "Davicom 9102"),
  47723. +PCI_ROM(0x1282, 0x9009, "dm9009", "Davicom 9009"),
  47724. +PCI_ROM(0x1282, 0x9132, "dm9132", "Davicom 9132"),
  47725. +PCI_ROM(0x1317, 0x0985, "centaur-p", "ADMtek Centaur-P"),
  47726. +PCI_ROM(0x1317, 0x0981, "an981", "ADMtek AN981 Comet"), /* ADMTek Centaur-P (stmicro) */
  47727. +PCI_ROM(0x1113, 0x1216, "an983", "ADMTek AN983 Comet"),
  47728. +PCI_ROM(0x1317, 0x9511, "an983b", "ADMTek Comet 983b"),
  47729. +PCI_ROM(0x1317, 0x1985, "centaur-c", "ADMTek Centaur-C"),
  47730. +PCI_ROM(0x8086, 0x0039, "intel21145", "Intel Tulip"),
  47731. +PCI_ROM(0x125b, 0x1400, "ax88140", "ASIX AX88140"),
  47732. +PCI_ROM(0x11f6, 0x9881, "rl100tx", "Compex RL100-TX"),
  47733. +PCI_ROM(0x115d, 0x0003, "xircomtulip", "Xircom Tulip"),
  47734. +PCI_ROM(0x104a, 0x0981, "tulip-0981", "Tulip 0x104a 0x0981"),
  47735. +PCI_ROM(0x104a, 0x2774, "tulip-2774", "Tulip 0x104a 0x2774"),
  47736. +PCI_ROM(0x1113, 0x9511, "tulip-9511", "Tulip 0x1113 0x9511"),
  47737. +PCI_ROM(0x1186, 0x1561, "tulip-1561", "Tulip 0x1186 0x1561"),
  47738. +PCI_ROM(0x1259, 0xa120, "tulip-a120", "Tulip 0x1259 0xa120"),
  47739. +PCI_ROM(0x13d1, 0xab02, "tulip-ab02", "Tulip 0x13d1 0xab02"),
  47740. +PCI_ROM(0x13d1, 0xab03, "tulip-ab03", "Tulip 0x13d1 0xab03"),
  47741. +PCI_ROM(0x13d1, 0xab08, "tulip-ab08", "Tulip 0x13d1 0xab08"),
  47742. +PCI_ROM(0x14f1, 0x1803, "lanfinity", "Conexant LANfinity"),
  47743. +PCI_ROM(0x1626, 0x8410, "tulip-8410", "Tulip 0x1626 0x8410"),
  47744. +PCI_ROM(0x1737, 0xab08, "tulip-1737-ab08","Tulip 0x1737 0xab08"),
  47745. +PCI_ROM(0x1737, 0xab09, "tulip-ab09", "Tulip 0x1737 0xab09"),
  47746. +};
  47747. +
  47748. +struct pci_driver tulip_driver = {
  47749. + .type = NIC_DRIVER,
  47750. + .name = "Tulip",
  47751. + .probe = tulip_probe,
  47752. + .ids = tulip_nics,
  47753. + .id_count = sizeof(tulip_nics)/sizeof(tulip_nics[0]),
  47754. + .class = 0,
  47755. +};
  47756. diff -Naur grub-0.97.orig/netboot/tulip.txt grub-0.97/netboot/tulip.txt
  47757. --- grub-0.97.orig/netboot/tulip.txt 2003-07-09 11:45:38.000000000 +0000
  47758. +++ grub-0.97/netboot/tulip.txt 1970-01-01 00:00:00.000000000 +0000
  47759. @@ -1,53 +0,0 @@
  47760. -This software may be used and distributed according to the terms of
  47761. -the GNU Public License, incorporated herein by reference.
  47762. -
  47763. -This is a tulip and clone driver for Etherboot. See the revision
  47764. -history in the tulip.c file for information on changes. This version
  47765. -of the driver incorporates changes from Bob Edwards and Paul Mackerras
  47766. -who cantributed changes to support the TRENDnet TE100-PCIA NIC which
  47767. -uses a genuine Intel 21143-PD chipset. There are also various code
  47768. -cleanups to make time-based activities more reliable.
  47769. -
  47770. -Of course you have to have all the usual Etherboot environment
  47771. -(bootp/dhcp/NFS) set up, and you need a Linux kernel with v0.91g
  47772. -(7.16.99) or later of the tulip.c driver compiled in to support some
  47773. -MX98715 based cards. That file is available at:
  47774. -
  47775. - http://cesdis.gsfc.nasa.gov/linux/drivers/test/tulip.c
  47776. -
  47777. -NOTES
  47778. -
  47779. -I've tested this driver with a SOHOware Fast 10/100 Model SDA110A,
  47780. -a Linksys LNE100TX v2.0, and a Netgear FA310TX card, and it worked at
  47781. -both 10 and 100 mbits. Other cards based on the tulip family may work as
  47782. -well.
  47783. -
  47784. -These cards are about 20$US, are supported by Linux and now Etherboot,
  47785. -and being PCI, they auto-configure IRQ and IOADDR and auto-negotiate
  47786. -10/100 half/full duplex. It seems like a pretty good value compared to
  47787. -some of the pricier cards, and can lower the cost of building/adapting
  47788. -thin client workstations substantially while giving a considerable
  47789. -performance increase.
  47790. -
  47791. -On some PCI tulip clone chipsets (MX987x5, LC82C115, LC82C168) this driver
  47792. -lets the card choose the fastest speed it can negotiate with the peer
  47793. -device. On other cards, it chooses 10mbit half-duplex.
  47794. -
  47795. -I burned an AM27C256 (32KByte) EPROM with mx987x5.lzrom and it worked.
  47796. -According to the data sheet the MX98715A supports up to 64K (27C512)
  47797. -EPROMs,
  47798. -
  47799. -I've liberally commented the code and header files in the hope that it
  47800. -will help the next person who hacks the code or needs to support some
  47801. -tulip clone card, or wishes to add functionality.
  47802. -
  47803. -Anyway, please test this if you can on your tulip based card, and let
  47804. -me (mdc@thinguin.org) and the netboot list (netboot@baghira.han.de)
  47805. -know how things go. I also would appreciate code review by people who
  47806. -program. I'm a strong believer in "another set of eyes".
  47807. -
  47808. -Regards,
  47809. -
  47810. -Marty Connor
  47811. -mdc@thinguin.org
  47812. -http://www.thinguin.org/
  47813. diff -Naur grub-0.97.orig/netboot/types.h grub-0.97/netboot/types.h
  47814. --- grub-0.97.orig/netboot/types.h 1970-01-01 00:00:00.000000000 +0000
  47815. +++ grub-0.97/netboot/types.h 2005-08-31 19:03:35.000000000 +0000
  47816. @@ -0,0 +1,44 @@
  47817. +#ifndef _TYPES_H
  47818. +#define _TYPES_H
  47819. +
  47820. +/* I'm architecture independed :-) */
  47821. +
  47822. +/*
  47823. + * It's architecture depended headers for common integer types
  47824. + */
  47825. +#include "stdint.h"
  47826. +
  47827. +/*
  47828. + * Here are some RPC types define from linux /usr/include/rpc/types.h
  47829. + */
  47830. +typedef int bool_t;
  47831. +typedef int enum_t;
  47832. +typedef uint32_t rpcprog_t;
  47833. +typedef uint32_t rpcvers_t;
  47834. +typedef uint32_t rpcproc_t;
  47835. +typedef uint32_t rpcprot_t;
  47836. +typedef uint32_t rpcport_t;
  47837. +
  47838. +/* For bool_t */
  47839. +/* typedef enum { */
  47840. +/* FALSE = 0, */
  47841. +/* TRUE = 1 */
  47842. +/* } boolean_t; */
  47843. +
  47844. +
  47845. +
  47846. +/* Some BSD or RPC style types */
  47847. +typedef unsigned char u_char;
  47848. +typedef unsigned short u_short;
  47849. +typedef unsigned int u_int;
  47850. +typedef unsigned long u_long;
  47851. +typedef long long quad_t;
  47852. +typedef unsigned long long u_quad_t;
  47853. +typedef struct {
  47854. + int __val[2];
  47855. +}fsid_t; /* Type of file system IDs, from bits/types.h */
  47856. +
  47857. +typedef int daddr_t; /* The type of a disk address, from bits/types.h */
  47858. +typedef char * caddr_t;
  47859. +
  47860. +#endif /* _TYPES_H */
  47861. diff -Naur grub-0.97.orig/netboot/udp.h grub-0.97/netboot/udp.h
  47862. --- grub-0.97.orig/netboot/udp.h 1970-01-01 00:00:00.000000000 +0000
  47863. +++ grub-0.97/netboot/udp.h 2005-08-31 19:03:35.000000000 +0000
  47864. @@ -0,0 +1,30 @@
  47865. +#ifndef _UDP_H
  47866. +#define _UDP_H
  47867. +
  47868. +/* We need 'uint16_t' and 'uint8_t' */
  47869. +#include "types.h"
  47870. +/* We need 'in_addr' */
  47871. +#include "in.h"
  47872. +
  47873. +struct udp_pseudo_hdr {
  47874. + in_addr src;
  47875. + in_addr dest;
  47876. + uint8_t unused;
  47877. + uint8_t protocol;
  47878. + uint16_t len;
  47879. +};
  47880. +struct udphdr {
  47881. + uint16_t src;
  47882. + uint16_t dest;
  47883. + uint16_t len;
  47884. + uint16_t chksum;
  47885. +};
  47886. +
  47887. +extern void build_udp_hdr(unsigned long __destip, unsigned int __srcsock,
  47888. + unsigned int __destsock, int __ttl, int __len,
  47889. + const void * __buf);
  47890. +
  47891. +extern int udp_transmit(unsigned long __destip, unsigned int __srcsock,
  47892. + unsigned int __destsock, int __len, const void * __buf);
  47893. +
  47894. +#endif /* _UDP_H */
  47895. diff -Naur grub-0.97.orig/netboot/via-rhine.c grub-0.97/netboot/via-rhine.c
  47896. --- grub-0.97.orig/netboot/via-rhine.c 2003-07-09 11:45:38.000000000 +0000
  47897. +++ grub-0.97/netboot/via-rhine.c 2005-08-31 19:03:35.000000000 +0000
  47898. @@ -18,7 +18,7 @@
  47899. */
  47900. -static const char *version = "rhine.c v1.0.0 2000-01-07\n";
  47901. +static const char *version = "rhine.c v1.0.1 2003-02-06\n";
  47902. /* A few user-configurable values. */
  47903. @@ -46,7 +46,6 @@
  47904. #include "etherboot.h"
  47905. #include "nic.h"
  47906. #include "pci.h"
  47907. -#include "cards.h"
  47908. /* define all ioaddr */
  47909. @@ -103,6 +102,11 @@
  47910. #define byCFGD ioaddr + 0x7b
  47911. #define wTallyCntMPA ioaddr + 0x7c
  47912. #define wTallyCntCRC ioaddr + 0x7d
  47913. +#define bySTICKHW ioaddr + 0x83
  47914. +#define byWOLcrClr ioaddr + 0xA4
  47915. +#define byWOLcgClr ioaddr + 0xA7
  47916. +#define byPwrcsrClr ioaddr + 0xAC
  47917. +
  47918. /*--------------------- Exioaddr Definitions -------------------------*/
  47919. /*
  47920. @@ -617,9 +621,6 @@
  47921. */
  47922. -#define PCI_VENDOR_ID_FET 0x1106
  47923. -#define PCI_DEVICE_ID_FET_3043 0x3043
  47924. -
  47925. /* The rest of these values should never change. */
  47926. #define NUM_TX_DESC 2 /* Number of Tx descriptor registers. */
  47927. @@ -652,23 +653,19 @@
  47928. }
  47929. rhine;
  47930. -static struct nic *rhine_probe1 (struct nic *dev, int ioaddr,
  47931. +static void rhine_probe1 (struct nic *nic, int ioaddr,
  47932. int chip_id, int options);
  47933. static int QueryAuto (int);
  47934. static int ReadMII (int byMIIIndex, int);
  47935. static void WriteMII (char, char, char, int);
  47936. static void MIIDelay (void);
  47937. static void rhine_init_ring (struct nic *dev);
  47938. -static void rhine_disable (struct nic *nic);
  47939. +static void rhine_disable (struct dev *dev);
  47940. static void rhine_reset (struct nic *nic);
  47941. -static int rhine_poll (struct nic *nic);
  47942. +static int rhine_poll (struct nic *nic, int retreive);
  47943. static void rhine_transmit (struct nic *nic, const char *d, unsigned int t,
  47944. unsigned int s, const char *p);
  47945. -/* Linux support functions */
  47946. -#define virt_to_bus(x) ((unsigned long)x)
  47947. -#define bus_to_virt(x) ((void *)x)
  47948. -
  47949. /* Initialize the Rx and Tx rings, along with various 'dev' bits. */
  47950. static void
  47951. rhine_init_ring (struct nic *nic)
  47952. @@ -854,26 +851,99 @@
  47953. }
  47954. }
  47955. -struct nic *
  47956. -rhine_probe (struct nic *nic, unsigned short *probeaddrs,
  47957. - struct pci_device *pci)
  47958. +/* Offsets to the device registers. */
  47959. +enum register_offsets {
  47960. + StationAddr=0x00, RxConfig=0x06, TxConfig=0x07, ChipCmd=0x08,
  47961. + IntrStatus=0x0C, IntrEnable=0x0E,
  47962. + MulticastFilter0=0x10, MulticastFilter1=0x14,
  47963. + RxRingPtr=0x18, TxRingPtr=0x1C, GFIFOTest=0x54,
  47964. + MIIPhyAddr=0x6C, MIIStatus=0x6D, PCIBusConfig=0x6E,
  47965. + MIICmd=0x70, MIIRegAddr=0x71, MIIData=0x72, MACRegEEcsr=0x74,
  47966. + ConfigA=0x78, ConfigB=0x79, ConfigC=0x7A, ConfigD=0x7B,
  47967. + RxMissed=0x7C, RxCRCErrs=0x7E, MiscCmd=0x81,
  47968. + StickyHW=0x83, IntrStatus2=0x84, WOLcrClr=0xA4, WOLcgClr=0xA7,
  47969. + PwrcsrClr=0xAC,
  47970. +};
  47971. +
  47972. +/* Bits in the interrupt status/mask registers. */
  47973. +enum intr_status_bits {
  47974. + IntrRxDone=0x0001, IntrRxErr=0x0004, IntrRxEmpty=0x0020,
  47975. + IntrTxDone=0x0002, IntrTxError=0x0008, IntrTxUnderrun=0x0210,
  47976. + IntrPCIErr=0x0040,
  47977. + IntrStatsMax=0x0080, IntrRxEarly=0x0100,
  47978. + IntrRxOverflow=0x0400, IntrRxDropped=0x0800, IntrRxNoBuf=0x1000,
  47979. + IntrTxAborted=0x2000, IntrLinkChange=0x4000,
  47980. + IntrRxWakeUp=0x8000,
  47981. + IntrNormalSummary=0x0003, IntrAbnormalSummary=0xC260,
  47982. + IntrTxDescRace=0x080000, /* mapped from IntrStatus2 */
  47983. + IntrTxErrSummary=0x082218,
  47984. +};
  47985. +#define DEFAULT_INTR (IntrRxDone | IntrRxErr | IntrRxEmpty| IntrRxOverflow | \
  47986. + IntrRxDropped | IntrRxNoBuf)
  47987. +
  47988. +/***************************************************************************
  47989. + IRQ - PXE IRQ Handler
  47990. +***************************************************************************/
  47991. +void rhine_irq ( struct nic *nic, irq_action_t action ) {
  47992. + struct rhine_private *tp = (struct rhine_private *) nic->priv_data;
  47993. + /* Enable interrupts by setting the interrupt mask. */
  47994. + unsigned int intr_status;
  47995. +
  47996. + switch ( action ) {
  47997. + case DISABLE :
  47998. + case ENABLE :
  47999. + intr_status = inw(nic->ioaddr + IntrStatus);
  48000. + /* On Rhine-II, Bit 3 indicates Tx descriptor write-back race. */
  48001. + if (tp->chip_id == 0x3065)
  48002. + intr_status |= inb(nic->ioaddr + IntrStatus2) << 16;
  48003. + intr_status = (intr_status & ~DEFAULT_INTR);
  48004. + if ( action == ENABLE )
  48005. + intr_status = intr_status | DEFAULT_INTR;
  48006. + outw(intr_status, nic->ioaddr + IntrEnable);
  48007. + break;
  48008. + case FORCE :
  48009. + outw(0x0010, nic->ioaddr + 0x84);
  48010. + break;
  48011. + }
  48012. +}
  48013. +
  48014. +static int
  48015. +rhine_probe (struct dev *dev, struct pci_device *pci)
  48016. {
  48017. + struct nic *nic = (struct nic *)dev;
  48018. + struct rhine_private *tp = &rhine;
  48019. if (!pci->ioaddr)
  48020. - return NULL;
  48021. - nic = rhine_probe1 (nic, pci->ioaddr, 0, -1);
  48022. + return 0;
  48023. + rhine_probe1 (nic, pci->ioaddr, pci->dev_id, -1);
  48024. - if (nic)
  48025. - adjust_pci_device(pci);
  48026. - nic->poll = rhine_poll;
  48027. - nic->transmit = rhine_transmit;
  48028. - nic->reset = rhine_reset;
  48029. - nic->disable = rhine_disable;
  48030. + adjust_pci_device(pci);
  48031. rhine_reset (nic);
  48032. - return nic;
  48033. + dev->disable = rhine_disable;
  48034. + nic->poll = rhine_poll;
  48035. + nic->transmit = rhine_transmit;
  48036. + nic->irqno = pci->irq;
  48037. + nic->irq = rhine_irq;
  48038. + nic->ioaddr = tp->ioaddr;
  48039. +
  48040. +
  48041. + return 1;
  48042. +}
  48043. +
  48044. +static void set_rx_mode(struct nic *nic __unused) {
  48045. + struct rhine_private *tp = (struct rhine_private *) nic->priv_data;
  48046. + unsigned char rx_mode;
  48047. + int ioaddr = tp->ioaddr;
  48048. +
  48049. + /* ! IFF_PROMISC */
  48050. + outl(0xffffffff, byMAR0);
  48051. + outl(0xffffffff, byMAR4);
  48052. + rx_mode = 0x0C;
  48053. +
  48054. + outb(0x60 /* thresh */ | rx_mode, byRCR );
  48055. }
  48056. -static struct nic *
  48057. +static void
  48058. rhine_probe1 (struct nic *nic, int ioaddr, int chip_id, int options)
  48059. {
  48060. struct rhine_private *tp;
  48061. @@ -885,6 +955,29 @@
  48062. if (rhine_debug > 0 && did_version++ == 0)
  48063. printf (version);
  48064. +
  48065. + /* D-Link provided reset code (with comment additions) */
  48066. + if((chip_id != 0x3043) && (chip_id != 0x6100)) {
  48067. + unsigned char byOrgValue;
  48068. +
  48069. + if(rhine_debug > 0)
  48070. + printf("Enabling Sticky Bit Workaround for Chip_id: 0x%hX\n"
  48071. + , chip_id);
  48072. + /* clear sticky bit before reset & read ethernet address */
  48073. + byOrgValue = inb(bySTICKHW);
  48074. + byOrgValue = byOrgValue & 0xFC;
  48075. + outb(byOrgValue, bySTICKHW);
  48076. +
  48077. + /* (bits written are cleared?) */
  48078. + /* disable force PME-enable */
  48079. + outb(0x80, byWOLcgClr);
  48080. + /* disable power-event config bit */
  48081. + outb(0xFF, byWOLcrClr);
  48082. + /* clear power status (undocumented in vt6102 docs?) */
  48083. + outb(0xFF, byPwrcsrClr);
  48084. +
  48085. + }
  48086. +
  48087. /* Perhaps this should be read from the EEPROM? */
  48088. for (i = 0; i < ETH_ALEN; i++)
  48089. nic->node_addr[i] = inb (byPAR0 + i);
  48090. @@ -920,6 +1013,7 @@
  48091. }
  48092. #endif
  48093. +
  48094. /* query MII to know LineSpeed,duplex mode */
  48095. byMIIvalue = inb (ioaddr + 0x6d);
  48096. LineSpeed = byMIIvalue & MIISR_SPEED;
  48097. @@ -971,15 +1065,19 @@
  48098. if (tp->default_port)
  48099. tp->medialock = 1;
  48100. }
  48101. - return nic;
  48102. + return;
  48103. }
  48104. -static void
  48105. -rhine_disable (struct nic *nic)
  48106. +static void
  48107. +rhine_disable (struct dev *dev)
  48108. {
  48109. + struct nic *nic = (struct nic *)dev;
  48110. struct rhine_private *tp = (struct rhine_private *) nic->priv_data;
  48111. int ioaddr = tp->ioaddr;
  48112. + /* merge reset and disable */
  48113. + rhine_reset(nic);
  48114. +
  48115. printf ("rhine disable\n");
  48116. /* Switch to loopback mode to avoid hardware races. */
  48117. writeb(0x60 | 0x01, byTCR);
  48118. @@ -1002,17 +1100,10 @@
  48119. int rx_bufs_tmp, rx_bufs_tmp1;
  48120. int tx_bufs_tmp, tx_bufs_tmp1;
  48121. -#ifdef USE_LOWMEM_BUFFER
  48122. -#define buf1 (0x10000 - (RX_RING_SIZE * PKT_BUF_SZ + 32))
  48123. -#define buf2 (buf1 - (RX_RING_SIZE * PKT_BUF_SZ + 32))
  48124. -#define desc1 (buf2 - (TX_RING_SIZE * sizeof (struct rhine_tx_desc) + 32))
  48125. -#define desc2 (desc1 - (TX_RING_SIZE * sizeof (struct rhine_tx_desc) + 32))
  48126. -#else
  48127. static char buf1[RX_RING_SIZE * PKT_BUF_SZ + 32];
  48128. static char buf2[RX_RING_SIZE * PKT_BUF_SZ + 32];
  48129. static char desc1[TX_RING_SIZE * sizeof (struct rhine_tx_desc) + 32];
  48130. static char desc2[TX_RING_SIZE * sizeof (struct rhine_tx_desc) + 32];
  48131. -#endif
  48132. /* printf ("rhine_reset\n"); */
  48133. /* Soft reset the chip. */
  48134. @@ -1069,6 +1160,9 @@
  48135. outl (virt_to_bus (tp->rx_ring), dwCurrentRxDescAddr);
  48136. outl (virt_to_bus (tp->tx_ring), dwCurrentTxDescAddr);
  48137. + /* Setup Multicast */
  48138. + set_rx_mode(nic);
  48139. +
  48140. /* close IMR */
  48141. outw (0x0000, byIMR0);
  48142. @@ -1093,15 +1187,34 @@
  48143. /*set IMR to work */
  48144. outw (IMRShadow, byIMR0);
  48145. }
  48146. +/* Beware of PCI posted writes */
  48147. +#define IOSYNC do { readb(nic->ioaddr + StationAddr); } while (0)
  48148. static int
  48149. -rhine_poll (struct nic *nic)
  48150. +rhine_poll (struct nic *nic, int retreive)
  48151. {
  48152. struct rhine_private *tp = (struct rhine_private *) nic->priv_data;
  48153. int rxstatus, good = 0;;
  48154. if (tp->rx_ring[tp->cur_rx].rx_status.bits.own_bit == 0)
  48155. {
  48156. + unsigned int intr_status;
  48157. + /* There is a packet ready */
  48158. + if(!retreive)
  48159. + return 1;
  48160. +
  48161. + intr_status = inw(nic->ioaddr + IntrStatus);
  48162. + /* On Rhine-II, Bit 3 indicates Tx descriptor write-back race. */
  48163. +#if 0
  48164. + if (tp->chip_id == 0x3065)
  48165. + intr_status |= inb(nic->ioaddr + IntrStatus2) << 16;
  48166. +#endif
  48167. + /* Acknowledge all of the current interrupt sources ASAP. */
  48168. + if (intr_status & IntrTxDescRace)
  48169. + outb(0x08, nic->ioaddr + IntrStatus2);
  48170. + outw(intr_status & 0xffff, nic->ioaddr + IntrStatus);
  48171. + IOSYNC;
  48172. +
  48173. rxstatus = tp->rx_ring[tp->cur_rx].rx_status.lw;
  48174. if ((rxstatus & 0x0300) != 0x0300)
  48175. {
  48176. @@ -1124,6 +1237,11 @@
  48177. tp->cur_rx++;
  48178. tp->cur_rx = tp->cur_rx % RX_RING_SIZE;
  48179. }
  48180. + /* Acknowledge all of the current interrupt sources ASAP. */
  48181. + outw(DEFAULT_INTR & ~IntrRxDone, nic->ioaddr + IntrStatus);
  48182. +
  48183. + IOSYNC;
  48184. +
  48185. return good;
  48186. }
  48187. @@ -1152,7 +1270,7 @@
  48188. while (s < ETH_ZLEN)
  48189. *((char *) tp->tx_buffs[entry] + ETH_HLEN + (s++)) = 0;
  48190. - tp->tx_ring[entry].tx_ctrl.bits.tx_buf_size = ETH_HLEN + s;
  48191. + tp->tx_ring[entry].tx_ctrl.bits.tx_buf_size = s;
  48192. tp->tx_ring[entry].tx_status.bits.own_bit = 1;
  48193. @@ -1170,6 +1288,9 @@
  48194. /*printf("td4=[%X]",inl(dwCurrentTDSE3)); */
  48195. outb (CR1bak, byCR1);
  48196. + /* Wait until transmit is finished */
  48197. + while (tp->tx_ring[entry].tx_status.bits.own_bit != 0)
  48198. + ;
  48199. tp->cur_tx++;
  48200. /*outw(IMRShadow,byIMR0); */
  48201. @@ -1177,4 +1298,21 @@
  48202. /*tp->tx_skbuff[entry] = 0; */
  48203. }
  48204. +static struct pci_id rhine_nics[] = {
  48205. +PCI_ROM(0x1106, 0x3065, "dlink-530tx", "VIA 6102"),
  48206. +PCI_ROM(0x1106, 0x3106, "via-rhine-6105", "VIA 6105"),
  48207. +PCI_ROM(0x1106, 0x3043, "dlink-530tx-old", "VIA 3043"), /* Rhine-I 86c100a */
  48208. +PCI_ROM(0x1106, 0x3053, "via6105m", "VIA 6105M"),
  48209. +PCI_ROM(0x1106, 0x6100, "via-rhine-old", "VIA 86C100A"), /* Rhine-II */
  48210. +};
  48211. +
  48212. +struct pci_driver rhine_driver = {
  48213. + .type = NIC_DRIVER,
  48214. + .name = "VIA 86C100",
  48215. + .probe = rhine_probe,
  48216. + .ids = rhine_nics,
  48217. + .id_count = sizeof(rhine_nics)/sizeof(rhine_nics[0]),
  48218. + .class = 0,
  48219. +};
  48220. +
  48221. /* EOF via-rhine.c */
  48222. diff -Naur grub-0.97.orig/netboot/w89c840.c grub-0.97/netboot/w89c840.c
  48223. --- grub-0.97.orig/netboot/w89c840.c 2003-07-09 11:45:38.000000000 +0000
  48224. +++ grub-0.97/netboot/w89c840.c 2005-08-31 19:03:35.000000000 +0000
  48225. @@ -43,6 +43,9 @@
  48226. * using timer2 routines. Proposed
  48227. * by Ken Yap to eliminate CPU speed
  48228. * dependency.
  48229. + * Dec 12 2003 V0.94 timlegge Fixed issues in 5.2, removed
  48230. + * interrupt usage, enabled
  48231. + * multicast support
  48232. *
  48233. * This is the etherboot driver for cards based on Winbond W89c840F chip.
  48234. *
  48235. @@ -77,10 +80,9 @@
  48236. #include "etherboot.h"
  48237. #include "nic.h"
  48238. #include "pci.h"
  48239. -#include "cards.h"
  48240. #include "timer.h"
  48241. -static const char *w89c840_version = "diver Version 0.92 - August 27, 2000";
  48242. +static const char *w89c840_version = "driver Version 0.94 - December 12, 2003";
  48243. typedef unsigned char u8;
  48244. typedef signed char s8;
  48245. @@ -90,9 +92,6 @@
  48246. typedef signed int s32;
  48247. /* Linux support functions */
  48248. -#define virt_to_bus(x) ((unsigned long)x)
  48249. -#define bus_to_virt(x) ((void *)x)
  48250. -
  48251. #define virt_to_le32desc(addr) virt_to_bus(addr)
  48252. #define le32desc_to_virt(addr) bus_to_virt(addr)
  48253. @@ -109,7 +108,6 @@
  48254. bonding and packet priority.
  48255. There are no ill effects from too-large receive rings. */
  48256. #define TX_RING_SIZE 2
  48257. -
  48258. #define RX_RING_SIZE 2
  48259. /* The presumed FIFO size for working around the Tx-FIFO-overflow bug.
  48260. @@ -260,32 +258,20 @@
  48261. static int ioaddr;
  48262. static unsigned short eeprom [0x40];
  48263. -
  48264. -#ifdef USE_LOWMEM_BUFFER
  48265. -#define rx_packet ((char *)0x10000 - PKT_BUF_SZ * RX_RING_SIZE)
  48266. -#define tx_packet ((char *)0x10000 - PKT_BUF_SZ * RX_RING_SIZE - PKT_BUF_SZ * TX_RING_SIZE)
  48267. -#else
  48268. static char rx_packet[PKT_BUF_SZ * RX_RING_SIZE];
  48269. static char tx_packet[PKT_BUF_SZ * TX_RING_SIZE];
  48270. -#endif
  48271. static int eeprom_read(long ioaddr, int location);
  48272. static int mdio_read(int base_address, int phy_id, int location);
  48273. +#if 0
  48274. static void mdio_write(int base_address, int phy_id, int location, int value);
  48275. +#endif
  48276. static void check_duplex(void);
  48277. static void set_rx_mode(void);
  48278. static void init_ring(void);
  48279. -/*
  48280. -static void wait_long_time(void)
  48281. -{
  48282. - printf("Paused - please read output above this line\n");
  48283. - sleep(3);
  48284. -}
  48285. -*/
  48286. -
  48287. -#if defined W89C840_DEBUG
  48288. +#if defined(W89C840_DEBUG)
  48289. static void decode_interrupt(u32 intr_status)
  48290. {
  48291. printf("Interrupt status: ");
  48292. @@ -349,15 +335,17 @@
  48293. check_duplex();
  48294. set_rx_mode();
  48295. - /* Clear and Enable interrupts by setting the interrupt mask. */
  48296. + /* Do not enable the interrupts Etherboot doesn't need them */
  48297. +/*
  48298. writel(0x1A0F5, ioaddr + IntrStatus);
  48299. writel(0x1A0F5, ioaddr + IntrEnable);
  48300. -
  48301. +*/
  48302. #if defined(W89C840_DEBUG)
  48303. printf("winbond-840 : Done reset.\n");
  48304. #endif
  48305. }
  48306. +#if 0
  48307. static void handle_intr(u32 intr_stat)
  48308. {
  48309. if ((intr_stat & (NormalIntr|AbnormalIntr)) == 0) {
  48310. @@ -372,7 +360,7 @@
  48311. /* There was an abnormal interrupt */
  48312. printf("\n-=- Abnormal interrupt.\n");
  48313. -#if defined (W89C840_DEBUG)
  48314. +#if defined(W89C840_DEBUG)
  48315. decode_interrupt(intr_stat);
  48316. #endif
  48317. @@ -383,19 +371,21 @@
  48318. }
  48319. }
  48320. }
  48321. +#endif
  48322. /**************************************************************************
  48323. w89c840_poll - Wait for a frame
  48324. ***************************************************************************/
  48325. -static int w89c840_poll(struct nic *nic)
  48326. +static int w89c840_poll(struct nic *nic, int retrieve)
  48327. {
  48328. /* return true if there's an ethernet packet ready to read */
  48329. /* nic->packet should contain data on return */
  48330. /* nic->packetlen should contain length of data */
  48331. int packet_received = 0;
  48332. +#if defined(W89C840_DEBUG)
  48333. u32 intr_status = readl(ioaddr + IntrStatus);
  48334. - /* handle_intr(intr_status); */ /* -- handled later */
  48335. +#endif
  48336. do {
  48337. /* Code from netdev_rx(dev) */
  48338. @@ -411,6 +401,11 @@
  48339. break;
  48340. }
  48341. + if ( !retrieve ) {
  48342. + packet_received = 1;
  48343. + break;
  48344. + }
  48345. +
  48346. if ((status & 0x38008300) != 0x0300) {
  48347. if ((status & 0x38000300) != 0x0300) {
  48348. /* Ingore earlier buffers. */
  48349. @@ -478,11 +473,7 @@
  48350. entry = (++w840private.cur_rx) % RX_RING_SIZE;
  48351. w840private.rx_head_desc = &w840private.rx_ring[entry];
  48352. } while (0);
  48353. -
  48354. - if (intr_status & (AbnormalIntr | TxFIFOUnderflow | IntrPCIErr |TimerInt | IntrTxStopped)) {
  48355. - handle_intr(intr_status);
  48356. - }
  48357. -
  48358. +
  48359. return packet_received;
  48360. }
  48361. @@ -521,13 +512,13 @@
  48362. w840private.tx_ring[entry].buffer1 = virt_to_le32desc(tx_packet);
  48363. - w840private.tx_ring[entry].length = (DescWholePkt | s);
  48364. + w840private.tx_ring[entry].length = (DescWholePkt | (u32) s);
  48365. if (entry >= TX_RING_SIZE-1) /* Wrap ring */
  48366. w840private.tx_ring[entry].length |= (DescIntr | DescEndRing);
  48367. w840private.tx_ring[entry].status = (DescOwn);
  48368. w840private.cur_tx++;
  48369. - w840private.tx_q_bytes += s;
  48370. + w840private.tx_q_bytes = (u16) s;
  48371. writel(0, ioaddr + TxStartDemand);
  48372. /* Work around horrible bug in the chip by marking the queue as full
  48373. @@ -550,33 +541,29 @@
  48374. load_timer2(TX_TIMEOUT);
  48375. {
  48376. +#if defined W89C840_DEBUG
  48377. u32 intr_stat = 0;
  48378. -
  48379. +#endif
  48380. while (1) {
  48381. - intr_stat = readl(ioaddr + IntrStatus);
  48382. #if defined(W89C840_DEBUG)
  48383. - decode_interrupt(intr_stat);
  48384. + decode_interrupt(intr_stat);
  48385. #endif
  48386. - if (intr_stat & (NormalIntr | IntrTxDone)) {
  48387. -
  48388. while ( (transmit_status & DescOwn) && timer2_running()) {
  48389. transmit_status = w840private.tx_ring[entry].status;
  48390. }
  48391. - writel(intr_stat & 0x0001ffff, ioaddr + IntrStatus);
  48392. break;
  48393. - }
  48394. }
  48395. }
  48396. if ((transmit_status & DescOwn) == 0) {
  48397. #if defined(W89C840_DEBUG)
  48398. - printf("winbond-840 : transmission complete after %d wait loop iterations, status %X\n",
  48399. - TX_LOOP_COUNT - transmit_loop_counter, w840private.tx_ring[entry].status);
  48400. + printf("winbond-840 : transmission complete after wait loop iterations, status %X\n",
  48401. + w840private.tx_ring[entry].status);
  48402. #endif
  48403. return;
  48404. @@ -592,8 +579,12 @@
  48405. /**************************************************************************
  48406. w89c840_disable - Turn off ethernet interface
  48407. ***************************************************************************/
  48408. -static void w89c840_disable(struct nic *nic)
  48409. +static void w89c840_disable(struct dev *dev)
  48410. {
  48411. + struct nic *nic = (struct nic *)dev;
  48412. + /* merge reset and disable */
  48413. + w89c840_reset(nic);
  48414. +
  48415. /* Don't know what to do to disable the board. Is this needed at all? */
  48416. /* Yes, a live NIC can corrupt the loaded memory later [Ken] */
  48417. /* Stop the chip's Tx and Rx processes. */
  48418. @@ -601,20 +592,37 @@
  48419. }
  48420. /**************************************************************************
  48421. +w89c840_irq - Enable, Disable, or Force interrupts
  48422. +***************************************************************************/
  48423. +static void w89c840_irq(struct nic *nic __unused, irq_action_t action __unused)
  48424. +{
  48425. + switch ( action ) {
  48426. + case DISABLE :
  48427. + break;
  48428. + case ENABLE :
  48429. + break;
  48430. + case FORCE :
  48431. + break;
  48432. + }
  48433. +}
  48434. +
  48435. +/**************************************************************************
  48436. w89c840_probe - Look for an adapter, this routine's visible to the outside
  48437. ***************************************************************************/
  48438. -struct nic *w89c840_probe(struct nic *nic, unsigned short *probe_addrs, struct pci_device *p)
  48439. +static int w89c840_probe(struct dev *dev, struct pci_device *p)
  48440. {
  48441. + struct nic *nic = (struct nic *)dev;
  48442. u16 sum = 0;
  48443. - int i, j, to;
  48444. + int i, j;
  48445. unsigned short value;
  48446. - int options;
  48447. - int promisc;
  48448. - if (probe_addrs == 0 || probe_addrs[0] == 0)
  48449. + if (p->ioaddr == 0)
  48450. return 0;
  48451. - ioaddr = probe_addrs[0]; /* Mask the bit that says "this is an io addr" */
  48452. + ioaddr = p->ioaddr;
  48453. + nic->ioaddr = p->ioaddr & ~3;
  48454. + nic->irqno = 0;
  48455. +
  48456. #if defined(W89C840_DEBUG)
  48457. printf("winbond-840: PCI bus %hhX device function %hhX: I/O address: %hX\n", p->bus, p->devfn, ioaddr);
  48458. @@ -622,8 +630,6 @@
  48459. ioaddr = ioaddr & ~3; /* Mask the bit that says "this is an io addr" */
  48460. - /* if probe_addrs is 0, then routine can use a hardwired default */
  48461. -
  48462. /* From Matt Hortman <mbhortman@acpthinclient.com> */
  48463. if (p->vendor == PCI_VENDOR_ID_WINBOND2
  48464. && p->dev_id == PCI_DEVICE_ID_WINBOND2_89C840) {
  48465. @@ -689,14 +695,14 @@
  48466. }
  48467. /* point to NIC specific routines */
  48468. - nic->reset = w89c840_reset;
  48469. - nic->poll = w89c840_poll;
  48470. + dev->disable = w89c840_disable;
  48471. + nic->poll = w89c840_poll;
  48472. nic->transmit = w89c840_transmit;
  48473. - nic->disable = w89c840_disable;
  48474. + nic->irq = w89c840_irq;
  48475. w89c840_reset(nic);
  48476. - return nic;
  48477. + return 1;
  48478. }
  48479. /* Read the EEPROM and MII Management Data I/O (MDIO) interfaces. These are
  48480. @@ -814,6 +820,7 @@
  48481. return (retval>>1) & 0xffff;
  48482. }
  48483. +#if 0
  48484. static void mdio_write(int base_address, int phy_id, int location, int value)
  48485. {
  48486. long mdio_addr = base_address + MIICtrl;
  48487. @@ -844,6 +851,7 @@
  48488. }
  48489. return;
  48490. }
  48491. +#endif
  48492. static void check_duplex(void)
  48493. {
  48494. @@ -877,12 +885,10 @@
  48495. memset(mc_filter, 0xff, sizeof(mc_filter));
  48496. /*
  48497. - * Actually, should work OK with multicast enabled. -- iko
  48498. - */
  48499. -/*
  48500. - * rx_mode = AcceptBroadcast | AcceptMyPhys | AcceptMulticast;
  48501. + * works OK with multicast enabled.
  48502. */
  48503. - rx_mode = AcceptBroadcast | AcceptMyPhys;
  48504. +
  48505. + rx_mode = AcceptBroadcast | AcceptMyPhys | AcceptMulticast;
  48506. writel(mc_filter[0], ioaddr + MulticastFilter0);
  48507. writel(mc_filter[1], ioaddr + MulticastFilter1);
  48508. @@ -932,3 +938,18 @@
  48509. }
  48510. return;
  48511. }
  48512. +
  48513. +
  48514. +static struct pci_id w89c840_nics[] = {
  48515. +PCI_ROM(0x1050, 0x0840, "winbond840", "Winbond W89C840F"),
  48516. +PCI_ROM(0x11f6, 0x2011, "compexrl100atx", "Compex RL100ATX"),
  48517. +};
  48518. +
  48519. +struct pci_driver w89c840_driver = {
  48520. + .type = NIC_DRIVER,
  48521. + .name = "W89C840F",
  48522. + .probe = w89c840_probe,
  48523. + .ids = w89c840_nics,
  48524. + .id_count = sizeof(w89c840_nics)/sizeof(w89c840_nics[0]),
  48525. + .class = 0,
  48526. +};
  48527. diff -Naur grub-0.97.orig/stage2/disk_io.c grub-0.97/stage2/disk_io.c
  48528. --- grub-0.97.orig/stage2/disk_io.c 2004-05-23 16:35:24.000000000 +0000
  48529. +++ grub-0.97/stage2/disk_io.c 2005-08-31 19:03:35.000000000 +0000
  48530. @@ -25,6 +25,7 @@
  48531. #ifdef SUPPORT_NETBOOT
  48532. # define GRUB 1
  48533. # include <etherboot.h>
  48534. +# include <grub.h>
  48535. #endif
  48536. #ifdef GRUB_UTIL